Merge "Check class type before creating animator" into tm-dev

This commit is contained in:
TreeHugger Robot
2022-03-09 21:43:27 +00:00
committed by Android (Google) Code Review
2 changed files with 19 additions and 4 deletions

View File

@@ -19,6 +19,8 @@ import android.content.Context;
import android.content.res.ColorStateList; import android.content.res.ColorStateList;
import android.content.res.Configuration; import android.content.res.Configuration;
import android.content.res.TypedArray; import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.GradientDrawable;
import android.graphics.drawable.VectorDrawable; import android.graphics.drawable.VectorDrawable;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.view.MotionEvent; import android.view.MotionEvent;
@@ -37,8 +39,14 @@ public class NumPadButton extends AlphaOptimizedImageButton {
public NumPadButton(Context context, AttributeSet attrs) { public NumPadButton(Context context, AttributeSet attrs) {
super(context, attrs); super(context, attrs);
mAnimator = new NumPadAnimator(context, getBackground().mutate(), Drawable background = getBackground();
attrs.getStyleAttribute()); if (background instanceof GradientDrawable) {
mAnimator = new NumPadAnimator(context, background.mutate(),
attrs.getStyleAttribute());
} else {
mAnimator = null;
}
} }
@Override @Override

View File

@@ -18,6 +18,8 @@ package com.android.keyguard;
import android.content.Context; import android.content.Context;
import android.content.res.Configuration; import android.content.res.Configuration;
import android.content.res.TypedArray; import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.GradientDrawable;
import android.os.PowerManager; import android.os.PowerManager;
import android.os.SystemClock; import android.os.SystemClock;
import android.util.AttributeSet; import android.util.AttributeSet;
@@ -129,8 +131,13 @@ public class NumPadKey extends ViewGroup {
setContentDescription(mDigitText.getText().toString()); setContentDescription(mDigitText.getText().toString());
mAnimator = new NumPadAnimator(context, getBackground().mutate(), Drawable background = getBackground();
R.style.NumPadKey, mDigitText); if (background instanceof GradientDrawable) {
mAnimator = new NumPadAnimator(context, background.mutate(),
R.style.NumPadKey, mDigitText);
} else {
mAnimator = null;
}
} }
@Override @Override