diff options
author | Michael Jurka <mikejurka@google.com> | 2011-01-26 00:00:44 -0800 |
---|---|---|
committer | Michael Jurka <mikejurka@google.com> | 2011-01-26 00:03:19 -0800 |
commit | 0bb8563b1381d92b0d7dbb5b0f814ad656c2f9bd (patch) | |
tree | f94ab0d1367e8708b9960eaf7afae10d0d75caad /src | |
parent | 5cc7c35dca4d1279575285f33ecef1a1df339d11 (diff) | |
download | android_packages_apps_Trebuchet-0bb8563b1381d92b0d7dbb5b0f814ad656c2f9bd.tar.gz android_packages_apps_Trebuchet-0bb8563b1381d92b0d7dbb5b0f814ad656c2f9bd.tar.bz2 android_packages_apps_Trebuchet-0bb8563b1381d92b0d7dbb5b0f814ad656c2f9bd.zip |
Fix issue with spring loaded mode
Bug # 3373320
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/launcher2/SpringLoadedDragController.java | 15 | ||||
-rw-r--r-- | src/com/android/launcher2/Workspace.java | 29 |
2 files changed, 38 insertions, 6 deletions
diff --git a/src/com/android/launcher2/SpringLoadedDragController.java b/src/com/android/launcher2/SpringLoadedDragController.java index a734258f9..900758118 100644 --- a/src/com/android/launcher2/SpringLoadedDragController.java +++ b/src/com/android/launcher2/SpringLoadedDragController.java @@ -26,6 +26,8 @@ public class SpringLoadedDragController implements OnAlarmListener { // the screen the user is currently hovering over, if any private CellLayout mScreen; private Launcher mLauncher; + boolean mFinishedAnimation = false; + boolean mWaitingToReenter = false; public SpringLoadedDragController(Launcher launcher) { mLauncher = launcher; @@ -33,9 +35,16 @@ public class SpringLoadedDragController implements OnAlarmListener { mAlarm.setOnAlarmListener(this); } - public void onDragEnter(CellLayout cl) { + public void onDragEnter(CellLayout cl, boolean isSpringLoaded) { mScreen = cl; mAlarm.setAlarm(ENTER_SPRING_LOAD_HOVER_TIME); + mFinishedAnimation = isSpringLoaded; + mWaitingToReenter = false; + } + + public void onEnterSpringLoadedMode(boolean waitToReenter) { + mFinishedAnimation = true; + mWaitingToReenter = waitToReenter; } public void onDragExit() { @@ -43,7 +52,9 @@ public class SpringLoadedDragController implements OnAlarmListener { mScreen.onDragExit(); } mScreen = null; - mAlarm.setAlarm(EXIT_SPRING_LOAD_HOVER_TIME); + if (mFinishedAnimation && !mWaitingToReenter) { + mAlarm.setAlarm(EXIT_SPRING_LOAD_HOVER_TIME); + } } // this is called when our timer runs out diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java index 270027bfc..842f2f3bf 100644 --- a/src/com/android/launcher2/Workspace.java +++ b/src/com/android/launcher2/Workspace.java @@ -209,6 +209,13 @@ public class Workspace extends SmoothPagedView boolean mUpdateWallpaperOffsetImmediately = false; boolean mSyncWallpaperOffsetWithScroll = true; + // info about the last drag + private DragView mLastDragView; + private int mLastDragOriginX; + private int mLastDragOriginY; + private int mLastDragXOffset; + private int mLastDragYOffset; + /** * Used to inflate the Workspace from XML. * @@ -275,11 +282,19 @@ public class Workspace extends SmoothPagedView mIsInUnshrinkAnimation = true; disableCacheUpdates(); } + @Override public void onAnimationEnd(Animator animation) { mIsInUnshrinkAnimation = false; mSyncWallpaperOffsetWithScroll = true; - if (mShrinkState != ShrinkState.SPRING_LOADED) { + if (mShrinkState == ShrinkState.SPRING_LOADED) { + View layout = null; + if (mLastDragView != null) { + layout = findMatchingPageForDragOver(mLastDragView, mLastDragOriginX, + mLastDragOriginY, mLastDragXOffset, mLastDragYOffset); + } + mSpringLoadedDragController.onEnterSpringLoadedMode(layout == null); + } else { mDrawCustomizeTrayBackground = false; } enableCacheUpdates(); @@ -1499,6 +1514,7 @@ public class Workspace extends SmoothPagedView // we call this method whenever a drag and drop in Launcher finishes, even if Workspace was // never dragged over public void onDragStopped(boolean success) { + mLastDragView = null; // In the success case, DragController has already called onDragExit() if (!success) { doDragExit(); @@ -2338,8 +2354,12 @@ public class Workspace extends SmoothPagedView int originY = y - yOffset; boolean shrunken = mIsSmall || mIsInUnshrinkAnimation; if (shrunken) { - layout = findMatchingPageForDragOver( - dragView, originX, originY, xOffset, yOffset); + mLastDragView = dragView; + mLastDragOriginX = originX; + mLastDragOriginY = originY; + mLastDragXOffset = xOffset; + mLastDragYOffset = yOffset; + layout = findMatchingPageForDragOver(dragView, originX, originY, xOffset, yOffset); if (layout != mDragTargetLayout) { if (mDragTargetLayout != null) { @@ -2349,7 +2369,8 @@ public class Workspace extends SmoothPagedView mDragTargetLayout = layout; if (mDragTargetLayout != null && mDragTargetLayout.getAcceptsDrops()) { mDragTargetLayout.setIsDragOverlapping(true); - mSpringLoadedDragController.onDragEnter(mDragTargetLayout); + mSpringLoadedDragController.onDragEnter( + mDragTargetLayout, mShrinkState == ShrinkState.SPRING_LOADED); } } } else { |