diff options
| author | Chet Haase <chet@google.com> | 2010-11-30 15:55:39 -0800 |
|---|---|---|
| committer | Chet Haase <chet@google.com> | 2010-12-01 11:05:59 -0800 |
| commit | 37a7bec599e8d877d8a7f12ab2c2c160d1c2cf8a (patch) | |
| tree | 0622b123416bd31093d07c0eb6f62af9af0ec39a /core/java | |
| parent | 7ae15f6c89a1d2d3b0ae3a05c594e545b1b7180a (diff) | |
Add methods to AnimatorSet that take collections
Change-Id: I5664bee6d27b32a70ca7d335e7fbe0af39a240bd
Diffstat (limited to 'core/java')
| -rw-r--r-- | core/java/android/animation/AnimatorSet.java | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/core/java/android/animation/AnimatorSet.java b/core/java/android/animation/AnimatorSet.java index f5420d1e966a..154e084ec591 100644 --- a/core/java/android/animation/AnimatorSet.java +++ b/core/java/android/animation/AnimatorSet.java @@ -17,7 +17,9 @@ package android.animation; import java.util.ArrayList; +import java.util.Collection; import java.util.HashMap; +import java.util.List; /** * This class plays a set of {@link Animator} objects in the specified order. Animations @@ -117,10 +119,29 @@ public final class AnimatorSet extends Animator { } /** + * Sets up this AnimatorSet to play all of the supplied animations at the same time. + * + * @param items The animations that will be started simultaneously. + */ + public void playTogether(Collection<Animator> items) { + if (items != null && items.size() > 0) { + mNeedsSort = true; + Builder builder = null; + for (Animator anim : items) { + if (builder == null) { + builder = play(anim); + } else { + builder.with(anim); + } + } + } + } + + /** * Sets up this AnimatorSet to play each of the supplied animations when the * previous animation ends. * - * @param items The aniamtions that will be started one after another. + * @param items The animations that will be started one after another. */ public void playSequentially(Animator... items) { if (items != null) { @@ -136,6 +157,25 @@ public final class AnimatorSet extends Animator { } /** + * Sets up this AnimatorSet to play each of the supplied animations when the + * previous animation ends. + * + * @param items The animations that will be started one after another. + */ + public void playSequentially(List<Animator> items) { + if (items != null && items.size() > 0) { + mNeedsSort = true; + if (items.size() == 1) { + play(items.get(0)); + } else { + for (int i = 0; i < items.size() - 1; ++i) { + play(items.get(i)).before(items.get(i+1)); + } + } + } + } + + /** * Returns the current list of child Animator objects controlled by this * AnimatorSet. This is a copy of the internal list; modifications to the returned list * will not affect the AnimatorSet, although changes to the underlying Animator objects |
