Fixing some issues with our use of GridLayout.

Change-Id: Id898258b31462f47d65f0ec674786b03a4ca326e
diff --git a/src/com/android/launcher2/AppsCustomizePagedView.java b/src/com/android/launcher2/AppsCustomizePagedView.java
index 8a4bdc7..f059469 100644
--- a/src/com/android/launcher2/AppsCustomizePagedView.java
+++ b/src/com/android/launcher2/AppsCustomizePagedView.java
@@ -734,15 +734,11 @@
                 mPageLayoutPaddingRight, mPageLayoutPaddingBottom);
 
         // Note: We force a measure here to get around the fact that when we do layout calculations
-        // immediately after syncing, we don't have a proper width.  That said, we already know the
-        // expected page width, so we can actually optimize by hiding all the TextView-based
-        // children that are expensive to measure, and let that happen naturally later.
-        setVisibilityOnChildren(layout, View.GONE);
+        // immediately after syncing, we don't have a proper width.
         int widthSpec = MeasureSpec.makeMeasureSpec(getMeasuredWidth(), MeasureSpec.AT_MOST);
         int heightSpec = MeasureSpec.makeMeasureSpec(getMeasuredHeight(), MeasureSpec.AT_MOST);
         layout.setMinimumWidth(getPageContentWidth());
         layout.measure(widthSpec, heightSpec);
-        setVisibilityOnChildren(layout, View.VISIBLE);
     }
     private void renderDrawableToBitmap(Drawable d, Bitmap bitmap, int x, int y, int w, int h,
             float scaleX, float scaleY) {
@@ -893,7 +889,8 @@
     private void onSyncWidgetPageItems(AsyncTaskPageData data) {
         int page = data.page;
         PagedViewGridLayout layout = (PagedViewGridLayout) getChildAt(page);
-        layout.removeAllViews();
+        // Only set the column count once we have items
+        layout.setColumnCount(layout.getCellCountX());
 
         ArrayList<Object> items = data.items;
         int count = items.size();
@@ -935,8 +932,8 @@
             int ix = i % cellCountX;
             int iy = i / cellCountX;
             GridLayout.LayoutParams lp = new GridLayout.LayoutParams(
-                    new GridLayout.Group(iy, 1, GridLayout.LEFT),
-                    new GridLayout.Group(ix, 1, GridLayout.TOP));
+                    GridLayout.spec(iy, GridLayout.LEFT, GridLayout.CAN_STRETCH),
+                    GridLayout.spec(ix, GridLayout.TOP, GridLayout.CAN_STRETCH));
             lp.width = cellWidth;
             lp.height = cellHeight;
             if (ix > 0) lp.leftMargin = mWidgetWidthGap;
diff --git a/src/com/android/launcher2/PagedViewCellLayout.java b/src/com/android/launcher2/PagedViewCellLayout.java
index fc1b012..39b0a62 100644
--- a/src/com/android/launcher2/PagedViewCellLayout.java
+++ b/src/com/android/launcher2/PagedViewCellLayout.java
@@ -221,8 +221,6 @@
             throw new RuntimeException("CellLayout cannot have UNSPECIFIED dimensions");
         }
 
-
-
         int numWidthGaps = mCellCountX - 1;
         int numHeightGaps = mCellCountY - 1;
 
diff --git a/src/com/android/launcher2/PagedViewGridLayout.java b/src/com/android/launcher2/PagedViewGridLayout.java
index a2ab763..4131d8b 100644
--- a/src/com/android/launcher2/PagedViewGridLayout.java
+++ b/src/com/android/launcher2/PagedViewGridLayout.java
@@ -35,7 +35,6 @@
         super(context, null, 0);
         mCellCountX = cellCountX;
         mCellCountY = cellCountY;
-        setColumnCount(mCellCountX);
     }
 
     int getCellCountX() {