I've found another problem with suggestions order when the suggestions list has been reversed and the view is restored from instance state.
The problem
When the suggestions list is reversed and onSaveInstanceState is called, the suggestions list is saved reversed, not as it has been delivered to the FloatingSearchView through swapSuggestions. Then, when the view is restored from instance state restoreFromInstanceState, the suggestions are reversed, and when they are delivered again to swapSuggestions the list is reversed again, so we end up with the results in reversed order.
The solution
If the suggestions list is reversed, then we reverse it again before saving on onSaveInstanceState.
Test
To test this, I had to change in MainActivity:51 from:
if (savedInstanceState == null) {
showFragment(new SlidingSearchResultsExampleFragment());
}
so the fragment is not created every time the Activity is destroyed if we are recovering from a previous instance. You should activate this option also in the developer settings to check restoring from instance state:
Hi again 🎉
I've found another problem with suggestions order when the suggestions list has been reversed and the view is restored from instance state.
The problem
When the suggestions list is reversed and
onSaveInstanceState
is called, the suggestions list is saved reversed, not as it has been delivered to theFloatingSearchView
throughswapSuggestions
. Then, when the view is restored from instance staterestoreFromInstanceState
, the suggestions are reversed, and when they are delivered again toswapSuggestions
the list is reversed again, so we end up with the results in reversed order.The solution
If the suggestions list is reversed, then we reverse it again before saving on
onSaveInstanceState
.Test
To test this, I had to change in
MainActivity:51
from:showFragment(new SlidingSearchResultsExampleFragment());
to:
so the fragment is not created every time the Activity is destroyed if we are recovering from a previous instance. You should activate this option also in the developer settings to check restoring from instance state:
Before the fix
After the fix