Skip to content

Commit 793807f

Browse files
chethaaseAndroid (Google) Code Review
authored andcommitted
Merge "Fix AnimatorSet duration issue"
2 parents decd303 + c299a33 commit 793807f

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

core/java/android/animation/AnimatorSet.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -420,11 +420,7 @@ public AnimatorSet setDuration(long duration) {
420420
if (duration < 0) {
421421
throw new IllegalArgumentException("duration must be a value of zero or greater");
422422
}
423-
for (Node node : mNodes) {
424-
// TODO: don't set the duration of the timing-only nodes created by AnimatorSet to
425-
// insert "play-after" delays
426-
node.animation.setDuration(duration);
427-
}
423+
// Just record the value for now - it will be used later when the AnimatorSet starts
428424
mDuration = duration;
429425
return this;
430426
}
@@ -456,6 +452,14 @@ public void start() {
456452
mTerminated = false;
457453
mStarted = true;
458454

455+
if (mDuration >= 0) {
456+
// If the duration was set on this AnimatorSet, pass it along to all child animations
457+
for (Node node : mNodes) {
458+
// TODO: don't set the duration of the timing-only nodes created by AnimatorSet to
459+
// insert "play-after" delays
460+
node.animation.setDuration(mDuration);
461+
}
462+
}
459463
// First, sort the nodes (if necessary). This will ensure that sortedNodes
460464
// contains the animation nodes in the correct order.
461465
sortNodes();

0 commit comments

Comments
 (0)