Skip to content

Commit

Permalink
Always clear suggestions when search is performed
Browse files Browse the repository at this point in the history
Signed-off-by: Jorge Ruesga <jorge@ruesga.com>
  • Loading branch information
jruesga committed Feb 9, 2019
1 parent c37314f commit fde0a4d
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions app/src/main/java/com/ruesga/rview/SearchActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -312,13 +312,14 @@ public boolean onSuggestionClicked(SearchSuggestion suggestion) {
}

// Directly complete the search
performSearch(s.mSuggestionText, s.mSuggestionData);
mHandler.postDelayed(() -> performSearch(
s.mSuggestionText, s.mSuggestionData), 100L);
return false;
}

@Override
public void onSearchAction(String currentQuery) {
performSearch(currentQuery, null);
mHandler.postDelayed(() -> performSearch(currentQuery, null), 100L);
}
});
mBinding.searchView.setOnQueryChangeListener((oldFilter, newFilter) -> {
Expand Down Expand Up @@ -482,7 +483,7 @@ private void performShowOptions() {

mHandler.removeMessages(FETCH_SUGGESTIONS_MESSAGE);
mHandler.removeMessages(SHOW_HISTORY_MESSAGE);
final Message msg = Message.obtain(mHandler, SHOW_HISTORY_MESSAGE);
Message msg = Message.obtain(mHandler, SHOW_HISTORY_MESSAGE);
mHandler.sendMessageDelayed(msg, 500L);
});
popupWindow.setModal(true);
Expand Down Expand Up @@ -538,8 +539,9 @@ private void clearSuggestions() {
}

private void performSearch(String query, String data) {
clearSuggestions();

if (TextUtils.isEmpty(query)) {
clearSuggestions();
return;
}

Expand Down

0 comments on commit fde0a4d

Please sign in to comment.