Bug 1277978 - Part 2 - Allow saving a cached recent tabs count in BrowserApp. r=liuche draft
authorJan Henning <jh+bugzilla@buttercookie.de>
Mon, 29 Aug 2016 20:03:12 +0200
changeset 412353 b5cd02ef0dc8d538bf9fc3402fb5ae44cf95fdf6
parent 412352 fb65db89dbc47028f21e5c92b1e8e51ed9bd10b4
child 412354 490581270e65c0e29afa100ee2351b4511114cbf
push id29155
push usermozilla@buttercookie.de
push dateSat, 10 Sep 2016 11:55:24 +0000
reviewersliuche
bugs1277978
milestone51.0a1
Bug 1277978 - Part 2 - Allow saving a cached recent tabs count in BrowserApp. r=liuche Getting the total number of recently closed tabs involves waiting for Gecko to actually send the closed tabs to the Java UI. This means that (unless there are some "Tabs from last time" present) when showing the history panel we always start out with the Recently closed folder hidden and then unhide (and animate) it once we've finally received the closed tabs. Because this is visually distracting, we should cache the closed tabs count somewhere, so we can decide on the smart folder visibility as soon as the CombinedHistoryAdapter initialises. MozReview-Commit-ID: 8uYCbM7eiSt
mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
mobile/android/base/java/org/mozilla/gecko/home/HomeFragment.java
--- a/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
+++ b/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
@@ -247,16 +247,17 @@ public class BrowserApp extends GeckoApp
     private HomeScreen mHomeScreen;
     private TabsPanel mTabsPanel;
     /**
      * Container for the home screen implementation. This will be populated with any valid
      * home screen implementation (currently that is just the HomePager, but that will be extended
      * to permit further experimental replacement panels such as the activity-stream panel).
      */
     private ViewGroup mHomeScreenContainer;
+    private int mCachedRecentTabsCount;
     private ActionModeCompat mActionMode;
     private TabHistoryController tabHistoryController;
     private ZoomedView mZoomedView;
 
     private static final int GECKO_TOOLS_MENU = -1;
     private static final int ADDON_MENU_OFFSET = 1000;
     public static final String TAB_HISTORY_FRAGMENT_TAG = "tabHistoryFragment";
 
@@ -2801,16 +2802,26 @@ public class BrowserApp extends GeckoApp
                 mHomeScreen.setPanelStateChangeListener(new HomeFragment.PanelStateChangeListener() {
                     @Override
                     public void onStateChanged(Bundle bundle) {
                         final Tab currentTab = Tabs.getInstance().getSelectedTab();
                         if (currentTab != null) {
                             currentTab.setMostRecentHomePanelData(bundle);
                         }
                     }
+
+                    @Override
+                    public void setCachedRecentTabsCount(int count) {
+                        mCachedRecentTabsCount = count;
+                    }
+
+                    @Override
+                    public int getCachedRecentTabsCount() {
+                        return mCachedRecentTabsCount;
+                    }
                 });
             }
 
             // Don't show the banner in guest mode.
             if (!Restrictions.isUserRestricted()) {
                 final ViewStub homeBannerStub = (ViewStub) findViewById(R.id.home_banner_stub);
                 final HomeBanner homeBanner = (HomeBanner) homeBannerStub.inflate();
                 mHomeScreen.setBanner(homeBanner);
--- a/mobile/android/base/java/org/mozilla/gecko/home/HomeFragment.java
+++ b/mobile/android/base/java/org/mozilla/gecko/home/HomeFragment.java
@@ -87,16 +87,20 @@ public abstract class HomeFragment exten
      */
     public interface PanelStateChangeListener {
 
         /**
          * @param bundle Data that should be persisted, and passed to this panel if restored at a later
          * stage.
          */
         void onStateChanged(Bundle bundle);
+
+        void setCachedRecentTabsCount(int count);
+
+        int getCachedRecentTabsCount();
     }
 
     public void restoreData(Bundle data) {
         // Do nothing
     }
 
     public void setPanelStateChangeListener(
             PanelStateChangeListener mPanelStateChangeListener) {