apk(点击下载) / MyGitFile$testGit$1.java


package com.gaoyuan.mianshu.network;

import android.content.Context;
import android.util.Log;
import androidx.core.app.NotificationCompat;
import com.gaoyuan.mianshu.f;
import com.meizu.cloud.pushsdk.constants.PushConstants;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import kotlin.h;
import kotlin.jvm.internal.i;
import kotlin.l;
import kotlin.o.a;
import kotlin.o.c;
import kotlin.text.StringsKt__StringsKt;
import kotlin.text.d;
import kotlin.text.o;
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.Response;
import okhttp3.ResponseBody;
import okio.BufferedSink;
import okio.Okio;

@h
/* compiled from: MyGitFile.kt */
public final class MyGitFile$testGit$1 implements Callback {
    final /* synthetic */ Context $context;
    final /* synthetic */ String $myUrl;
    final /* synthetic */ long $startTime;

    MyGitFile$testGit$1(String str, Context context, long j) {
        this.$myUrl = str;
        this.$context = context;
        this.$startTime = j;
    }

    @Override // okhttp3.Callback
    public void onFailure(Call call, IOException iOException) {
        i.e(call, NotificationCompat.CATEGORY_CALL);
        i.e(iOException, "e");
        iOException.printStackTrace();
        f.a.B("1", o.x((String) StringsKt__StringsKt.q0(this.$myUrl, new String[]{"raw"}, false, 0, 6, null).get(0), "https://gitee.com/", "", false, 4, null), String.valueOf(iOException.getMessage()));
        MyGitFile.INSTANCE.setInnerFenfa(this.$context);
    }

    /* JADX WARNING: Code restructure failed: missing block: B:33:0x0147, code lost:
        r0 = move-exception;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:34:0x0148, code lost:
        kotlin.o.a.a(r7, r0);
     */
    /* JADX WARNING: Code restructure failed: missing block: B:35:0x014c, code lost:
        throw r0;
     */
    /* JADX WARNING: Removed duplicated region for block: B:45:0x0196  */
    /* JADX WARNING: Removed duplicated region for block: B:47:0x019c  */
    /* JADX WARNING: Removed duplicated region for block: B:56:? A[RETURN, SYNTHETIC] */
    @Override // okhttp3.Callback
    public void onResponse(Call call, Response response) {
        Throwable th;
        Exception e;
        int i;
        i.e(call, NotificationCompat.CATEGORY_CALL);
        i.e(response, "response");
        BufferedSink bufferedSink = null;
        try {
            String absolutePath = this.$context.getCacheDir().getAbsolutePath();
            String str = this.$myUrl;
            String substring = str.substring(StringsKt__StringsKt.W(str, "/", 0, false, 6, null) + 1);
            i.d(substring, "this as java.lang.String).substring(startIndex)");
            File file = new File(absolutePath, substring);
            BufferedSink buffer = Okio.buffer(Okio.sink$default(file, false, 1, null));
            try {
                ResponseBody body = response.body();
                i.c(body);
                buffer.writeAll(body.source());
                buffer.close();
                InputStreamReader inputStreamReader = new InputStreamReader(new FileInputStream(file), d.b);
                BufferedReader bufferedReader = inputStreamReader instanceof BufferedReader ? (BufferedReader) inputStreamReader : new BufferedReader(inputStreamReader, 8192);
                Context context = this.$context;
                String str2 = this.$myUrl;
                boolean z = false;
                int i2 = 0;
                for (String str3 : c.a(bufferedReader)) {
                    if (i2 != 14 || z) {
                        i2++;
                    } else {
                        String obj = StringsKt__StringsKt.E0(str3).toString();
                        Log.e("aaaaaaaaaaaa", obj);
                        if (obj.length() > 0) {
                            String substring2 = obj.substring(1, obj.length() - 1);
                            i.d(substring2, "this as java.lang.String…ing(startIndex, endIndex)");
                            MyGitFile.INSTANCE.dealDomain(context, f.a.a(substring2), "G");
                            i = i2;
                        } else {
                            i = i2;
                            f.a.B("1", o.x((String) StringsKt__StringsKt.q0(str2, new String[]{"raw"}, false, 0, 6, null).get(0), "https://gitee.com/", "", false, 4, null), "读取结果为空");
                            MyGitFile.INSTANCE.setInnerFenfa(context);
                        }
                        i2 = i;
                        z = true;
                    }
                }
                l lVar = l.a;
                a.a(bufferedReader, null);
                Log.e("gitee", "myUrl=" + this.$myUrl);
                Log.e("gitee", "totalTime=" + (System.currentTimeMillis() - this.$startTime));
                if (buffer != null) {
                    buffer.close();
                }
            } catch (Exception e2) {
                e = e2;
                bufferedSink = buffer;
                try {
                    e.printStackTrace();
                    Log.e("gitee", "download failed2");
                    f.a.B(PushConstants.PUSH_TYPE_UPLOAD_LOG, o.x((String) StringsKt__StringsKt.q0(this.$myUrl, new String[]{"raw"}, false, 0, 6, null).get(0), "https://gitee.com/", "", false, 4, null), String.valueOf(e.getMessage()));
                    MyGitFile.INSTANCE.setInnerFenfa(this.$context);
                    if (bufferedSink == null) {
                        bufferedSink.close();
                    }
                } catch (Throwable th2) {
                    th = th2;
                    if (bufferedSink != null) {
                        bufferedSink.close();
                    }
                    throw th;
                }
            } catch (Throwable th3) {
                th = th3;
                bufferedSink = buffer;
                if (bufferedSink != null) {
                }
                throw th;
            }
        } catch (Exception e3) {
            e = e3;
            e.printStackTrace();
            Log.e("gitee", "download failed2");
            f.a.B(PushConstants.PUSH_TYPE_UPLOAD_LOG, o.x((String) StringsKt__StringsKt.q0(this.$myUrl, new String[]{"raw"}, false, 0, 6, null).get(0), "https://gitee.com/", "", false, 4, null), String.valueOf(e.getMessage()));
            MyGitFile.INSTANCE.setInnerFenfa(this.$context);
            if (bufferedSink == null) {
            }
        }
    }
}