2021-07-24 02:37:17 +00:00
|
|
|
package androidx.vectordrawable.graphics.drawable;
|
|
|
|
|
|
|
|
import android.animation.Animator;
|
|
|
|
import android.animation.AnimatorListenerAdapter;
|
|
|
|
import android.animation.AnimatorSet;
|
|
|
|
import android.animation.ArgbEvaluator;
|
|
|
|
import android.animation.ObjectAnimator;
|
|
|
|
import android.content.Context;
|
|
|
|
import android.content.res.ColorStateList;
|
|
|
|
import android.content.res.Resources;
|
|
|
|
import android.content.res.TypedArray;
|
|
|
|
import android.content.res.XmlResourceParser;
|
|
|
|
import android.graphics.Canvas;
|
|
|
|
import android.graphics.ColorFilter;
|
|
|
|
import android.graphics.PorterDuff;
|
|
|
|
import android.graphics.Rect;
|
|
|
|
import android.graphics.Region;
|
|
|
|
import android.graphics.drawable.Animatable;
|
|
|
|
import android.graphics.drawable.AnimatedVectorDrawable;
|
|
|
|
import android.graphics.drawable.Drawable;
|
|
|
|
import android.os.Build;
|
|
|
|
import android.util.AttributeSet;
|
|
|
|
import android.util.Log;
|
|
|
|
import android.util.Xml;
|
|
|
|
import androidx.annotation.DrawableRes;
|
|
|
|
import androidx.annotation.NonNull;
|
|
|
|
import androidx.annotation.Nullable;
|
|
|
|
import androidx.annotation.RequiresApi;
|
|
|
|
import androidx.collection.ArrayMap;
|
|
|
|
import androidx.core.content.res.ResourcesCompat;
|
|
|
|
import androidx.core.content.res.TypedArrayUtils;
|
|
|
|
import androidx.core.graphics.drawable.DrawableCompat;
|
|
|
|
import androidx.vectordrawable.graphics.drawable.Animatable2Compat;
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import org.xmlpull.v1.XmlPullParser;
|
|
|
|
import org.xmlpull.v1.XmlPullParserException;
|
2022-03-07 09:34:54 +00:00
|
|
|
/* loaded from: classes.dex */
|
2021-07-24 02:37:17 +00:00
|
|
|
public class AnimatedVectorDrawableCompat extends VectorDrawableCommon implements Animatable2Compat {
|
|
|
|
private static final String ANIMATED_VECTOR = "animated-vector";
|
|
|
|
private static final boolean DBG_ANIMATION_VECTOR_DRAWABLE = false;
|
|
|
|
private static final String LOGTAG = "AnimatedVDCompat";
|
|
|
|
private static final String TARGET = "target";
|
|
|
|
private AnimatedVectorDrawableCompatState mAnimatedVectorState;
|
|
|
|
public ArrayList<Animatable2Compat.AnimationCallback> mAnimationCallbacks;
|
|
|
|
private Animator.AnimatorListener mAnimatorListener;
|
|
|
|
private ArgbEvaluator mArgbEvaluator;
|
|
|
|
public AnimatedVectorDrawableDelegateState mCachedConstantStateDelegate;
|
|
|
|
public final Drawable.Callback mCallback;
|
|
|
|
private Context mContext;
|
|
|
|
|
|
|
|
/* renamed from: androidx.vectordrawable.graphics.drawable.AnimatedVectorDrawableCompat$1 reason: invalid class name */
|
2022-03-07 09:34:54 +00:00
|
|
|
/* loaded from: classes.dex */
|
2021-07-24 02:37:17 +00:00
|
|
|
public class AnonymousClass1 implements Drawable.Callback {
|
|
|
|
public AnonymousClass1() {
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // android.graphics.drawable.Drawable.Callback
|
|
|
|
public void invalidateDrawable(Drawable drawable) {
|
|
|
|
AnimatedVectorDrawableCompat.this.invalidateSelf();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // android.graphics.drawable.Drawable.Callback
|
|
|
|
public void scheduleDrawable(Drawable drawable, Runnable runnable, long j) {
|
|
|
|
AnimatedVectorDrawableCompat.this.scheduleSelf(runnable, j);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // android.graphics.drawable.Drawable.Callback
|
|
|
|
public void unscheduleDrawable(Drawable drawable, Runnable runnable) {
|
|
|
|
AnimatedVectorDrawableCompat.this.unscheduleSelf(runnable);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* renamed from: androidx.vectordrawable.graphics.drawable.AnimatedVectorDrawableCompat$2 reason: invalid class name */
|
2022-03-07 09:34:54 +00:00
|
|
|
/* loaded from: classes.dex */
|
2021-07-24 02:37:17 +00:00
|
|
|
public class AnonymousClass2 extends AnimatorListenerAdapter {
|
|
|
|
public AnonymousClass2() {
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
|
|
|
|
public void onAnimationEnd(Animator animator) {
|
|
|
|
ArrayList arrayList = new ArrayList(AnimatedVectorDrawableCompat.this.mAnimationCallbacks);
|
|
|
|
int size = arrayList.size();
|
|
|
|
for (int i = 0; i < size; i++) {
|
|
|
|
((Animatable2Compat.AnimationCallback) arrayList.get(i)).onAnimationEnd(AnimatedVectorDrawableCompat.this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
|
|
|
|
public void onAnimationStart(Animator animator) {
|
|
|
|
ArrayList arrayList = new ArrayList(AnimatedVectorDrawableCompat.this.mAnimationCallbacks);
|
|
|
|
int size = arrayList.size();
|
|
|
|
for (int i = 0; i < size; i++) {
|
|
|
|
((Animatable2Compat.AnimationCallback) arrayList.get(i)).onAnimationStart(AnimatedVectorDrawableCompat.this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-07 09:34:54 +00:00
|
|
|
/* loaded from: classes.dex */
|
2021-07-24 02:37:17 +00:00
|
|
|
public static class AnimatedVectorDrawableCompatState extends Drawable.ConstantState {
|
|
|
|
public AnimatorSet mAnimatorSet;
|
|
|
|
public ArrayList<Animator> mAnimators;
|
|
|
|
public int mChangingConfigurations;
|
|
|
|
public ArrayMap<Animator, String> mTargetNameMap;
|
|
|
|
public VectorDrawableCompat mVectorDrawable;
|
|
|
|
|
|
|
|
public AnimatedVectorDrawableCompatState(Context context, AnimatedVectorDrawableCompatState animatedVectorDrawableCompatState, Drawable.Callback callback, Resources resources) {
|
|
|
|
if (animatedVectorDrawableCompatState != null) {
|
|
|
|
this.mChangingConfigurations = animatedVectorDrawableCompatState.mChangingConfigurations;
|
|
|
|
VectorDrawableCompat vectorDrawableCompat = animatedVectorDrawableCompatState.mVectorDrawable;
|
|
|
|
if (vectorDrawableCompat != null) {
|
|
|
|
Drawable.ConstantState constantState = vectorDrawableCompat.getConstantState();
|
|
|
|
if (resources != null) {
|
|
|
|
this.mVectorDrawable = (VectorDrawableCompat) constantState.newDrawable(resources);
|
|
|
|
} else {
|
|
|
|
this.mVectorDrawable = (VectorDrawableCompat) constantState.newDrawable();
|
|
|
|
}
|
|
|
|
VectorDrawableCompat vectorDrawableCompat2 = (VectorDrawableCompat) this.mVectorDrawable.mutate();
|
|
|
|
this.mVectorDrawable = vectorDrawableCompat2;
|
|
|
|
vectorDrawableCompat2.setCallback(callback);
|
|
|
|
this.mVectorDrawable.setBounds(animatedVectorDrawableCompatState.mVectorDrawable.getBounds());
|
|
|
|
this.mVectorDrawable.setAllowCaching(false);
|
|
|
|
}
|
|
|
|
ArrayList<Animator> arrayList = animatedVectorDrawableCompatState.mAnimators;
|
|
|
|
if (arrayList != null) {
|
|
|
|
int size = arrayList.size();
|
|
|
|
this.mAnimators = new ArrayList<>(size);
|
|
|
|
this.mTargetNameMap = new ArrayMap<>(size);
|
|
|
|
for (int i = 0; i < size; i++) {
|
|
|
|
Animator animator = animatedVectorDrawableCompatState.mAnimators.get(i);
|
|
|
|
Animator clone = animator.clone();
|
|
|
|
String str = animatedVectorDrawableCompatState.mTargetNameMap.get(animator);
|
|
|
|
clone.setTarget(this.mVectorDrawable.getTargetByName(str));
|
|
|
|
this.mAnimators.add(clone);
|
|
|
|
this.mTargetNameMap.put(clone, str);
|
|
|
|
}
|
|
|
|
setupAnimatorSet();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // android.graphics.drawable.Drawable.ConstantState
|
|
|
|
public int getChangingConfigurations() {
|
|
|
|
return this.mChangingConfigurations;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // android.graphics.drawable.Drawable.ConstantState
|
|
|
|
public Drawable newDrawable() {
|
|
|
|
throw new IllegalStateException("No constant state support for SDK < 24.");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // android.graphics.drawable.Drawable.ConstantState
|
|
|
|
public Drawable newDrawable(Resources resources) {
|
|
|
|
throw new IllegalStateException("No constant state support for SDK < 24.");
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setupAnimatorSet() {
|
|
|
|
if (this.mAnimatorSet == null) {
|
|
|
|
this.mAnimatorSet = new AnimatorSet();
|
|
|
|
}
|
|
|
|
this.mAnimatorSet.playTogether(this.mAnimators);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@RequiresApi(24)
|
2022-03-07 09:34:54 +00:00
|
|
|
/* loaded from: classes.dex */
|
2021-07-24 02:37:17 +00:00
|
|
|
public static class AnimatedVectorDrawableDelegateState extends Drawable.ConstantState {
|
|
|
|
private final Drawable.ConstantState mDelegateState;
|
|
|
|
|
|
|
|
public AnimatedVectorDrawableDelegateState(Drawable.ConstantState constantState) {
|
|
|
|
this.mDelegateState = constantState;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // android.graphics.drawable.Drawable.ConstantState
|
|
|
|
public boolean canApplyTheme() {
|
|
|
|
return this.mDelegateState.canApplyTheme();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // android.graphics.drawable.Drawable.ConstantState
|
|
|
|
public int getChangingConfigurations() {
|
|
|
|
return this.mDelegateState.getChangingConfigurations();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // android.graphics.drawable.Drawable.ConstantState
|
|
|
|
public Drawable newDrawable() {
|
|
|
|
AnimatedVectorDrawableCompat animatedVectorDrawableCompat = new AnimatedVectorDrawableCompat();
|
|
|
|
Drawable newDrawable = this.mDelegateState.newDrawable();
|
|
|
|
animatedVectorDrawableCompat.mDelegateDrawable = newDrawable;
|
|
|
|
newDrawable.setCallback(animatedVectorDrawableCompat.mCallback);
|
|
|
|
return animatedVectorDrawableCompat;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // android.graphics.drawable.Drawable.ConstantState
|
|
|
|
public Drawable newDrawable(Resources resources) {
|
|
|
|
AnimatedVectorDrawableCompat animatedVectorDrawableCompat = new AnimatedVectorDrawableCompat();
|
|
|
|
Drawable newDrawable = this.mDelegateState.newDrawable(resources);
|
|
|
|
animatedVectorDrawableCompat.mDelegateDrawable = newDrawable;
|
|
|
|
newDrawable.setCallback(animatedVectorDrawableCompat.mCallback);
|
|
|
|
return animatedVectorDrawableCompat;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // android.graphics.drawable.Drawable.ConstantState
|
|
|
|
public Drawable newDrawable(Resources resources, Resources.Theme theme) {
|
|
|
|
AnimatedVectorDrawableCompat animatedVectorDrawableCompat = new AnimatedVectorDrawableCompat();
|
|
|
|
Drawable newDrawable = this.mDelegateState.newDrawable(resources, theme);
|
|
|
|
animatedVectorDrawableCompat.mDelegateDrawable = newDrawable;
|
|
|
|
newDrawable.setCallback(animatedVectorDrawableCompat.mCallback);
|
|
|
|
return animatedVectorDrawableCompat;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public AnimatedVectorDrawableCompat() {
|
|
|
|
this(null, null, null);
|
|
|
|
}
|
|
|
|
|
|
|
|
private AnimatedVectorDrawableCompat(@Nullable Context context) {
|
|
|
|
this(context, null, null);
|
|
|
|
}
|
|
|
|
|
|
|
|
private AnimatedVectorDrawableCompat(@Nullable Context context, @Nullable AnimatedVectorDrawableCompatState animatedVectorDrawableCompatState, @Nullable Resources resources) {
|
|
|
|
this.mArgbEvaluator = null;
|
|
|
|
this.mAnimatorListener = null;
|
|
|
|
this.mAnimationCallbacks = null;
|
|
|
|
AnonymousClass1 r0 = new AnonymousClass1();
|
|
|
|
this.mCallback = r0;
|
|
|
|
this.mContext = context;
|
|
|
|
if (animatedVectorDrawableCompatState != null) {
|
|
|
|
this.mAnimatedVectorState = animatedVectorDrawableCompatState;
|
|
|
|
} else {
|
|
|
|
this.mAnimatedVectorState = new AnimatedVectorDrawableCompatState(context, animatedVectorDrawableCompatState, r0, resources);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void clearAnimationCallbacks(Drawable drawable) {
|
|
|
|
if (drawable instanceof Animatable) {
|
|
|
|
if (Build.VERSION.SDK_INT >= 24) {
|
|
|
|
((AnimatedVectorDrawable) drawable).clearAnimationCallbacks();
|
|
|
|
} else {
|
|
|
|
((AnimatedVectorDrawableCompat) drawable).clearAnimationCallbacks();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Nullable
|
|
|
|
public static AnimatedVectorDrawableCompat create(@NonNull Context context, @DrawableRes int i) {
|
|
|
|
int next;
|
|
|
|
if (Build.VERSION.SDK_INT >= 24) {
|
|
|
|
AnimatedVectorDrawableCompat animatedVectorDrawableCompat = new AnimatedVectorDrawableCompat(context);
|
|
|
|
Drawable drawable = ResourcesCompat.getDrawable(context.getResources(), i, context.getTheme());
|
|
|
|
animatedVectorDrawableCompat.mDelegateDrawable = drawable;
|
|
|
|
drawable.setCallback(animatedVectorDrawableCompat.mCallback);
|
|
|
|
animatedVectorDrawableCompat.mCachedConstantStateDelegate = new AnimatedVectorDrawableDelegateState(animatedVectorDrawableCompat.mDelegateDrawable.getConstantState());
|
|
|
|
return animatedVectorDrawableCompat;
|
|
|
|
}
|
|
|
|
try {
|
2022-03-07 09:34:54 +00:00
|
|
|
XmlResourceParser xml = context.getResources().getXml(i);
|
2021-07-24 02:37:17 +00:00
|
|
|
AttributeSet asAttributeSet = Xml.asAttributeSet(xml);
|
2022-03-07 09:34:54 +00:00
|
|
|
while (true) {
|
|
|
|
next = xml.next();
|
|
|
|
if (next == 2 || next == 1) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2021-07-24 02:37:17 +00:00
|
|
|
if (next == 2) {
|
|
|
|
return createFromXmlInner(context, context.getResources(), xml, asAttributeSet, context.getTheme());
|
|
|
|
}
|
|
|
|
throw new XmlPullParserException("No start tag found");
|
2022-03-07 09:34:54 +00:00
|
|
|
} catch (IOException e) {
|
2021-08-09 22:51:56 +00:00
|
|
|
Log.e(LOGTAG, "parser error", e);
|
2021-07-24 02:37:17 +00:00
|
|
|
return null;
|
2022-03-07 09:34:54 +00:00
|
|
|
} catch (XmlPullParserException e2) {
|
2021-08-09 22:51:56 +00:00
|
|
|
Log.e(LOGTAG, "parser error", e2);
|
2021-07-24 02:37:17 +00:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static AnimatedVectorDrawableCompat createFromXmlInner(Context context, Resources resources, XmlPullParser xmlPullParser, AttributeSet attributeSet, Resources.Theme theme) throws XmlPullParserException, IOException {
|
|
|
|
AnimatedVectorDrawableCompat animatedVectorDrawableCompat = new AnimatedVectorDrawableCompat(context);
|
|
|
|
animatedVectorDrawableCompat.inflate(resources, xmlPullParser, attributeSet, theme);
|
|
|
|
return animatedVectorDrawableCompat;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void registerAnimationCallback(Drawable drawable, Animatable2Compat.AnimationCallback animationCallback) {
|
|
|
|
if (drawable != null && animationCallback != null && (drawable instanceof Animatable)) {
|
|
|
|
if (Build.VERSION.SDK_INT >= 24) {
|
|
|
|
registerPlatformCallback((AnimatedVectorDrawable) drawable, animationCallback);
|
|
|
|
} else {
|
|
|
|
((AnimatedVectorDrawableCompat) drawable).registerAnimationCallback(animationCallback);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@RequiresApi(23)
|
|
|
|
private static void registerPlatformCallback(@NonNull AnimatedVectorDrawable animatedVectorDrawable, @NonNull Animatable2Compat.AnimationCallback animationCallback) {
|
|
|
|
animatedVectorDrawable.registerAnimationCallback(animationCallback.getPlatformCallback());
|
|
|
|
}
|
|
|
|
|
|
|
|
private void removeAnimatorSetListener() {
|
|
|
|
Animator.AnimatorListener animatorListener = this.mAnimatorListener;
|
|
|
|
if (animatorListener != null) {
|
|
|
|
this.mAnimatedVectorState.mAnimatorSet.removeListener(animatorListener);
|
|
|
|
this.mAnimatorListener = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void setupAnimatorsForTarget(String str, Animator animator) {
|
|
|
|
animator.setTarget(this.mAnimatedVectorState.mVectorDrawable.getTargetByName(str));
|
|
|
|
AnimatedVectorDrawableCompatState animatedVectorDrawableCompatState = this.mAnimatedVectorState;
|
|
|
|
if (animatedVectorDrawableCompatState.mAnimators == null) {
|
|
|
|
animatedVectorDrawableCompatState.mAnimators = new ArrayList<>();
|
|
|
|
this.mAnimatedVectorState.mTargetNameMap = new ArrayMap<>();
|
|
|
|
}
|
|
|
|
this.mAnimatedVectorState.mAnimators.add(animator);
|
|
|
|
this.mAnimatedVectorState.mTargetNameMap.put(animator, str);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void setupColorAnimator(Animator animator) {
|
|
|
|
ArrayList<Animator> childAnimations;
|
|
|
|
if ((animator instanceof AnimatorSet) && (childAnimations = ((AnimatorSet) animator).getChildAnimations()) != null) {
|
|
|
|
for (int i = 0; i < childAnimations.size(); i++) {
|
|
|
|
setupColorAnimator(childAnimations.get(i));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (animator instanceof ObjectAnimator) {
|
|
|
|
ObjectAnimator objectAnimator = (ObjectAnimator) animator;
|
|
|
|
String propertyName = objectAnimator.getPropertyName();
|
|
|
|
if ("fillColor".equals(propertyName) || "strokeColor".equals(propertyName)) {
|
|
|
|
if (this.mArgbEvaluator == null) {
|
|
|
|
this.mArgbEvaluator = new ArgbEvaluator();
|
|
|
|
}
|
|
|
|
objectAnimator.setEvaluator(this.mArgbEvaluator);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static boolean unregisterAnimationCallback(Drawable drawable, Animatable2Compat.AnimationCallback animationCallback) {
|
|
|
|
if (drawable == null || animationCallback == null || !(drawable instanceof Animatable)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return Build.VERSION.SDK_INT >= 24 ? unregisterPlatformCallback((AnimatedVectorDrawable) drawable, animationCallback) : ((AnimatedVectorDrawableCompat) drawable).unregisterAnimationCallback(animationCallback);
|
|
|
|
}
|
|
|
|
|
|
|
|
@RequiresApi(23)
|
|
|
|
private static boolean unregisterPlatformCallback(AnimatedVectorDrawable animatedVectorDrawable, Animatable2Compat.AnimationCallback animationCallback) {
|
|
|
|
return animatedVectorDrawable.unregisterAnimationCallback(animationCallback.getPlatformCallback());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // androidx.vectordrawable.graphics.drawable.VectorDrawableCommon, android.graphics.drawable.Drawable
|
|
|
|
public void applyTheme(Resources.Theme theme) {
|
|
|
|
Drawable drawable = this.mDelegateDrawable;
|
|
|
|
if (drawable != null) {
|
|
|
|
DrawableCompat.applyTheme(drawable, theme);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // android.graphics.drawable.Drawable
|
|
|
|
public boolean canApplyTheme() {
|
|
|
|
Drawable drawable = this.mDelegateDrawable;
|
|
|
|
if (drawable != null) {
|
|
|
|
return DrawableCompat.canApplyTheme(drawable);
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // androidx.vectordrawable.graphics.drawable.Animatable2Compat
|
|
|
|
public void clearAnimationCallbacks() {
|
|
|
|
Drawable drawable = this.mDelegateDrawable;
|
|
|
|
if (drawable != null) {
|
|
|
|
((AnimatedVectorDrawable) drawable).clearAnimationCallbacks();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
removeAnimatorSetListener();
|
|
|
|
ArrayList<Animatable2Compat.AnimationCallback> arrayList = this.mAnimationCallbacks;
|
|
|
|
if (arrayList != null) {
|
|
|
|
arrayList.clear();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // androidx.vectordrawable.graphics.drawable.VectorDrawableCommon, android.graphics.drawable.Drawable
|
|
|
|
public /* bridge */ /* synthetic */ void clearColorFilter() {
|
|
|
|
super.clearColorFilter();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // android.graphics.drawable.Drawable
|
|
|
|
public void draw(Canvas canvas) {
|
|
|
|
Drawable drawable = this.mDelegateDrawable;
|
|
|
|
if (drawable != null) {
|
|
|
|
drawable.draw(canvas);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
this.mAnimatedVectorState.mVectorDrawable.draw(canvas);
|
|
|
|
if (this.mAnimatedVectorState.mAnimatorSet.isStarted()) {
|
|
|
|
invalidateSelf();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // android.graphics.drawable.Drawable
|
|
|
|
public int getAlpha() {
|
|
|
|
Drawable drawable = this.mDelegateDrawable;
|
|
|
|
return drawable != null ? DrawableCompat.getAlpha(drawable) : this.mAnimatedVectorState.mVectorDrawable.getAlpha();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // android.graphics.drawable.Drawable
|
|
|
|
public int getChangingConfigurations() {
|
|
|
|
Drawable drawable = this.mDelegateDrawable;
|
|
|
|
return drawable != null ? drawable.getChangingConfigurations() : super.getChangingConfigurations() | this.mAnimatedVectorState.mChangingConfigurations;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // android.graphics.drawable.Drawable
|
|
|
|
public ColorFilter getColorFilter() {
|
|
|
|
Drawable drawable = this.mDelegateDrawable;
|
|
|
|
return drawable != null ? DrawableCompat.getColorFilter(drawable) : this.mAnimatedVectorState.mVectorDrawable.getColorFilter();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // android.graphics.drawable.Drawable
|
|
|
|
public Drawable.ConstantState getConstantState() {
|
|
|
|
if (this.mDelegateDrawable == null || Build.VERSION.SDK_INT < 24) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
return new AnimatedVectorDrawableDelegateState(this.mDelegateDrawable.getConstantState());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // androidx.vectordrawable.graphics.drawable.VectorDrawableCommon, android.graphics.drawable.Drawable
|
|
|
|
public /* bridge */ /* synthetic */ Drawable getCurrent() {
|
|
|
|
return super.getCurrent();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // android.graphics.drawable.Drawable
|
|
|
|
public int getIntrinsicHeight() {
|
|
|
|
Drawable drawable = this.mDelegateDrawable;
|
|
|
|
return drawable != null ? drawable.getIntrinsicHeight() : this.mAnimatedVectorState.mVectorDrawable.getIntrinsicHeight();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // android.graphics.drawable.Drawable
|
|
|
|
public int getIntrinsicWidth() {
|
|
|
|
Drawable drawable = this.mDelegateDrawable;
|
|
|
|
return drawable != null ? drawable.getIntrinsicWidth() : this.mAnimatedVectorState.mVectorDrawable.getIntrinsicWidth();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // androidx.vectordrawable.graphics.drawable.VectorDrawableCommon, android.graphics.drawable.Drawable
|
|
|
|
public /* bridge */ /* synthetic */ int getMinimumHeight() {
|
|
|
|
return super.getMinimumHeight();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // androidx.vectordrawable.graphics.drawable.VectorDrawableCommon, android.graphics.drawable.Drawable
|
|
|
|
public /* bridge */ /* synthetic */ int getMinimumWidth() {
|
|
|
|
return super.getMinimumWidth();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // android.graphics.drawable.Drawable
|
|
|
|
public int getOpacity() {
|
|
|
|
Drawable drawable = this.mDelegateDrawable;
|
|
|
|
return drawable != null ? drawable.getOpacity() : this.mAnimatedVectorState.mVectorDrawable.getOpacity();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // androidx.vectordrawable.graphics.drawable.VectorDrawableCommon, android.graphics.drawable.Drawable
|
|
|
|
public /* bridge */ /* synthetic */ boolean getPadding(Rect rect) {
|
|
|
|
return super.getPadding(rect);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // androidx.vectordrawable.graphics.drawable.VectorDrawableCommon, android.graphics.drawable.Drawable
|
|
|
|
public /* bridge */ /* synthetic */ int[] getState() {
|
|
|
|
return super.getState();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // androidx.vectordrawable.graphics.drawable.VectorDrawableCommon, android.graphics.drawable.Drawable
|
|
|
|
public /* bridge */ /* synthetic */ Region getTransparentRegion() {
|
|
|
|
return super.getTransparentRegion();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // android.graphics.drawable.Drawable
|
|
|
|
public void inflate(Resources resources, XmlPullParser xmlPullParser, AttributeSet attributeSet) throws XmlPullParserException, IOException {
|
|
|
|
inflate(resources, xmlPullParser, attributeSet, null);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // android.graphics.drawable.Drawable
|
|
|
|
public void inflate(Resources resources, XmlPullParser xmlPullParser, AttributeSet attributeSet, Resources.Theme theme) throws XmlPullParserException, IOException {
|
|
|
|
Drawable drawable = this.mDelegateDrawable;
|
|
|
|
if (drawable != null) {
|
|
|
|
DrawableCompat.inflate(drawable, resources, xmlPullParser, attributeSet, theme);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
int eventType = xmlPullParser.getEventType();
|
|
|
|
int depth = xmlPullParser.getDepth() + 1;
|
|
|
|
while (eventType != 1 && (xmlPullParser.getDepth() >= depth || eventType != 3)) {
|
|
|
|
if (eventType == 2) {
|
|
|
|
String name = xmlPullParser.getName();
|
2021-08-09 22:51:56 +00:00
|
|
|
if (ANIMATED_VECTOR.equals(name)) {
|
2021-07-24 02:37:17 +00:00
|
|
|
TypedArray obtainAttributes = TypedArrayUtils.obtainAttributes(resources, theme, attributeSet, AndroidResources.STYLEABLE_ANIMATED_VECTOR_DRAWABLE);
|
|
|
|
int resourceId = obtainAttributes.getResourceId(0, 0);
|
|
|
|
if (resourceId != 0) {
|
|
|
|
VectorDrawableCompat create = VectorDrawableCompat.create(resources, resourceId, theme);
|
|
|
|
create.setAllowCaching(false);
|
|
|
|
create.setCallback(this.mCallback);
|
|
|
|
VectorDrawableCompat vectorDrawableCompat = this.mAnimatedVectorState.mVectorDrawable;
|
|
|
|
if (vectorDrawableCompat != null) {
|
|
|
|
vectorDrawableCompat.setCallback(null);
|
|
|
|
}
|
|
|
|
this.mAnimatedVectorState.mVectorDrawable = create;
|
|
|
|
}
|
|
|
|
obtainAttributes.recycle();
|
2021-08-09 22:51:56 +00:00
|
|
|
} else if (TARGET.equals(name)) {
|
2021-07-24 02:37:17 +00:00
|
|
|
TypedArray obtainAttributes2 = resources.obtainAttributes(attributeSet, AndroidResources.STYLEABLE_ANIMATED_VECTOR_DRAWABLE_TARGET);
|
|
|
|
String string = obtainAttributes2.getString(0);
|
|
|
|
int resourceId2 = obtainAttributes2.getResourceId(1, 0);
|
|
|
|
if (resourceId2 != 0) {
|
|
|
|
Context context = this.mContext;
|
|
|
|
if (context != null) {
|
|
|
|
setupAnimatorsForTarget(string, AnimatorInflaterCompat.loadAnimator(context, resourceId2));
|
|
|
|
} else {
|
|
|
|
obtainAttributes2.recycle();
|
|
|
|
throw new IllegalStateException("Context can't be null when inflating animators");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
obtainAttributes2.recycle();
|
|
|
|
} else {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
eventType = xmlPullParser.next();
|
|
|
|
}
|
|
|
|
this.mAnimatedVectorState.setupAnimatorSet();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // android.graphics.drawable.Drawable
|
|
|
|
public boolean isAutoMirrored() {
|
|
|
|
Drawable drawable = this.mDelegateDrawable;
|
|
|
|
return drawable != null ? DrawableCompat.isAutoMirrored(drawable) : this.mAnimatedVectorState.mVectorDrawable.isAutoMirrored();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // android.graphics.drawable.Animatable
|
|
|
|
public boolean isRunning() {
|
|
|
|
Drawable drawable = this.mDelegateDrawable;
|
|
|
|
return drawable != null ? ((AnimatedVectorDrawable) drawable).isRunning() : this.mAnimatedVectorState.mAnimatorSet.isRunning();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // android.graphics.drawable.Drawable
|
|
|
|
public boolean isStateful() {
|
|
|
|
Drawable drawable = this.mDelegateDrawable;
|
|
|
|
return drawable != null ? drawable.isStateful() : this.mAnimatedVectorState.mVectorDrawable.isStateful();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // androidx.vectordrawable.graphics.drawable.VectorDrawableCommon, android.graphics.drawable.Drawable
|
|
|
|
public /* bridge */ /* synthetic */ void jumpToCurrentState() {
|
|
|
|
super.jumpToCurrentState();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // android.graphics.drawable.Drawable
|
|
|
|
public Drawable mutate() {
|
|
|
|
Drawable drawable = this.mDelegateDrawable;
|
|
|
|
if (drawable != null) {
|
|
|
|
drawable.mutate();
|
|
|
|
}
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // androidx.vectordrawable.graphics.drawable.VectorDrawableCommon, android.graphics.drawable.Drawable
|
|
|
|
public void onBoundsChange(Rect rect) {
|
|
|
|
Drawable drawable = this.mDelegateDrawable;
|
|
|
|
if (drawable != null) {
|
|
|
|
drawable.setBounds(rect);
|
|
|
|
} else {
|
|
|
|
this.mAnimatedVectorState.mVectorDrawable.setBounds(rect);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // androidx.vectordrawable.graphics.drawable.VectorDrawableCommon, android.graphics.drawable.Drawable
|
|
|
|
public boolean onLevelChange(int i) {
|
|
|
|
Drawable drawable = this.mDelegateDrawable;
|
|
|
|
return drawable != null ? drawable.setLevel(i) : this.mAnimatedVectorState.mVectorDrawable.setLevel(i);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // android.graphics.drawable.Drawable
|
|
|
|
public boolean onStateChange(int[] iArr) {
|
|
|
|
Drawable drawable = this.mDelegateDrawable;
|
|
|
|
return drawable != null ? drawable.setState(iArr) : this.mAnimatedVectorState.mVectorDrawable.setState(iArr);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // androidx.vectordrawable.graphics.drawable.Animatable2Compat
|
|
|
|
public void registerAnimationCallback(@NonNull Animatable2Compat.AnimationCallback animationCallback) {
|
|
|
|
Drawable drawable = this.mDelegateDrawable;
|
|
|
|
if (drawable != null) {
|
|
|
|
registerPlatformCallback((AnimatedVectorDrawable) drawable, animationCallback);
|
|
|
|
} else if (animationCallback != null) {
|
|
|
|
if (this.mAnimationCallbacks == null) {
|
|
|
|
this.mAnimationCallbacks = new ArrayList<>();
|
|
|
|
}
|
|
|
|
if (!this.mAnimationCallbacks.contains(animationCallback)) {
|
|
|
|
this.mAnimationCallbacks.add(animationCallback);
|
|
|
|
if (this.mAnimatorListener == null) {
|
|
|
|
this.mAnimatorListener = new AnonymousClass2();
|
|
|
|
}
|
|
|
|
this.mAnimatedVectorState.mAnimatorSet.addListener(this.mAnimatorListener);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // android.graphics.drawable.Drawable
|
|
|
|
public void setAlpha(int i) {
|
|
|
|
Drawable drawable = this.mDelegateDrawable;
|
|
|
|
if (drawable != null) {
|
|
|
|
drawable.setAlpha(i);
|
|
|
|
} else {
|
|
|
|
this.mAnimatedVectorState.mVectorDrawable.setAlpha(i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // android.graphics.drawable.Drawable
|
|
|
|
public void setAutoMirrored(boolean z2) {
|
|
|
|
Drawable drawable = this.mDelegateDrawable;
|
|
|
|
if (drawable != null) {
|
|
|
|
DrawableCompat.setAutoMirrored(drawable, z2);
|
|
|
|
} else {
|
|
|
|
this.mAnimatedVectorState.mVectorDrawable.setAutoMirrored(z2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // androidx.vectordrawable.graphics.drawable.VectorDrawableCommon, android.graphics.drawable.Drawable
|
|
|
|
public /* bridge */ /* synthetic */ void setChangingConfigurations(int i) {
|
|
|
|
super.setChangingConfigurations(i);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // androidx.vectordrawable.graphics.drawable.VectorDrawableCommon, android.graphics.drawable.Drawable
|
|
|
|
public /* bridge */ /* synthetic */ void setColorFilter(int i, PorterDuff.Mode mode) {
|
|
|
|
super.setColorFilter(i, mode);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // android.graphics.drawable.Drawable
|
|
|
|
public void setColorFilter(ColorFilter colorFilter) {
|
|
|
|
Drawable drawable = this.mDelegateDrawable;
|
|
|
|
if (drawable != null) {
|
|
|
|
drawable.setColorFilter(colorFilter);
|
|
|
|
} else {
|
|
|
|
this.mAnimatedVectorState.mVectorDrawable.setColorFilter(colorFilter);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // androidx.vectordrawable.graphics.drawable.VectorDrawableCommon, android.graphics.drawable.Drawable
|
|
|
|
public /* bridge */ /* synthetic */ void setFilterBitmap(boolean z2) {
|
|
|
|
super.setFilterBitmap(z2);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // androidx.vectordrawable.graphics.drawable.VectorDrawableCommon, android.graphics.drawable.Drawable
|
|
|
|
public /* bridge */ /* synthetic */ void setHotspot(float f, float f2) {
|
|
|
|
super.setHotspot(f, f2);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // androidx.vectordrawable.graphics.drawable.VectorDrawableCommon, android.graphics.drawable.Drawable
|
|
|
|
public /* bridge */ /* synthetic */ void setHotspotBounds(int i, int i2, int i3, int i4) {
|
|
|
|
super.setHotspotBounds(i, i2, i3, i4);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // androidx.vectordrawable.graphics.drawable.VectorDrawableCommon, android.graphics.drawable.Drawable
|
|
|
|
public /* bridge */ /* synthetic */ boolean setState(int[] iArr) {
|
|
|
|
return super.setState(iArr);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // android.graphics.drawable.Drawable, androidx.core.graphics.drawable.TintAwareDrawable
|
|
|
|
public void setTint(int i) {
|
|
|
|
Drawable drawable = this.mDelegateDrawable;
|
|
|
|
if (drawable != null) {
|
|
|
|
DrawableCompat.setTint(drawable, i);
|
|
|
|
} else {
|
|
|
|
this.mAnimatedVectorState.mVectorDrawable.setTint(i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // android.graphics.drawable.Drawable, androidx.core.graphics.drawable.TintAwareDrawable
|
|
|
|
public void setTintList(ColorStateList colorStateList) {
|
|
|
|
Drawable drawable = this.mDelegateDrawable;
|
|
|
|
if (drawable != null) {
|
|
|
|
DrawableCompat.setTintList(drawable, colorStateList);
|
|
|
|
} else {
|
|
|
|
this.mAnimatedVectorState.mVectorDrawable.setTintList(colorStateList);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // android.graphics.drawable.Drawable, androidx.core.graphics.drawable.TintAwareDrawable
|
|
|
|
public void setTintMode(PorterDuff.Mode mode) {
|
|
|
|
Drawable drawable = this.mDelegateDrawable;
|
|
|
|
if (drawable != null) {
|
|
|
|
DrawableCompat.setTintMode(drawable, mode);
|
|
|
|
} else {
|
|
|
|
this.mAnimatedVectorState.mVectorDrawable.setTintMode(mode);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // android.graphics.drawable.Drawable
|
|
|
|
public boolean setVisible(boolean z2, boolean z3) {
|
|
|
|
Drawable drawable = this.mDelegateDrawable;
|
|
|
|
if (drawable != null) {
|
|
|
|
return drawable.setVisible(z2, z3);
|
|
|
|
}
|
|
|
|
this.mAnimatedVectorState.mVectorDrawable.setVisible(z2, z3);
|
|
|
|
return super.setVisible(z2, z3);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // android.graphics.drawable.Animatable
|
|
|
|
public void start() {
|
|
|
|
Drawable drawable = this.mDelegateDrawable;
|
|
|
|
if (drawable != null) {
|
|
|
|
((AnimatedVectorDrawable) drawable).start();
|
|
|
|
} else if (!this.mAnimatedVectorState.mAnimatorSet.isStarted()) {
|
|
|
|
this.mAnimatedVectorState.mAnimatorSet.start();
|
|
|
|
invalidateSelf();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // android.graphics.drawable.Animatable
|
|
|
|
public void stop() {
|
|
|
|
Drawable drawable = this.mDelegateDrawable;
|
|
|
|
if (drawable != null) {
|
|
|
|
((AnimatedVectorDrawable) drawable).stop();
|
|
|
|
} else {
|
|
|
|
this.mAnimatedVectorState.mAnimatorSet.end();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // androidx.vectordrawable.graphics.drawable.Animatable2Compat
|
|
|
|
public boolean unregisterAnimationCallback(@NonNull Animatable2Compat.AnimationCallback animationCallback) {
|
|
|
|
Drawable drawable = this.mDelegateDrawable;
|
|
|
|
if (drawable != null) {
|
|
|
|
unregisterPlatformCallback((AnimatedVectorDrawable) drawable, animationCallback);
|
|
|
|
}
|
|
|
|
ArrayList<Animatable2Compat.AnimationCallback> arrayList = this.mAnimationCallbacks;
|
|
|
|
if (arrayList == null || animationCallback == null) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
boolean remove = arrayList.remove(animationCallback);
|
|
|
|
if (this.mAnimationCallbacks.size() == 0) {
|
|
|
|
removeAnimatorSetListener();
|
|
|
|
}
|
|
|
|
return remove;
|
|
|
|
}
|
|
|
|
}
|