225 lines
7 KiB
Java
225 lines
7 KiB
Java
package c.c.a;
|
|
|
|
import android.content.Context;
|
|
import android.graphics.Bitmap;
|
|
import android.graphics.BitmapFactory;
|
|
import androidx.annotation.Nullable;
|
|
import androidx.annotation.RawRes;
|
|
import androidx.annotation.WorkerThread;
|
|
import c.c.a.a0.h0.d;
|
|
import c.c.a.a0.s;
|
|
import c.c.a.b0.g;
|
|
import c.c.a.y.h;
|
|
import d0.z.d.m;
|
|
import g0.n;
|
|
import g0.r;
|
|
import g0.y;
|
|
import java.io.IOException;
|
|
import java.io.InputStream;
|
|
import java.util.HashMap;
|
|
import java.util.Iterator;
|
|
import java.util.Map;
|
|
import java.util.Objects;
|
|
import java.util.concurrent.Callable;
|
|
import java.util.zip.ZipEntry;
|
|
import java.util.zip.ZipInputStream;
|
|
/* compiled from: LottieCompositionFactory */
|
|
public class e {
|
|
public static final Map<String, r<d>> a = new HashMap();
|
|
|
|
/* compiled from: LottieCompositionFactory */
|
|
public class a implements l<d> {
|
|
public final /* synthetic */ String a;
|
|
|
|
public a(String str) {
|
|
this.a = str;
|
|
}
|
|
|
|
/* 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) {
|
|
e.a.remove(this.a);
|
|
}
|
|
}
|
|
|
|
/* compiled from: LottieCompositionFactory */
|
|
public class b implements l<Throwable> {
|
|
public final /* synthetic */ String a;
|
|
|
|
public b(String str) {
|
|
this.a = str;
|
|
}
|
|
|
|
/* 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) {
|
|
e.a.remove(this.a);
|
|
}
|
|
}
|
|
|
|
/* compiled from: LottieCompositionFactory */
|
|
public class c implements Callable<p<d>> {
|
|
public final /* synthetic */ d i;
|
|
|
|
public c(d dVar) {
|
|
this.i = dVar;
|
|
}
|
|
|
|
/* Return type fixed from 'java.lang.Object' to match base method */
|
|
@Override // java.util.concurrent.Callable
|
|
public p<d> call() throws Exception {
|
|
return new p<>(this.i);
|
|
}
|
|
}
|
|
|
|
public static r<d> a(@Nullable String str, Callable<p<d>> callable) {
|
|
d dVar;
|
|
if (str == null) {
|
|
dVar = null;
|
|
} else {
|
|
h hVar = h.a;
|
|
Objects.requireNonNull(hVar);
|
|
dVar = hVar.b.get(str);
|
|
}
|
|
if (dVar != null) {
|
|
return new r<>(new c(dVar));
|
|
}
|
|
if (str != null) {
|
|
Map<String, r<d>> map = a;
|
|
if (map.containsKey(str)) {
|
|
return map.get(str);
|
|
}
|
|
}
|
|
r<d> rVar = new r<>(callable);
|
|
if (str != null) {
|
|
rVar.b(new a(str));
|
|
rVar.a(new b(str));
|
|
a.put(str, rVar);
|
|
}
|
|
return rVar;
|
|
}
|
|
|
|
@WorkerThread
|
|
public static p<d> b(InputStream inputStream, @Nullable String str) {
|
|
try {
|
|
m.checkParameterIsNotNull(inputStream, "$this$source");
|
|
n nVar = new n(inputStream, new y());
|
|
m.checkParameterIsNotNull(nVar, "$this$buffer");
|
|
r rVar = new r(nVar);
|
|
String[] strArr = c.c.a.a0.h0.c.i;
|
|
return c(new d(rVar), str, true);
|
|
} finally {
|
|
g.b(inputStream);
|
|
}
|
|
}
|
|
|
|
public static p<d> c(c.c.a.a0.h0.c cVar, @Nullable String str, boolean z2) {
|
|
try {
|
|
d a2 = s.a(cVar);
|
|
if (str != null) {
|
|
h hVar = h.a;
|
|
Objects.requireNonNull(hVar);
|
|
hVar.b.put(str, a2);
|
|
}
|
|
p<d> pVar = new p<>(a2);
|
|
if (z2) {
|
|
g.b(cVar);
|
|
}
|
|
return pVar;
|
|
} catch (Exception e) {
|
|
p<d> pVar2 = new p<>(e);
|
|
if (z2) {
|
|
g.b(cVar);
|
|
}
|
|
return pVar2;
|
|
} catch (Throwable th) {
|
|
if (z2) {
|
|
g.b(cVar);
|
|
}
|
|
throw th;
|
|
}
|
|
}
|
|
|
|
@WorkerThread
|
|
public static p<d> d(ZipInputStream zipInputStream, @Nullable String str) {
|
|
try {
|
|
return e(zipInputStream, str);
|
|
} finally {
|
|
g.b(zipInputStream);
|
|
}
|
|
}
|
|
|
|
@WorkerThread
|
|
public static p<d> e(ZipInputStream zipInputStream, @Nullable String str) {
|
|
k kVar;
|
|
HashMap hashMap = new HashMap();
|
|
try {
|
|
ZipEntry nextEntry = zipInputStream.getNextEntry();
|
|
d dVar = null;
|
|
while (nextEntry != null) {
|
|
String name = nextEntry.getName();
|
|
if (name.contains("__MACOSX")) {
|
|
zipInputStream.closeEntry();
|
|
} else if (nextEntry.getName().contains(".json")) {
|
|
m.checkParameterIsNotNull(zipInputStream, "$this$source");
|
|
n nVar = new n(zipInputStream, new y());
|
|
m.checkParameterIsNotNull(nVar, "$this$buffer");
|
|
r rVar = new r(nVar);
|
|
String[] strArr = c.c.a.a0.h0.c.i;
|
|
dVar = c(new d(rVar), null, false).a;
|
|
} else {
|
|
if (!name.contains(".png")) {
|
|
if (!name.contains(".webp")) {
|
|
zipInputStream.closeEntry();
|
|
}
|
|
}
|
|
String[] split = name.split("/");
|
|
hashMap.put(split[split.length - 1], BitmapFactory.decodeStream(zipInputStream));
|
|
}
|
|
nextEntry = zipInputStream.getNextEntry();
|
|
}
|
|
if (dVar == null) {
|
|
return new p<>(new IllegalArgumentException("Unable to parse composition"));
|
|
}
|
|
for (Map.Entry entry : hashMap.entrySet()) {
|
|
String str2 = (String) entry.getKey();
|
|
Iterator<k> it = dVar.d.values().iterator();
|
|
while (true) {
|
|
if (!it.hasNext()) {
|
|
kVar = null;
|
|
break;
|
|
}
|
|
kVar = it.next();
|
|
if (kVar.d.equals(str2)) {
|
|
break;
|
|
}
|
|
}
|
|
if (kVar != null) {
|
|
kVar.e = g.e((Bitmap) entry.getValue(), kVar.a, kVar.b);
|
|
}
|
|
}
|
|
for (Map.Entry<String, k> entry2 : dVar.d.entrySet()) {
|
|
if (entry2.getValue().e == null) {
|
|
StringBuilder L = c.d.b.a.a.L("There is no image for ");
|
|
L.append(entry2.getValue().d);
|
|
return new p<>(new IllegalStateException(L.toString()));
|
|
}
|
|
}
|
|
if (str != null) {
|
|
h hVar = h.a;
|
|
Objects.requireNonNull(hVar);
|
|
hVar.b.put(str, dVar);
|
|
}
|
|
return new p<>(dVar);
|
|
} catch (IOException e) {
|
|
return new p<>(e);
|
|
}
|
|
}
|
|
|
|
public static String f(Context context, @RawRes int i) {
|
|
StringBuilder L = c.d.b.a.a.L("rawRes");
|
|
L.append((context.getResources().getConfiguration().uiMode & 48) == 32 ? "_night_" : "_day_");
|
|
L.append(i);
|
|
return L.toString();
|
|
}
|
|
}
|