Bug 1223983 - Hide recycled search items when suggestions/history are disabled too. r=mcomella draft
authorAndrzej Hunt <ahunt@mozilla.com>
Wed, 16 Dec 2015 15:56:02 -0800
changeset 317776 c3f8e8355483fa36dfb89fb860f8cc6641783ce8
parent 317767 5b9292b9f878471b54498c1a70cecb76d5a409b3
child 512357 5e8c393bd3dcc63d7ca33a4e6a1cf90a7d94587b
push id8762
push userahunt@mozilla.com
push dateMon, 28 Dec 2015 23:07:13 +0000
reviewersmcomella
bugs1223983
milestone46.0a1
Bug 1223983 - Hide recycled search items when suggestions/history are disabled too. r=mcomella
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) {