Bug 961954 - Lazy load main menu. r=mfinkle

This commit is contained in:
Wes Johnston 2014-02-03 16:19:00 -08:00
parent ae530953e5
commit 7d61855f4f
2 changed files with 13 additions and 14 deletions

View File

@ -543,6 +543,9 @@ abstract public class BrowserApp extends GeckoApp
registerEventListener("Telemetry:Gather");
registerEventListener("Settings:Show");
registerEventListener("Updater:Launch");
registerEventListener("Menu:Add");
registerEventListener("Menu:Remove");
registerEventListener("Menu:Update");
Distribution.init(this);
JavaAddonManager.getInstance().init(getApplicationContext());
@ -857,6 +860,9 @@ abstract public class BrowserApp extends GeckoApp
unregisterEventListener("Telemetry:Gather");
unregisterEventListener("Settings:Show");
unregisterEventListener("Updater:Launch");
unregisterEventListener("Menu:Add");
unregisterEventListener("Menu:Remove");
unregisterEventListener("Menu:Update");
if (AppConstants.MOZ_ANDROID_BEAM && Build.VERSION.SDK_INT >= 14) {
NfcAdapter nfc = NfcAdapter.getDefaultAdapter(this);

View File

@ -360,6 +360,10 @@ public abstract class GeckoApp
}
public MenuPanel getMenuPanel() {
if (mMenuPanel == null) {
onCreatePanelMenu(Window.FEATURE_OPTIONS_PANEL, null);
invalidateOptionsMenu();
}
return mMenuPanel;
}
@ -442,8 +446,9 @@ public abstract class GeckoApp
if (Build.VERSION.SDK_INT >= 11 && featureId == Window.FEATURE_OPTIONS_PANEL) {
if (mMenu == null) {
onCreatePanelMenu(featureId, menu);
onPreparePanel(featureId, mMenuPanel, mMenu);
// getMenuPanel() will force the creation of the menu as well
MenuPanel panel = getMenuPanel();
onPreparePanel(featureId, panel, mMenu);
}
// Scroll custom menu to the top
@ -1409,12 +1414,6 @@ public abstract class GeckoApp
private void initialize() {
mInitialized = true;
if (Build.VERSION.SDK_INT >= 11) {
// Create the panel and inflate the custom menu.
onCreatePanelMenu(Window.FEATURE_OPTIONS_PANEL, null);
}
invalidateOptionsMenu();
Intent intent = getIntent();
String action = intent.getAction();
@ -1528,9 +1527,6 @@ public abstract class GeckoApp
registerEventListener("Reader:Share");
registerEventListener("Reader:FaviconRequest");
registerEventListener("onCameraCapture");
registerEventListener("Menu:Add");
registerEventListener("Menu:Remove");
registerEventListener("Menu:Update");
registerEventListener("Gecko:Ready");
registerEventListener("Gecko:DelayedStartup");
registerEventListener("Toast:Show");
@ -2058,9 +2054,6 @@ public abstract class GeckoApp
unregisterEventListener("Reader:Share");
unregisterEventListener("Reader:FaviconRequest");
unregisterEventListener("onCameraCapture");
unregisterEventListener("Menu:Add");
unregisterEventListener("Menu:Remove");
unregisterEventListener("Menu:Update");
unregisterEventListener("Gecko:Ready");
unregisterEventListener("Gecko:DelayedStartup");
unregisterEventListener("Toast:Show");