Bug 816902 - Prevent suggestion prompt buttons from being clicked multiple times. r=mfinkle
authorBrian Nicholson <bnicholson@mozilla.com>
Mon, 03 Dec 2012 12:08:15 -0800
changeset 114832 550d6b2f98aacbd05fae4efa35252bec24aed6b9
parent 114831 2a3f0a806e7bb1a95533d101b37b487da5e521df
child 114833 c4bb1f2098cd0616d7743db98b40bc12c444f8e2
push id23947
push useremorley@mozilla.com
push dateTue, 04 Dec 2012 14:54:11 +0000
treeherdermozilla-central@0035f77045bc [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmfinkle
bugs816902
milestone20.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 816902 - Prevent suggestion prompt buttons from being clicked multiple times. r=mfinkle
mobile/android/base/awesomebar/AllPagesTab.java
--- a/mobile/android/base/awesomebar/AllPagesTab.java
+++ b/mobile/android/base/awesomebar/AllPagesTab.java
@@ -573,26 +573,31 @@ public class AllPagesTab extends Awesome
 
         filterSuggestions(mSearchTerm);
     }
 
     private void showSuggestionsOptIn() {
         mSuggestionsOptInPrompt = LayoutInflater.from(mContext).inflate(R.layout.awesomebar_suggestion_prompt, (LinearLayout)getView(), false);
         ((TextView) mSuggestionsOptInPrompt.findViewById(R.id.suggestions_prompt_title))
                 .setText(getResources().getString(R.string.suggestions_prompt, mSearchEngines.get(0).name));
-        mSuggestionsOptInPrompt.findViewById(R.id.suggestions_prompt_yes).setOnClickListener(new OnClickListener() {
+
+        final View yesButton = mSuggestionsOptInPrompt.findViewById(R.id.suggestions_prompt_yes);
+        final View noButton = mSuggestionsOptInPrompt.findViewById(R.id.suggestions_prompt_no);
+        OnClickListener listener = new OnClickListener() {
             public void onClick(View v) {
-                setSuggestionsEnabled(true);
+                // Prevent the buttons from being clicked multiple times (bug 816902)
+                yesButton.setOnClickListener(null);
+                noButton.setOnClickListener(null);
+
+                setSuggestionsEnabled(v == yesButton);
             }
-        });
-        mSuggestionsOptInPrompt.findViewById(R.id.suggestions_prompt_no).setOnClickListener(new OnClickListener() {
-            public void onClick(View v) {
-                setSuggestionsEnabled(false);
-            }
-        });
+        };
+        yesButton.setOnClickListener(listener);
+        noButton.setOnClickListener(listener);
+
         mSuggestionsOptInPrompt.setVisibility(View.GONE);
         ((LinearLayout)getView()).addView(mSuggestionsOptInPrompt, 0);
     }
 
     private void setSuggestionsEnabled(final boolean enabled) {
         // Make suggestions appear immediately after the user opts in
         primeSuggestions();