From eda0dbc81cdb38c48df3bddf869b942e499b3811 Mon Sep 17 00:00:00 2001 From: Chet Haase Date: Fri, 9 Jan 2015 11:17:22 -0800 Subject: [PATCH] Add examples of animator resource files to ApiDemos Issue #17939329 Expose multi-property and multi-keyframe capabilities in animation resources Change-Id: If5b66b054b132b34c56b921209835793c7bbe674 --- samples/ApiDemos/res/anim/animator.xml | 2 ++ samples/ApiDemos/res/anim/object_animator.xml | 2 ++ .../ApiDemos/res/anim/object_animator_pvh.xml | 25 ++++++++++++++ .../res/anim/object_animator_pvh_kf.xml | 33 +++++++++++++++++++ .../res/anim/value_animator_pvh_kf.xml | 28 ++++++++++++++++ .../apis/animation/AnimationLoading.java | 24 +++++++++++++- 6 files changed, 113 insertions(+), 1 deletion(-) create mode 100644 samples/ApiDemos/res/anim/object_animator_pvh.xml create mode 100644 samples/ApiDemos/res/anim/object_animator_pvh_kf.xml create mode 100644 samples/ApiDemos/res/anim/value_animator_pvh_kf.xml diff --git a/samples/ApiDemos/res/anim/animator.xml b/samples/ApiDemos/res/anim/animator.xml index 2432f19a6..67aca3ffb 100644 --- a/samples/ApiDemos/res/anim/animator.xml +++ b/samples/ApiDemos/res/anim/animator.xml @@ -14,6 +14,7 @@ limitations under the License. --> + + diff --git a/samples/ApiDemos/res/anim/object_animator.xml b/samples/ApiDemos/res/anim/object_animator.xml index 863d42353..dc503d2d2 100644 --- a/samples/ApiDemos/res/anim/object_animator.xml +++ b/samples/ApiDemos/res/anim/object_animator.xml @@ -14,6 +14,7 @@ limitations under the License. --> + + diff --git a/samples/ApiDemos/res/anim/object_animator_pvh.xml b/samples/ApiDemos/res/anim/object_animator_pvh.xml new file mode 100644 index 000000000..10c4e4d79 --- /dev/null +++ b/samples/ApiDemos/res/anim/object_animator_pvh.xml @@ -0,0 +1,25 @@ + + + + + + + + + diff --git a/samples/ApiDemos/res/anim/object_animator_pvh_kf.xml b/samples/ApiDemos/res/anim/object_animator_pvh_kf.xml new file mode 100644 index 000000000..859a50849 --- /dev/null +++ b/samples/ApiDemos/res/anim/object_animator_pvh_kf.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + diff --git a/samples/ApiDemos/res/anim/value_animator_pvh_kf.xml b/samples/ApiDemos/res/anim/value_animator_pvh_kf.xml new file mode 100644 index 000000000..86b2e175c --- /dev/null +++ b/samples/ApiDemos/res/anim/value_animator_pvh_kf.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + diff --git a/samples/ApiDemos/src/com/example/android/apis/animation/AnimationLoading.java b/samples/ApiDemos/src/com/example/android/apis/animation/AnimationLoading.java index 910ee28aa..bac4f92d5 100644 --- a/samples/ApiDemos/src/com/example/android/apis/animation/AnimationLoading.java +++ b/samples/ApiDemos/src/com/example/android/apis/animation/AnimationLoading.java @@ -78,6 +78,9 @@ public class AnimationLoading extends Activity { addBall(200, 50); addBall(350, 50); addBall(500, 50, Color.GREEN); + addBall(650, 50); + addBall(800, 50); + addBall(950, 50); } private void createAnimation() { @@ -106,8 +109,27 @@ public class AnimationLoading extends Activity { loadAnimator(appContext, R.anim.color_animator); colorizer.setTarget(balls.get(3)); + ObjectAnimator animPvh = (ObjectAnimator) AnimatorInflater. + loadAnimator(appContext, R.anim.object_animator_pvh); + animPvh.setTarget(balls.get(4)); + + + ObjectAnimator animPvhKf = (ObjectAnimator) AnimatorInflater. + loadAnimator(appContext, R.anim.object_animator_pvh_kf); + animPvhKf.setTarget(balls.get(5)); + + ValueAnimator faderKf = (ValueAnimator) AnimatorInflater. + loadAnimator(appContext, R.anim.value_animator_pvh_kf); + faderKf.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { + public void onAnimationUpdate(ValueAnimator animation) { + balls.get(6).setAlpha((Float) animation.getAnimatedValue()); + } + }); + animation = new AnimatorSet(); - ((AnimatorSet) animation).playTogether(anim, fader, seq, colorizer); + ((AnimatorSet) animation).playTogether(anim, fader, seq, colorizer, animPvh, + animPvhKf, faderKf); + } }