Bug 1223983 - Hide recycled search items when suggestions/history are disabled too. r=mcomella a=ritu
authorAndrzej Hunt <ahunt@mozilla.com>
Wed, 16 Dec 2015 15:56:02 -0800
changeset 310754 1a1b6f09bccf81a83d0e620e9be19b5e9612fd7d
parent 310753 c1cb670465ef6cd4ea2a09a4e8050bace601ac37
child 310755 ea3577f09d579676c20da9278fbca444e26f87c2
push id5513
push userraliiev@mozilla.com
push dateMon, 25 Jan 2016 13:55:34 +0000
treeherdermozilla-beta@5ee97dd05b5c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmcomella, ritu
bugs1223983
milestone45.0a2
Bug 1223983 - Hide recycled search items when suggestions/history are disabled too. r=mcomella a=ritu
mobile/android/base/java/org/mozilla/gecko/home/SearchEngineRow.java
--- 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) {