Bug 1403754 - Skip browser search opt-in prompt if it's not ready. r?maliu draft
authorNevin Chen <cnevinchen@gmail.com>
Tue, 16 Jan 2018 16:18:13 +0800
changeset 720773 b9840d28b53cac91ae9ea2374cee906f1d65ce96
parent 720739 a3887394965f161d011eebc74e8987a653366e4b
child 746146 36d076fd925d684beca70e118ec2cae67c147cfc
push id95636
push userbmo:cnevinchen@gmail.com
push dateTue, 16 Jan 2018 08:23:34 +0000
reviewersmaliu
bugs1403754
milestone59.0a1
Bug 1403754 - Skip browser search opt-in prompt if it's not ready. r?maliu MozReview-Commit-ID: 5Gcz1KVbdUt
mobile/android/base/java/org/mozilla/gecko/home/BrowserSearch.java
--- a/mobile/android/base/java/org/mozilla/gecko/home/BrowserSearch.java
+++ b/mobile/android/base/java/org/mozilla/gecko/home/BrowserSearch.java
@@ -842,17 +842,22 @@ public class BrowserSearch extends HomeF
         // Only make the ViewStub visible again if it has already previously been shown.
         // (An inflated ViewStub is removed from the View hierarchy so a second call to findViewById will return null,
         // which also further necessitates handling this separately.)
         if (mSuggestionsOptInPrompt != null) {
             mSuggestionsOptInPrompt.setVisibility(View.VISIBLE);
             return;
         }
 
-        mSuggestionsOptInPrompt = ((ViewStub) mView.findViewById(R.id.suggestions_opt_in_prompt)).inflate();
+        final ViewStub suggestionOptInPromptStub = (ViewStub) mView.findViewById(R.id.suggestions_opt_in_prompt);
+        if (suggestionOptInPromptStub == null) {
+            // If the stub is not ready, we skip the prompt inflation till the next time.
+            return;
+        }
+        mSuggestionsOptInPrompt = suggestionOptInPromptStub.inflate();
 
         TextView promptText = (TextView) mSuggestionsOptInPrompt.findViewById(R.id.suggestions_prompt_title);
         promptText.setText(getResources().getString(R.string.suggestions_prompt));
 
         final View yesButton = mSuggestionsOptInPrompt.findViewById(R.id.suggestions_prompt_yes);
         final View noButton = mSuggestionsOptInPrompt.findViewById(R.id.suggestions_prompt_no);
 
         final OnClickListener listener = new OnClickListener() {