Bug 912524: Do not reinflate SuggestionOptIn ViewStub. r=bnicholson
authorMichael Comella <michael.l.comella@gmail.com>
Tue, 10 Sep 2013 10:00:47 -0700
changeset 146388 6d8738e8dc7118fef4855c98127e58075a320b94
parent 146387 2ea8259f7e39bbb3ca673e4c796d0a4e47e2c03e
child 146389 c3384a3b42801dfecb3ea01e18dff554354a594c
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersbnicholson
bugs912524
milestone26.0a1
Bug 912524: Do not reinflate SuggestionOptIn ViewStub. r=bnicholson
mobile/android/base/home/BrowserSearch.java
--- a/mobile/android/base/home/BrowserSearch.java
+++ b/mobile/android/base/home/BrowserSearch.java
@@ -452,16 +452,22 @@ public class BrowserSearch extends HomeF
         } catch (JSONException e) {
             Log.e(LOGTAG, "Error getting search engine JSON", e);
         }
 
         filterSuggestions();
     }
 
     private void showSuggestionsOptIn() {
+        // Return if the ViewStub was already inflated - an inflated ViewStub is removed from the
+        // View hierarchy so a second call to findViewById will return null.
+        if (mSuggestionsOptInPrompt != null) {
+            return;
+        }
+
         mSuggestionsOptInPrompt = ((ViewStub) mView.findViewById(R.id.suggestions_opt_in_prompt)).inflate();
 
         TextView promptText = (TextView) mSuggestionsOptInPrompt.findViewById(R.id.suggestions_prompt_title);
         promptText.setText(getResources().getString(R.string.suggestions_prompt, mSearchEngines.get(0).name));
 
         final View yesButton = mSuggestionsOptInPrompt.findViewById(R.id.suggestions_prompt_yes);
         final View noButton = mSuggestionsOptInPrompt.findViewById(R.id.suggestions_prompt_no);