Allow determining # of rows/columns for All Apps and Customize at run time

DO NOT MERGE

Change-Id: I9ba0add8f2b2ffb324468768ad058c8426db6894
diff --git a/src/com/android/launcher2/CustomizeTrayTabHost.java b/src/com/android/launcher2/CustomizeTrayTabHost.java
index 3e04025..765c41d 100644
--- a/src/com/android/launcher2/CustomizeTrayTabHost.java
+++ b/src/com/android/launcher2/CustomizeTrayTabHost.java
@@ -110,17 +110,6 @@
                 }
             }
         });
-
-        // Set the width of the tab bar properly
-        int pageWidth = customizePagedView.getPageContentWidth();
-        TabWidget customizeTabBar = (TabWidget) findViewById(com.android.internal.R.id.tabs);
-        if (customizeTabBar == null) throw new Resources.NotFoundException();
-        int tabWidgetPadding = 0;
-        final int childCount = tabWidget.getChildCount();
-        if (childCount > 0) {
-            tabWidgetPadding += tabWidget.getChildAt(0).getPaddingLeft() * 2;
-        }
-        customizeTabBar.getLayoutParams().width = pageWidth + tabWidgetPadding;
     }
 
     @Override
@@ -145,7 +134,23 @@
 
     @Override
     protected void onLayout(boolean changed, int l, int t, int r, int b) {
-        mFirstLayout = false;
+        if (mFirstLayout) {
+            mFirstLayout = false;
+
+            final CustomizePagedView customizePagedView =
+                (CustomizePagedView) findViewById(R.id.customization_drawer_tab_contents);
+            TabWidget tabWidget = (TabWidget) findViewById(com.android.internal.R.id.tabs);
+            // Set the width of the tab bar properly
+            int pageWidth = customizePagedView.getPageContentWidth();
+            TabWidget customizeTabBar = (TabWidget) findViewById(com.android.internal.R.id.tabs);
+            if (customizeTabBar == null) throw new Resources.NotFoundException();
+            int tabWidgetPadding = 0;
+            final int childCount = tabWidget.getChildCount();
+            if (childCount > 0) {
+                tabWidgetPadding += tabWidget.getChildAt(0).getPaddingLeft() * 2;
+            }
+            customizeTabBar.getLayoutParams().width = pageWidth + tabWidgetPadding;
+        }
         super.onLayout(changed, l, t, r, b);
     }