七色猫视频 v9.9.9版本的 MD5 值为:6e3740f68cd7a75ec951b5f356e1fd2c
以下内容为反编译后的 SVGAParser.java 源代码,内容仅作参考
package com.opensource.svgaplayer;
import android.content.Context;
import android.content.res.AssetManager;
import android.net.http.HttpResponseCache;
import android.os.Handler;
import android.util.Log;
import com.alipay.sdk.cons.c;
import com.alipay.sdk.data.a;
import com.opensource.svgaplayer.SVGAParser;
import com.opensource.svgaplayer.proto.MovieEntity;
import com.umeng.analytics.pro.b;
import java.io.BufferedInputStream;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
import java.nio.charset.Charset;
import java.security.MessageDigest;
import java.util.Arrays;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.zip.Inflater;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import kotlin.Deprecated;
import kotlin.Metadata;
import kotlin.ReplaceWith;
import kotlin.TypeCastException;
import kotlin.Unit;
import kotlin.io.CloseableKt;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.jvm.internal.Intrinsics;
import kotlin.jvm.internal.Ref;
import kotlin.jvm.internal.StringCompanionObject;
import kotlin.text.StringsKt;
import org.json.JSONObject;
import tv.danmaku.ijk.media.player.IjkMediaPlayer;
@Metadata(bv = {1, 0, 3}, d1 = {"\u0000j\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000e\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000b\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u0012\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\t\u0018\u0000 02\u00020\u0001:\u0003012B\u000f\u0012\b\u0010\u0002\u001a\u0004\u0018\u00010\u0003¢\u0006\u0002\u0010\u0004J\u0010\u0010\u000b\u001a\u00020\f2\u0006\u0010\r\u001a\u00020\u000eH\u0002J\u0010\u0010\u000f\u001a\u00020\u000e2\u0006\u0010\u0010\u001a\u00020\u0011H\u0002J\u0010\u0010\u000f\u001a\u00020\u000e2\u0006\u0010\u0012\u001a\u00020\u000eH\u0002J\u0018\u0010\u0013\u001a\u00020\u00142\u0006\u0010\u0015\u001a\u00020\u000e2\b\u0010\u0016\u001a\u0004\u0018\u00010\u0017J\u001a\u0010\u0018\u001a\u00020\u00142\u0006\u0010\r\u001a\u00020\u000e2\b\u0010\u0016\u001a\u0004\u0018\u00010\u0017H\u0002J*\u0010\u0019\u001a\u00020\u00142\u0006\u0010\u001a\u001a\u00020\u001b2\u0006\u0010\r\u001a\u00020\u000e2\b\u0010\u0016\u001a\u0004\u0018\u00010\u00172\b\b\u0002\u0010\u001c\u001a\u00020\u001dJ \u0010\u001e\u001a\n\u0012\u0004\u0012\u00020\u0014\u0018\u00010\u001f2\u0006\u0010\u0010\u001a\u00020\u00112\b\u0010\u0016\u001a\u0004\u0018\u00010\u0017J\u0012\u0010 \u001a\u0004\u0018\u00010!2\u0006\u0010\"\u001a\u00020!H\u0002J\u000e\u0010#\u001a\u00020\u00142\u0006\u0010$\u001a\u00020\u0003J\u001a\u0010%\u001a\u00020\u00142\u0006\u0010&\u001a\u00020'2\b\u0010\u0016\u001a\u0004\u0018\u00010\u0017H\u0002J\u001a\u0010(\u001a\u00020\u00142\u0006\u0010)\u001a\u00020*2\b\u0010\u0016\u001a\u0004\u0018\u00010\u0017H\u0002J\u0010\u0010+\u001a\u00020\u001d2\u0006\u0010\r\u001a\u00020\u000eH\u0002J,\u0010,\u001a\u00020\u00142\u0006\u0010\u001a\u001a\u00020\u001b2\u0006\u0010\r\u001a\u00020\u000e2\b\u0010\u0016\u001a\u0004\u0018\u00010\u00172\b\b\u0002\u0010\u001c\u001a\u00020\u001dH\u0007J\u001a\u0010,\u001a\u00020\u00142\u0006\u0010\u0010\u001a\u00020\u00112\b\u0010\u0016\u001a\u0004\u0018\u00010\u0017H\u0007J\u001a\u0010,\u001a\u00020\u00142\u0006\u0010-\u001a\u00020\u000e2\b\u0010\u0016\u001a\u0004\u0018\u00010\u0017H\u0007J\u0012\u0010.\u001a\u0004\u0018\u00010!2\u0006\u0010\u001a\u001a\u00020\u001bH\u0002J\u0018\u0010/\u001a\u00020\u00142\u0006\u0010\u001a\u001a\u00020\u001b2\u0006\u0010\r\u001a\u00020\u000eH\u0002R\u001a\u0010\u0005\u001a\u00020\u0006X\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b\u0007\u0010\b\"\u0004\b\t\u0010\nR\u0010\u0010\u0002\u001a\u0004\u0018\u00010\u0003X\u0082\u000e¢\u0006\u0002\n\u0000¨\u00063"}, d2 = {"Lcom/opensource/svgaplayer/SVGAParser;", "", "mContext", "Landroid/content/Context;", "(Landroid/content/Context;)V", "fileDownloader", "Lcom/opensource/svgaplayer/SVGAParser$FileDownloader;", "getFileDownloader", "()Lcom/opensource/svgaplayer/SVGAParser$FileDownloader;", "setFileDownloader", "(Lcom/opensource/svgaplayer/SVGAParser$FileDownloader;)V", "buildCacheDir", "Ljava/io/File;", "cacheKey", "", "buildCacheKey", IjkMediaPlayer.OnNativeInvokeListener.ARG_URL, "Ljava/net/URL;", "str", "decodeFromAssets", "", c.e, "callback", "Lcom/opensource/svgaplayer/SVGAParser$ParseCompletion;", "decodeFromCacheKey", "decodeFromInputStream", "inputStream", "Ljava/io/InputStream;", "closeInputStream", "", "decodeFromURL", "Lkotlin/Function0;", "inflate", "", "byteArray", "init", b.Q, "invokeCompleteCallback", "videoItem", "Lcom/opensource/svgaplayer/SVGAVideoEntity;", "invokeErrorCallback", "e", "Ljava/lang/Exception;", "isCached", "parse", "assetsName", "readAsBytes", "unzip", "Companion", "FileDownloader", "ParseCompletion", "library_release"}, k = 1, mv = {1, 1, 13})
public final class SVGAParser {
private FileDownloader fileDownloader = new FileDownloader();
private Context mContext;
public static final Companion Companion = new Companion(null);
private static ExecutorService threadPoolExecutor = Executors.newCachedThreadPool();
private static SVGAParser mShareParser = new SVGAParser(null);
@Metadata(bv = {1, 0, 3}, d1 = {"\u0000\u0018\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0000\n\u0002\u0010\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\bf\u0018\u00002\u00020\u0001J\u0010\u0010\u0002\u001a\u00020\u00032\u0006\u0010\u0004\u001a\u00020\u0005H&J\b\u0010\u0006\u001a\u00020\u0003H&¨\u0006\u0007"}, d2 = {"Lcom/opensource/svgaplayer/SVGAParser$ParseCompletion;", "", "onComplete", "", "videoItem", "Lcom/opensource/svgaplayer/SVGAVideoEntity;", "onError", "library_release"}, k = 1, mv = {1, 1, 13})
public interface ParseCompletion {
void onComplete(SVGAVideoEntity sVGAVideoEntity);
void onError();
}
public SVGAParser(Context context) {
this.mContext = context;
}
@Metadata(bv = {1, 0, 3}, d1 = {"\u0000@\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0002\n\u0002\u0010\u000b\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0002\u0010\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\b\u0016\u0018\u00002\u00020\u0001B\u0005¢\u0006\u0002\u0010\u0002J`\u0010\t\u001a\b\u0012\u0004\u0012\u00020\u000b0\n2\u0006\u0010\f\u001a\u00020\r2!\u0010\u000e\u001a\u001d\u0012\u0013\u0012\u00110\u0010¢\u0006\f\b\u0011\u0012\b\b\u0012\u0012\u0004\b\b(\u0013\u0012\u0004\u0012\u00020\u000b0\u000f2%\u0010\u0014\u001a!\u0012\u0017\u0012\u00150\u0015j\u0002`\u0016¢\u0006\f\b\u0011\u0012\b\b\u0012\u0012\u0004\b\b(\u0017\u0012\u0004\u0012\u00020\u000b0\u000fH\u0016R\u001a\u0010\u0003\u001a\u00020\u0004X\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b\u0005\u0010\u0006\"\u0004\b\u0007\u0010\b¨\u0006\u0018"}, d2 = {"Lcom/opensource/svgaplayer/SVGAParser$FileDownloader;", "", "()V", "noCache", "", "getNoCache", "()Z", "setNoCache", "(Z)V", "resume", "Lkotlin/Function0;", "", IjkMediaPlayer.OnNativeInvokeListener.ARG_URL, "Ljava/net/URL;", "complete", "Lkotlin/Function1;", "Ljava/io/InputStream;", "Lkotlin/ParameterName;", c.e, "inputStream", "failure", "Ljava/lang/Exception;", "Lkotlin/Exception;", "e", "library_release"}, k = 1, mv = {1, 1, 13})
public static class FileDownloader {
private boolean noCache;
public final boolean getNoCache() {
return this.noCache;
}
public final void setNoCache(boolean z) {
this.noCache = z;
}
public Function0<Unit> resume(final URL url, final Function1<? super InputStream, Unit> complete, final Function1<? super Exception, Unit> failure) {
Intrinsics.checkParameterIsNotNull(url, "url");
Intrinsics.checkParameterIsNotNull(complete, "complete");
Intrinsics.checkParameterIsNotNull(failure, "failure");
final Ref.BooleanRef booleanRef = new Ref.BooleanRef();
booleanRef.element = false;
Function0<Unit> function0 = new Function0<Unit>() {
{
super(0);
}
@Override
public Unit invoke() {
invoke2();
return Unit.INSTANCE;
}
public final void invoke2() {
Ref.BooleanRef.this.element = true;
}
};
SVGAParser.Companion.getThreadPoolExecutor$library_release().execute(new Runnable() {
@Override
public final void run() {
int read;
try {
if (HttpResponseCache.getInstalled() == null && !SVGAParser.FileDownloader.this.getNoCache()) {
Log.e("SVGAParser", "SVGAParser can not handle cache before install HttpResponseCache. see https://github.com/yyued/SVGAPlayer-Android#cache");
Log.e("SVGAParser", "在配置 HttpResponseCache 前 SVGAParser 无法缓存. 查看 https://github.com/yyued/SVGAPlayer-Android#cache ");
}
URLConnection openConnection = url.openConnection();
if (!(openConnection instanceof HttpURLConnection)) {
openConnection = null;
}
HttpURLConnection httpURLConnection = (HttpURLConnection) openConnection;
if (httpURLConnection != null) {
httpURLConnection.setConnectTimeout(a.g);
httpURLConnection.setRequestMethod("GET");
httpURLConnection.connect();
InputStream inputStream = httpURLConnection.getInputStream();
Throwable th = null;
InputStream inputStream2 = inputStream;
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
Throwable th2 = null;
try {
ByteArrayOutputStream byteArrayOutputStream2 = byteArrayOutputStream;
byte[] bArr = new byte[4096];
while (!booleanRef.element && (read = inputStream2.read(bArr, 0, 4096)) != -1) {
byteArrayOutputStream2.write(bArr, 0, read);
}
if (booleanRef.element) {
CloseableKt.closeFinally(byteArrayOutputStream, null);
CloseableKt.closeFinally(inputStream, null);
return;
}
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(byteArrayOutputStream2.toByteArray());
Throwable th3 = null;
complete.invoke(byteArrayInputStream);
Unit unit = Unit.INSTANCE;
CloseableKt.closeFinally(byteArrayInputStream, null);
Unit unit2 = Unit.INSTANCE;
CloseableKt.closeFinally(byteArrayOutputStream, null);
Unit unit3 = Unit.INSTANCE;
CloseableKt.closeFinally(inputStream, null);
} catch (Throwable th4) {
try {
throw th4;
} catch (Throwable th5) {
CloseableKt.closeFinally(byteArrayOutputStream, th4);
throw th5;
}
}
}
} catch (Exception e) {
e.printStackTrace();
failure.invoke(e);
}
}
});
return function0;
}
}
public final FileDownloader getFileDownloader() {
return this.fileDownloader;
}
public final void setFileDownloader(FileDownloader fileDownloader) {
Intrinsics.checkParameterIsNotNull(fileDownloader, "<set-?>");
this.fileDownloader = fileDownloader;
}
@Metadata(bv = {1, 0, 3}, d1 = {"\u0000(\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0006\n\u0002\u0010\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\b\u0086\u0003\u0018\u00002\u00020\u0001B\u0007\b\u0002¢\u0006\u0002\u0010\u0002J\u000e\u0010\f\u001a\u00020\r2\u0006\u0010\u000e\u001a\u00020\u000fJ\u0006\u0010\u0010\u001a\u00020\u0004R\u000e\u0010\u0003\u001a\u00020\u0004X\u0082\u000e¢\u0006\u0002\n\u0000R\"\u0010\u0005\u001a\n \u0007*\u0004\u0018\u00010\u00060\u0006X\u0080\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b\b\u0010\t\"\u0004\b\n\u0010\u000b¨\u0006\u0011"}, d2 = {"Lcom/opensource/svgaplayer/SVGAParser$Companion;", "", "()V", "mShareParser", "Lcom/opensource/svgaplayer/SVGAParser;", "threadPoolExecutor", "Ljava/util/concurrent/ExecutorService;", "kotlin.jvm.PlatformType", "getThreadPoolExecutor$library_release", "()Ljava/util/concurrent/ExecutorService;", "setThreadPoolExecutor$library_release", "(Ljava/util/concurrent/ExecutorService;)V", "setThreadPoolExecutor", "", "executor", "Ljava/util/concurrent/ThreadPoolExecutor;", "shareParser", "library_release"}, k = 1, mv = {1, 1, 13})
public static final class Companion {
private Companion() {
}
public Companion(DefaultConstructorMarker defaultConstructorMarker) {
this();
}
public final ExecutorService getThreadPoolExecutor$library_release() {
return SVGAParser.threadPoolExecutor;
}
public final void setThreadPoolExecutor$library_release(ExecutorService executorService) {
SVGAParser.threadPoolExecutor = executorService;
}
public final void setThreadPoolExecutor(ThreadPoolExecutor executor) {
Intrinsics.checkParameterIsNotNull(executor, "executor");
setThreadPoolExecutor$library_release(executor);
}
public final SVGAParser shareParser() {
return SVGAParser.mShareParser;
}
}
public final void init(Context context) {
Intrinsics.checkParameterIsNotNull(context, "context");
this.mContext = context;
}
public final void decodeFromAssets(String name, ParseCompletion parseCompletion) {
AssetManager assets;
InputStream open;
Intrinsics.checkParameterIsNotNull(name, "name");
if (this.mContext == null) {
Log.e("SVGAParser", "在配置 SVGAParser context 前, 无法解析 SVGA 文件。");
}
try {
Context context = this.mContext;
if (context == null || (assets = context.getAssets()) == null || (open = assets.open(name)) == null) {
return;
}
decodeFromInputStream(open, buildCacheKey("file:///assets/" + name), parseCompletion, true);
} catch (Exception e) {
invokeErrorCallback(e, parseCompletion);
}
}
public final Function0<Unit> decodeFromURL(final URL url, final ParseCompletion parseCompletion) {
Intrinsics.checkParameterIsNotNull(url, "url");
if (isCached(buildCacheKey(url))) {
threadPoolExecutor.execute(new Runnable() {
@Override
public final void run() {
String buildCacheKey;
SVGAParser sVGAParser = SVGAParser.this;
buildCacheKey = sVGAParser.buildCacheKey(url);
sVGAParser.decodeFromCacheKey(buildCacheKey, parseCompletion);
}
});
return null;
}
return this.fileDownloader.resume(url, new Function1<InputStream, Unit>() {
{
super(1);
}
@Override
public Unit invoke(InputStream inputStream) {
invoke2(inputStream);
return Unit.INSTANCE;
}
public final void invoke2(InputStream it) {
String buildCacheKey;
Intrinsics.checkParameterIsNotNull(it, "it");
SVGAParser sVGAParser = SVGAParser.this;
buildCacheKey = sVGAParser.buildCacheKey(url);
SVGAParser.decodeFromInputStream$default(sVGAParser, it, buildCacheKey, parseCompletion, false, 8, null);
}
}, new Function1<Exception, Unit>() {
{
super(1);
}
@Override
public Unit invoke(Exception exc) {
invoke2(exc);
return Unit.INSTANCE;
}
public final void invoke2(Exception it) {
Intrinsics.checkParameterIsNotNull(it, "it");
SVGAParser.this.invokeErrorCallback(it, parseCompletion);
}
});
}
public static void decodeFromInputStream$default(SVGAParser sVGAParser, InputStream inputStream, String str, ParseCompletion parseCompletion, boolean z, int i, Object obj) {
if ((i & 8) != 0) {
z = false;
}
sVGAParser.decodeFromInputStream(inputStream, str, parseCompletion, z);
}
public final void decodeFromInputStream(InputStream inputStream, String cacheKey, ParseCompletion parseCompletion, boolean z) {
Intrinsics.checkParameterIsNotNull(inputStream, "inputStream");
Intrinsics.checkParameterIsNotNull(cacheKey, "cacheKey");
threadPoolExecutor.execute(new SVGAParser$decodeFromInputStream$1(this, inputStream, cacheKey, parseCompletion, z));
}
@Deprecated(message = "This method has been deprecated from 2.4.0.", replaceWith = @ReplaceWith(expression = "this.decodeFromAssets(assetsName, callback)", imports = {}))
public final void parse(String assetsName, ParseCompletion parseCompletion) {
Intrinsics.checkParameterIsNotNull(assetsName, "assetsName");
decodeFromAssets(assetsName, parseCompletion);
}
@Deprecated(message = "This method has been deprecated from 2.4.0.", replaceWith = @ReplaceWith(expression = "this.decodeFromURL(url, callback)", imports = {}))
public final void parse(URL url, ParseCompletion parseCompletion) {
Intrinsics.checkParameterIsNotNull(url, "url");
decodeFromURL(url, parseCompletion);
}
@Deprecated(message = "This method has been deprecated from 2.4.0.", replaceWith = @ReplaceWith(expression = "this.decodeFromInputStream(inputStream, cacheKey, callback, closeInputStream)", imports = {}))
public static void parse$default(SVGAParser sVGAParser, InputStream inputStream, String str, ParseCompletion parseCompletion, boolean z, int i, Object obj) {
if ((i & 8) != 0) {
z = false;
}
sVGAParser.parse(inputStream, str, parseCompletion, z);
}
@Deprecated(message = "This method has been deprecated from 2.4.0.", replaceWith = @ReplaceWith(expression = "this.decodeFromInputStream(inputStream, cacheKey, callback, closeInputStream)", imports = {}))
public final void parse(InputStream inputStream, String cacheKey, ParseCompletion parseCompletion, boolean z) {
Intrinsics.checkParameterIsNotNull(inputStream, "inputStream");
Intrinsics.checkParameterIsNotNull(cacheKey, "cacheKey");
decodeFromInputStream(inputStream, cacheKey, parseCompletion, z);
}
public final void invokeCompleteCallback(final SVGAVideoEntity sVGAVideoEntity, final ParseCompletion parseCompletion) {
if (this.mContext == null) {
Log.e("SVGAParser", "在配置 SVGAParser context 前, 无法解析 SVGA 文件。");
}
Context context = this.mContext;
new Handler(context != null ? context.getMainLooper() : null).post(new Runnable() {
@Override
public final void run() {
SVGAParser.ParseCompletion parseCompletion2 = SVGAParser.ParseCompletion.this;
if (parseCompletion2 != null) {
parseCompletion2.onComplete(sVGAVideoEntity);
}
}
});
}
public final void invokeErrorCallback(Exception exc, final ParseCompletion parseCompletion) {
exc.printStackTrace();
if (this.mContext == null) {
Log.e("SVGAParser", "在配置 SVGAParser context 前, 无法解析 SVGA 文件。");
}
Context context = this.mContext;
new Handler(context != null ? context.getMainLooper() : null).post(new Runnable() {
@Override
public final void run() {
SVGAParser.ParseCompletion parseCompletion2 = SVGAParser.ParseCompletion.this;
if (parseCompletion2 != null) {
parseCompletion2.onError();
}
}
});
}
private final boolean isCached(String str) {
return buildCacheDir(str).exists();
}
public final void decodeFromCacheKey(String str, ParseCompletion parseCompletion) {
File cacheDir;
if (this.mContext == null) {
Log.e("SVGAParser", "在配置 SVGAParser context 前, 无法解析 SVGA 文件。");
}
try {
StringBuilder sb = new StringBuilder();
Context context = this.mContext;
sb.append((context == null || (cacheDir = context.getCacheDir()) == null) ? null : cacheDir.getAbsolutePath());
sb.append("/");
sb.append(str);
sb.append("/");
File file = new File(sb.toString());
File file2 = new File(file, "movie.binary");
if (!file2.isFile()) {
file2 = null;
}
if (file2 != null) {
try {
FileInputStream fileInputStream = new FileInputStream(file2);
Throwable th = null;
MovieEntity decode = MovieEntity.ADAPTER.decode(fileInputStream);
Intrinsics.checkExpressionValueIsNotNull(decode, "MovieEntity.ADAPTER.decode(it)");
invokeCompleteCallback(new SVGAVideoEntity(decode, file), parseCompletion);
Unit unit = Unit.INSTANCE;
CloseableKt.closeFinally(fileInputStream, null);
} catch (Exception e) {
file.delete();
file2.delete();
throw e;
}
}
File file3 = new File(file, "movie.spec");
if (!file3.isFile()) {
file3 = null;
}
if (file3 == null) {
return;
}
try {
FileInputStream fileInputStream2 = new FileInputStream(file3);
Throwable th2 = null;
FileInputStream fileInputStream3 = fileInputStream2;
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
Throwable th3 = null;
ByteArrayOutputStream byteArrayOutputStream2 = byteArrayOutputStream;
byte[] bArr = new byte[2048];
while (true) {
int read = fileInputStream3.read(bArr, 0, 2048);
if (read != -1) {
byteArrayOutputStream2.write(bArr, 0, read);
} else {
invokeCompleteCallback(new SVGAVideoEntity(new JSONObject(byteArrayOutputStream2.toString()), file), parseCompletion);
Unit unit2 = Unit.INSTANCE;
CloseableKt.closeFinally(byteArrayOutputStream, null);
Unit unit3 = Unit.INSTANCE;
CloseableKt.closeFinally(fileInputStream2, null);
return;
}
}
} catch (Exception e2) {
file.delete();
file3.delete();
throw e2;
}
} catch (Exception e3) {
invokeErrorCallback(e3, parseCompletion);
}
}
private final String buildCacheKey(String str) {
byte[] digest;
MessageDigest messageDigest = MessageDigest.getInstance("MD5");
Charset forName = Charset.forName("UTF-8");
Intrinsics.checkExpressionValueIsNotNull(forName, "Charset.forName(charsetName)");
if (str == null) {
throw new TypeCastException("null cannot be cast to non-null type java.lang.String");
}
byte[] bytes = str.getBytes(forName);
Intrinsics.checkExpressionValueIsNotNull(bytes, "(this as java.lang.String).getBytes(charset)");
messageDigest.update(bytes);
String str2 = "";
for (byte b : messageDigest.digest()) {
StringBuilder sb = new StringBuilder();
sb.append(str2);
StringCompanionObject stringCompanionObject = StringCompanionObject.INSTANCE;
String format = String.format("%02x", Arrays.copyOf(new Object[]{Byte.valueOf(b)}, 1));
Intrinsics.checkExpressionValueIsNotNull(format, "java.lang.String.format(format, *args)");
sb.append(format);
str2 = sb.toString();
}
return str2;
}
public final String buildCacheKey(URL url) {
String url2 = url.toString();
Intrinsics.checkExpressionValueIsNotNull(url2, "url.toString()");
return buildCacheKey(url2);
}
public final File buildCacheDir(String str) {
File cacheDir;
StringBuilder sb = new StringBuilder();
Context context = this.mContext;
sb.append((context == null || (cacheDir = context.getCacheDir()) == null) ? null : cacheDir.getAbsolutePath());
sb.append("/");
sb.append(str);
sb.append("/");
return new File(sb.toString());
}
public final byte[] readAsBytes(InputStream inputStream) {
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
try {
ByteArrayOutputStream byteArrayOutputStream2 = byteArrayOutputStream;
byte[] bArr = new byte[2048];
while (true) {
int read = inputStream.read(bArr, 0, 2048);
if (read > 0) {
byteArrayOutputStream2.write(bArr, 0, read);
} else {
byte[] byteArray = byteArrayOutputStream2.toByteArray();
CloseableKt.closeFinally(byteArrayOutputStream, null);
return byteArray;
}
}
} finally {
}
}
public final byte[] inflate(byte[] bArr) {
Inflater inflater = new Inflater();
inflater.setInput(bArr, 0, bArr.length);
byte[] bArr2 = new byte[2048];
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
try {
ByteArrayOutputStream byteArrayOutputStream2 = byteArrayOutputStream;
while (true) {
int inflate = inflater.inflate(bArr2, 0, 2048);
if (inflate > 0) {
byteArrayOutputStream2.write(bArr2, 0, inflate);
} else {
inflater.end();
byte[] byteArray = byteArrayOutputStream2.toByteArray();
CloseableKt.closeFinally(byteArrayOutputStream, null);
return byteArray;
}
}
} finally {
}
}
public final void unzip(InputStream inputStream, String str) {
int i;
i = SVGAParserKt.fileLock;
synchronized (Integer.valueOf(i)) {
File buildCacheDir = buildCacheDir(str);
buildCacheDir.mkdirs();
try {
FileOutputStream bufferedInputStream = new BufferedInputStream(inputStream);
Throwable th = null;
try {
ZipInputStream zipInputStream = new ZipInputStream(bufferedInputStream);
Throwable th2 = null;
ZipInputStream zipInputStream2 = zipInputStream;
while (true) {
ZipEntry nextEntry = zipInputStream2.getNextEntry();
if (nextEntry != null) {
String name = nextEntry.getName();
Intrinsics.checkExpressionValueIsNotNull(name, "zipItem.name");
if (!StringsKt.contains$default((CharSequence) name, (CharSequence) "/", false, 2, (Object) null)) {
bufferedInputStream = new FileOutputStream(new File(buildCacheDir, nextEntry.getName()));
Throwable th3 = null;
try {
FileOutputStream fileOutputStream = bufferedInputStream;
byte[] bArr = new byte[2048];
while (true) {
int read = zipInputStream2.read(bArr);
if (read <= 0) {
break;
}
fileOutputStream.write(bArr, 0, read);
}
Unit unit = Unit.INSTANCE;
CloseableKt.closeFinally(bufferedInputStream, null);
zipInputStream2.closeEntry();
} finally {
}
}
} else {
Unit unit2 = Unit.INSTANCE;
CloseableKt.closeFinally(zipInputStream, null);
Unit unit3 = Unit.INSTANCE;
CloseableKt.closeFinally(bufferedInputStream, null);
Unit unit4 = Unit.INSTANCE;
}
}
} finally {
try {
throw th;
} finally {
}
}
} catch (Exception e) {
buildCacheDir.delete();
throw e;
}
}
}
}