what-the-bank/sources/androidx/vectordrawable/graphics/drawable/AnimatedVectorDrawableCompa...

654 lines
22 KiB
Java
Raw Normal View History

2024-07-27 18:17:47 +07:00
package androidx.vectordrawable.graphics.drawable;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
import android.animation.ArgbEvaluator;
import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.ColorFilter;
import android.graphics.PorterDuff;
import android.graphics.Rect;
import android.graphics.Region;
import android.graphics.drawable.AnimatedVectorDrawable;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import androidx.vectordrawable.graphics.drawable.Animatable2Compat;
import java.io.IOException;
import java.util.ArrayList;
import o.C0363FHj;
import o.C16078kwa;
import o.IFU;
import o.Tlu;
import o.kVs;
import o.nyh;
import o.tuV;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
/* loaded from: classes.dex */
public class AnimatedVectorDrawableCompat extends IFU implements Animatable2Compat {
final Drawable.Callback a;
ArrayList<Animatable2Compat.AnimationCallback> b;
private IeS c;
LWm d;
private Animator.AnimatorListener f;
private ArgbEvaluator i;
private Context j;
@Override // o.IFU, android.graphics.drawable.Drawable
public /* bridge */ /* synthetic */ void clearColorFilter() {
super.clearColorFilter();
}
@Override // o.IFU, android.graphics.drawable.Drawable
public /* bridge */ /* synthetic */ Drawable getCurrent() {
return super.getCurrent();
}
@Override // o.IFU, android.graphics.drawable.Drawable
public /* bridge */ /* synthetic */ int getMinimumHeight() {
return super.getMinimumHeight();
}
@Override // o.IFU, android.graphics.drawable.Drawable
public /* bridge */ /* synthetic */ int getMinimumWidth() {
return super.getMinimumWidth();
}
@Override // o.IFU, android.graphics.drawable.Drawable
public /* bridge */ /* synthetic */ boolean getPadding(Rect rect) {
return super.getPadding(rect);
}
@Override // o.IFU, android.graphics.drawable.Drawable
public /* bridge */ /* synthetic */ int[] getState() {
return super.getState();
}
@Override // o.IFU, android.graphics.drawable.Drawable
public /* bridge */ /* synthetic */ Region getTransparentRegion() {
return super.getTransparentRegion();
}
@Override // o.IFU, android.graphics.drawable.Drawable
public /* bridge */ /* synthetic */ void jumpToCurrentState() {
super.jumpToCurrentState();
}
@Override // o.IFU, android.graphics.drawable.Drawable
public /* bridge */ /* synthetic */ void setChangingConfigurations(int i) {
super.setChangingConfigurations(i);
}
@Override // o.IFU, android.graphics.drawable.Drawable
public /* bridge */ /* synthetic */ void setColorFilter(int i, PorterDuff.Mode mode) {
super.setColorFilter(i, mode);
}
@Override // o.IFU, android.graphics.drawable.Drawable
public /* bridge */ /* synthetic */ void setFilterBitmap(boolean z) {
super.setFilterBitmap(z);
}
@Override // o.IFU, android.graphics.drawable.Drawable
public /* bridge */ /* synthetic */ void setHotspot(float f, float f2) {
super.setHotspot(f, f2);
}
@Override // o.IFU, android.graphics.drawable.Drawable
public /* bridge */ /* synthetic */ void setHotspotBounds(int i, int i2, int i3, int i4) {
super.setHotspotBounds(i, i2, i3, i4);
}
@Override // o.IFU, android.graphics.drawable.Drawable
public /* bridge */ /* synthetic */ boolean setState(int[] iArr) {
return super.setState(iArr);
}
AnimatedVectorDrawableCompat() {
this(null, null, null);
}
private AnimatedVectorDrawableCompat(Context context) {
this(context, null, null);
}
private AnimatedVectorDrawableCompat(Context context, IeS ieS, Resources resources) {
this.i = null;
this.f = null;
this.b = null;
Drawable.Callback callback = new Drawable.Callback(this) { // from class: androidx.vectordrawable.graphics.drawable.AnimatedVectorDrawableCompat.3
final AnimatedVectorDrawableCompat c;
{
this.c = this;
}
@Override // android.graphics.drawable.Drawable.Callback
public void invalidateDrawable(Drawable drawable) {
this.c.invalidateSelf();
}
@Override // android.graphics.drawable.Drawable.Callback
public void scheduleDrawable(Drawable drawable, Runnable runnable, long j) {
this.c.scheduleSelf(runnable, j);
}
@Override // android.graphics.drawable.Drawable.Callback
public void unscheduleDrawable(Drawable drawable, Runnable runnable) {
this.c.unscheduleSelf(runnable);
}
};
this.a = callback;
this.j = context;
if (ieS != null) {
this.c = ieS;
} else {
this.c = new IeS(context, ieS, callback, resources);
}
}
@Override // android.graphics.drawable.Drawable
public Drawable mutate() {
if (this.e != null) {
this.e.mutate();
}
return this;
}
public static AnimatedVectorDrawableCompat c(Context context, int i) {
AnimatedVectorDrawableCompat animatedVectorDrawableCompat = new AnimatedVectorDrawableCompat(context);
animatedVectorDrawableCompat.e = kVs.nZ_(context.getResources(), i, context.getTheme());
animatedVectorDrawableCompat.e.setCallback(animatedVectorDrawableCompat.a);
animatedVectorDrawableCompat.d = new LWm(animatedVectorDrawableCompat.e.getConstantState());
return animatedVectorDrawableCompat;
}
@Override // android.graphics.drawable.Drawable
public Drawable.ConstantState getConstantState() {
if (this.e != null) {
return new LWm(this.e.getConstantState());
}
return null;
}
@Override // android.graphics.drawable.Drawable
public int getChangingConfigurations() {
if (this.e != null) {
return this.e.getChangingConfigurations();
}
return super.getChangingConfigurations() | this.c.a;
}
@Override // android.graphics.drawable.Drawable
public void draw(Canvas canvas) {
if (this.e != null) {
this.e.draw(canvas);
return;
}
this.c.b.draw(canvas);
if (this.c.d.isStarted()) {
invalidateSelf();
}
}
@Override // o.IFU, android.graphics.drawable.Drawable
public void onBoundsChange(Rect rect) {
if (this.e != null) {
this.e.setBounds(rect);
} else {
this.c.b.setBounds(rect);
}
}
@Override // android.graphics.drawable.Drawable
protected boolean onStateChange(int[] iArr) {
if (this.e != null) {
return this.e.setState(iArr);
}
return this.c.b.setState(iArr);
}
@Override // o.IFU, android.graphics.drawable.Drawable
public boolean onLevelChange(int i) {
if (this.e != null) {
return this.e.setLevel(i);
}
return this.c.b.setLevel(i);
}
@Override // android.graphics.drawable.Drawable
public int getAlpha() {
if (this.e != null) {
return Tlu.pu_(this.e);
}
return this.c.b.getAlpha();
}
@Override // android.graphics.drawable.Drawable
public void setAlpha(int i) {
if (this.e != null) {
this.e.setAlpha(i);
} else {
this.c.b.setAlpha(i);
}
}
@Override // android.graphics.drawable.Drawable
public void setColorFilter(ColorFilter colorFilter) {
if (this.e != null) {
this.e.setColorFilter(colorFilter);
} else {
this.c.b.setColorFilter(colorFilter);
}
}
@Override // android.graphics.drawable.Drawable
public ColorFilter getColorFilter() {
if (this.e != null) {
return Tlu.pv_(this.e);
}
return this.c.b.getColorFilter();
}
@Override // android.graphics.drawable.Drawable
public void setTint(int i) {
if (this.e != null) {
Tlu.pE_(this.e, i);
} else {
this.c.b.setTint(i);
}
}
@Override // android.graphics.drawable.Drawable
public void setTintList(ColorStateList colorStateList) {
if (this.e != null) {
Tlu.pF_(this.e, colorStateList);
} else {
this.c.b.setTintList(colorStateList);
}
}
@Override // android.graphics.drawable.Drawable
public void setTintMode(PorterDuff.Mode mode) {
if (this.e != null) {
Tlu.pG_(this.e, mode);
} else {
this.c.b.setTintMode(mode);
}
}
@Override // android.graphics.drawable.Drawable
public boolean setVisible(boolean z, boolean z2) {
if (this.e != null) {
return this.e.setVisible(z, z2);
}
this.c.b.setVisible(z, z2);
return super.setVisible(z, z2);
}
@Override // android.graphics.drawable.Drawable
public boolean isStateful() {
if (this.e != null) {
return this.e.isStateful();
}
return this.c.b.isStateful();
}
@Override // android.graphics.drawable.Drawable
public int getOpacity() {
if (this.e != null) {
return this.e.getOpacity();
}
return this.c.b.getOpacity();
}
@Override // android.graphics.drawable.Drawable
public int getIntrinsicWidth() {
if (this.e != null) {
return this.e.getIntrinsicWidth();
}
return this.c.b.getIntrinsicWidth();
}
@Override // android.graphics.drawable.Drawable
public int getIntrinsicHeight() {
if (this.e != null) {
return this.e.getIntrinsicHeight();
}
return this.c.b.getIntrinsicHeight();
}
@Override // android.graphics.drawable.Drawable
public boolean isAutoMirrored() {
if (this.e != null) {
return Tlu.py_(this.e);
}
return this.c.b.isAutoMirrored();
}
@Override // android.graphics.drawable.Drawable
public void setAutoMirrored(boolean z) {
if (this.e != null) {
Tlu.pA_(this.e, z);
} else {
this.c.b.setAutoMirrored(z);
}
}
@Override // android.graphics.drawable.Drawable
public void inflate(Resources resources, XmlPullParser xmlPullParser, AttributeSet attributeSet, Resources.Theme theme) throws XmlPullParserException, IOException {
TypedArray obtainStyledAttributes;
if (this.e != null) {
Tlu.px_(this.e, resources, xmlPullParser, attributeSet, theme);
return;
}
int eventType = xmlPullParser.getEventType();
int depth = xmlPullParser.getDepth();
while (eventType != 1 && (xmlPullParser.getDepth() >= depth + 1 || eventType != 3)) {
if (eventType == 2) {
String name = xmlPullParser.getName();
if ("animated-vector".equals(name)) {
int[] iArr = C0363FHj.b;
if (theme == null) {
obtainStyledAttributes = resources.obtainAttributes(attributeSet, iArr);
} else {
obtainStyledAttributes = theme.obtainStyledAttributes(attributeSet, iArr, 0, 0);
}
int resourceId = obtainStyledAttributes.getResourceId(0, 0);
if (resourceId != 0) {
C16078kwa BD_ = C16078kwa.BD_(resources, resourceId, theme);
BD_.a(false);
BD_.setCallback(this.a);
if (this.c.b != null) {
this.c.b.setCallback(null);
}
this.c.b = BD_;
}
obtainStyledAttributes.recycle();
} else if ("target".equals(name)) {
TypedArray obtainAttributes = resources.obtainAttributes(attributeSet, C0363FHj.d);
String string = obtainAttributes.getString(0);
int resourceId2 = obtainAttributes.getResourceId(1, 0);
if (resourceId2 != 0) {
Context context = this.j;
if (context != null) {
BA_(string, tuV.BC_(context, resourceId2));
} else {
obtainAttributes.recycle();
throw new IllegalStateException("Context can't be null when inflating animators");
}
}
obtainAttributes.recycle();
} else {
continue;
}
}
eventType = xmlPullParser.next();
}
this.c.c();
}
@Override // android.graphics.drawable.Drawable
public void inflate(Resources resources, XmlPullParser xmlPullParser, AttributeSet attributeSet) throws XmlPullParserException, IOException {
inflate(resources, xmlPullParser, attributeSet, null);
}
@Override // o.IFU, android.graphics.drawable.Drawable
public void applyTheme(Resources.Theme theme) {
if (this.e != null) {
Tlu.pr_(this.e, theme);
}
}
@Override // android.graphics.drawable.Drawable
public boolean canApplyTheme() {
if (this.e != null) {
return Tlu.ps_(this.e);
}
return false;
}
/* loaded from: classes.dex */
static class LWm extends Drawable.ConstantState {
private final Drawable.ConstantState c;
public LWm(Drawable.ConstantState constantState) {
this.c = constantState;
}
@Override // android.graphics.drawable.Drawable.ConstantState
public Drawable newDrawable() {
AnimatedVectorDrawableCompat animatedVectorDrawableCompat = new AnimatedVectorDrawableCompat();
animatedVectorDrawableCompat.e = this.c.newDrawable();
animatedVectorDrawableCompat.e.setCallback(animatedVectorDrawableCompat.a);
return animatedVectorDrawableCompat;
}
@Override // android.graphics.drawable.Drawable.ConstantState
public Drawable newDrawable(Resources resources) {
AnimatedVectorDrawableCompat animatedVectorDrawableCompat = new AnimatedVectorDrawableCompat();
animatedVectorDrawableCompat.e = this.c.newDrawable(resources);
animatedVectorDrawableCompat.e.setCallback(animatedVectorDrawableCompat.a);
return animatedVectorDrawableCompat;
}
@Override // android.graphics.drawable.Drawable.ConstantState
public Drawable newDrawable(Resources resources, Resources.Theme theme) {
AnimatedVectorDrawableCompat animatedVectorDrawableCompat = new AnimatedVectorDrawableCompat();
animatedVectorDrawableCompat.e = this.c.newDrawable(resources, theme);
animatedVectorDrawableCompat.e.setCallback(animatedVectorDrawableCompat.a);
return animatedVectorDrawableCompat;
}
@Override // android.graphics.drawable.Drawable.ConstantState
public boolean canApplyTheme() {
return this.c.canApplyTheme();
}
@Override // android.graphics.drawable.Drawable.ConstantState
public int getChangingConfigurations() {
return this.c.getChangingConfigurations();
}
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes.dex */
public static class IeS extends Drawable.ConstantState {
int a;
C16078kwa b;
ArrayList<Animator> c;
AnimatorSet d;
nyh<Animator, String> e;
public IeS(Context context, IeS ieS, Drawable.Callback callback, Resources resources) {
if (ieS != null) {
this.a = ieS.a;
C16078kwa c16078kwa = ieS.b;
if (c16078kwa != null) {
Drawable.ConstantState constantState = c16078kwa.getConstantState();
if (resources != null) {
this.b = (C16078kwa) constantState.newDrawable(resources);
} else {
this.b = (C16078kwa) constantState.newDrawable();
}
C16078kwa c16078kwa2 = (C16078kwa) this.b.mutate();
this.b = c16078kwa2;
c16078kwa2.setCallback(callback);
this.b.setBounds(ieS.b.getBounds());
this.b.a(false);
}
ArrayList<Animator> arrayList = ieS.c;
if (arrayList != null) {
int size = arrayList.size();
this.c = new ArrayList<>(size);
this.e = new nyh<>(size);
for (int i = 0; i < size; i++) {
Animator animator = ieS.c.get(i);
Animator clone = animator.clone();
String str = ieS.e.get(animator);
clone.setTarget(this.b.a(str));
this.c.add(clone);
this.e.put(clone, str);
}
c();
}
}
}
@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 c() {
if (this.d == null) {
this.d = new AnimatorSet();
}
this.d.playTogether(this.c);
}
@Override // android.graphics.drawable.Drawable.ConstantState
public int getChangingConfigurations() {
return this.a;
}
}
private void BA_(String str, Animator animator) {
animator.setTarget(this.c.b.a(str));
if (this.c.c == null) {
this.c.c = new ArrayList<>();
this.c.e = new nyh<>();
}
this.c.c.add(animator);
this.c.e.put(animator, str);
}
@Override // android.graphics.drawable.Animatable
public boolean isRunning() {
if (this.e != null) {
return ((AnimatedVectorDrawable) this.e).isRunning();
}
return this.c.d.isRunning();
}
@Override // android.graphics.drawable.Animatable
public void start() {
if (this.e != null) {
((AnimatedVectorDrawable) this.e).start();
} else {
if (this.c.d.isStarted()) {
return;
}
this.c.d.start();
invalidateSelf();
}
}
@Override // android.graphics.drawable.Animatable
public void stop() {
if (this.e != null) {
((AnimatedVectorDrawable) this.e).stop();
} else {
this.c.d.end();
}
}
private static boolean BB_(AnimatedVectorDrawable animatedVectorDrawable, Animatable2Compat.AnimationCallback animationCallback) {
return animatedVectorDrawable.unregisterAnimationCallback(animationCallback.getPlatformCallback());
}
public void a(Animatable2Compat.AnimationCallback animationCallback) {
if (this.e != null) {
Bz_((AnimatedVectorDrawable) this.e, animationCallback);
return;
}
if (animationCallback == null) {
return;
}
if (this.b == null) {
this.b = new ArrayList<>();
}
if (this.b.contains(animationCallback)) {
return;
}
this.b.add(animationCallback);
if (this.f == null) {
this.f = new AnimatorListenerAdapter(this) { // from class: androidx.vectordrawable.graphics.drawable.AnimatedVectorDrawableCompat.5
final AnimatedVectorDrawableCompat b;
{
this.b = this;
}
@Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
public void onAnimationStart(Animator animator) {
ArrayList arrayList = new ArrayList(this.b.b);
int size = arrayList.size();
for (int i = 0; i < size; i++) {
((Animatable2Compat.AnimationCallback) arrayList.get(i)).onAnimationStart(this.b);
}
}
@Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
public void onAnimationEnd(Animator animator) {
ArrayList arrayList = new ArrayList(this.b.b);
int size = arrayList.size();
for (int i = 0; i < size; i++) {
((Animatable2Compat.AnimationCallback) arrayList.get(i)).onAnimationEnd(this.b);
}
}
};
}
this.c.d.addListener(this.f);
}
private static void Bz_(AnimatedVectorDrawable animatedVectorDrawable, Animatable2Compat.AnimationCallback animationCallback) {
animatedVectorDrawable.registerAnimationCallback(animationCallback.getPlatformCallback());
}
private void b() {
if (this.f != null) {
this.c.d.removeListener(this.f);
this.f = null;
}
}
public boolean e(Animatable2Compat.AnimationCallback animationCallback) {
if (this.e != null) {
BB_((AnimatedVectorDrawable) this.e, animationCallback);
}
ArrayList<Animatable2Compat.AnimationCallback> arrayList = this.b;
if (arrayList == null || animationCallback == null) {
return false;
}
boolean remove = arrayList.remove(animationCallback);
if (this.b.size() == 0) {
b();
}
return remove;
}
public void c() {
if (this.e != null) {
((AnimatedVectorDrawable) this.e).clearAnimationCallbacks();
return;
}
b();
ArrayList<Animatable2Compat.AnimationCallback> arrayList = this.b;
if (arrayList == null) {
return;
}
arrayList.clear();
}
}