diff options
author | Adam Cohen <adamcohen@google.com> | 2012-05-24 18:50:02 -0700 |
---|---|---|
committer | Adam Cohen <adamcohen@google.com> | 2012-05-24 18:50:41 -0700 |
commit | e7587d2f23f3ab9e133b40cd7fed4b030609f252 (patch) | |
tree | cd94b2dc279ef5913bc2502c5413a115444fcd86 /src/com/android/launcher2/CellLayout.java | |
parent | 7ce9985d37e253a93617404d5991017e1ea81907 (diff) | |
download | android_packages_apps_Trebuchet-e7587d2f23f3ab9e133b40cd7fed4b030609f252.tar.gz android_packages_apps_Trebuchet-e7587d2f23f3ab9e133b40cd7fed4b030609f252.tar.bz2 android_packages_apps_Trebuchet-e7587d2f23f3ab9e133b40cd7fed4b030609f252.zip |
Fix issue where reorder animations could leave views in translated state
Change-Id: I75f590c4ba43fec0550bbd003022d5c8309881a3
Diffstat (limited to 'src/com/android/launcher2/CellLayout.java')
-rw-r--r-- | src/com/android/launcher2/CellLayout.java | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/src/com/android/launcher2/CellLayout.java b/src/com/android/launcher2/CellLayout.java index c7ad92310..a96b5b168 100644 --- a/src/com/android/launcher2/CellLayout.java +++ b/src/com/android/launcher2/CellLayout.java @@ -31,7 +31,6 @@ import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.graphics.Point; -import android.graphics.PointF; import android.graphics.PorterDuff; import android.graphics.PorterDuffXfermode; import android.graphics.Rect; @@ -426,7 +425,7 @@ public class CellLayout extends ViewGroup { if (DEBUG_VISUALIZE_OCCUPIED) { int[] pt = new int[2]; ColorDrawable cd = new ColorDrawable(Color.RED); - cd.setBounds(0, 0, 80, 80); + cd.setBounds(0, 0, mCellWidth, mCellHeight); for (int i = 0; i < mCountX; i++) { for (int j = 0; j < mCountY; j++) { if (mOccupied[i][j]) { @@ -1926,7 +1925,7 @@ public class CellLayout extends ViewGroup { float finalScale; float initScale; private static final int DURATION = 300; - ValueAnimator va; + Animator a; public ReorderHintAnimation(View child, int cellX0, int cellY0, int cellX1, int cellY1, int spanX, int spanY) { @@ -1969,11 +1968,16 @@ public class CellLayout extends ViewGroup { ReorderHintAnimation oldAnimation = mShakeAnimators.get(child); oldAnimation.cancel(); mShakeAnimators.remove(child); + if (finalDeltaX == 0 && finalDeltaY == 0) { + completeAnimationImmediately(); + return; + } } if (finalDeltaX == 0 && finalDeltaY == 0) { return; } - va = ValueAnimator.ofFloat(0f, 1f); + ValueAnimator va = ValueAnimator.ofFloat(0f, 1f); + a = va; va.setRepeatMode(ValueAnimator.REVERSE); va.setRepeatCount(ValueAnimator.INFINITE); va.setDuration(DURATION); @@ -2004,12 +2008,18 @@ public class CellLayout extends ViewGroup { } private void cancel() { - va.cancel(); + if (a != null) { + a.cancel(); + } } + private void completeAnimationImmediately() { - va.cancel(); + if (a != null) { + a.cancel(); + } AnimatorSet s = new AnimatorSet(); + a = s; s.playTogether( ObjectAnimator.ofFloat(child, "scaleX", 1f), ObjectAnimator.ofFloat(child, "scaleY", 1f), |