Skip to content

Conversation

@eduardbosch
Copy link

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

If user calls swapsuggestions multiple times in a single frame, and
the suggestions should be reversed at the first call but not at the
second one, then the suggestions keeps reversed due to
OnGlobalLayoutListener called twice.
besimdobrucali pushed a commit to besimdobrucali/floatingsearchview that referenced this pull request Mar 22, 2019
Eduard Bosch Bertran
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant