Don't scroll to top after delete a suggestion

This commit is contained in:
seven332 committed 2018-12-15 04:11:47 +08:00
1 parent 419405f4e2
commit 24d386da44
1 file changed
+9 -2
@@ -162,6 +162,10 @@ public class SearchBar extends CardView implements View.OnClickListener,
}
private void updateSuggestions() {
updateSuggestions(true);
}
private void updateSuggestions(boolean scrollToTop) {
mSuggestionList.clear();
String text = mEditText.getText().toString();
@@ -184,7 +188,10 @@ public class SearchBar extends CardView implements View.OnClickListener,
addListHeader();
}
mSuggestionAdapter.notifyDataSetChanged();
mListView.setSelection(0);
if (scrollToTop) {
mListView.setSelection(0);
}
}
public void setAllowEmptySearch(boolean allowEmptySearch) {
@@ -575,7 +582,7 @@ public class SearchBar extends CardView implements View.OnClickListener,
@Override
public void onLongClick() {
mSearchDatabase.deleteQuery(mKeyword);
updateSuggestions();
updateSuggestions(false);
}
}
}