diff options
author | Chet Haase <chet@google.com> | 2010-10-14 07:02:04 -0700 |
---|---|---|
committer | Chet Haase <chet@google.com> | 2010-10-14 10:51:21 -0700 |
commit | 472b281d5cb4f5660df981a6c912266b9f5703fe (patch) | |
tree | ec2393d2d472bda0893e861e19722ab9f7cc3c27 /src/com/android/launcher2/CellLayout.java | |
parent | 564976a46ef02d665aa0e455ad7867746a0b5325 (diff) | |
download | packages_apps_trebuchet-472b281d5cb4f5660df981a6c912266b9f5703fe.zip packages_apps_trebuchet-472b281d5cb4f5660df981a6c912266b9f5703fe.tar.gz packages_apps_trebuchet-472b281d5cb4f5660df981a6c912266b9f5703fe.tar.bz2 |
Updating code to use new non-generified animator APIs
Change-Id: Ie1928a22f774b226d90fa0918f61dba35d183dd6
Diffstat (limited to 'src/com/android/launcher2/CellLayout.java')
-rw-r--r-- | src/com/android/launcher2/CellLayout.java | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/src/com/android/launcher2/CellLayout.java b/src/com/android/launcher2/CellLayout.java index 3c6a8aa..c7c850b 100644 --- a/src/com/android/launcher2/CellLayout.java +++ b/src/com/android/launcher2/CellLayout.java @@ -94,7 +94,7 @@ public class CellLayout extends ViewGroup implements Dimmable { // These arrays are used to implement the drag visualization on x-large screens. // They are used as circular arrays, indexed by mDragOutlineCurrent. private Point[] mDragOutlines = new Point[8]; - private int[] mDragOutlineAlphas = new int[mDragOutlines.length]; + private float[] mDragOutlineAlphas = new float[mDragOutlines.length]; private InterruptibleInOutAnimator[] mDragOutlineAnims = new InterruptibleInOutAnimator[mDragOutlines.length]; @@ -175,13 +175,13 @@ public class CellLayout extends ViewGroup implements Dimmable { // Set up the animation for fading the crosshairs in and out int animDuration = res.getInteger(R.integer.config_crosshairsFadeInTime); mCrosshairsAnimator = new InterruptibleInOutAnimator(animDuration, 0.0f, 1.0f); - mCrosshairsAnimator.addUpdateListener(new AnimatorUpdateListener() { + mCrosshairsAnimator.getAnimator().addUpdateListener(new AnimatorUpdateListener() { public void onAnimationUpdate(ValueAnimator animation) { mCrosshairsVisibility = ((Float) animation.getAnimatedValue()).floatValue(); CellLayout.this.invalidate(); } }); - mCrosshairsAnimator.setInterpolator(interp); + mCrosshairsAnimator.getAnimator().setInterpolator(interp); for (int i = 0; i < mDragOutlines.length; i++) { mDragOutlines[i] = new Point(-1, -1); @@ -192,8 +192,8 @@ public class CellLayout extends ViewGroup implements Dimmable { // behind the drag path. // Set up all the animations that are used to implement this fading. final int duration = res.getInteger(R.integer.config_dragOutlineFadeTime); - final int fromAlphaValue = 0; - final int toAlphaValue = res.getInteger(R.integer.config_dragOutlineMaxAlpha); + final float fromAlphaValue = 0; + final float toAlphaValue = (float)res.getInteger(R.integer.config_dragOutlineMaxAlpha); for (int i = 0; i < mDragOutlineAlphas.length; i++) { mDragOutlineAlphas[i] = fromAlphaValue; @@ -202,10 +202,9 @@ public class CellLayout extends ViewGroup implements Dimmable { for (int i = 0; i < mDragOutlineAnims.length; i++) { final InterruptibleInOutAnimator anim = new InterruptibleInOutAnimator(duration, fromAlphaValue, toAlphaValue); - anim.setInterpolator(interp); - + anim.getAnimator().setInterpolator(interp); final int thisIndex = i; - anim.addUpdateListener(new AnimatorUpdateListener() { + anim.getAnimator().addUpdateListener(new AnimatorUpdateListener() { public void onAnimationUpdate(ValueAnimator animation) { final Bitmap outline = (Bitmap)anim.getTag(); @@ -221,7 +220,7 @@ public class CellLayout extends ViewGroup implements Dimmable { // Try to prevent it from continuing to run animation.cancel(); } else { - mDragOutlineAlphas[thisIndex] = (Integer) animation.getAnimatedValue(); + mDragOutlineAlphas[thisIndex] = (Float) animation.getAnimatedValue(); final int left = mDragOutlines[thisIndex].x; final int top = mDragOutlines[thisIndex].y; CellLayout.this.invalidate(left, top, @@ -231,9 +230,9 @@ public class CellLayout extends ViewGroup implements Dimmable { }); // The animation holds a reference to the drag outline bitmap as long is it's // running. This way the bitmap can be GCed when the animations are complete. - anim.addListener(new AnimatorListenerAdapter() { + anim.getAnimator().addListener(new AnimatorListenerAdapter() { public void onAnimationEnd(Animator animation) { - if ((Integer) anim.getAnimatedValue() == 0) { + if ((Float) ((ValueAnimator) animation).getAnimatedValue() == 0f) { anim.setTag(null); } } @@ -311,11 +310,11 @@ public class CellLayout extends ViewGroup implements Dimmable { final Paint paint = new Paint(); for (int i = 0; i < mDragOutlines.length; i++) { - final int alpha = mDragOutlineAlphas[i]; + final float alpha = mDragOutlineAlphas[i]; if (alpha > 0) { final Point p = mDragOutlines[i]; final Bitmap b = (Bitmap) mDragOutlineAnims[i].getTag(); - paint.setAlpha(alpha); + paint.setAlpha((int)(alpha + .5f)); canvas.drawBitmap(b, p.x, p.y, paint); } } |