package com.tencent.mm.plugin.appbrand.ui;

import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import com.tencent.matrix.trace.core.AppMethodBeat;
import com.tencent.mm.cj.c;
import com.tencent.mm.pluginsdk.ui.tools.m;
import com.tencent.mm.sdk.platformtools.ab;
import com.tencent.mm.sdk.platformtools.ah;
import com.tencent.mm.sdk.platformtools.al;
import com.tencent.xweb.x5.sdk.d;
import com.tencent.xweb.x5.sdk.h;

final class AppBrandTBSDownloadProxyUI$a implements h {
    final /* synthetic */ AppBrandTBSDownloadProxyUI iIJ;

    private AppBrandTBSDownloadProxyUI$a(AppBrandTBSDownloadProxyUI appBrandTBSDownloadProxyUI) {
        this.iIJ = appBrandTBSDownloadProxyUI;
    }

    /* synthetic */ AppBrandTBSDownloadProxyUI$a(AppBrandTBSDownloadProxyUI appBrandTBSDownloadProxyUI, byte b) {
        this(appBrandTBSDownloadProxyUI);
    }

    public final void onDownloadFinish(int i) {
        AppMethodBeat.i(133107);
        ab.i("MicroMsg.AppBrandTBSDownloadProxyUI", "onDownloadFinish, result = %d", new Object[]{Integer.valueOf(i)});
        m.gu(5, i);
        if (i == 100 || i == 120 || i == 122) {
            com.tencent.mm.plugin.report.service.h.pYm.a(366, 4, 1, false);
        } else {
            com.tencent.mm.plugin.report.service.h.pYm.a(366, 5, 1, false);
        }
        SharedPreferences sharedPreferences;
        Editor edit;
        if (i != 110) {
            if (i == 100 || i == 120 || i == 122) {
                com.tencent.mm.plugin.report.service.h.pYm.a(64, 64, 4, 3, 1, 1, false);
            } else {
                AppBrandTBSDownloadProxyUI.d(this.iIJ);
                d.a(AppBrandTBSDownloadProxyUI.e(this.iIJ));
                com.tencent.mm.plugin.report.service.h.pYm.a(64, 3, 1, false);
                this.iIJ.setResult(0, new Intent());
                this.iIJ.finish();
            }
            sharedPreferences = ah.getContext().getSharedPreferences("com.tencent.mm_webview_x5_preferences", 4);
            if (sharedPreferences != null) {
                ab.i("MicroMsg.AppBrandTBSDownloadProxyUI", "tbs has download finished, save to sharedpreference");
                edit = sharedPreferences.edit();
                edit.putBoolean("tbs_download_finished", true);
                edit.apply();
            }
            AppMethodBeat.o(133107);
            return;
        }
        sharedPreferences = ah.getContext().getSharedPreferences("com.tencent.mm_webview_x5_preferences", 4);
        if (sharedPreferences != null) {
            ab.i("MicroMsg.AppBrandTBSDownloadProxyUI", "tbs has download finished, save to sharedpreference");
            edit = sharedPreferences.edit();
            edit.putBoolean("tbs_download_finished", true);
            edit.apply();
        }
        AppBrandTBSDownloadProxyUI.d(this.iIJ);
        d.a(AppBrandTBSDownloadProxyUI.e(this.iIJ));
        this.iIJ.setResult(0, new Intent());
        this.iIJ.finish();
        AppMethodBeat.o(133107);
    }

    public final void onInstallFinish(int i) {
        AppMethodBeat.i(133108);
        ab.i("MicroMsg.AppBrandTBSDownloadProxyUI", "onInstallFinish, result = %d", new Object[]{Integer.valueOf(i)});
        if (this.iIJ.tipDialog != null) {
            this.iIJ.tipDialog.dismiss();
            this.iIJ.tipDialog = null;
        }
        m.gu(6, i);
        if (i == 200 || i == 220) {
            com.tencent.mm.plugin.report.service.h.pYm.a(64, 64, 7, 6, 1, 1, false);
            com.tencent.mm.plugin.report.service.h.pYm.a(366, 6, 1, false);
            ab.i("MicroMsg.AppBrandTBSDownloadProxyUI", "onInstallFinish, restart tool");
            c.aNX();
            AppBrandTBSDownloadProxyUI.d(this.iIJ);
            d.a(AppBrandTBSDownloadProxyUI.e(this.iIJ));
            this.iIJ.setResult(-1, new Intent());
            this.iIJ.finish();
            AppMethodBeat.o(133108);
            return;
        }
        com.tencent.mm.plugin.report.service.h.pYm.a(64, 6, 1, false);
        com.tencent.mm.plugin.report.service.h.pYm.a(366, 7, 1, false);
        AppBrandTBSDownloadProxyUI.d(this.iIJ);
        d.a(AppBrandTBSDownloadProxyUI.e(this.iIJ));
        this.iIJ.setResult(0, new Intent());
        this.iIJ.finish();
        AppMethodBeat.o(133108);
    }

    public final void onDownloadProgress(int i) {
        AppMethodBeat.i(133109);
        ab.i("MicroMsg.AppBrandTBSDownloadProxyUI", "onDownloadProgress, percent = %d", new Object[]{Integer.valueOf(i)});
        if (this.iIJ.tipDialog != null) {
            al.d(new 1(this, i));
        }
        AppMethodBeat.o(133109);
    }
}
