Bug 1352133 - Handle selected tab not yet existing when exiting BrowserSearch. r=nechen a=gchang
authorJan Henning <jh+bugzilla@buttercookie.de>
Thu, 28 Dec 2017 15:29:24 +0100
changeset 443121 ac3cd70b8967b4917b4c51ca9b6d71ad727b6942
parent 443120 a0c1f3a8bdb40853e598c602fbf73c56f8a92d6a
child 443122 46fabe0cc9dc12719f9f96f0146508093a6a0dfe
push id8490
push userdluca@mozilla.com
push dateMon, 08 Jan 2018 10:18:49 +0000
treeherdermozilla-beta@641211059e52 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnechen, gchang
bugs1352133
milestone58.0
Bug 1352133 - Handle selected tab not yet existing when exiting BrowserSearch. r=nechen a=gchang Early during startup there might not be a selected tab yet, so we can't use its data to decide which home panel to show again. Fortunately showHomePager can be called with a null panelId, in which case it will eventually simply fall back to using the default home panel from our settings. MozReview-Commit-ID: GbmozJeYZVb
mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
--- a/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
+++ b/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
@@ -3148,20 +3148,30 @@ public class BrowserApp extends GeckoApp
         getWindow().setBackgroundDrawableResource(android.R.color.white);
     }
 
     private void hideBrowserSearch() {
         if (!mBrowserSearch.getUserVisibleHint()) {
             return;
         }
 
+        final Tab selectedTab = Tabs.getInstance().getSelectedTab();
+        final String panelId;
+        final Bundle panelData;
+        if (selectedTab != null) {
+            panelId = selectedTab.getMostRecentHomePanel();
+            panelData = selectedTab.getMostRecentHomePanelData();
+        } else {
+            panelId = null;
+            panelData = null;
+        }
+
         // To prevent overdraw, the HomePager is hidden when BrowserSearch is displayed:
         // reverse that.
-        showHomePager(Tabs.getInstance().getSelectedTab().getMostRecentHomePanel(),
-                Tabs.getInstance().getSelectedTab().getMostRecentHomePanelData());
+        showHomePager(panelId, panelData);
 
         mBrowserSearchContainer.setVisibility(View.INVISIBLE);
 
         getSupportFragmentManager().beginTransaction()
                 .hide(mBrowserSearch).commitAllowingStateLoss();
         mBrowserSearch.setUserVisibleHint(false);
 
         getWindow().setBackgroundDrawable(null);