discord-jadx/app/src/main/java/com/airbnb/lottie/LottieAnimationView.java

766 lines
23 KiB
Java

package com.airbnb.lottie;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Bitmap;
import android.graphics.PathMeasure;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Parcel;
import android.os.Parcelable;
import android.provider.Settings;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageView;
import androidx.annotation.DrawableRes;
import androidx.annotation.FloatRange;
import androidx.annotation.MainThread;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RawRes;
import androidx.appcompat.widget.AppCompatImageView;
import androidx.core.view.ViewCompat;
import c.c.a.b0.g;
import c.c.a.d;
import c.c.a.e;
import c.c.a.h;
import c.c.a.i;
import c.c.a.j;
import c.c.a.l;
import c.c.a.n;
import c.c.a.o;
import c.c.a.r;
import c.c.a.s;
import c.c.a.t;
import c.c.a.u;
import c.c.a.v;
import c.c.a.y.f;
import java.io.ByteArrayInputStream;
import java.io.InterruptedIOException;
import java.lang.ref.WeakReference;
import java.net.ProtocolException;
import java.net.SocketException;
import java.net.UnknownHostException;
import java.net.UnknownServiceException;
import java.nio.channels.ClosedChannelException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import javax.net.ssl.SSLException;
public class LottieAnimationView extends AppCompatImageView {
public static final String i = LottieAnimationView.class.getSimpleName();
public static final l<Throwable> j = new a();
@Nullable
public r<d> A;
@Nullable
public d B;
public final l<d> k = new b();
public final l<Throwable> l = new c();
@Nullable
public l<Throwable> m;
@DrawableRes
public int n;
public final j o;
public boolean p;
public String q;
@RawRes
public int r;
/* renamed from: s reason: collision with root package name */
public boolean f1537s;
public boolean t;
public boolean u;
public boolean v;
public boolean w;
/* renamed from: x reason: collision with root package name */
public t f1538x;
/* renamed from: y reason: collision with root package name */
public Set<n> f1539y;
/* renamed from: z reason: collision with root package name */
public int f1540z;
public static class SavedState extends View.BaseSavedState {
public static final Parcelable.Creator<SavedState> CREATOR = new a();
public String i;
public int j;
public float k;
public boolean l;
public String m;
public int n;
public int o;
public class a implements Parcelable.Creator<SavedState> {
/* Return type fixed from 'java.lang.Object' to match base method */
@Override // android.os.Parcelable.Creator
public SavedState createFromParcel(Parcel parcel) {
return new SavedState(parcel, null);
}
/* Return type fixed from 'java.lang.Object[]' to match base method */
@Override // android.os.Parcelable.Creator
public SavedState[] newArray(int i) {
return new SavedState[i];
}
}
public SavedState(Parcel parcel, a aVar) {
super(parcel);
this.i = parcel.readString();
this.k = parcel.readFloat();
this.l = parcel.readInt() != 1 ? false : true;
this.m = parcel.readString();
this.n = parcel.readInt();
this.o = parcel.readInt();
}
public SavedState(Parcelable parcelable) {
super(parcelable);
}
@Override // android.view.View.BaseSavedState, android.os.Parcelable, android.view.AbsSavedState
public void writeToParcel(Parcel parcel, int i) {
super.writeToParcel(parcel, i);
parcel.writeString(this.i);
parcel.writeFloat(this.k);
parcel.writeInt(this.l ? 1 : 0);
parcel.writeString(this.m);
parcel.writeInt(this.n);
parcel.writeInt(this.o);
}
}
public class a implements l<Throwable> {
/* JADX DEBUG: Method arguments types fixed to match base method, original types: [java.lang.Object] */
@Override // c.c.a.l
public void a(Throwable th) {
Throwable th2 = th;
PathMeasure pathMeasure = g.a;
if ((th2 instanceof SocketException) || (th2 instanceof ClosedChannelException) || (th2 instanceof InterruptedIOException) || (th2 instanceof ProtocolException) || (th2 instanceof SSLException) || (th2 instanceof UnknownHostException) || (th2 instanceof UnknownServiceException)) {
c.c.a.b0.c.c("Unable to load composition.", th2);
return;
}
throw new IllegalStateException("Unable to parse composition", th2);
}
}
public class b implements l<d> {
public b() {
}
/* JADX DEBUG: Method arguments types fixed to match base method, original types: [java.lang.Object] */
@Override // c.c.a.l
public void a(d dVar) {
LottieAnimationView.this.setComposition(dVar);
}
}
public class c implements l<Throwable> {
public c() {
}
/* JADX DEBUG: Method arguments types fixed to match base method, original types: [java.lang.Object] */
@Override // c.c.a.l
public void a(Throwable th) {
Throwable th2 = th;
LottieAnimationView lottieAnimationView = LottieAnimationView.this;
int i = lottieAnimationView.n;
if (i != 0) {
lottieAnimationView.setImageResource(i);
}
l<Throwable> lVar = LottieAnimationView.this.m;
if (lVar == null) {
String str = LottieAnimationView.i;
lVar = LottieAnimationView.j;
}
lVar.a(th2);
}
}
public LottieAnimationView(Context context, AttributeSet attributeSet) {
super(context, attributeSet);
String string;
boolean z2 = false;
this.n = 0;
j jVar = new j();
this.o = jVar;
this.f1537s = false;
this.t = false;
this.u = false;
this.v = false;
this.w = true;
this.f1538x = t.AUTOMATIC;
this.f1539y = new HashSet();
this.f1540z = 0;
TypedArray obtainStyledAttributes = getContext().obtainStyledAttributes(attributeSet, R.b.LottieAnimationView, R.a.lottieAnimationViewStyle, 0);
if (!isInEditMode()) {
this.w = obtainStyledAttributes.getBoolean(R.b.LottieAnimationView_lottie_cacheComposition, true);
int i2 = R.b.LottieAnimationView_lottie_rawRes;
boolean hasValue = obtainStyledAttributes.hasValue(i2);
int i3 = R.b.LottieAnimationView_lottie_fileName;
boolean hasValue2 = obtainStyledAttributes.hasValue(i3);
int i4 = R.b.LottieAnimationView_lottie_url;
boolean hasValue3 = obtainStyledAttributes.hasValue(i4);
if (!hasValue || !hasValue2) {
if (hasValue) {
int resourceId = obtainStyledAttributes.getResourceId(i2, 0);
if (resourceId != 0) {
setAnimation(resourceId);
}
} else if (hasValue2) {
String string2 = obtainStyledAttributes.getString(i3);
if (string2 != null) {
setAnimation(string2);
}
} else if (hasValue3 && (string = obtainStyledAttributes.getString(i4)) != null) {
setAnimationFromUrl(string);
}
setFallbackResource(obtainStyledAttributes.getResourceId(R.b.LottieAnimationView_lottie_fallbackRes, 0));
} else {
throw new IllegalArgumentException("lottie_rawRes and lottie_fileName cannot be used at the same time. Please use only one at once.");
}
}
if (obtainStyledAttributes.getBoolean(R.b.LottieAnimationView_lottie_autoPlay, false)) {
this.u = true;
this.v = true;
}
if (obtainStyledAttributes.getBoolean(R.b.LottieAnimationView_lottie_loop, false)) {
jVar.k.setRepeatCount(-1);
}
int i5 = R.b.LottieAnimationView_lottie_repeatMode;
if (obtainStyledAttributes.hasValue(i5)) {
setRepeatMode(obtainStyledAttributes.getInt(i5, 1));
}
int i6 = R.b.LottieAnimationView_lottie_repeatCount;
if (obtainStyledAttributes.hasValue(i6)) {
setRepeatCount(obtainStyledAttributes.getInt(i6, -1));
}
int i7 = R.b.LottieAnimationView_lottie_speed;
if (obtainStyledAttributes.hasValue(i7)) {
setSpeed(obtainStyledAttributes.getFloat(i7, 1.0f));
}
setImageAssetsFolder(obtainStyledAttributes.getString(R.b.LottieAnimationView_lottie_imageAssetsFolder));
setProgress(obtainStyledAttributes.getFloat(R.b.LottieAnimationView_lottie_progress, 0.0f));
boolean z3 = obtainStyledAttributes.getBoolean(R.b.LottieAnimationView_lottie_enableMergePathsForKitKatAndAbove, false);
if (jVar.v != z3) {
jVar.v = z3;
if (jVar.j != null) {
jVar.b();
}
}
int i8 = R.b.LottieAnimationView_lottie_colorFilter;
if (obtainStyledAttributes.hasValue(i8)) {
jVar.a(new f("**"), o.C, new c.c.a.c0.c(new u(obtainStyledAttributes.getColor(i8, 0))));
}
int i9 = R.b.LottieAnimationView_lottie_scale;
if (obtainStyledAttributes.hasValue(i9)) {
jVar.l = obtainStyledAttributes.getFloat(i9, 1.0f);
jVar.v();
}
int i10 = R.b.LottieAnimationView_lottie_renderMode;
if (obtainStyledAttributes.hasValue(i10)) {
int i11 = obtainStyledAttributes.getInt(i10, 0);
t.values();
setRenderMode(t.values()[i11 >= 3 ? 0 : i11]);
}
if (getScaleType() != null) {
jVar.q = getScaleType();
}
obtainStyledAttributes.recycle();
Context context2 = getContext();
PathMeasure pathMeasure = g.a;
Boolean valueOf = Boolean.valueOf(Settings.Global.getFloat(context2.getContentResolver(), "animator_duration_scale", 1.0f) != 0.0f ? true : z2);
Objects.requireNonNull(jVar);
jVar.m = valueOf.booleanValue();
b();
this.p = true;
}
private void setCompositionTask(r<d> rVar) {
this.B = null;
this.o.c();
a();
rVar.b(this.k);
rVar.a(this.l);
this.A = rVar;
}
public final void a() {
r<d> rVar = this.A;
if (rVar != null) {
l<d> lVar = this.k;
synchronized (rVar) {
rVar.b.remove(lVar);
}
r<d> rVar2 = this.A;
l<Throwable> lVar2 = this.l;
synchronized (rVar2) {
rVar2.f269c.remove(lVar2);
}
}
}
/* JADX WARNING: Code restructure failed: missing block: B:14:0x0027, code lost:
if (r3 != false) goto L_0x0029;
*/
/* JADX WARNING: Code restructure failed: missing block: B:2:0x000a, code lost:
if (r0 != 1) goto L_0x000c;
*/
public final void b() {
int ordinal = this.f1538x.ordinal();
int i2 = 2;
if (ordinal == 0) {
d dVar = this.B;
boolean z2 = false;
if ((dVar == null || !dVar.n || Build.VERSION.SDK_INT >= 28) && (dVar == null || dVar.o <= 4)) {
z2 = true;
}
}
i2 = 1;
if (i2 != getLayerType()) {
setLayerType(i2, null);
}
}
@Override // android.view.View
public void buildDrawingCache(boolean z2) {
this.f1540z++;
super.buildDrawingCache(z2);
if (this.f1540z == 1 && getWidth() > 0 && getHeight() > 0 && getLayerType() == 1 && getDrawingCache(z2) == null) {
setRenderMode(t.HARDWARE);
}
this.f1540z--;
c.c.a.c.a("buildDrawingCache");
}
@MainThread
public void c() {
if (isShown()) {
this.o.j();
b();
return;
}
this.f1537s = true;
}
@Nullable
public d getComposition() {
return this.B;
}
public long getDuration() {
d dVar = this.B;
if (dVar != null) {
return (long) dVar.b();
}
return 0;
}
public int getFrame() {
return (int) this.o.k.n;
}
@Nullable
public String getImageAssetsFolder() {
return this.o.f257s;
}
public float getMaxFrame() {
return this.o.e();
}
public float getMinFrame() {
return this.o.f();
}
@Nullable
public s getPerformanceTracker() {
d dVar = this.o.j;
if (dVar != null) {
return dVar.a;
}
return null;
}
@FloatRange(from = 0.0d, to = 1.0d)
public float getProgress() {
return this.o.g();
}
public int getRepeatCount() {
return this.o.h();
}
public int getRepeatMode() {
return this.o.k.getRepeatMode();
}
public float getScale() {
return this.o.l;
}
public float getSpeed() {
return this.o.k.k;
}
@Override // android.widget.ImageView, android.graphics.drawable.Drawable.Callback, android.view.View
public void invalidateDrawable(@NonNull Drawable drawable) {
Drawable drawable2 = getDrawable();
j jVar = this.o;
if (drawable2 == jVar) {
super.invalidateDrawable(jVar);
} else {
super.invalidateDrawable(drawable);
}
}
@Override // android.widget.ImageView, android.view.View
public void onAttachedToWindow() {
super.onAttachedToWindow();
if (this.v || this.u) {
c();
this.v = false;
this.u = false;
}
if (Build.VERSION.SDK_INT < 23) {
onVisibilityChanged(this, getVisibility());
}
}
@Override // android.widget.ImageView, android.view.View
public void onDetachedFromWindow() {
if (this.o.i()) {
this.u = false;
this.t = false;
this.f1537s = false;
j jVar = this.o;
jVar.o.clear();
jVar.k.cancel();
b();
this.u = true;
}
super.onDetachedFromWindow();
}
@Override // android.view.View
public void onRestoreInstanceState(Parcelable parcelable) {
if (!(parcelable instanceof SavedState)) {
super.onRestoreInstanceState(parcelable);
return;
}
SavedState savedState = (SavedState) parcelable;
super.onRestoreInstanceState(savedState.getSuperState());
String str = savedState.i;
this.q = str;
if (!TextUtils.isEmpty(str)) {
setAnimation(this.q);
}
int i2 = savedState.j;
this.r = i2;
if (i2 != 0) {
setAnimation(i2);
}
setProgress(savedState.k);
if (savedState.l) {
c();
}
this.o.f257s = savedState.m;
setRepeatMode(savedState.n);
setRepeatCount(savedState.o);
}
@Override // android.view.View
public Parcelable onSaveInstanceState() {
SavedState savedState = new SavedState(super.onSaveInstanceState());
savedState.i = this.q;
savedState.j = this.r;
savedState.k = this.o.g();
savedState.l = this.o.i() || (!ViewCompat.isAttachedToWindow(this) && this.u);
j jVar = this.o;
savedState.m = jVar.f257s;
savedState.n = jVar.k.getRepeatMode();
savedState.o = this.o.h();
return savedState;
}
@Override // android.view.View
public void onVisibilityChanged(@NonNull View view, int i2) {
if (this.p) {
if (isShown()) {
if (this.t) {
if (isShown()) {
this.o.k();
b();
} else {
this.f1537s = false;
this.t = true;
}
} else if (this.f1537s) {
c();
}
this.t = false;
this.f1537s = false;
} else if (this.o.i()) {
this.v = false;
this.u = false;
this.t = false;
this.f1537s = false;
j jVar = this.o;
jVar.o.clear();
jVar.k.m();
b();
this.t = true;
}
}
}
public void setAnimation(@RawRes int i2) {
r<d> rVar;
this.r = i2;
this.q = null;
if (this.w) {
Context context = getContext();
rVar = e.a(e.f(context, i2), new h(new WeakReference(context), context.getApplicationContext(), i2));
} else {
Context context2 = getContext();
Map<String, r<d>> map = e.a;
rVar = e.a(null, new h(new WeakReference(context2), context2.getApplicationContext(), i2));
}
setCompositionTask(rVar);
}
public void setAnimation(String str) {
r<d> rVar;
this.q = str;
this.r = 0;
if (this.w) {
Context context = getContext();
Map<String, r<d>> map = e.a;
String u = c.d.b.a.a.u("asset_", str);
rVar = e.a(u, new c.c.a.g(context.getApplicationContext(), str, u));
} else {
Context context2 = getContext();
Map<String, r<d>> map2 = e.a;
rVar = e.a(null, new c.c.a.g(context2.getApplicationContext(), str, null));
}
setCompositionTask(rVar);
}
@Deprecated
public void setAnimationFromJson(String str) {
setCompositionTask(e.a(null, new i(new ByteArrayInputStream(str.getBytes()), null)));
}
public void setAnimationFromUrl(String str) {
r<d> rVar;
if (this.w) {
Context context = getContext();
Map<String, r<d>> map = e.a;
String u = c.d.b.a.a.u("url_", str);
rVar = e.a(u, new c.c.a.f(context, str, u));
} else {
rVar = e.a(null, new c.c.a.f(getContext(), str, null));
}
setCompositionTask(rVar);
}
public void setApplyingOpacityToLayersEnabled(boolean z2) {
this.o.f260z = z2;
}
public void setCacheComposition(boolean z2) {
this.w = z2;
}
public void setComposition(@NonNull d dVar) {
this.o.setCallback(this);
this.B = dVar;
j jVar = this.o;
boolean z2 = false;
if (jVar.j != dVar) {
jVar.B = false;
jVar.c();
jVar.j = dVar;
jVar.b();
c.c.a.b0.d dVar2 = jVar.k;
if (dVar2.r == null) {
z2 = true;
}
dVar2.r = dVar;
if (z2) {
dVar2.o((float) ((int) Math.max(dVar2.p, dVar.k)), (float) ((int) Math.min(dVar2.q, dVar.l)));
} else {
dVar2.o((float) ((int) dVar.k), (float) ((int) dVar.l));
}
float f = dVar2.n;
dVar2.n = 0.0f;
dVar2.n((float) ((int) f));
dVar2.f();
jVar.u(jVar.k.getAnimatedFraction());
jVar.l = jVar.l;
jVar.v();
jVar.v();
Iterator it = new ArrayList(jVar.o).iterator();
while (it.hasNext()) {
((j.o) it.next()).a(dVar);
it.remove();
}
jVar.o.clear();
dVar.a.a = jVar.f259y;
Drawable.Callback callback = jVar.getCallback();
if (callback instanceof ImageView) {
ImageView imageView = (ImageView) callback;
imageView.setImageDrawable(null);
imageView.setImageDrawable(jVar);
}
z2 = true;
}
b();
if (getDrawable() != this.o || z2) {
onVisibilityChanged(this, getVisibility());
requestLayout();
for (n nVar : this.f1539y) {
nVar.a(dVar);
}
}
}
public void setFailureListener(@Nullable l<Throwable> lVar) {
this.m = lVar;
}
public void setFallbackResource(@DrawableRes int i2) {
this.n = i2;
}
public void setFontAssetDelegate(c.c.a.a aVar) {
c.c.a.x.a aVar2 = this.o.u;
}
public void setFrame(int i2) {
this.o.l(i2);
}
public void setImageAssetDelegate(c.c.a.b bVar) {
j jVar = this.o;
jVar.t = bVar;
c.c.a.x.b bVar2 = jVar.r;
if (bVar2 != null) {
bVar2.d = bVar;
}
}
public void setImageAssetsFolder(String str) {
this.o.f257s = str;
}
@Override // androidx.appcompat.widget.AppCompatImageView, android.widget.ImageView
public void setImageBitmap(Bitmap bitmap) {
a();
super.setImageBitmap(bitmap);
}
@Override // androidx.appcompat.widget.AppCompatImageView, android.widget.ImageView
public void setImageDrawable(Drawable drawable) {
a();
super.setImageDrawable(drawable);
}
@Override // androidx.appcompat.widget.AppCompatImageView, android.widget.ImageView
public void setImageResource(int i2) {
a();
super.setImageResource(i2);
}
public void setMaxFrame(int i2) {
this.o.m(i2);
}
public void setMaxFrame(String str) {
this.o.n(str);
}
public void setMaxProgress(@FloatRange(from = 0.0d, to = 1.0d) float f) {
this.o.o(f);
}
public void setMinAndMaxFrame(String str) {
this.o.q(str);
}
public void setMinFrame(int i2) {
this.o.r(i2);
}
public void setMinFrame(String str) {
this.o.s(str);
}
public void setMinProgress(float f) {
this.o.t(f);
}
public void setPerformanceTrackingEnabled(boolean z2) {
j jVar = this.o;
jVar.f259y = z2;
d dVar = jVar.j;
if (dVar != null) {
dVar.a.a = z2;
}
}
public void setProgress(@FloatRange(from = 0.0d, to = 1.0d) float f) {
this.o.u(f);
}
public void setRenderMode(t tVar) {
this.f1538x = tVar;
b();
}
public void setRepeatCount(int i2) {
this.o.k.setRepeatCount(i2);
}
public void setRepeatMode(int i2) {
this.o.k.setRepeatMode(i2);
}
public void setSafeMode(boolean z2) {
this.o.n = z2;
}
public void setScale(float f) {
j jVar = this.o;
jVar.l = f;
jVar.v();
if (getDrawable() == this.o) {
setImageDrawable(null);
setImageDrawable(this.o);
}
}
@Override // android.widget.ImageView
public void setScaleType(ImageView.ScaleType scaleType) {
super.setScaleType(scaleType);
j jVar = this.o;
if (jVar != null) {
jVar.q = scaleType;
}
}
public void setSpeed(float f) {
this.o.k.k = f;
}
public void setTextDelegate(v vVar) {
Objects.requireNonNull(this.o);
}
}