Bug 984873 - Hide banner for the rest of the session after the user has clicked on it. r=bnicholson, a=sledru
authorMargaret Leibovic <margaret.leibovic@gmail.com>
Tue, 18 Mar 2014 15:39:58 -0700
changeset 191161 3c6774e9040e47044a9b97cc03b41325939e38db
parent 191160 8ba50e20e7bbdcb0055a1e274ec6aafad87c3e4d
child 191162 c801b0f775199f0ae47d64f9236a269719d0a339
push id3503
push userraliiev@mozilla.com
push dateMon, 28 Apr 2014 18:51:11 +0000
treeherdermozilla-beta@c95ac01e332e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbnicholson, sledru
bugs984873
milestone30.0a2
Bug 984873 - Hide banner for the rest of the session after the user has clicked on it. r=bnicholson, a=sledru
mobile/android/base/home/HomeBanner.java
--- a/mobile/android/base/home/HomeBanner.java
+++ b/mobile/android/base/home/HomeBanner.java
@@ -85,33 +85,27 @@ public class HomeBanner extends LinearLa
         final ImageButton closeButton = (ImageButton) findViewById(R.id.close);
 
         // The drawable should have 50% opacity.
         closeButton.getDrawable().setAlpha(127);
 
         closeButton.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View view) {
-                HomeBanner.this.setVisibility(View.GONE);
+                HomeBanner.this.dismiss();
 
                 // Send the current message id back to JS.
                 GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("HomeBanner:Dismiss", (String) getTag()));
-
-                if (mOnDismissListener != null) {
-                    mOnDismissListener.onDismiss();
-                }
             }
         });
 
         setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
-                // Hide the banner. This does not remove the message from the rotation, so it may appear
-                // again if the JS onclick handler doesn't choose to remove it.
-                HomeBanner.this.setVisibility(View.GONE);
+                HomeBanner.this.dismiss();
 
                 // Send the current message id back to JS.
                 GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("HomeBanner:Click", (String) getTag()));
             }
         });
 
         GeckoAppShell.getEventDispatcher().registerEventListener("HomeBanner:Data", this);
     }
@@ -138,16 +132,28 @@ public class HomeBanner extends LinearLa
         mScrollingPages = scrollingPages;
     }
 
     public void setOnDismissListener(OnDismissListener listener) {
         mOnDismissListener = listener;
     }
 
     /**
+     * Hides and disables the banner.
+     */
+    private void dismiss() {
+        setVisibility(View.GONE);
+        setEnabled(false);
+
+        if (mOnDismissListener != null) {
+            mOnDismissListener.onDismiss();
+        }
+    }
+
+    /**
      * Sends a message to gecko to request a new banner message. UI is updated in handleMessage.
      */
     public void update() {
         GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("HomeBanner:Get", null));
     }
 
     @Override
     public void handleMessage(String event, JSONObject message) {