diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java index 6a4698f926..01e5cba373 100644 --- a/quickstep/src/com/android/quickstep/views/RecentsView.java +++ b/quickstep/src/com/android/quickstep/views/RecentsView.java @@ -345,14 +345,22 @@ public abstract class RecentsView extends PagedView impl private float calculateClearAllButtonAlpha() { final int childCount = getChildCount(); - if (mShowEmptyMessage || childCount == 0) return 0; + if (mShowEmptyMessage || childCount == 0 || mPageScrolls == null + || childCount != mPageScrolls.length) { + return 0; + } final int scrollEnd = getScrollEnd(); final int oldestChildScroll = getScrollForPage(childCount - 1); - return Utilities.boundToRange( - ((float) (getScrollX() - oldestChildScroll)) / - (scrollEnd - oldestChildScroll), 0, 1); + final int clearAllButtonMotionRange = scrollEnd - oldestChildScroll; + if (clearAllButtonMotionRange == 0) return 0; + + final float alphaUnbound = ((float) (getScrollX() - oldestChildScroll)) / + clearAllButtonMotionRange; + if (alphaUnbound > 1) return 0; + + return Math.max(alphaUnbound, 0); } private void updateClearAllButtonAlpha() { diff --git a/src/com/android/launcher3/PagedView.java b/src/com/android/launcher3/PagedView.java index eb816c58cc..a98867d752 100644 --- a/src/com/android/launcher3/PagedView.java +++ b/src/com/android/launcher3/PagedView.java @@ -109,7 +109,7 @@ public abstract class PagedView extends ViewGrou private float mLastMotionXRemainder; private float mTotalMotionX; - private int[] mPageScrolls; + protected int[] mPageScrolls; protected final static int TOUCH_STATE_REST = 0; protected final static int TOUCH_STATE_SCROLLING = 1;