Merge "Fix listeners not getting called when AVD falls back on UI thread" into nyc-mr1-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
69115b8e29
@@ -244,10 +244,7 @@ public class AnimatedVectorDrawable extends Drawable implements Animatable2 {
|
|||||||
// to UI thread animation for AVD.
|
// to UI thread animation for AVD.
|
||||||
if (!mAnimatorSet.isRunning() &&
|
if (!mAnimatorSet.isRunning() &&
|
||||||
((VectorDrawableAnimatorRT) mAnimatorSet).mPendingAnimationActions.size() > 0) {
|
((VectorDrawableAnimatorRT) mAnimatorSet).mPendingAnimationActions.size() > 0) {
|
||||||
VectorDrawableAnimatorRT oldAnim = (VectorDrawableAnimatorRT) mAnimatorSet;
|
fallbackOntoUI();
|
||||||
mAnimatorSet = new VectorDrawableAnimatorUI(this);
|
|
||||||
mAnimatorSet.init(mAnimatorSetFromXml);
|
|
||||||
oldAnim.transferPendingActions(mAnimatorSet);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mAnimatorSet.onDraw(canvas);
|
mAnimatorSet.onDraw(canvas);
|
||||||
@@ -490,10 +487,22 @@ public class AnimatedVectorDrawable extends Drawable implements Animatable2 {
|
|||||||
throw new UnsupportedOperationException("Cannot force Animated Vector Drawable to" +
|
throw new UnsupportedOperationException("Cannot force Animated Vector Drawable to" +
|
||||||
" run on UI thread when the animation has started on RenderThread.");
|
" run on UI thread when the animation has started on RenderThread.");
|
||||||
}
|
}
|
||||||
|
fallbackOntoUI();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void fallbackOntoUI() {
|
||||||
|
if (mAnimatorSet instanceof VectorDrawableAnimatorRT) {
|
||||||
|
VectorDrawableAnimatorRT oldAnim = (VectorDrawableAnimatorRT) mAnimatorSet;
|
||||||
mAnimatorSet = new VectorDrawableAnimatorUI(this);
|
mAnimatorSet = new VectorDrawableAnimatorUI(this);
|
||||||
if (mAnimatorSetFromXml != null) {
|
if (mAnimatorSetFromXml != null) {
|
||||||
mAnimatorSet.init(mAnimatorSetFromXml);
|
mAnimatorSet.init(mAnimatorSetFromXml);
|
||||||
}
|
}
|
||||||
|
// Transfer the listener from RT animator to UI animator
|
||||||
|
if (oldAnim.mListener != null) {
|
||||||
|
mAnimatorSet.setListener(oldAnim.mListener);
|
||||||
|
}
|
||||||
|
oldAnim.transferPendingActions(mAnimatorSet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user