From c299a3384171e36fc9ab6d1011d8a589a7f344d1 Mon Sep 17 00:00:00 2001 From: Chet Haase Date: Thu, 12 Apr 2012 07:51:50 -0700 Subject: Fix AnimatorSet duration issue Setting the duration on an AnimatorSet should propagate that value to its children. This works, but only if all children are added to the set before setDuration() is called. This fix delays that propagation until the set is started, making it possible to have a more flexible order of when the children are added and when the duration is set. Issue #6324904 AnimatorSet durations too long Change-Id: I797971c2310eb2e3fe931b4aa35de505f2a519f7 --- core/java/android/animation/AnimatorSet.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/core/java/android/animation/AnimatorSet.java b/core/java/android/animation/AnimatorSet.java index c5a4171..f9fa444 100644 --- a/core/java/android/animation/AnimatorSet.java +++ b/core/java/android/animation/AnimatorSet.java @@ -420,11 +420,7 @@ public final class AnimatorSet extends Animator { if (duration < 0) { throw new IllegalArgumentException("duration must be a value of zero or greater"); } - for (Node node : mNodes) { - // TODO: don't set the duration of the timing-only nodes created by AnimatorSet to - // insert "play-after" delays - node.animation.setDuration(duration); - } + // Just record the value for now - it will be used later when the AnimatorSet starts mDuration = duration; return this; } @@ -456,6 +452,14 @@ public final class AnimatorSet extends Animator { mTerminated = false; mStarted = true; + if (mDuration >= 0) { + // If the duration was set on this AnimatorSet, pass it along to all child animations + for (Node node : mNodes) { + // TODO: don't set the duration of the timing-only nodes created by AnimatorSet to + // insert "play-after" delays + node.animation.setDuration(mDuration); + } + } // First, sort the nodes (if necessary). This will ensure that sortedNodes // contains the animation nodes in the correct order. sortNodes(); -- cgit v1.1