Merge "Ensure invalidate is called after start()/reverse()" into nyc-dev
This commit is contained in:
@@ -154,7 +154,7 @@ public class AnimatedVectorDrawable extends Drawable implements Animatable2 {
|
|||||||
private static final boolean DBG_ANIMATION_VECTOR_DRAWABLE = false;
|
private static final boolean DBG_ANIMATION_VECTOR_DRAWABLE = false;
|
||||||
|
|
||||||
/** Local, mutable animator set. */
|
/** Local, mutable animator set. */
|
||||||
private final VectorDrawableAnimator mAnimatorSet = new VectorDrawableAnimator();
|
private final VectorDrawableAnimator mAnimatorSet = new VectorDrawableAnimator(this);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The resources against which this drawable was created. Used to attempt
|
* The resources against which this drawable was created. Used to attempt
|
||||||
@@ -613,14 +613,12 @@ public class AnimatedVectorDrawable extends Drawable implements Animatable2 {
|
|||||||
*/
|
*/
|
||||||
public void reset() {
|
public void reset() {
|
||||||
mAnimatorSet.reset();
|
mAnimatorSet.reset();
|
||||||
invalidateSelf();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void start() {
|
public void start() {
|
||||||
ensureAnimatorSet();
|
ensureAnimatorSet();
|
||||||
mAnimatorSet.start();
|
mAnimatorSet.start();
|
||||||
invalidateSelf();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@@ -639,7 +637,6 @@ public class AnimatedVectorDrawable extends Drawable implements Animatable2 {
|
|||||||
@Override
|
@Override
|
||||||
public void stop() {
|
public void stop() {
|
||||||
mAnimatorSet.end();
|
mAnimatorSet.end();
|
||||||
invalidateSelf();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -659,7 +656,6 @@ public class AnimatedVectorDrawable extends Drawable implements Animatable2 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mAnimatorSet.reverse();
|
mAnimatorSet.reverse();
|
||||||
invalidateSelf();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -781,8 +777,10 @@ public class AnimatedVectorDrawable extends Drawable implements Animatable2 {
|
|||||||
private WeakReference<RenderNode> mLastSeenTarget = null;
|
private WeakReference<RenderNode> mLastSeenTarget = null;
|
||||||
private int mLastListenerId = 0;
|
private int mLastListenerId = 0;
|
||||||
private int mPendingAnimationAction = NONE;
|
private int mPendingAnimationAction = NONE;
|
||||||
|
private final Drawable mDrawable;
|
||||||
|
|
||||||
VectorDrawableAnimator() {
|
VectorDrawableAnimator(AnimatedVectorDrawable drawable) {
|
||||||
|
mDrawable = drawable;
|
||||||
mSetPtr = nCreateAnimatorSet();
|
mSetPtr = nCreateAnimatorSet();
|
||||||
// Increment ref count on native AnimatorSet, so it doesn't get released before Java
|
// Increment ref count on native AnimatorSet, so it doesn't get released before Java
|
||||||
// side is done using it.
|
// side is done using it.
|
||||||
@@ -1058,12 +1056,17 @@ public class AnimatedVectorDrawable extends Drawable implements Animatable2 {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void invalidateOwningView() {
|
||||||
|
mDrawable.invalidateSelf();
|
||||||
|
}
|
||||||
|
|
||||||
public void start() {
|
public void start() {
|
||||||
if (!mInitialized) {
|
if (!mInitialized) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!useLastSeenTarget()) {
|
if (!useLastSeenTarget()) {
|
||||||
|
invalidateOwningView();
|
||||||
mPendingAnimationAction = START_ANIMATION;
|
mPendingAnimationAction = START_ANIMATION;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1074,6 +1077,7 @@ public class AnimatedVectorDrawable extends Drawable implements Animatable2 {
|
|||||||
|
|
||||||
mStarted = true;
|
mStarted = true;
|
||||||
nStart(mSetPtr, this, ++mLastListenerId);
|
nStart(mSetPtr, this, ++mLastListenerId);
|
||||||
|
invalidateOwningView();
|
||||||
if (mListener != null) {
|
if (mListener != null) {
|
||||||
mListener.onAnimationStart(null);
|
mListener.onAnimationStart(null);
|
||||||
}
|
}
|
||||||
@@ -1083,6 +1087,7 @@ public class AnimatedVectorDrawable extends Drawable implements Animatable2 {
|
|||||||
if (mInitialized && useLastSeenTarget()) {
|
if (mInitialized && useLastSeenTarget()) {
|
||||||
// If no target has ever been set, no-op
|
// If no target has ever been set, no-op
|
||||||
nEnd(mSetPtr);
|
nEnd(mSetPtr);
|
||||||
|
invalidateOwningView();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1090,6 +1095,7 @@ public class AnimatedVectorDrawable extends Drawable implements Animatable2 {
|
|||||||
if (mInitialized && useLastSeenTarget()) {
|
if (mInitialized && useLastSeenTarget()) {
|
||||||
// If no target has ever been set, no-op
|
// If no target has ever been set, no-op
|
||||||
nReset(mSetPtr);
|
nReset(mSetPtr);
|
||||||
|
invalidateOwningView();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1100,6 +1106,7 @@ public class AnimatedVectorDrawable extends Drawable implements Animatable2 {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!useLastSeenTarget()) {
|
if (!useLastSeenTarget()) {
|
||||||
|
invalidateOwningView();
|
||||||
mPendingAnimationAction = REVERSE_ANIMATION;
|
mPendingAnimationAction = REVERSE_ANIMATION;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1108,6 +1115,7 @@ public class AnimatedVectorDrawable extends Drawable implements Animatable2 {
|
|||||||
}
|
}
|
||||||
mStarted = true;
|
mStarted = true;
|
||||||
nReverse(mSetPtr, this, ++mLastListenerId);
|
nReverse(mSetPtr, this, ++mLastListenerId);
|
||||||
|
invalidateOwningView();
|
||||||
if (mListener != null) {
|
if (mListener != null) {
|
||||||
mListener.onAnimationStart(null);
|
mListener.onAnimationStart(null);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user