diff options
Diffstat (limited to 'src/com/android/launcher2/PagedView.java')
-rw-r--r-- | src/com/android/launcher2/PagedView.java | 41 |
1 files changed, 26 insertions, 15 deletions
diff --git a/src/com/android/launcher2/PagedView.java b/src/com/android/launcher2/PagedView.java index cb952356b..c2fcd9f21 100644 --- a/src/com/android/launcher2/PagedView.java +++ b/src/com/android/launcher2/PagedView.java @@ -100,6 +100,7 @@ public abstract class PagedView extends ViewGroup { protected int mTouchSlop; private int mPagingTouchSlop; private int mMaximumVelocity; + private int mMinimumWidth; protected int mPageSpacing; protected int mPageLayoutPaddingTop; protected int mPageLayoutPaddingBottom; @@ -175,13 +176,13 @@ public abstract class PagedView extends ViewGroup { R.styleable.PagedView, defStyle, 0); mPageSpacing = a.getDimensionPixelSize(R.styleable.PagedView_pageSpacing, 0); mPageLayoutPaddingTop = a.getDimensionPixelSize( - R.styleable.PagedView_pageLayoutPaddingTop, 10); + R.styleable.PagedView_pageLayoutPaddingTop, 0); mPageLayoutPaddingBottom = a.getDimensionPixelSize( - R.styleable.PagedView_pageLayoutPaddingBottom, 10); + R.styleable.PagedView_pageLayoutPaddingBottom, 0); mPageLayoutPaddingLeft = a.getDimensionPixelSize( - R.styleable.PagedView_pageLayoutPaddingLeft, 10); + R.styleable.PagedView_pageLayoutPaddingLeft, 0); mPageLayoutPaddingRight = a.getDimensionPixelSize( - R.styleable.PagedView_pageLayoutPaddingRight, 10); + R.styleable.PagedView_pageLayoutPaddingRight, 0); mPageLayoutWidthGap = a.getDimensionPixelSize( R.styleable.PagedView_pageLayoutWidthGap, -1); mPageLayoutHeightGap = a.getDimensionPixelSize( @@ -500,6 +501,11 @@ public abstract class PagedView extends ViewGroup { } } + protected void forceUpdateAdjacentPagesAlpha() { + mDirtyPageAlpha = true; + updateAdjacentPagesAlpha(); + } + protected void updateAdjacentPagesAlpha() { if (mFadeInAdjacentScreens) { if (mDirtyPageAlpha || (mTouchState == TOUCH_STATE_SCROLLING) || !mScroller.isFinished()) { @@ -546,6 +552,11 @@ public abstract class PagedView extends ViewGroup { alpha = 1.0f; } + // Due to the way we're setting alpha on our children in PagedViewCellLayout, + // this optimization causes alpha to not be properly updated sometimes (repro + // case: in xlarge mode, swipe to second page in All Apps, then click on "My + // Apps" tab. the page will have alpha 0 until you swipe it). Removing + // optimization fixes the issue, but we should fix this in a better manner //if (Float.compare(alpha, layout.getAlpha()) != 0) { layout.setAlpha(alpha); //} @@ -1128,8 +1139,16 @@ public abstract class PagedView extends ViewGroup { return -1; } + protected void setMinimumWidthOverride(int minimumWidth) { + mMinimumWidth = minimumWidth; + } + + protected int getChildWidth(int index) { + return Math.max(mMinimumWidth, getChildAt(index).getMeasuredWidth()); + } + protected int getRelativeChildOffset(int index) { - return (getMeasuredWidth() - getChildAt(index).getMeasuredWidth()) / 2; + return (getMeasuredWidth() - getChildWidth(index)) / 2; } protected int getChildOffset(int index) { @@ -1144,7 +1163,7 @@ public abstract class PagedView extends ViewGroup { } protected int getScaledMeasuredWidth(View child) { - return (int) (child.getMeasuredWidth() * mLayoutScale + 0.5f); + return (int) (Math.max(mMinimumWidth, child.getMeasuredWidth()) * mLayoutScale + 0.5f); } int getPageNearestToCenterOfScreen() { @@ -1410,7 +1429,7 @@ public abstract class PagedView extends ViewGroup { * Otherwise, returns null. */ protected Checkable getSingleCheckedGrandchild() { - if (mChoiceMode == CHOICE_MODE_SINGLE) { + if (mChoiceMode != CHOICE_MODE_MULTIPLE) { final int childCount = getChildCount(); for (int i = 0; i < childCount; ++i) { Page layout = (Page) getChildAt(i); @@ -1426,14 +1445,6 @@ public abstract class PagedView extends ViewGroup { return null; } - public Object getChosenItem() { - View checkedView = (View) getSingleCheckedGrandchild(); - if (checkedView != null) { - return checkedView.getTag(); - } - return null; - } - protected void resetCheckedGrandchildren() { // loop through children, and set all of their children to _not_ be checked final ArrayList<Checkable> checked = getCheckedGrandchildren(); |