diff --git a/src/com/android/launcher2/PagedView.java b/src/com/android/launcher2/PagedView.java index 0772c0a6c7..2cd7f206e5 100644 --- a/src/com/android/launcher2/PagedView.java +++ b/src/com/android/launcher2/PagedView.java @@ -877,7 +877,7 @@ public abstract class PagedView extends ViewGroup { return offset; } - protected void snapToDestination() { + int getPageNearestToCenterOfScreen() { int minDistanceFromScreenCenter = getMeasuredWidth(); int minDistanceFromScreenCenterIndex = -1; int screenCenter = mScrollX + (getMeasuredWidth() / 2); @@ -893,7 +893,11 @@ public abstract class PagedView extends ViewGroup { minDistanceFromScreenCenterIndex = i; } } - snapToPage(minDistanceFromScreenCenterIndex, PAGE_SNAP_ANIMATION_DURATION); + return minDistanceFromScreenCenterIndex; + } + + protected void snapToDestination() { + snapToPage(getPageNearestToCenterOfScreen(), PAGE_SNAP_ANIMATION_DURATION); } protected void snapToPageWithVelocity(int whichPage, int velocity) { diff --git a/src/com/android/launcher2/SmoothPagedView.java b/src/com/android/launcher2/SmoothPagedView.java index 73e147a220..5f80f2587f 100644 --- a/src/com/android/launcher2/SmoothPagedView.java +++ b/src/com/android/launcher2/SmoothPagedView.java @@ -96,7 +96,7 @@ public abstract class SmoothPagedView extends PagedView { @Override protected void snapToDestination() { - snapToPageWithVelocity(mCurrentPage, 0); + snapToPageWithVelocity(getPageNearestToCenterOfScreen(), 0); } @Override