Bug 1403754 - Skip browser search opt-in prompt if it's not ready. r?maliu
MozReview-Commit-ID: 5Gcz1KVbdUt
--- 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() {