diff options
author | Adam Cohen <adamcohen@google.com> | 2011-08-01 20:28:08 -0700 |
---|---|---|
committer | Adam Cohen <adamcohen@google.com> | 2011-08-01 20:30:29 -0700 |
commit | ed51cc9a12c50d12e7d30ed209a49f1a40858043 (patch) | |
tree | 6c16f3f03335067366c1c2584326bc5d3fc007c9 /src/com/android/launcher2/Workspace.java | |
parent | 8182e5bc3c2d1a0140df345599b89369d457bb4a (diff) | |
download | android_packages_apps_Trebuchet-ed51cc9a12c50d12e7d30ed209a49f1a40858043.tar.gz android_packages_apps_Trebuchet-ed51cc9a12c50d12e7d30ed209a49f1a40858043.tar.bz2 android_packages_apps_Trebuchet-ed51cc9a12c50d12e7d30ed209a49f1a40858043.zip |
Fixing animation when dropping to adjacent screen, issue 4990545
Change-Id: I575e9257a211ed72a6aefb119bccf1154d2a0c9f
Diffstat (limited to 'src/com/android/launcher2/Workspace.java')
-rw-r--r-- | src/com/android/launcher2/Workspace.java | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java index 57d176047..c10bd1aea 100644 --- a/src/com/android/launcher2/Workspace.java +++ b/src/com/android/launcher2/Workspace.java @@ -97,6 +97,8 @@ public class Workspace extends SmoothPagedView private static final int BACKGROUND_FADE_OUT_DURATION = 350; private static final int BACKGROUND_FADE_IN_DURATION = 350; + private static final int ADJACENT_SCREEN_DROP_DURATION = 300; + // These animators are used to fade the children's outlines private ObjectAnimator mChildrenOutlineFadeInAnimation; private ObjectAnimator mChildrenOutlineFadeOutAnimation; @@ -213,6 +215,9 @@ public class Workspace extends SmoothPagedView final static float TOUCH_SLOP_DAMPING_FACTOR = 4; // These variables are used for storing the initial and final values during workspace animations + private int mSavedScrollX; + private float mSavedRotationY; + private float mSavedTranslationX; private float mCurrentScaleX; private float mCurrentScaleY; private float mCurrentRotationY; @@ -2293,6 +2298,7 @@ public class Workspace extends SmoothPagedView } CellLayout dropTargetLayout = mDragTargetLayout; + int snapScreen = -1; if (d.dragSource != this) { final int[] touchXY = new int[] { (int) mDragViewVisualCenter[0], (int) mDragViewVisualCenter[1] }; @@ -2344,10 +2350,10 @@ public class Workspace extends SmoothPagedView dropTargetLayout, mTargetCell); if (dropInscrollArea && mState != State.SPRING_LOADED) { + snapScreen = screen; snapToPage(screen); } - if (mTargetCell[0] >= 0 && mTargetCell[1] >= 0) { if (hasMovedLayouts) { // Reparent the view @@ -2410,8 +2416,11 @@ public class Workspace extends SmoothPagedView }; mAnimatingViewIntoPlace = true; if (d.dragView.hasDrawn()) { - mLauncher.getDragLayer().animateViewIntoPosition(d.dragView, cell, + int duration = snapScreen < 0 ? -1 : ADJACENT_SCREEN_DROP_DURATION; + setFinalScrollForPageChange(snapScreen); + mLauncher.getDragLayer().animateViewIntoPosition(d.dragView, cell, duration, disableHardwareLayersRunnable); + resetFinalScrollForPageChange(snapScreen); } else { cell.setVisibility(VISIBLE); } @@ -2419,6 +2428,28 @@ public class Workspace extends SmoothPagedView } } + public void setFinalScrollForPageChange(int screen) { + if (screen >= 0) { + mSavedScrollX = getScrollX(); + CellLayout cl = (CellLayout) getChildAt(screen); + mSavedTranslationX = cl.getTranslationX(); + mSavedRotationY = cl.getRotationY(); + final int newX = getChildOffset(screen) - getRelativeChildOffset(screen); + setScrollX(newX); + cl.setTranslationX(0f); + cl.setRotationY(0f); + } + } + + public void resetFinalScrollForPageChange(int screen) { + if (screen >= 0) { + CellLayout cl = (CellLayout) getChildAt(screen); + setScrollX(mSavedScrollX); + cl.setTranslationX(mSavedTranslationX); + cl.setRotationY(mSavedRotationY); + } + } + public void getViewLocationRelativeToSelf(View v, int[] location) { getLocationInWindow(location); int x = location[0]; |