diff options
Diffstat (limited to 'src/com/android')
-rw-r--r-- | src/com/android/launcher2/AllAppsPagedView.java | 15 | ||||
-rw-r--r-- | src/com/android/launcher2/CustomizePagedView.java | 16 | ||||
-rw-r--r-- | src/com/android/launcher2/LauncherAppWidgetHostView.java | 10 | ||||
-rw-r--r-- | src/com/android/launcher2/PagedView.java | 4 |
4 files changed, 36 insertions, 9 deletions
diff --git a/src/com/android/launcher2/AllAppsPagedView.java b/src/com/android/launcher2/AllAppsPagedView.java index 64e6f9807..94e6af4c3 100644 --- a/src/com/android/launcher2/AllAppsPagedView.java +++ b/src/com/android/launcher2/AllAppsPagedView.java @@ -72,6 +72,7 @@ public class AllAppsPagedView extends PagedViewWithDraggableItems implements All private int mLastMeasureWidth = -1; private int mLastMeasureHeight = -1; + private boolean mWaitingToInitPages = true; private int mMaxCellCountY; @@ -119,13 +120,16 @@ public class AllAppsPagedView extends PagedViewWithDraggableItems implements All mCellCountY = determineCellCountY(height, layout); mLastMeasureWidth = width; mLastMeasureHeight = height; + removeAllViews(); + invalidatePageData(); } super.onMeasure(widthMeasureSpec, heightMeasureSpec); } @Override protected void onLayout(boolean changed, int left, int top, int right, int bottom) { - if (mFirstLayout) { + if (mWaitingToInitPages) { + mWaitingToInitPages = false; invalidatePageData(); // invalidatePageData() is what causes the child pages to be created. We need the @@ -567,12 +571,17 @@ public class AllAppsPagedView extends PagedViewWithDraggableItems implements All } @Override - public void syncPages() { - if (mCellCountX <= 0 || mCellCountY <= 0) { + protected void invalidatePageData() { + if (mWaitingToInitPages || mCellCountX <= 0 || mCellCountY <= 0) { // 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; } + super.invalidatePageData(); + } + + @Override + public void syncPages() { // 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))); diff --git a/src/com/android/launcher2/CustomizePagedView.java b/src/com/android/launcher2/CustomizePagedView.java index 5ac261f10..e1256d08b 100644 --- a/src/com/android/launcher2/CustomizePagedView.java +++ b/src/com/android/launcher2/CustomizePagedView.java @@ -151,6 +151,8 @@ public class CustomizePagedView extends PagedViewWithDraggableItems private AllAppsPagedView mAllAppsPagedView; + private boolean mWaitingToInitPages = true; + public CustomizePagedView(Context context) { this(context, null, 0); } @@ -208,6 +210,8 @@ public class CustomizePagedView extends PagedViewWithDraggableItems mPageContentWidth = layout.getContentWidth(); mPageContentHeight = layout.getContentHeight(); mMinPageWidth = layout.getWidthBeforeFirstLayout(); + removeAllViews(); + invalidatePageData(); } if (mPageContentHeight > 0) { // Lock our height to the size of the page content @@ -220,7 +224,8 @@ public class CustomizePagedView extends PagedViewWithDraggableItems @Override protected void onLayout(boolean changed, int left, int top, int right, int bottom) { - if (mFirstLayout) { + if (mWaitingToInitPages) { + mWaitingToInitPages = false; invalidatePageData(); // invalidatePageData() is what causes the child pages to be created. We need the @@ -1138,12 +1143,17 @@ public class CustomizePagedView extends PagedViewWithDraggableItems } @Override - public void syncPages() { - if (mFirstMeasure) { + protected void invalidatePageData() { + if (mWaitingToInitPages || mCellCountX <= 0 || mCellCountY <= 0) { // 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; } + super.invalidatePageData(); + } + + @Override + public void syncPages() { boolean enforceMinimumPagedWidths = false; boolean centerPagedViewCellLayouts = false; switch (mCustomizationType) { diff --git a/src/com/android/launcher2/LauncherAppWidgetHostView.java b/src/com/android/launcher2/LauncherAppWidgetHostView.java index 0dd1d8398..099a676bb 100644 --- a/src/com/android/launcher2/LauncherAppWidgetHostView.java +++ b/src/com/android/launcher2/LauncherAppWidgetHostView.java @@ -18,6 +18,7 @@ package com.android.launcher2; import android.appwidget.AppWidgetHostView; import android.content.Context; +import android.content.res.Resources; import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.View; @@ -39,8 +40,15 @@ public class LauncherAppWidgetHostView extends AppWidgetHostView public LauncherAppWidgetHostView(Context context) { super(context); mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); + + Resources r = context.getResources(); + // We add necessary padding to the AppWidgetHostView + setPadding(r.getDimensionPixelSize(R.dimen.app_widget_padding_left), + r.getDimensionPixelSize(R.dimen.app_widget_padding_top), + r.getDimensionPixelSize(R.dimen.app_widget_padding_right), + r.getDimensionPixelSize(R.dimen.app_widget_padding_bottom)); } - + @Override protected View getErrorView() { return mInflater.inflate(R.layout.appwidget_error, this, false); diff --git a/src/com/android/launcher2/PagedView.java b/src/com/android/launcher2/PagedView.java index bd41e02ef..79f647ad4 100644 --- a/src/com/android/launcher2/PagedView.java +++ b/src/com/android/launcher2/PagedView.java @@ -113,8 +113,8 @@ public abstract class PagedView extends ViewGroup { protected int mPageLayoutWidthGap; protected int mPageLayoutHeightGap; protected int mPageLayoutMaxHeight; - protected int mCellCountX = -1; - protected int mCellCountY = -1; + protected int mCellCountX = 0; + protected int mCellCountY = 0; protected boolean mCenterPagesVertically; protected boolean mAllowOverScroll = true; protected int mUnboundedScrollX; |