diff options
Diffstat (limited to 'src/com/android/launcher2/PagedView.java')
-rw-r--r-- | src/com/android/launcher2/PagedView.java | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/com/android/launcher2/PagedView.java b/src/com/android/launcher2/PagedView.java index 8ee381021..605f4b69f 100644 --- a/src/com/android/launcher2/PagedView.java +++ b/src/com/android/launcher2/PagedView.java @@ -62,7 +62,7 @@ public abstract class PagedView extends ViewGroup { private static final int PAGE_SNAP_ANIMATION_DURATION = 550; protected static final float NANOTIME_DIV = 1000000000.0f; - private static final float OVERSCROLL_DAMP_FACTOR = 0.08f; + private static final float OVERSCROLL_DAMP_FACTOR = 0.14f; private static final int MINIMUM_SNAP_VELOCITY = 2200; private static final int MIN_FLING_VELOCITY = 250; private static final float RETURN_TO_ORIGINAL_PAGE_THRESHOLD = 0.33f; @@ -470,12 +470,18 @@ public abstract class PagedView extends ViewGroup { childrenX[i] = child.getX(); childrenY[i] = child.getY(); } - onLayout(false, mLeft, mTop, mRight, mBottom); + // Trigger a full re-layout (never just call onLayout directly!) + int widthSpec = MeasureSpec.makeMeasureSpec(getMeasuredWidth(), MeasureSpec.EXACTLY); + int heightSpec = MeasureSpec.makeMeasureSpec(getMeasuredHeight(), MeasureSpec.EXACTLY); + requestLayout(); + measure(widthSpec, heightSpec); + layout(mLeft, mTop, mRight, mBottom); for (int i = 0; i < childCount; i++) { final View child = getChildAt(i); child.setX(childrenX[i]); child.setY(childrenY[i]); } + // Also, the page offset has changed (since the pages are now smaller); // update the page offset, but again preserving absolute X and Y coordinates scrollToNewPageWithoutMovingPages(mCurrentPage); @@ -1300,7 +1306,7 @@ public abstract class PagedView extends ViewGroup { // snap duration. This is a function of the actual distance that needs to be traveled; // we keep this value close to half screen size in order to reduce the variance in snap // duration as a function of the distance the page needs to travel. - float distanceRatio = 1.0f * Math.abs(delta) / 2 * halfScreenSize; + float distanceRatio = Math.min(1f, 1.0f * Math.abs(delta) / (2 * halfScreenSize)); float distance = halfScreenSize + halfScreenSize * distanceInfluenceForSnapDuration(distanceRatio); @@ -1309,8 +1315,8 @@ public abstract class PagedView extends ViewGroup { // we want the page's snap velocity to approximately match the velocity at which the // user flings, so we scale the duration by a value near to the derivative of the scroll - // interpolator at zero, ie. 5. We use 6 to make it a little slower. - duration = 6 * Math.round(1000 * Math.abs(distance / velocity)); + // interpolator at zero, ie. 5. We use 4 to make it a little slower. + duration = 4 * Math.round(1000 * Math.abs(distance / velocity)); snapToPage(whichPage, delta, duration); } |