floatingsearchview icon indicating copy to clipboard operation
floatingsearchview copied to clipboard

Fix reversed suggestions

Open eduardbosch opened this issue 7 years ago • 0 comments

Hi again 🎉

I've fixed that if swapSuggestions is called twice in a row, then the suggestions are displayed incorrectly.

The problem

OnGlobalLayoutListener is called twice for single suggestion swap if we call swapSuggestion in the same frame. The problem is that the second time we call swapSuggestion, OnGlobalLayoutListener has still not being called, so it ends up calling it twice (or many times).

The solution

Instead of removing the listener when it's processed, we remove it every time we try to swap suggestions.


Test

To test this problem, I've called the swapSuggestions twice in a row:

mSearchView.swapSuggestions(someSuggestions);
mSearchView.swapSuggestions(someOtherSuggestions);

Before the fix

incorrect_swap

After the fix

correct_swap

eduardbosch avatar Jul 19 '17 11:07 eduardbosch