最右.apk(点击下载) / SVGAParser$FileDownloader$resume$1.java


package com.opensource.svgaplayer;

import android.net.http.HttpResponseCache;
import android.util.Log;
import com.opensource.svgaplayer.SVGAParser;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
import kotlin.Metadata;
import kotlin.Unit;
import kotlin.io.CloseableKt;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.internal.Ref;

@Metadata(bv = {1, 0, 3}, d1 = {"\u0000\b\n\u0002\u0010\u0002\n\u0002\b\u0003\u0010\u0003\u001a\u00020\u0000H\n¢\u0006\u0004\b\u0001\u0010\u0002"}, d2 = {"", "run", "()V", "<anonymous>"}, k = 3, mv = {1, 4, 1})
public final class SVGAParser$FileDownloader$resume$1 implements Runnable {
    public final /* synthetic */ Ref.BooleanRef $cancelled;
    public final /* synthetic */ Function1 $complete;
    public final /* synthetic */ Function1 $failure;
    public final /* synthetic */ URL $url;
    public final /* synthetic */ SVGAParser.FileDownloader this$0;

    public SVGAParser$FileDownloader$resume$1(SVGAParser.FileDownloader fileDownloader, URL url, Ref.BooleanRef booleanRef, Function1 function1, Function1 function12) {
        this.this$0 = fileDownloader;
        this.$url = url;
        this.$cancelled = booleanRef;
        this.$complete = function1;
        this.$failure = function12;
    }

    /* JADX WARNING: Code restructure failed: missing block: B:34:0x007c, code lost:
        r4 = move-exception;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:35:0x007d, code lost:
        kotlin.io.CloseableKt.closeFinally(r3, r2);
     */
    /* JADX WARNING: Code restructure failed: missing block: B:36:0x0080, code lost:
        throw r4;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:41:0x0087, code lost:
        r3 = move-exception;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:42:0x0088, code lost:
        kotlin.io.CloseableKt.closeFinally(r1, r2);
     */
    /* JADX WARNING: Code restructure failed: missing block: B:43:0x008b, code lost:
        throw r3;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:47:0x008e, code lost:
        r2 = move-exception;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:48:0x008f, code lost:
        kotlin.io.CloseableKt.closeFinally(r0, r1);
     */
    /* JADX WARNING: Code restructure failed: missing block: B:49:0x0092, code lost:
        throw r2;
     */
    public final void run() {
        try {
            if (HttpResponseCache.getInstalled() == null && !this.this$0.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 = this.$url.openConnection();
            if (!(openConnection instanceof HttpURLConnection)) {
                openConnection = null;
            }
            HttpURLConnection httpURLConnection = (HttpURLConnection) openConnection;
            if (httpURLConnection != null) {
                httpURLConnection.setConnectTimeout(20000);
                httpURLConnection.setRequestMethod("GET");
                httpURLConnection.connect();
                InputStream inputStream = httpURLConnection.getInputStream();
                ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
                byte[] bArr = new byte[4096];
                while (true) {
                    if (this.$cancelled.element) {
                        break;
                    }
                    int read = inputStream.read(bArr, 0, 4096);
                    if (read == -1) {
                        break;
                    }
                    byteArrayOutputStream.write(bArr, 0, read);
                }
                if (this.$cancelled.element) {
                    CloseableKt.closeFinally(byteArrayOutputStream, null);
                    CloseableKt.closeFinally(inputStream, null);
                    return;
                }
                ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
                this.$complete.invoke(byteArrayInputStream);
                Unit unit = Unit.INSTANCE;
                CloseableKt.closeFinally(byteArrayInputStream, null);
                CloseableKt.closeFinally(byteArrayOutputStream, null);
                CloseableKt.closeFinally(inputStream, null);
            }
        } catch (Exception e) {
            e.printStackTrace();
            this.$failure.invoke(e);
        }
    }
}