diff options
author | Adam Powell <adamp@google.com> | 2010-04-02 10:41:38 -0700 |
---|---|---|
committer | Adam Powell <adamp@google.com> | 2010-04-02 10:41:38 -0700 |
commit | 327a9a3a309eeda5bdc18281066f2e19236455bc (patch) | |
tree | 136ea23533afcc5ca47927360e3acfd5fafd75b3 /src/com/android/launcher2/Workspace.java | |
parent | 8b5eef7d3ff30ec3823f73dfec63cfc54ce9935e (diff) | |
download | android_packages_apps_Trebuchet-327a9a3a309eeda5bdc18281066f2e19236455bc.tar.gz android_packages_apps_Trebuchet-327a9a3a309eeda5bdc18281066f2e19236455bc.tar.bz2 android_packages_apps_Trebuchet-327a9a3a309eeda5bdc18281066f2e19236455bc.zip |
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
Diffstat (limited to 'src/com/android/launcher2/Workspace.java')
-rw-r--r-- | src/com/android/launcher2/Workspace.java | 13 |
1 files 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(); } |