翰林优商.apk(点击下载) / e.java


package com.mbridge.msdk.mbjscommon.confirmation;

import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.IntentFilter;
import android.graphics.Bitmap;
import android.net.Uri;
import android.net.http.SslError;
import android.os.Build;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.text.TextUtils;
import android.view.ViewGroup;
import android.webkit.SslErrorHandler;
import android.webkit.WebView;
import com.mbridge.msdk.c.d;
import com.mbridge.msdk.click.c;
import com.mbridge.msdk.foundation.download.download.H5DownLoadManager;
import com.mbridge.msdk.foundation.download.download.HTMLResourceManager;
import com.mbridge.msdk.foundation.entity.CampaignEx;
import com.mbridge.msdk.foundation.tools.aa;
import com.mbridge.msdk.foundation.tools.w;
import com.mbridge.msdk.mbjscommon.windvane.WindVaneWebView;
import com.mbridge.msdk.mbjscommon.windvane.h;
import com.mbridge.msdk.widget.custom.CustomViewMessageWrap;
import com.mbridge.msdk.widget.custom.DownloadMessageDialog;
import com.mbridge.msdk.widget.custom.a;
import com.mbridge.msdk.widget.custom.baseview.MBButton;
import com.mbridge.msdk.widget.dialog.MBAlertDialog;
import java.io.Serializable;
import java.lang.ref.WeakReference;
import java.util.HashMap;
import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.atomic.AtomicBoolean;

/* compiled from: SecondaryConfirmationManager */
public final class e implements Serializable {
    public static int b = 1;
    public static int c = 0;
    public static int d = 2;
    HashMap<String, Integer> a;
    private WindVaneWebView e;
    private WindVaneWebView f;
    private b g;
    private b h;
    private c i;
    private int j;
    private MBAlertDialog k;
    private DownloadMessageDialog l;
    private AtomicBoolean m;
    private AtomicBoolean n;
    private volatile boolean o;
    private Timer p;
    private a q;
    private final Handler r;

    /* access modifiers changed from: package-private */
    /* compiled from: SecondaryConfirmationManager */
    public static class b {
        private static final e a = new e();
    }

    private e() {
        this.a = new HashMap<>();
        this.j = 1;
        this.m = new AtomicBoolean(false);
        this.n = new AtomicBoolean(false);
        this.o = false;
        this.p = new Timer();
        this.r = new Handler(Looper.getMainLooper()) {
            /* class com.mbridge.msdk.mbjscommon.confirmation.e.AnonymousClass1 */

            public final void handleMessage(Message message) {
                super.handleMessage(message);
                int i = message.what;
                if (i != 1) {
                    if (i == 2 && e.this.h != null) {
                        e.this.h.a(1, "render is time out");
                    }
                } else if (e.this.g != null) {
                    e.this.g.a(1, "render is time out");
                } else {
                    e.this.b();
                }
            }
        };
    }

    public static e a() {
        return b.a;
    }

    private String a(String str, String str2) {
        if (!TextUtils.isEmpty(str)) {
            return str;
        }
        if (com.mbridge.msdk.c.b.a().e(com.mbridge.msdk.foundation.controller.a.f().k(), str2) != null) {
            str = d.a;
        }
        return !TextUtils.isEmpty(str) ? str : "";
    }

    public final void b() {
        this.p.cancel();
        this.o = false;
    }

    /* JADX WARNING: Removed duplicated region for block: B:74:0x0163 A[Catch:{ all -> 0x0202 }] */
    /* JADX WARNING: Removed duplicated region for block: B:86:0x019a A[Catch:{ all -> 0x0202 }] */
    /* JADX WARNING: Removed duplicated region for block: B:89:0x01be A[Catch:{ all -> 0x0202 }] */
    /* JADX WARNING: Removed duplicated region for block: B:90:0x01e5 A[Catch:{ all -> 0x0202 }] */
    public final synchronized void a(String str, final CampaignEx campaignEx, Context context, final String str2, com.mbridge.msdk.widget.dialog.a aVar) {
        boolean z;
        boolean z2;
        WindVaneWebView windVaneWebView;
        Object object;
        Activity activity;
        int clickTimeOutInterval;
        if (!this.o) {
            if (!(campaignEx == null || (clickTimeOutInterval = campaignEx.getClickTimeOutInterval() * 1000) == 0)) {
                Timer timer = new Timer();
                this.p = timer;
                timer.schedule(new TimerTask() {
                    /* class com.mbridge.msdk.mbjscommon.confirmation.e.AnonymousClass2 */

                    public final void run() {
                        e.this.o = false;
                    }
                }, (long) clickTimeOutInterval);
            }
            this.o = true;
            final String a2 = a(str, str2);
            Context c2 = com.mbridge.msdk.foundation.controller.a.f().c();
            Activity activity2 = null;
            if (c2 instanceof Activity) {
                activity2 = (Activity) c2;
            }
            if ((context instanceof Activity) && (Build.VERSION.SDK_INT < 17 || !((Activity) context).isDestroyed())) {
                activity2 = (Activity) context;
            }
            WeakReference<Activity> a3 = com.mbridge.msdk.foundation.controller.a.f().a();
            final Activity activity3 = (a3 == null || (activity = a3.get()) == null || activity.isFinishing() || (Build.VERSION.SDK_INT >= 17 && activity.isDestroyed())) ? activity2 : activity;
            if (activity3 == null || activity3.isFinishing() || (Build.VERSION.SDK_INT >= 17 && activity3.isDestroyed())) {
                b();
                return;
            }
            this.i = new c(aVar, activity3, campaignEx, a2, str2);
            MBAlertDialog mBAlertDialog = new MBAlertDialog(activity3, this.i);
            this.k = mBAlertDialog;
            mBAlertDialog.setCancelable(true);
            if (campaignEx.getApkDisplayInfo() == null) {
                a(campaignEx, activity3, a2, str2, this.i);
                return;
            }
            a aVar2 = new a(a2 + campaignEx.getApkDisplayInfo().toString(), this.i, this.e, this.f, this.j);
            this.q = aVar2;
            this.k.setOnDismissListener(aVar2);
            try {
                final c cVar = this.i;
                if (campaignEx != null) {
                    if (campaignEx.getApkDisplayInfo() == null) {
                        a(campaignEx, activity3, a2, str2, cVar);
                    } else if (TextUtils.isEmpty(a2)) {
                        b(a2, campaignEx, activity3, str2, cVar);
                    } else {
                        WindVaneWebView windVaneWebView2 = this.e;
                        if (windVaneWebView2 != null && !windVaneWebView2.isDestoryed()) {
                            Object object2 = this.e.getObject();
                            if (object2 instanceof a) {
                                a aVar3 = (a) object2;
                                Object c3 = aVar3.c();
                                if (aVar3.a() == b && a2.equals(c3)) {
                                    z = true;
                                    if (!z && (windVaneWebView = this.f) != null && !windVaneWebView.isDestoryed()) {
                                        object = this.f.getObject();
                                        if (object instanceof a) {
                                            a aVar4 = (a) object;
                                            Object c4 = aVar4.c();
                                            if (aVar4.a() == b && a2.equals(c4)) {
                                                this.e = this.f;
                                                z2 = true;
                                                WindVaneWebView windVaneWebView3 = this.e;
                                                if (windVaneWebView3 == null || windVaneWebView3.isDestoryed()) {
                                                    WindVaneWebView windVaneWebView4 = new WindVaneWebView(activity3);
                                                    this.e = windVaneWebView4;
                                                    windVaneWebView4.setBackgroundColor(0);
                                                    if (this.e.getBackground() != null) {
                                                        this.e.getBackground().setAlpha(0);
                                                    }
                                                }
                                                this.g = new b() {
                                                    /* class com.mbridge.msdk.mbjscommon.confirmation.e.AnonymousClass5 */

                                                    @Override // com.mbridge.msdk.mbjscommon.confirmation.b
                                                    public final void a() {
                                                        e.this.r.removeMessages(1);
                                                        if (e.this.m.compareAndSet(false, true)) {
                                                            a aVar = (a) e.this.e.getObject();
                                                            aVar.a(e.b);
                                                            e.this.e.setObject(aVar);
                                                            e eVar = e.this;
                                                            eVar.a((e) eVar.e, (WindVaneWebView) a2, (String) campaignEx, (CampaignEx) activity3, (Context) str2, (String) cVar);
                                                            com.mbridge.msdk.foundation.same.report.e.a(activity3, campaignEx, a2, str2, 1, "", 2);
                                                        }
                                                    }

                                                    @Override // com.mbridge.msdk.mbjscommon.confirmation.b
                                                    public final void a(int i, String str) {
                                                        e.this.r.removeMessages(1);
                                                        if (e.this.m.compareAndSet(false, true)) {
                                                            a aVar = (a) e.this.e.getObject();
                                                            aVar.a(e.d);
                                                            e.this.e.setObject(aVar);
                                                            e.this.b(a2, campaignEx, activity3, str2, cVar);
                                                            com.mbridge.msdk.foundation.same.report.e.a(activity3, campaignEx, a2, str2, 2, str, 2);
                                                        }
                                                    }
                                                };
                                                this.r.sendEmptyMessageDelayed(1, 500);
                                                if (z2) {
                                                    a aVar5 = new a(campaignEx, a2, str2);
                                                    aVar5.a(c);
                                                    this.e.setObject(aVar5);
                                                    h.a().a(this.e);
                                                    a(this.e, a2, campaignEx, activity3, str2, cVar);
                                                } else {
                                                    this.m.compareAndSet(true, false);
                                                    a(this.e, a2, campaignEx, activity3, str2, cVar, this.g);
                                                }
                                            }
                                        }
                                    }
                                    z2 = z;
                                    WindVaneWebView windVaneWebView32 = this.e;
                                    WindVaneWebView windVaneWebView42 = new WindVaneWebView(activity3);
                                    this.e = windVaneWebView42;
                                    windVaneWebView42.setBackgroundColor(0);
                                    if (this.e.getBackground() != null) {
                                    }
                                    this.g = new b() {
                                        /* class com.mbridge.msdk.mbjscommon.confirmation.e.AnonymousClass5 */

                                        @Override // com.mbridge.msdk.mbjscommon.confirmation.b
                                        public final void a() {
                                            e.this.r.removeMessages(1);
                                            if (e.this.m.compareAndSet(false, true)) {
                                                a aVar = (a) e.this.e.getObject();
                                                aVar.a(e.b);
                                                e.this.e.setObject(aVar);
                                                e eVar = e.this;
                                                eVar.a((e) eVar.e, (WindVaneWebView) a2, (String) campaignEx, (CampaignEx) activity3, (Context) str2, (String) cVar);
                                                com.mbridge.msdk.foundation.same.report.e.a(activity3, campaignEx, a2, str2, 1, "", 2);
                                            }
                                        }

                                        @Override // com.mbridge.msdk.mbjscommon.confirmation.b
                                        public final void a(int i, String str) {
                                            e.this.r.removeMessages(1);
                                            if (e.this.m.compareAndSet(false, true)) {
                                                a aVar = (a) e.this.e.getObject();
                                                aVar.a(e.d);
                                                e.this.e.setObject(aVar);
                                                e.this.b(a2, campaignEx, activity3, str2, cVar);
                                                com.mbridge.msdk.foundation.same.report.e.a(activity3, campaignEx, a2, str2, 2, str, 2);
                                            }
                                        }
                                    };
                                    this.r.sendEmptyMessageDelayed(1, 500);
                                    if (z2) {
                                    }
                                }
                            }
                        }
                        z = false;
                        object = this.f.getObject();
                        if (object instanceof a) {
                        }
                        z2 = z;
                        WindVaneWebView windVaneWebView322 = this.e;
                        WindVaneWebView windVaneWebView422 = new WindVaneWebView(activity3);
                        this.e = windVaneWebView422;
                        windVaneWebView422.setBackgroundColor(0);
                        if (this.e.getBackground() != null) {
                        }
                        this.g = new b() {
                            /* class com.mbridge.msdk.mbjscommon.confirmation.e.AnonymousClass5 */

                            @Override // com.mbridge.msdk.mbjscommon.confirmation.b
                            public final void a() {
                                e.this.r.removeMessages(1);
                                if (e.this.m.compareAndSet(false, true)) {
                                    a aVar = (a) e.this.e.getObject();
                                    aVar.a(e.b);
                                    e.this.e.setObject(aVar);
                                    e eVar = e.this;
                                    eVar.a((e) eVar.e, (WindVaneWebView) a2, (String) campaignEx, (CampaignEx) activity3, (Context) str2, (String) cVar);
                                    com.mbridge.msdk.foundation.same.report.e.a(activity3, campaignEx, a2, str2, 1, "", 2);
                                }
                            }

                            @Override // com.mbridge.msdk.mbjscommon.confirmation.b
                            public final void a(int i, String str) {
                                e.this.r.removeMessages(1);
                                if (e.this.m.compareAndSet(false, true)) {
                                    a aVar = (a) e.this.e.getObject();
                                    aVar.a(e.d);
                                    e.this.e.setObject(aVar);
                                    e.this.b(a2, campaignEx, activity3, str2, cVar);
                                    com.mbridge.msdk.foundation.same.report.e.a(activity3, campaignEx, a2, str2, 2, str, 2);
                                }
                            }
                        };
                        this.r.sendEmptyMessageDelayed(1, 500);
                        if (z2) {
                        }
                    }
                } else if (cVar != null) {
                    cVar.a();
                }
            } catch (Throwable unused) {
                a(campaignEx, activity3, a2, str2, this.i);
            }
        }
    }

    public final void a(String str, final CampaignEx campaignEx, Context context, final String str2, c cVar) {
        final String a2 = a(str, str2);
        this.h = new b() {
            /* class com.mbridge.msdk.mbjscommon.confirmation.e.AnonymousClass3 */

            @Override // com.mbridge.msdk.mbjscommon.confirmation.b
            public final void a() {
                a aVar;
                e.this.r.removeMessages(2);
                if (!(e.this.f == null || (aVar = (a) e.this.f.getObject()) == null)) {
                    aVar.a(e.b);
                    e.this.f.setObject(aVar);
                }
                com.mbridge.msdk.foundation.same.report.e.a(com.mbridge.msdk.foundation.controller.a.f().j(), campaignEx, a2, str2, 1, "", 2);
            }

            @Override // com.mbridge.msdk.mbjscommon.confirmation.b
            public final void a(int i, String str) {
                a aVar;
                e.this.r.removeMessages(2);
                if (!(e.this.f == null || (aVar = (a) e.this.f.getObject()) == null)) {
                    aVar.a(e.d);
                    e.this.f.setObject(aVar);
                }
                if (i != 5) {
                    com.mbridge.msdk.foundation.same.report.e.a(com.mbridge.msdk.foundation.controller.a.f().j(), campaignEx, a2, str2, 2, str, 2);
                }
            }
        };
        if (TextUtils.isEmpty(str)) {
            this.h.a(2, "url is null");
        } else if (!str.contains("ldtm=1")) {
            this.h.a(5, "unwanted prerender");
        } else {
            WindVaneWebView windVaneWebView = this.f;
            if (windVaneWebView == null || windVaneWebView.isDestoryed()) {
                WindVaneWebView windVaneWebView2 = new WindVaneWebView(context);
                this.f = windVaneWebView2;
                windVaneWebView2.setBackgroundColor(0);
                if (this.f.getBackground() != null) {
                    this.f.getBackground().setAlpha(0);
                }
            }
            this.n.compareAndSet(true, false);
            this.r.sendEmptyMessageDelayed(2, 500);
            a(this.f, str, campaignEx, context, str2, cVar, this.h);
        }
    }

    /* JADX WARNING: Removed duplicated region for block: B:10:0x0044 A[Catch:{ Exception -> 0x00d1 }] */
    /* JADX WARNING: Removed duplicated region for block: B:11:0x0046 A[Catch:{ Exception -> 0x00d1 }] */
    /* JADX WARNING: Removed duplicated region for block: B:14:0x004d A[Catch:{ Exception -> 0x00d1 }] */
    /* JADX WARNING: Removed duplicated region for block: B:23:0x00c9  */
    private void a(WindVaneWebView windVaneWebView, String str, CampaignEx campaignEx, Context context, String str2, c cVar, final b bVar) {
        String str3;
        String htmlContentFromUrl;
        String str4;
        com.mbridge.msdk.mbjscommon.base.b bVar2 = new com.mbridge.msdk.mbjscommon.base.b();
        bVar2.a(new com.mbridge.msdk.mbjscommon.windvane.d() {
            /* class com.mbridge.msdk.mbjscommon.confirmation.e.AnonymousClass4 */

            @Override // com.mbridge.msdk.mbjscommon.windvane.d
            public final void a(WebView webView, String str, Bitmap bitmap) {
            }

            @Override // com.mbridge.msdk.mbjscommon.windvane.d
            public final void b(WebView webView, int i) {
            }

            @Override // com.mbridge.msdk.mbjscommon.windvane.d
            public final boolean b(WebView webView, String str) {
                return false;
            }

            @Override // com.mbridge.msdk.mbjscommon.windvane.d
            public final void c(WebView webView, int i) {
            }

            @Override // com.mbridge.msdk.mbjscommon.windvane.d
            public final void a(WebView webView, int i, String str, String str2) {
                b bVar = bVar;
                if (bVar != null) {
                    bVar.a(i, str);
                }
            }

            @Override // com.mbridge.msdk.mbjscommon.windvane.d
            public final void a(WebView webView, SslErrorHandler sslErrorHandler, SslError sslError) {
                b bVar = bVar;
                if (bVar != null) {
                    bVar.a(0, sslError.toString());
                }
            }

            @Override // com.mbridge.msdk.mbjscommon.windvane.d
            public final void a(WebView webView, String str) {
                h.a().a(webView);
            }

            @Override // com.mbridge.msdk.mbjscommon.windvane.d
            public final void a(WebView webView, int i) {
                b bVar = bVar;
                if (bVar != null) {
                    bVar.a();
                }
            }
        });
        a aVar = new a(campaignEx, str, str2);
        aVar.a(c);
        windVaneWebView.setObject(aVar);
        windVaneWebView.setWebViewClient(bVar2);
        try {
            if (!TextUtils.isEmpty(str)) {
                str3 = H5DownLoadManager.getInstance().getH5ResAddress(str);
                if (!TextUtils.isEmpty(str3)) {
                    htmlContentFromUrl = HTMLResourceManager.getInstance().getHtmlContentFromUrl(str);
                    if (TextUtils.isEmpty(htmlContentFromUrl)) {
                        str4 = htmlContentFromUrl;
                    } else {
                        str4 = "";
                    }
                    if (windVaneWebView.isDestoryed()) {
                        if (!TextUtils.isEmpty(str4)) {
                            String a2 = a(str);
                            w.a("SecondaryConfirmationManager", "load====== html url:" + str3);
                            w.a("SecondaryConfirmationManager", "load===== html..." + str4);
                            w.a("SecondaryConfirmationManager", "load=====lastUrl html..." + a2);
                            windVaneWebView.loadDataWithBaseURL(a2, str4, "text/html", "UTF-8", null);
                            return;
                        } else if (!TextUtils.isEmpty(str3)) {
                            String a3 = a(str3);
                            w.a("SecondaryConfirmationManager", "load====== url:" + a3);
                            windVaneWebView.loadUrl(a3);
                            return;
                        } else if (bVar != null) {
                            bVar.a(3, "localUrl is null");
                            return;
                        } else {
                            return;
                        }
                    } else if (bVar != null) {
                        bVar.a(3, "webview has destoryed");
                        return;
                    } else {
                        return;
                    }
                }
            }
            str3 = str;
            htmlContentFromUrl = HTMLResourceManager.getInstance().getHtmlContentFromUrl(str);
            if (TextUtils.isEmpty(htmlContentFromUrl)) {
            }
            if (windVaneWebView.isDestoryed()) {
            }
        } catch (Exception e2) {
            e2.printStackTrace();
            if (bVar != null) {
                bVar.a(3, e2.getMessage());
            }
        }
    }

    private String a(String str) {
        if (TextUtils.isEmpty(str)) {
            return str;
        }
        Uri.Builder buildUpon = Uri.parse(str).buildUpon();
        buildUpon.appendQueryParameter("dialogRenderMode", "default");
        return buildUpon.toString();
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private void a(CampaignEx campaignEx, Context context, String str, String str2, c cVar) {
        MBAlertDialog mBAlertDialog = this.k;
        if (mBAlertDialog != null) {
            mBAlertDialog.makeDownloadAlert(campaignEx.getAppName());
            if (context instanceof Activity) {
                Activity activity = (Activity) context;
                if (Build.VERSION.SDK_INT >= 17 && activity.isDestroyed()) {
                    com.mbridge.msdk.foundation.same.report.e.a(context, campaignEx, str, str2, 4, 2);
                    b();
                } else if (!activity.isFinishing()) {
                    this.k.show();
                    this.j = 1;
                    a(1);
                    cVar.a(this.j);
                    com.mbridge.msdk.foundation.same.report.e.a(context, campaignEx, str, str2, 1, 2);
                } else {
                    com.mbridge.msdk.foundation.same.report.e.a(context, campaignEx, str, str2, 4, 2);
                    b();
                }
            } else {
                b();
            }
        }
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private void a(WindVaneWebView windVaneWebView, String str, CampaignEx campaignEx, Context context, String str2, c cVar) {
        if (windVaneWebView == null || windVaneWebView.isDestoryed()) {
            b(str, campaignEx, context, str2, cVar);
            return;
        }
        a(windVaneWebView);
        if (windVaneWebView.getParent() != null) {
            ((ViewGroup) windVaneWebView.getParent()).removeView(windVaneWebView);
        }
        this.k.setContentView(windVaneWebView);
        if (context instanceof Activity) {
            Activity activity = (Activity) context;
            if (Build.VERSION.SDK_INT >= 17 && activity.isDestroyed()) {
                com.mbridge.msdk.foundation.same.report.e.a(context, campaignEx, str, str2, 4, 2);
                b();
            } else if (!activity.isFinishing()) {
                this.k.show();
                this.j = 2;
                a(2);
                cVar.a(this.j);
                com.mbridge.msdk.foundation.same.report.e.a(context, campaignEx, str, str2, 2, 2);
            } else {
                com.mbridge.msdk.foundation.same.report.e.a(context, campaignEx, str, str2, 4, 2);
                b();
            }
        } else {
            b();
        }
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    /* JADX WARNING: Removed duplicated region for block: B:16:0x008c  */
    /* JADX WARNING: Removed duplicated region for block: B:27:0x00ef  */
    private void b(final String str, final CampaignEx campaignEx, final Context context, final String str2, final c cVar) {
        CloseDialogBroadcastReceiver closeDialogBroadcastReceiver;
        final d[] dVarArr = {null};
        this.l = new DownloadMessageDialog(context, true, new CustomViewMessageWrap(campaignEx, CustomViewMessageWrap.getViewFilePath("mbridge_download_dialog_view")), new com.mbridge.msdk.widget.custom.a() {
            /* class com.mbridge.msdk.mbjscommon.confirmation.e.AnonymousClass6 */

            @Override // com.mbridge.msdk.widget.custom.a
            public final void a(DownloadMessageDialog downloadMessageDialog, CustomViewMessageWrap customViewMessageWrap) {
            }

            @Override // com.mbridge.msdk.widget.custom.a
            public final void b(DownloadMessageDialog downloadMessageDialog, CustomViewMessageWrap customViewMessageWrap) {
                com.mbridge.msdk.foundation.same.report.e.a(com.mbridge.msdk.foundation.controller.a.f().j(), campaignEx, str, str2, 1, "", 2);
            }

            @Override // com.mbridge.msdk.widget.custom.a
            public final void c(DownloadMessageDialog downloadMessageDialog, CustomViewMessageWrap customViewMessageWrap) {
                if (e.this.k != null) {
                    e.this.k.clear();
                    e.this.k.setOnDismissListener(null);
                    e.this.k = null;
                }
            }

            @Override // com.mbridge.msdk.widget.custom.a
            public final void a(DownloadMessageDialog downloadMessageDialog, CustomViewMessageWrap customViewMessageWrap, Exception exc) {
                e.this.a((e) campaignEx, (CampaignEx) context, (Context) str, str2, (String) cVar);
                com.mbridge.msdk.foundation.same.report.e.a(com.mbridge.msdk.foundation.controller.a.f().j(), campaignEx, str, str2, 2, exc.getMessage(), 2);
            }

            @Override // com.mbridge.msdk.widget.custom.a
            public final void a(DownloadMessageDialog downloadMessageDialog, CustomViewMessageWrap customViewMessageWrap, a.EnumC0242a aVar) {
                if (aVar == a.EnumC0242a.CLICK_EVENT_CLOSE) {
                    if (downloadMessageDialog != null) {
                        downloadMessageDialog.dismiss();
                    }
                    d[] dVarArr = dVarArr;
                    if (dVarArr[0] != null) {
                        dVarArr[0].b();
                    }
                } else if (aVar == a.EnumC0242a.CLICK_EVENT_DOWNLOAD) {
                    MBButton mBButton = (MBButton) customViewMessageWrap.getView("button_download");
                    d[] dVarArr2 = dVarArr;
                    if (dVarArr2[0] == null) {
                        dVarArr2[0] = new d(mBButton);
                        dVarArr[0].b(campaignEx.getLinkType());
                        dVarArr[0].a(campaignEx.getAkdlui());
                        dVarArr[0].b(str);
                    }
                    dVarArr[0].a();
                    c cVar = cVar;
                    if (cVar != null) {
                        cVar.a(e.this.j);
                        cVar.c();
                    }
                } else if (aVar == a.EnumC0242a.CLICK_EVENT_OPEN_PRIVACY) {
                    String applicationPrivacy = customViewMessageWrap.getApplicationPrivacy();
                    if (!TextUtils.isEmpty(applicationPrivacy)) {
                        c.b(com.mbridge.msdk.foundation.controller.a.f().j(), applicationPrivacy);
                    }
                }
            }
        });
        if (!(context == null || campaignEx == null || !aa.a(campaignEx))) {
            try {
                IntentFilter intentFilter = new IntentFilter();
                intentFilter.addAction("mb_dp_close_broadcast_receiver");
                CloseDialogBroadcastReceiver closeDialogBroadcastReceiver2 = new CloseDialogBroadcastReceiver(this.l);
                try {
                    context.registerReceiver(closeDialogBroadcastReceiver2, intentFilter);
                } catch (Exception unused) {
                }
                closeDialogBroadcastReceiver = closeDialogBroadcastReceiver2;
            } catch (Exception e2) {
                w.a("SecondaryConfirmationManager", e2.getMessage());
            }
            this.j = 1;
            this.l.setOnDismissListener(new a(closeDialogBroadcastReceiver, str + campaignEx.getApkDisplayInfo().toString(), cVar, this.e, this.f, this.j));
            if (!(context instanceof Activity)) {
                Activity activity = (Activity) context;
                if (Build.VERSION.SDK_INT >= 17 && activity.isDestroyed()) {
                    com.mbridge.msdk.foundation.same.report.e.a(com.mbridge.msdk.foundation.controller.a.f().j(), campaignEx, str, str2, 4, 2);
                    b();
                    return;
                } else if (!activity.isFinishing()) {
                    this.l.show();
                    cVar.a(this.j);
                    com.mbridge.msdk.foundation.same.report.e.a(com.mbridge.msdk.foundation.controller.a.f().j(), campaignEx, str, str2, 3, 2);
                    return;
                } else {
                    com.mbridge.msdk.foundation.same.report.e.a(com.mbridge.msdk.foundation.controller.a.f().j(), campaignEx, str, str2, 4, 2);
                    b();
                    return;
                }
            } else {
                b();
                return;
            }
        }
        closeDialogBroadcastReceiver = null;
        this.j = 1;
        this.l.setOnDismissListener(new a(closeDialogBroadcastReceiver, str + campaignEx.getApkDisplayInfo().toString(), cVar, this.e, this.f, this.j));
        if (!(context instanceof Activity)) {
        }
    }

    public final void a(Object obj, int i2) {
        b bVar;
        b bVar2;
        WindVaneWebView windVaneWebView = this.e;
        if (!(windVaneWebView == null || windVaneWebView.getObject() == null || !this.e.getObject().equals(a(obj)) || this.m.compareAndSet(true, true) || (bVar2 = this.g) == null)) {
            if (i2 == b) {
                bVar2.a();
            } else {
                bVar2.a(0, "webview render error and undefault");
            }
        }
        WindVaneWebView windVaneWebView2 = this.f;
        if (windVaneWebView2 != null && windVaneWebView2.getObject() != null && this.f.getObject().equals(a(obj)) && !this.n.compareAndSet(true, true) && (bVar = this.h) != null) {
            if (i2 == b) {
                bVar.a();
            } else {
                bVar.a(0, "webview render error and undefault");
            }
        }
    }

    public final void a(Object obj, String str) {
        w.a("SecondaryConfirmationManager", "closeDialog");
        MBAlertDialog mBAlertDialog = this.k;
        if (mBAlertDialog != null && mBAlertDialog.isShowing()) {
            this.k.dismiss();
            this.k.clear();
        }
    }

    private void a(WindVaneWebView windVaneWebView) {
        if (windVaneWebView != null) {
            h.a().a((WebView) windVaneWebView, "webviewshow", "");
        }
    }

    public final void b(Object obj, String str) {
        MBAlertDialog mBAlertDialog = this.k;
        if (mBAlertDialog != null && mBAlertDialog.isShowing() && this.k.getListener() != null) {
            this.k.getListener().c();
        }
    }

    /* access modifiers changed from: private */
    /* compiled from: SecondaryConfirmationManager */
    public static final class a implements DialogInterface.OnDismissListener {
        private BroadcastReceiver a;
        private final String b;
        private final c c;
        private final WindVaneWebView d;
        private final WindVaneWebView e;
        private int f;

        public a(BroadcastReceiver broadcastReceiver, String str, c cVar, WindVaneWebView windVaneWebView, WindVaneWebView windVaneWebView2, int i) {
            this.a = broadcastReceiver;
            this.b = str;
            this.c = cVar;
            this.d = windVaneWebView;
            this.e = windVaneWebView2;
            this.f = i;
        }

        public a(String str, c cVar, WindVaneWebView windVaneWebView, WindVaneWebView windVaneWebView2, int i) {
            this.b = str;
            this.c = cVar;
            this.d = windVaneWebView;
            this.e = windVaneWebView2;
            this.f = i;
        }

        public final void a(int i) {
            this.f = i;
        }

        public final void onDismiss(DialogInterface dialogInterface) {
            if (this.a != null) {
                try {
                    com.mbridge.msdk.foundation.controller.a.f().j().unregisterReceiver(this.a);
                } catch (Exception e2) {
                    w.a("SecondaryConfirmationManager", e2.getMessage());
                }
            }
            String str = this.b;
            c cVar = this.c;
            WindVaneWebView windVaneWebView = this.d;
            if (windVaneWebView != null && !windVaneWebView.isDestoryed() && this.d.getObject() != null && this.d.getObject().equals(e.a().a((e) str))) {
                e.a(e.a(), this.d);
            }
            WindVaneWebView windVaneWebView2 = this.e;
            if (!(windVaneWebView2 == null || windVaneWebView2.getObject() == null || !this.e.getObject().equals(e.a().a((e) str)))) {
                e.a(e.a(), this.e);
            }
            if (cVar != null) {
                cVar.a(this.f);
                cVar.b();
            }
            e.i(e.a());
        }
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private a a(Object obj) {
        if (obj instanceof com.mbridge.msdk.mbjscommon.windvane.a) {
            Object object = ((com.mbridge.msdk.mbjscommon.windvane.a) obj).a.getObject();
            if (object instanceof a) {
                return (a) object;
            }
        }
        return null;
    }

    private void a(int i2) {
        a aVar = this.q;
        if (aVar != null) {
            aVar.a(i2);
        }
    }

    public final void c() {
        try {
            DownloadMessageDialog downloadMessageDialog = this.l;
            if (downloadMessageDialog != null) {
                downloadMessageDialog.dismiss();
            }
            MBAlertDialog mBAlertDialog = this.k;
            if (mBAlertDialog != null) {
                mBAlertDialog.dismiss();
            }
        } catch (Throwable th) {
            w.d("SecondaryConfirmationManager", th.getMessage());
        }
    }

    public final MBAlertDialog d() {
        return this.k;
    }

    static /* synthetic */ void a(e eVar, WindVaneWebView windVaneWebView) {
        MBAlertDialog mBAlertDialog = eVar.k;
        if (mBAlertDialog != null) {
            mBAlertDialog.clear();
        }
        if (windVaneWebView != null) {
            h.a().a((WebView) windVaneWebView, "close", "");
        }
    }

    static /* synthetic */ void i(e eVar) {
        if (eVar.i != null) {
            eVar.i = null;
        }
        if (eVar.g != null) {
            eVar.g = null;
        }
        WindVaneWebView windVaneWebView = eVar.e;
        if (windVaneWebView != null) {
            windVaneWebView.release();
        }
        WindVaneWebView windVaneWebView2 = eVar.f;
        if (windVaneWebView2 != null) {
            windVaneWebView2.release();
        }
        MBAlertDialog mBAlertDialog = eVar.k;
        if (mBAlertDialog != null && mBAlertDialog.isShowing()) {
            eVar.k.dismiss();
        }
        DownloadMessageDialog downloadMessageDialog = eVar.l;
        if (downloadMessageDialog != null && downloadMessageDialog.isShowing()) {
            eVar.l.dismiss();
        }
        eVar.b();
    }
}