discord-jadx/app/src/main/java/c/f/h/a/b/e/c.java
2021-08-31 09:21:49 +02:00

113 lines
3.9 KiB
Java

package c.f.h.a.b.e;
import android.graphics.Bitmap;
import android.util.SparseArray;
import c.f.h.a.b.b;
import com.facebook.common.references.CloseableReference;
import com.facebook.imagepipeline.bitmaps.PlatformBitmapFactory;
import java.util.concurrent.ExecutorService;
/* compiled from: DefaultBitmapFramePreparer */
public class c implements b {
public final PlatformBitmapFactory a;
public final c.f.h.a.b.c b;
/* renamed from: c reason: collision with root package name */
public final Bitmap.Config f416c;
public final ExecutorService d;
public final SparseArray<Runnable> e = new SparseArray<>();
/* compiled from: DefaultBitmapFramePreparer */
public class a implements Runnable {
public final b i;
public final c.f.h.a.a.a j;
public final int k;
public final int l;
public a(c.f.h.a.a.a aVar, b bVar, int i, int i2) {
this.j = aVar;
this.i = bVar;
this.k = i;
this.l = i2;
}
public final boolean a(int i, int i2) {
CloseableReference closeableReference;
int i3 = 2;
CloseableReference closeableReference2 = null;
if (i2 == 1) {
closeableReference = this.i.a(i, this.j.i(), this.j.g());
} else if (i2 != 2) {
Class<CloseableReference> cls = CloseableReference.i;
return false;
} else {
try {
closeableReference = c.this.a.a(this.j.i(), this.j.g(), c.this.f416c);
i3 = -1;
} catch (RuntimeException e) {
c.f.d.e.a.l(c.class, "Failed to create frame bitmap", e);
Class<CloseableReference> cls2 = CloseableReference.i;
return false;
} catch (Throwable th) {
Class<CloseableReference> cls3 = CloseableReference.i;
if (0 != 0) {
closeableReference2.close();
}
throw th;
}
}
boolean b = b(i, closeableReference, i2);
if (closeableReference != null) {
closeableReference.close();
}
return (b || i3 == -1) ? b : a(i, i3);
}
public final boolean b(int i, CloseableReference<Bitmap> closeableReference, int i2) {
if (!CloseableReference.z(closeableReference)) {
return false;
}
if (!((c.f.h.a.b.f.b) c.this.b).a(i, closeableReference.w())) {
return false;
}
int i3 = c.f.d.e.a.a;
synchronized (c.this.e) {
this.i.b(this.k, closeableReference, i2);
}
return true;
}
@Override // java.lang.Runnable
public void run() {
try {
if (this.i.c(this.k)) {
int i = c.f.d.e.a.a;
synchronized (c.this.e) {
c.this.e.remove(this.l);
}
return;
}
if (a(this.k, 1)) {
int i2 = c.f.d.e.a.a;
} else {
c.f.d.e.a.c(c.class, "Could not prepare frame %d.", Integer.valueOf(this.k));
}
synchronized (c.this.e) {
c.this.e.remove(this.l);
}
} catch (Throwable th) {
synchronized (c.this.e) {
c.this.e.remove(this.l);
throw th;
}
}
}
}
public c(PlatformBitmapFactory platformBitmapFactory, c.f.h.a.b.c cVar, Bitmap.Config config, ExecutorService executorService) {
this.a = platformBitmapFactory;
this.b = cVar;
this.f416c = config;
this.d = executorService;
}
}