Bug 1122072 - Close tabs tray when last normal tab is closed. r=mhaigh
authorChristian Schmitz <tynn.dev@gmail.com>
Tue, 29 Sep 2015 15:53:56 +0200
changeset 298909 9629c91c939b07c6c0a5f8c878a079407729a084
parent 298908 32dc4f8f3aa0def426ec4745a402981050a8a6c8
child 298910 6ce747756f921f36d0dc1a7d37ea4c1f4a2c37ba
push id5392
push userraliiev@mozilla.com
push dateMon, 14 Dec 2015 20:08:23 +0000
treeherdermozilla-beta@16ce8562a975 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmhaigh
bugs1122072
milestone44.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 1122072 - Close tabs tray when last normal tab is closed. r=mhaigh
mobile/android/base/tabs/TabsGridLayout.java
--- a/mobile/android/base/tabs/TabsGridLayout.java
+++ b/mobile/android/base/tabs/TabsGridLayout.java
@@ -194,18 +194,21 @@ class TabsGridLayout extends GridView
     private void autoHidePanel() {
         tabsPanel.autoHidePanel();
     }
 
     @Override
     public void onTabChanged(Tab tab, Tabs.TabEvents msg, Object data) {
         switch (msg) {
             case ADDED:
-                // Refresh the list to make sure the new tab is added in the right position.
-                refreshTabsData();
+                // Refresh only if panel is shown. show() will call refreshTabsData() later again.
+                if (tabsPanel.isShown()) {
+                    // Refresh the list to make sure the new tab is added in the right position.
+                    refreshTabsData();
+                }
                 break;
 
             case CLOSED:
 
                 // This is limited to >= ICS as animations on GB devices are generally pants
                 if (Build.VERSION.SDK_INT >= 11 && tabsAdapter.getCount() > 0) {
                     animateRemoveTab(tab);
                 }
@@ -332,16 +335,20 @@ class TabsGridLayout extends GridView
     }
 
     private View getViewForTab(Tab tab) {
         final int position = tabsAdapter.getPositionForTab(tab);
         return getChildAt(position - getFirstVisiblePosition());
     }
 
     void closeTab(View v) {
+        if (tabsAdapter.getCount() == 1) {
+            autoHidePanel();
+        }
+
         TabsLayoutItemView itemView = (TabsLayoutItemView) v.getTag();
         Tab tab = Tabs.getInstance().getTab(itemView.getTabId());
 
         Tabs.getInstance().closeTab(tab, true);
     }
 
     private void animateRemoveTab(final Tab removedTab) {
         final int removedPosition = tabsAdapter.getPositionForTab(removedTab);