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
--- 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) {