floatingsearchview icon indicating copy to clipboard operation
floatingsearchview copied to clipboard

Reversed list of suggestions after recreating view.

Open Gloix opened this issue 7 years ago • 3 comments

When a search is done, the list of results appears in the right order, but after the view hierarchy is destroyed and then later recreated, the results are reversed.

Gloix avatar Jun 15 '17 15:06 Gloix

Hi @Gloix,

Could you add some details to your problem?

Maybe your problem is that you are swapping the suggestions with an array and then you try to swap the suggestions again with the same array instance. If FloatingSearchView had to reverse the suggestions list, then, your array has been reversed twice, so the suggestions list appears reversed.

If you want to maintain and reuse a suggestions list, then you should pass a copy to the FloatingSearchView.swapSuggestions:

public class MyClass {
  FloatingSearchView mSearchView;
  ArrayList<SearchSuggestion> mMySuggestions;

...

  private void updateSuggestions() {
    mSearchView.swapSuggestions(new ArrayList<>(mMySuggestions));
  }

...

}

If this is not your problem, you can check at this fix I've just created #262

eduardbosch avatar Jul 19 '17 11:07 eduardbosch

I've found another problem with reversed suggestions.

There is a new PR with a fix #263

eduardbosch avatar Jul 19 '17 15:07 eduardbosch

Thank you so much :D I think #263 will highly likely solve the issue. Will report back when I test a new version.

Gloix avatar Jul 20 '17 15:07 Gloix