Merge "Ensure that animated key button drawable has callbacks" into rvc-dev am: acf0750084 am: 9542a56d6b
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/12145664 Change-Id: Ieb3582c9948e8049431f9ffb62191561938d4f23
This commit is contained in:
@@ -80,6 +80,22 @@ public class KeyButtonDrawable extends Drawable {
|
|||||||
private final Paint mShadowPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG);
|
private final Paint mShadowPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG);
|
||||||
private final ShadowDrawableState mState;
|
private final ShadowDrawableState mState;
|
||||||
private AnimatedVectorDrawable mAnimatedDrawable;
|
private AnimatedVectorDrawable mAnimatedDrawable;
|
||||||
|
private final Callback mAnimatedDrawableCallback = new Callback() {
|
||||||
|
@Override
|
||||||
|
public void invalidateDrawable(@NonNull Drawable who) {
|
||||||
|
invalidateSelf();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void scheduleDrawable(@NonNull Drawable who, @NonNull Runnable what, long when) {
|
||||||
|
scheduleSelf(what, when);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void unscheduleDrawable(@NonNull Drawable who, @NonNull Runnable what) {
|
||||||
|
unscheduleSelf(what);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
public KeyButtonDrawable(Drawable d, @ColorInt int lightColor, @ColorInt int darkColor,
|
public KeyButtonDrawable(Drawable d, @ColorInt int lightColor, @ColorInt int darkColor,
|
||||||
boolean horizontalFlip, Color ovalBackgroundColor) {
|
boolean horizontalFlip, Color ovalBackgroundColor) {
|
||||||
@@ -97,6 +113,7 @@ public class KeyButtonDrawable extends Drawable {
|
|||||||
}
|
}
|
||||||
if (canAnimate()) {
|
if (canAnimate()) {
|
||||||
mAnimatedDrawable = (AnimatedVectorDrawable) mState.mChildState.newDrawable().mutate();
|
mAnimatedDrawable = (AnimatedVectorDrawable) mState.mChildState.newDrawable().mutate();
|
||||||
|
mAnimatedDrawable.setCallback(mAnimatedDrawableCallback);
|
||||||
setDrawableBounds(mAnimatedDrawable);
|
setDrawableBounds(mAnimatedDrawable);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user