Bug 1223983 - Hide recycled search items when suggestions/history are disabled too. r=mcomella
--- a/mobile/android/base/java/org/mozilla/gecko/home/SearchEngineRow.java
+++ b/mobile/android/base/java/org/mozilla/gecko/home/SearchEngineRow.java
@@ -296,16 +296,17 @@ class SearchEngineRow extends AnimatedHe
* enforce a ui maximum or filter. It will show all the suggestions in this list.
* @param suggestionStartIndex global index of where to start adding suggestion "buttons" in the search engine row. Also
* acts as a counter for total number of suggestions visible.
* @param animate whether or not to animate suggestions for visual polish
* @param recycledSuggestionCount How many suggestion "button" views we could recycle from previous calls
*/
private void updateFromSavedSearches(List<String> savedSuggestions, boolean animate, int suggestionStartIndex, int recycledSuggestionCount) {
if (savedSuggestions == null || savedSuggestions.isEmpty()) {
+ hideRecycledSuggestions(suggestionStartIndex, recycledSuggestionCount);
return;
}
final int numSavedSearches = savedSuggestions.size();
int indexOfPreviousSuggestion = 0;
for (int i = 0; i < numSavedSearches; i++) {
String telemetryTag = "history." + i;
final String suggestion = savedSuggestions.get(i);
@@ -397,16 +398,21 @@ class SearchEngineRow extends AnimatedHe
if (searchSuggestionsEnabled && savedSearchesEnabled) {
final int suggestionViewCount = updateFromSearchEngine(animate, searchEngineSuggestions, recycledSuggestionCount, searchHistoryCount);
updateFromSavedSearches(searchHistorySuggestions, animate, suggestionViewCount, recycledSuggestionCount);
} else if (savedSearchesEnabled) {
updateFromSavedSearches(searchHistorySuggestions, animate, 0, recycledSuggestionCount);
} else if (searchSuggestionsEnabled) {
updateFromSearchEngine(animate, searchEngineSuggestions, recycledSuggestionCount, 0);
+ } else {
+ // The current search term is treated separately from the suggestions list, hence we can
+ // recycle ALL suggestion items here. (We always show the current search term, i.e. 1 item,
+ // in front of the search engine suggestions and/or the search history.)
+ hideRecycledSuggestions(0, recycledSuggestionCount);
}
}
@Override
public boolean onKeyDown(int keyCode, android.view.KeyEvent event) {
final View suggestion = mSuggestionView.getChildAt(mSelectedView);
if (event.getAction() != android.view.KeyEvent.ACTION_DOWN) {