Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix reversed suggestions #262

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

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.

None yet

1 participant