Bug 966047 - Hide banner when there are no panels enabled. r=lucasr
authorJosh Dover <gerfuls@gmail.com>
Mon, 24 Feb 2014 17:05:52 -0800
changeset 191032 b1150afb0f41aaba748b0ea7acb52c0bacbb1fc0
parent 191031 945ddca04d49fb3989885833e36c1d856fed4e6b
child 191033 affa309bdf7a1dd86fbbdc083b216e9f0fb106c0
push id474
push userasasaki@mozilla.com
push dateMon, 02 Jun 2014 21:01:02 +0000
treeherdermozilla-release@967f4cf1b31c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerslucasr
bugs966047
milestone30.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 966047 - Hide banner when there are no panels enabled. r=lucasr
mobile/android/base/home/HomePager.java
--- a/mobile/android/base/home/HomePager.java
+++ b/mobile/android/base/home/HomePager.java
@@ -219,16 +219,20 @@ public class HomePager extends ViewPager
 
     @Override
     public void setCurrentItem(int item, boolean smoothScroll) {
         super.setCurrentItem(item, smoothScroll);
 
         if (mDecor != null) {
             mDecor.onPageSelected(item);
         }
+
+        if (mHomeBanner != null) {
+            mHomeBanner.setActive(item == mDefaultPageIndex);
+        }
     }
 
     @Override
     public boolean onInterceptTouchEvent(MotionEvent event) {
         if (event.getActionMasked() == MotionEvent.ACTION_DOWN) {
             // Drop the soft keyboard by stealing focus from the URL bar.
             requestFocus();
         }
@@ -295,32 +299,40 @@ public class HomePager extends ViewPager
             // Restore original background.
             setBackgroundDrawable(mOriginalBackground);
         }
 
         // Re-install the adapter with the final state
         // in the pager.
         setAdapter(adapter);
 
-        // Use the default panel as defined in the HomePager's configuration
-        // if the initial panel wasn't explicitly set by the load() caller,
-        // or if the initial panel is not found in the adapter.
-        final int itemPosition = (mInitialPanelId == null) ? -1 : adapter.getItemPosition(mInitialPanelId);
-        if (itemPosition > -1) {
-            setCurrentItem(itemPosition, false);
-            mInitialPanelId = null;
+        if (count == 0) {
+            mDefaultPageIndex = -1;
+
+            // Hide the banner if there are no enabled panels.
+            if (mHomeBanner != null) {
+                mHomeBanner.setActive(false);
+            }
         } else {
             for (int i = 0; i < count; i++) {
-                final PanelConfig panelConfig = enabledPanels.get(i);
-                if (panelConfig.isDefault()) {
+                if (enabledPanels.get(i).isDefault()) {
                     mDefaultPageIndex = i;
-                    setCurrentItem(i, false);
                     break;
                 }
             }
+
+            // Use the default panel if the initial panel wasn't explicitly set by the
+            // load() caller, or if the initial panel is not found in the adapter.
+            final int itemPosition = (mInitialPanelId == null) ? -1 : adapter.getItemPosition(mInitialPanelId);
+            if (itemPosition > -1) {
+                setCurrentItem(itemPosition, false);
+                mInitialPanelId = null;
+            } else {
+                setCurrentItem(mDefaultPageIndex, false);
+            }
         }
     }
 
     private class ConfigLoaderCallbacks implements LoaderCallbacks<HomeConfig.State> {
         @Override
         public Loader<HomeConfig.State> onCreateLoader(int id, Bundle args) {
             return new HomeConfigLoader(mContext, mConfig);
         }