OSDN Git Service

Setting content bounds in onMeasure as it uses measuredWidth, which might
authorSunny Goyal <sunnygoyal@google.com>
Tue, 16 Feb 2016 22:56:33 +0000 (14:56 -0800)
committerSunny Goyal <sunnygoyal@google.com>
Tue, 16 Feb 2016 23:24:14 +0000 (15:24 -0800)
not be available during onCreate

Also fixing the calculation of allApps column could, which was counting an
additional icon gap

Bug: 27173894
Change-Id: I8be8cccc76d7e7d945cf9383567a3026228b6c86

src/com/android/launcher3/BaseContainerView.java
src/com/android/launcher3/DeviceProfile.java
src/com/android/launcher3/allapps/AllAppsContainerView.java

index 8bb8c55..b8e7b63 100644 (file)
@@ -38,10 +38,8 @@ public abstract class BaseContainerView extends FrameLayout implements Insettabl
     // The bounds of the search bar.  Only the left, top, right are used to inset the
     // search bar and the height is determined by the measurement of the layout
     private final Rect mFixedSearchBarBounds = new Rect();
-    // The computed bounds of the container
-    protected final Rect mContentBounds = new Rect();
     // The computed padding to apply to the container to achieve the container bounds
-    private final Rect mContentPadding = new Rect();
+    protected final Rect mContentPadding = new Rect();
     // The inset to apply to the edges and between the search bar and the container
     private final int mContainerBoundsInset;
 
@@ -126,9 +124,6 @@ public abstract class BaseContainerView extends FrameLayout implements Insettabl
         // The container padding changed, notify the container.
         if (!padding.equals(mContentPadding)) {
             mContentPadding.set(padding);
-            mContentBounds.set(padding.left, padding.top,
-                    getMeasuredWidth() - padding.right,
-                    getMeasuredHeight() - padding.bottom);
             onUpdateBackgroundAndPaddings(padding);
         }
     }
index 61c4b1a..380c6b1 100644 (file)
@@ -270,7 +270,7 @@ public class DeviceProfile {
         int allAppsCellWidthGap =
                 res.getDimensionPixelSize(R.dimen.all_apps_icon_width_gap);
         int availableAppsWidthPx = (recyclerViewWidth > 0) ? recyclerViewWidth : availableWidthPx;
-        int numAppsCols = (availableAppsWidthPx - appsViewLeftMarginPx) /
+        int numAppsCols = (availableAppsWidthPx + allAppsCellWidthGap - appsViewLeftMarginPx) /
                 (allAppsIconSizePx + allAppsCellWidthGap);
         int numPredictiveAppCols = Math.max(inv.minAllAppsPredictionColumns, numAppsCols);
         allAppsNumCols = numAppsCols;
index 945125b..997f0fa 100644 (file)
@@ -138,6 +138,9 @@ public class AllAppsContainerView extends BaseContainerView implements DragSourc
     private final RecyclerView.LayoutManager mLayoutManager;
     private final RecyclerView.ItemDecoration mItemDecoration;
 
+    // The computed bounds of the container
+    private final Rect mContentBounds = new Rect();
+
     private AllAppsRecyclerView mAppsRecyclerView;
     private AllAppsSearchBarController mSearchBarController;
 
@@ -318,6 +321,10 @@ public class AllAppsContainerView extends BaseContainerView implements DragSourc
 
     @Override
     protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+        mContentBounds.set(mContentPadding.left, mContentPadding.top,
+                MeasureSpec.getSize(widthMeasureSpec) - mContentPadding.right,
+                MeasureSpec.getSize(heightMeasureSpec) - mContentPadding.bottom);
+
         // Update the number of items in the grid before we measure the view
         // TODO: mSectionNamesMargin is currently 0, but also account for it,
         // if it's enabled in the future.