From 327a9a3a309eeda5bdc18281066f2e19236455bc Mon Sep 17 00:00:00 2001 From: Adam Powell Date: Fri, 2 Apr 2010 10:41:38 -0700 Subject: Limit workspace flings to one screen at a time. This prevents users from scrolling left slightly, flinging right, and scrolling by two screens as a result (and vice versa). Change-Id: I04c60438c022b24defcd8e4cbedf1c6b07c24423 --- src/com/android/launcher2/Workspace.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java index cb4ba1145..7a175164d 100644 --- a/src/com/android/launcher2/Workspace.java +++ b/src/com/android/launcher2/Workspace.java @@ -838,13 +838,20 @@ public class Workspace extends ViewGroup implements DropTarget, DragSource, Drag final int screenWidth = getWidth(); final int whichScreen = (mScrollX + (screenWidth / 2)) / screenWidth; + final float scrolledPos = (float) mScrollX / screenWidth; if (velocityX > SNAP_VELOCITY && mCurrentScreen > 0) { - // Fling hard enough to move left - snapToScreen(Math.min(whichScreen, mCurrentScreen - 1)); + // Fling hard enough to move left. + // Don't fling across more than one screen at a time. + final int bound = scrolledPos < whichScreen ? + mCurrentScreen - 1 : mCurrentScreen; + snapToScreen(Math.min(whichScreen, bound)); } else if (velocityX < -SNAP_VELOCITY && mCurrentScreen < getChildCount() - 1) { // Fling hard enough to move right - snapToScreen(Math.max(whichScreen, mCurrentScreen + 1)); + // Don't fling across more than one screen at a time. + final int bound = scrolledPos > whichScreen ? + mCurrentScreen + 1 : mCurrentScreen; + snapToScreen(Math.max(whichScreen, bound)); } else { snapToDestination(); } -- cgit v1.2.3