From 2d3d5377a8e08a4fb83ed394c1a5b84c6a79cd98 Mon Sep 17 00:00:00 2001 From: Chet Haase Date: Sat, 23 Oct 2010 08:54:43 -0700 Subject: [PATCH] Updated to the new optimized keyframe APIs Also fixed some existing bugs in some of the animation apps Change-Id: Iff39a8396f8c49e2db8601b04012a0bb784a78ed --- .../android/apis/animation/AnimationCloning.java | 4 +--- .../android/apis/animation/LayoutAnimations.java | 6 +++--- .../apis/animation/LayoutAnimationsHideShow.java | 6 +++--- .../apis/animation/MultiPropertyAnimation.java | 11 ++++++----- 4 files changed, 13 insertions(+), 14 deletions(-) diff --git a/samples/ApiDemos/src/com/example/android/apis/animation/AnimationCloning.java b/samples/ApiDemos/src/com/example/android/apis/animation/AnimationCloning.java index f8f2da5b5..61896fa72 100644 --- a/samples/ApiDemos/src/com/example/android/apis/animation/AnimationCloning.java +++ b/samples/ApiDemos/src/com/example/android/apis/animation/AnimationCloning.java @@ -73,8 +73,6 @@ public class AnimationCloning extends Activity { ShapeHolder ball1 = addBall(150f, 25f); ShapeHolder ball2 = addBall(250f, 25f); ShapeHolder ball3 = addBall(350f, 25f); - - } private void createAnimation() { @@ -91,7 +89,7 @@ public class AnimationCloning extends Activity { animDown.setInterpolator(new AccelerateInterpolator()); ObjectAnimator animUp = ObjectAnimator.ofFloat(ball2, "y", getHeight() - ball2.getHeight(), 0f).setDuration(500); - animDown.setInterpolator(new DecelerateInterpolator()); + animUp.setInterpolator(new DecelerateInterpolator()); AnimatorSet s1 = new AnimatorSet(); s1.playSequentially(animDown, animUp); animDown.addUpdateListener(this); diff --git a/samples/ApiDemos/src/com/example/android/apis/animation/LayoutAnimations.java b/samples/ApiDemos/src/com/example/android/apis/animation/LayoutAnimations.java index e98a6875d..5d38b03b4 100644 --- a/samples/ApiDemos/src/com/example/android/apis/animation/LayoutAnimations.java +++ b/samples/ApiDemos/src/com/example/android/apis/animation/LayoutAnimations.java @@ -170,9 +170,9 @@ public class LayoutAnimations extends Activity { }); // Changing while Removing - Keyframe kf0 = new Keyframe(0f, 0f); - Keyframe kf1 = new Keyframe(.9999f, 360f); - Keyframe kf2 = new Keyframe(1f, 0f); + Keyframe kf0 = Keyframe.ofFloat(0f, 0f); + Keyframe kf1 = Keyframe.ofFloat(.9999f, 360f); + Keyframe kf2 = Keyframe.ofFloat(1f, 0f); PropertyValuesHolder pvhRotation = PropertyValuesHolder.ofKeyframe("rotation", kf0, kf1, kf2); customChangingDisappearingAnim = ObjectAnimator.ofPropertyValuesHolder( diff --git a/samples/ApiDemos/src/com/example/android/apis/animation/LayoutAnimationsHideShow.java b/samples/ApiDemos/src/com/example/android/apis/animation/LayoutAnimationsHideShow.java index 44d3f6db4..66e424ea1 100644 --- a/samples/ApiDemos/src/com/example/android/apis/animation/LayoutAnimationsHideShow.java +++ b/samples/ApiDemos/src/com/example/android/apis/animation/LayoutAnimationsHideShow.java @@ -136,9 +136,9 @@ public class LayoutAnimationsHideShow extends Activity { }); // Changing while Removing - Keyframe kf0 = new Keyframe(0f, 0f); - Keyframe kf1 = new Keyframe(.9999f, 360f); - Keyframe kf2 = new Keyframe(1f, 0f); + Keyframe kf0 = Keyframe.ofFloat(0f, 0f); + Keyframe kf1 = Keyframe.ofFloat(.9999f, 360f); + Keyframe kf2 = Keyframe.ofFloat(1f, 0f); PropertyValuesHolder pvhRotation = PropertyValuesHolder.ofKeyframe("rotation", kf0, kf1, kf2); final ObjectAnimator changeOut = ObjectAnimator.ofPropertyValuesHolder( diff --git a/samples/ApiDemos/src/com/example/android/apis/animation/MultiPropertyAnimation.java b/samples/ApiDemos/src/com/example/android/apis/animation/MultiPropertyAnimation.java index f6e878cac..71af03f75 100644 --- a/samples/ApiDemos/src/com/example/android/apis/animation/MultiPropertyAnimation.java +++ b/samples/ApiDemos/src/com/example/android/apis/animation/MultiPropertyAnimation.java @@ -109,7 +109,7 @@ public class MultiPropertyAnimation extends Activity { ball.getHeight() * 2); PropertyValuesHolder pvTX = PropertyValuesHolder.ofFloat("x", ball.getX(), ball.getX() - BALL_SIZE/2f); - PropertyValuesHolder pvTY = PropertyValuesHolder.ofFloat("y", 0f, ball.getY(), + PropertyValuesHolder pvTY = PropertyValuesHolder.ofFloat("y", ball.getY(), ball.getY() - BALL_SIZE/2f); ObjectAnimator whxyBouncer = ObjectAnimator.ofPropertyValuesHolder(ball, pvhW, pvhH, pvTX, pvTY).setDuration(DURATION/2); @@ -119,9 +119,9 @@ public class MultiPropertyAnimation extends Activity { ball = balls.get(3); pvhY = PropertyValuesHolder.ofFloat("y", ball.getY(), getHeight() - BALL_SIZE); float ballX = ball.getX(); - Keyframe kf0 = new Keyframe(0f, ballX); - Keyframe kf1 = new Keyframe(.5f, ballX + 100f); - Keyframe kf2 = new Keyframe(1f, ballX + 50f); + Keyframe kf0 = Keyframe.ofFloat(0f, ballX); + Keyframe kf1 = Keyframe.ofFloat(.5f, ballX + 100f); + Keyframe kf2 = Keyframe.ofFloat(1f, ballX + 50f); PropertyValuesHolder pvhX = PropertyValuesHolder.ofKeyframe("x", kf0, kf1, kf2); ObjectAnimator yxBouncer = ObjectAnimator.ofPropertyValuesHolder(ball, pvhY, pvhX).setDuration(DURATION/2); @@ -130,7 +130,8 @@ public class MultiPropertyAnimation extends Activity { bounceAnim = new AnimatorSet(); - ((AnimatorSet)bounceAnim).playTogether(yBouncer, yAlphaBouncer, whxyBouncer, yxBouncer); + ((AnimatorSet)bounceAnim).playTogether(yBouncer, yAlphaBouncer, whxyBouncer, + yxBouncer); } }