discord-jadx/app/src/main/java/c/f/j/p/n.java

450 lines
16 KiB
Java

package c.f.j.p;
import android.graphics.Bitmap;
import c.f.d.d.f;
import c.f.j.h.d;
import c.f.j.j.e;
import c.f.j.j.h;
import c.f.j.j.i;
import c.f.j.p.c0;
import com.airbnb.lottie.parser.AnimatableValueParser;
import com.facebook.common.internal.Supplier;
import com.facebook.common.references.CloseableReference;
import com.facebook.common.util.ExceptionWithNoStacktrace;
import com.facebook.imagepipeline.decoder.DecodeException;
import com.facebook.imagepipeline.request.ImageRequest;
import java.io.Closeable;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.Executor;
/* compiled from: DecodeProducer */
public class n implements v0<CloseableReference<c.f.j.j.c>> {
public final c.f.d.g.a a;
public final Executor b;
/* renamed from: c reason: collision with root package name */
public final c.f.j.h.b f484c;
public final c.f.j.h.c d;
public final v0<e> e;
public final boolean f;
public final boolean g;
public final boolean h;
public final int i;
public final c.f.j.e.a j;
public final Runnable k = null;
public final Supplier<Boolean> l;
/* compiled from: DecodeProducer */
public class a extends c {
public a(n nVar, l<CloseableReference<c.f.j.j.c>> lVar, w0 w0Var, boolean z2, int i) {
super(lVar, w0Var, z2, i);
}
@Override // c.f.j.p.n.c
public int o(e eVar) {
return eVar.f();
}
@Override // c.f.j.p.n.c
public i p() {
return new h(0, false, false);
}
@Override // c.f.j.p.n.c
public synchronized boolean w(e eVar, int i) {
if (b.f(i)) {
return false;
}
return this.g.f(eVar, i);
}
}
/* compiled from: DecodeProducer */
public class b extends c {
public final d i;
public final c.f.j.h.c j;
public int k = 0;
public b(n nVar, l<CloseableReference<c.f.j.j.c>> lVar, w0 w0Var, d dVar, c.f.j.h.c cVar, boolean z2, int i) {
super(lVar, w0Var, z2, i);
this.i = dVar;
Objects.requireNonNull(cVar);
this.j = cVar;
}
@Override // c.f.j.p.n.c
public int o(e eVar) {
return this.i.f;
}
@Override // c.f.j.p.n.c
public i p() {
return this.j.a(this.i.e);
}
@Override // c.f.j.p.n.c
public synchronized boolean w(e eVar, int i) {
boolean f = this.g.f(eVar, i);
if ((b.f(i) || b.m(i, 8)) && !b.m(i, 4) && e.t(eVar)) {
eVar.w();
if (eVar.k == c.f.i.b.a) {
if (!this.i.b(eVar)) {
return false;
}
int i2 = this.i.e;
int i3 = this.k;
if (i2 <= i3) {
return false;
}
if (i2 < this.j.b(i3) && !this.i.g) {
return false;
}
this.k = i2;
}
}
return f;
}
}
/* compiled from: DecodeProducer */
public abstract class c extends p<e, CloseableReference<c.f.j.j.c>> {
/* renamed from: c reason: collision with root package name */
public final w0 f485c;
public final y0 d;
public final c.f.j.d.b e;
public boolean f = false;
public final c0 g;
/* compiled from: DecodeProducer */
public class a implements c0.c {
public final /* synthetic */ w0 a;
public final /* synthetic */ int b;
public a(n nVar, w0 w0Var, int i) {
this.a = w0Var;
this.b = i;
}
@Override // c.f.j.p.c0.c
public void a(e eVar, int i) {
boolean z2;
String str;
long j;
c.f.j.j.c cVar;
Exception e;
int i2 = i;
if (eVar != null) {
w0 w0Var = c.this.f485c;
eVar.w();
w0Var.d("image_format", eVar.k.b);
if (n.this.f || !b.m(i2, 16)) {
ImageRequest e2 = this.a.e();
if (n.this.g || !c.f.d.l.b.e(e2.f2182c)) {
eVar.p = AnimatableValueParser.c0(e2.j, e2.i, eVar, this.b);
}
}
Objects.requireNonNull(this.a.g().w);
c cVar2 = c.this;
Objects.requireNonNull(cVar2);
eVar.w();
if (eVar.k == c.f.i.b.a || !b.f(i)) {
synchronized (cVar2) {
z2 = cVar2.f;
}
if (!z2 && e.t(eVar)) {
eVar.w();
c.f.i.c cVar3 = eVar.k;
String str2 = cVar3 != null ? cVar3.b : "unknown";
StringBuilder sb = new StringBuilder();
eVar.w();
sb.append(eVar.n);
sb.append("x");
eVar.w();
sb.append(eVar.o);
String sb2 = sb.toString();
String valueOf = String.valueOf(eVar.p);
boolean e3 = b.e(i);
boolean z3 = e3 && !b.m(i2, 8);
boolean m = b.m(i2, 4);
c.f.j.d.e eVar2 = cVar2.f485c.e().i;
if (eVar2 != null) {
str = eVar2.a + "x" + eVar2.b;
} else {
str = "unknown";
}
try {
c0 c0Var = cVar2.g;
synchronized (c0Var) {
j = c0Var.j - c0Var.i;
}
String valueOf2 = String.valueOf(cVar2.f485c.e().f2182c);
int f = (z3 || m) ? eVar.f() : cVar2.o(eVar);
i p = (z3 || m) ? h.a : cVar2.p();
cVar2.d.e(cVar2.f485c, "DecodeProducer");
try {
cVar = cVar2.t(eVar, f, p);
try {
if (eVar.p != 1) {
i2 |= 16;
}
cVar2.d.j(cVar2.f485c, "DecodeProducer", cVar2.n(cVar, j, p, e3, str2, sb2, str, valueOf));
cVar2.v(eVar, cVar);
cVar2.s(cVar, i2);
} catch (Exception e4) {
e = e4;
cVar2.d.k(cVar2.f485c, "DecodeProducer", e, cVar2.n(cVar, j, p, e3, str2, sb2, str, valueOf));
cVar2.u(true);
cVar2.b.c(e);
}
} catch (DecodeException e5) {
e a = e5.a();
c.f.d.e.a.o("ProgressiveDecoder", "%s, {uri: %s, firstEncodedBytes: %s, length: %d}", e5.getMessage(), valueOf2, a.d(10), Integer.valueOf(a.f()));
throw e5;
} catch (Exception e6) {
e = e6;
cVar = null;
cVar2.d.k(cVar2.f485c, "DecodeProducer", e, cVar2.n(cVar, j, p, e3, str2, sb2, str, valueOf));
cVar2.u(true);
cVar2.b.c(e);
}
} finally {
eVar.close();
}
}
}
}
}
}
/* compiled from: DecodeProducer */
public class b extends e {
public final /* synthetic */ boolean a;
public b(n nVar, boolean z2) {
this.a = z2;
}
@Override // c.f.j.p.x0
public void a() {
if (this.a) {
c cVar = c.this;
cVar.u(true);
cVar.b.d();
}
}
@Override // c.f.j.p.e, c.f.j.p.x0
public void b() {
if (c.this.f485c.p()) {
c.this.g.d();
}
}
}
public c(l<CloseableReference<c.f.j.j.c>> lVar, w0 w0Var, boolean z2, int i) {
super(lVar);
this.f485c = w0Var;
this.d = w0Var.o();
c.f.j.d.b bVar = w0Var.e().h;
this.e = bVar;
this.g = new c0(n.this.b, new a(n.this, w0Var, i), bVar.b);
w0Var.f(new b(n.this, z2));
}
@Override // c.f.j.p.p, c.f.j.p.b
public void g() {
q();
}
@Override // c.f.j.p.p, c.f.j.p.b
public void h(Throwable th) {
r(th);
}
/* JADX INFO: finally extract failed */
@Override // c.f.j.p.b
public void i(Object obj, int i) {
e eVar = (e) obj;
try {
c.f.j.r.b.b();
boolean e = b.e(i);
if (e) {
if (eVar == null) {
ExceptionWithNoStacktrace exceptionWithNoStacktrace = new ExceptionWithNoStacktrace("Encoded image is null.");
u(true);
this.b.c(exceptionWithNoStacktrace);
} else if (!eVar.s()) {
ExceptionWithNoStacktrace exceptionWithNoStacktrace2 = new ExceptionWithNoStacktrace("Encoded image is not valid.");
u(true);
this.b.c(exceptionWithNoStacktrace2);
}
c.f.j.r.b.b();
}
if (w(eVar, i)) {
boolean m = b.m(i, 4);
if (e || m || this.f485c.p()) {
this.g.d();
}
}
c.f.j.r.b.b();
} catch (Throwable th) {
c.f.j.r.b.b();
throw th;
}
}
@Override // c.f.j.p.p, c.f.j.p.b
public void j(float f) {
this.b.a(f * 0.99f);
}
public final Map<String, String> n(c.f.j.j.c cVar, long j, i iVar, boolean z2, String str, String str2, String str3, String str4) {
if (!this.d.g(this.f485c, "DecodeProducer")) {
return null;
}
String valueOf = String.valueOf(j);
String valueOf2 = String.valueOf(((h) iVar).f449c);
String valueOf3 = String.valueOf(z2);
if (cVar instanceof c.f.j.j.d) {
Bitmap bitmap = ((c.f.j.j.d) cVar).l;
HashMap hashMap = new HashMap(8);
hashMap.put("bitmapSize", bitmap.getWidth() + "x" + bitmap.getHeight());
hashMap.put("queueTime", valueOf);
hashMap.put("hasGoodQuality", valueOf2);
hashMap.put("isFinal", valueOf3);
hashMap.put("encodedImageSize", str2);
hashMap.put("imageFormat", str);
hashMap.put("requestedImageSize", str3);
hashMap.put("sampleSize", str4);
hashMap.put("byteCount", bitmap.getByteCount() + "");
return new f(hashMap);
}
HashMap hashMap2 = new HashMap(7);
hashMap2.put("queueTime", valueOf);
hashMap2.put("hasGoodQuality", valueOf2);
hashMap2.put("isFinal", valueOf3);
hashMap2.put("encodedImageSize", str2);
hashMap2.put("imageFormat", str);
hashMap2.put("requestedImageSize", str3);
hashMap2.put("sampleSize", str4);
return new f(hashMap2);
}
public abstract int o(e eVar);
public abstract i p();
public final void q() {
u(true);
this.b.d();
}
public final void r(Throwable th) {
u(true);
this.b.c(th);
}
public final void s(c.f.j.j.c cVar, int i) {
CloseableReference.c cVar2 = n.this.j.a;
Class<CloseableReference> cls = CloseableReference.i;
CloseableReference closeableReference = null;
Throwable th = null;
if (cVar != null) {
c.f.d.h.f<Closeable> fVar = CloseableReference.k;
if (cVar2.b()) {
th = new Throwable();
}
closeableReference = CloseableReference.I(cVar, fVar, cVar2, th);
}
try {
u(b.e(i));
this.b.b(closeableReference, i);
} finally {
if (closeableReference != null) {
closeableReference.close();
}
}
}
public final c.f.j.j.c t(e eVar, int i, i iVar) {
n nVar = n.this;
boolean z2 = nVar.k != null && nVar.l.get().booleanValue();
try {
return n.this.f484c.a(eVar, i, iVar, this.e);
} catch (OutOfMemoryError e) {
if (z2) {
n.this.k.run();
System.gc();
return n.this.f484c.a(eVar, i, iVar, this.e);
}
throw e;
}
}
public final void u(boolean z2) {
synchronized (this) {
if (z2) {
if (!this.f) {
this.b.a(1.0f);
this.f = true;
this.g.a();
}
}
}
}
public final void v(e eVar, c.f.j.j.c cVar) {
w0 w0Var = this.f485c;
eVar.w();
w0Var.d("encoded_width", Integer.valueOf(eVar.n));
w0 w0Var2 = this.f485c;
eVar.w();
w0Var2.d("encoded_height", Integer.valueOf(eVar.o));
this.f485c.d("encoded_size", Integer.valueOf(eVar.f()));
if (cVar instanceof c.f.j.j.b) {
Bitmap f = ((c.f.j.j.b) cVar).f();
this.f485c.d("bitmap_config", String.valueOf(f == null ? null : f.getConfig()));
}
if (cVar != null) {
cVar.e(this.f485c.a());
}
}
public abstract boolean w(e eVar, int i);
}
public n(c.f.d.g.a aVar, Executor executor, c.f.j.h.b bVar, c.f.j.h.c cVar, boolean z2, boolean z3, boolean z4, v0<e> v0Var, int i, c.f.j.e.a aVar2, Runnable runnable, Supplier<Boolean> supplier) {
Objects.requireNonNull(aVar);
this.a = aVar;
Objects.requireNonNull(executor);
this.b = executor;
Objects.requireNonNull(bVar);
this.f484c = bVar;
Objects.requireNonNull(cVar);
this.d = cVar;
this.f = z2;
this.g = z3;
Objects.requireNonNull(v0Var);
this.e = v0Var;
this.h = z4;
this.i = i;
this.j = aVar2;
this.l = supplier;
}
/* JADX INFO: finally extract failed */
@Override // c.f.j.p.v0
public void b(l<CloseableReference<c.f.j.j.c>> lVar, w0 w0Var) {
try {
c.f.j.r.b.b();
this.e.b(!c.f.d.l.b.e(w0Var.e().f2182c) ? new a(this, lVar, w0Var, this.h, this.i) : new b(this, lVar, w0Var, new d(this.a), this.d, this.h, this.i), w0Var);
c.f.j.r.b.b();
} catch (Throwable th) {
c.f.j.r.b.b();
throw th;
}
}
}