diff options
Diffstat (limited to 'src/com/android/launcher2/AllAppsPagedView.java')
-rw-r--r-- | src/com/android/launcher2/AllAppsPagedView.java | 37 |
1 files changed, 32 insertions, 5 deletions
diff --git a/src/com/android/launcher2/AllAppsPagedView.java b/src/com/android/launcher2/AllAppsPagedView.java index c812a4698..59ba57bdf 100644 --- a/src/com/android/launcher2/AllAppsPagedView.java +++ b/src/com/android/launcher2/AllAppsPagedView.java @@ -66,6 +66,8 @@ public class AllAppsPagedView extends PagedViewWithDraggableItems implements All private final LayoutInflater mInflater; private boolean mAllowHardwareLayerCreation; + private boolean mFirstMeasure = true; + private int mPageContentWidth; private boolean mHasMadeSuccessfulDrop; @@ -91,11 +93,6 @@ public class AllAppsPagedView extends PagedViewWithDraggableItems implements All Resources r = context.getResources(); setDragSlopeThreshold( r.getInteger(R.integer.config_appsCustomizeDragSlopeThreshold) / 100.0f); - - // Create a dummy page and set it up to find out the content width (used by our parent) - PagedViewCellLayout layout = new PagedViewCellLayout(getContext()); - setupPage(layout); - mPageContentWidth = layout.getContentWidth(); } @Override @@ -104,6 +101,31 @@ public class AllAppsPagedView extends PagedViewWithDraggableItems implements All mCenterPagesVertically = false; } + @Override + protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + super.onMeasure(widthMeasureSpec, heightMeasureSpec); + + final int widthSize = MeasureSpec.getSize(widthMeasureSpec); + final int heightSize = MeasureSpec.getSize(heightMeasureSpec); + + if (mFirstMeasure) { + mFirstMeasure = false; + + // TODO: actually calculate mCellCountX/mCellCountY as some function of + // widthSize and heightSize + //mCellCountX = ?; + //mCellCountY = ?; + + // Since mCellCountX/mCellCountY changed, we need to update the pages + invalidatePageData(); + + // Create a dummy page and set it up to find out the content width (used by our parent) + PagedViewCellLayout layout = new PagedViewCellLayout(getContext()); + setupPage(layout); + mPageContentWidth = layout.getContentWidth(); + } + } + void allowHardwareLayerCreation() { // This is called after the first time we launch into All Apps. Before that point, // there's no need for hardware layers here since there's a hardware layer set on the @@ -482,6 +504,11 @@ public class AllAppsPagedView extends PagedViewWithDraggableItems implements All @Override public void syncPages() { + if (mFirstMeasure) { + // We don't know our size yet, which means we haven't calculated cell count x/y; + // onMeasure will call us once we figure out our size + return; + } // ensure that we have the right number of pages (min of 1, since we have placeholders) int numPages = Math.max(1, (int) Math.ceil((float) mFilteredApps.size() / (mCellCountX * mCellCountY))); |