Fixing AVD animation with startOffset
b/17160751
Change-Id: If030ca04f5a7dd7e732dcc5dfb18d51faa7e7b79
diff --git a/graphics/java/android/graphics/drawable/AnimatedVectorDrawable.java b/graphics/java/android/graphics/drawable/AnimatedVectorDrawable.java
index 00c92fa..a9ebf21 100644
--- a/graphics/java/android/graphics/drawable/AnimatedVectorDrawable.java
+++ b/graphics/java/android/graphics/drawable/AnimatedVectorDrawable.java
@@ -152,7 +152,7 @@
@Override
public void draw(Canvas canvas) {
mAnimatedVectorState.mVectorDrawable.draw(canvas);
- if (isRunning()) {
+ if (isStarted()) {
invalidateSelf();
}
}
@@ -306,13 +306,25 @@
return false;
}
+ private boolean isStarted() {
+ final ArrayList<Animator> animators = mAnimatedVectorState.mAnimators;
+ final int size = animators.size();
+ for (int i = 0; i < size; i++) {
+ final Animator animator = animators.get(i);
+ if (animator.isStarted()) {
+ return true;
+ }
+ }
+ return false;
+ }
+
@Override
public void start() {
final ArrayList<Animator> animators = mAnimatedVectorState.mAnimators;
final int size = animators.size();
for (int i = 0; i < size; i++) {
final Animator animator = animators.get(i);
- if (!animator.isRunning()) {
+ if (!animator.isStarted()) {
animator.start();
}
}