c.java 源代码


package com.mbridge.msdk.reward.adapter;

import android.content.Context;
import android.graphics.Bitmap;
import android.net.http.SslError;
import android.os.Bundle;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.Looper;
import android.os.Message;
import android.text.TextUtils;
import android.util.Base64;
import android.webkit.SslErrorHandler;
import android.webkit.WebView;
import android.widget.FrameLayout;
import com.anythink.expressad.foundation.d.p;
import com.mbridge.msdk.MBridgeConstans;
import com.mbridge.msdk.foundation.entity.CampaignEx;
import com.mbridge.msdk.foundation.tools.q;
import com.mbridge.msdk.foundation.tools.u;
import com.mbridge.msdk.mbsignalcommon.windvane.WindVaneWebView;
import com.mbridge.msdk.playercommon.exoplayer2.DefaultRenderersFactory;
import com.mbridge.msdk.video.bt.module.MBridgeBTLayout;
import com.mbridge.msdk.video.bt.module.MBridgeBTRootLayout;
import com.mbridge.msdk.videocommon.a;
import com.mbridge.msdk.videocommon.download.g;
import com.x8zs.plugin.apache.http.HttpStatus;
import java.util.AbstractMap;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;
import org.json.JSONObject;

public final class c {

    private static Map<String, a> f18084c;

    private final h f18085a;

    private ConcurrentHashMap<String, List<CampaignEx>> f18086b;

    private boolean f18087d;

    private volatile List<WindVaneWebView> f18088e;

    public final class AnonymousClass1 implements Runnable {

        final List f18089a;

        final Context f18090b;

        final String f18091c;

        final int f18092d;

        final String f18093e;

        final String f18094f;

        final i f18095g;

        AnonymousClass1(List list, Context context, String str, int i6, String str2, String str3, i iVar) {
            r2 = list;
            r3 = context;
            r4 = str;
            r5 = i6;
            r6 = str2;
            r7 = str3;
            r8 = iVar;
        }

        @Override
        public final void run() {
            Iterator it;
            CharSequence charSequence;
            boolean isDynamicView;
            String iconUrl;
            String imageUrl;
            CampaignEx.c cVar;
            List<CampaignEx.c.a> f6;
            List<String> list;
            CharSequence charSequence2;
            List list2 = r2;
            if (list2 != null && list2.size() > 0) {
                try {
                    com.mbridge.msdk.videocommon.download.i.a().a(r2);
                    com.mbridge.msdk.videocommon.download.c.getInstance().createUnitCache(r3, r4, r2, r5, new f(c.this.f18085a, r6, r4, r7));
                    com.mbridge.msdk.videocommon.download.c.getInstance().load(r4);
                } catch (Exception e6) {
                    if (MBridgeConstans.DEBUG) {
                        q.d("RewardCampaignsResourceManager", e6.getLocalizedMessage());
                    }
                }
                Iterator it2 = r2.iterator();
                while (it2.hasNext()) {
                    CampaignEx campaignEx = (CampaignEx) it2.next();
                    if (campaignEx != null) {
                        CampaignEx.c rewardTemplateMode = campaignEx.getRewardTemplateMode();
                        if (rewardTemplateMode != null && !campaignEx.isDynamicView()) {
                            String e7 = rewardTemplateMode.e();
                            if (!TextUtils.isEmpty(e7) && !e7.contains(CampaignEx.KEY_IS_CMPT_ENTRY)) {
                                if (e7.contains(".zip")) {
                                    try {
                                        it = it2;
                                        charSequence2 = ".zip";
                                    } catch (Exception e8) {
                                        e = e8;
                                        it = it2;
                                        charSequence2 = ".zip";
                                    }
                                    try {
                                        com.mbridge.msdk.videocommon.download.g.a().b(e7, new g(r3, r6, r4, r7, campaignEx, 859, c.this.f18085a, r8, r2));
                                    } catch (Exception e9) {
                                        e = e9;
                                        if (MBridgeConstans.DEBUG) {
                                            q.d("RewardCampaignsResourceManager", e.getLocalizedMessage());
                                        }
                                        charSequence = charSequence2;
                                        String str = campaignEx.getendcard_url();
                                        isDynamicView = campaignEx.isDynamicView();
                                        boolean g6 = u.g(str);
                                        if (isDynamicView) {
                                        }
                                        if (!TextUtils.isEmpty(campaignEx.getEndScreenUrl())) {
                                        }
                                        iconUrl = campaignEx.getIconUrl();
                                        if (!TextUtils.isEmpty(iconUrl)) {
                                        }
                                        imageUrl = campaignEx.getImageUrl();
                                        if (!TextUtils.isEmpty(imageUrl)) {
                                        }
                                        if (rewardTemplateMode != null) {
                                        }
                                        it2 = it;
                                    }
                                    charSequence = charSequence2;
                                } else {
                                    it = it2;
                                    try {
                                        charSequence = ".zip";
                                        try {
                                            com.mbridge.msdk.videocommon.download.g.a().b(e7, new d(859, r6, r4, r7, campaignEx, r8, c.this.f18085a, r2));
                                        } catch (Exception e10) {
                                            e = e10;
                                            if (MBridgeConstans.DEBUG) {
                                                q.d("RewardCampaignsResourceManager", e.getLocalizedMessage());
                                            }
                                            String str2 = campaignEx.getendcard_url();
                                            isDynamicView = campaignEx.isDynamicView();
                                            boolean g62 = u.g(str2);
                                            if (isDynamicView) {
                                            }
                                            if (!TextUtils.isEmpty(campaignEx.getEndScreenUrl())) {
                                            }
                                            iconUrl = campaignEx.getIconUrl();
                                            if (!TextUtils.isEmpty(iconUrl)) {
                                            }
                                            imageUrl = campaignEx.getImageUrl();
                                            if (!TextUtils.isEmpty(imageUrl)) {
                                            }
                                            if (rewardTemplateMode != null) {
                                            }
                                            it2 = it;
                                        }
                                    } catch (Exception e11) {
                                        e = e11;
                                        charSequence = ".zip";
                                    }
                                }
                                String str22 = campaignEx.getendcard_url();
                                isDynamicView = campaignEx.isDynamicView();
                                boolean g622 = u.g(str22);
                                if (isDynamicView) {
                                    c.a(c.this, r3, r6, r4, r7, campaignEx, str22, r8, r2);
                                } else if (g622) {
                                    c.a(c.this, r3, r6, r4, r7, campaignEx, str22, r8, r2);
                                }
                                if (!TextUtils.isEmpty(campaignEx.getEndScreenUrl()) && !campaignEx.isDynamicView()) {
                                    com.mbridge.msdk.videocommon.download.g.a().a(campaignEx.getEndScreenUrl(), null);
                                }
                                iconUrl = campaignEx.getIconUrl();
                                if (!TextUtils.isEmpty(iconUrl)) {
                                    try {
                                        com.mbridge.msdk.foundation.same.c.b.a(r3).a(iconUrl, new e(c.this.f18085a, 0, r6, r4, r7, campaignEx));
                                    } catch (Exception e12) {
                                        if (MBridgeConstans.DEBUG) {
                                            q.d("RewardCampaignsResourceManager", e12.getLocalizedMessage());
                                        }
                                    }
                                }
                                imageUrl = campaignEx.getImageUrl();
                                if (!TextUtils.isEmpty(imageUrl)) {
                                    try {
                                        com.mbridge.msdk.foundation.same.c.b.a(r3).a(imageUrl, new e(c.this.f18085a, 0, r6, r4, r7, campaignEx));
                                    } catch (Exception e13) {
                                        if (MBridgeConstans.DEBUG) {
                                            q.d("RewardCampaignsResourceManager", e13.getLocalizedMessage());
                                        }
                                    }
                                }
                                if (rewardTemplateMode != null) {
                                    String d6 = rewardTemplateMode.d();
                                    if (!TextUtils.isEmpty(d6) && !campaignEx.isDynamicView()) {
                                        if (d6.contains(charSequence)) {
                                            try {
                                                cVar = rewardTemplateMode;
                                            } catch (Exception e14) {
                                                e = e14;
                                                cVar = rewardTemplateMode;
                                            }
                                            try {
                                                com.mbridge.msdk.videocommon.download.g.a().b(d6, new g(r3, r6, r4, r7, campaignEx, 313, c.this.f18085a, r8, r2));
                                            } catch (Exception e15) {
                                                e = e15;
                                                if (MBridgeConstans.DEBUG) {
                                                    q.d("RewardCampaignsResourceManager", e.getLocalizedMessage());
                                                }
                                                f6 = cVar.f();
                                                if (f6 != null) {
                                                    while (r3.hasNext()) {
                                                    }
                                                }
                                                it2 = it;
                                            }
                                        } else {
                                            cVar = rewardTemplateMode;
                                            try {
                                                com.mbridge.msdk.videocommon.download.g.a().b(d6, new d(313, r6, r4, r7, campaignEx, r8, c.this.f18085a, r2));
                                            } catch (Exception e16) {
                                                if (MBridgeConstans.DEBUG) {
                                                    q.d("RewardCampaignsResourceManager", e16.getLocalizedMessage());
                                                }
                                            }
                                        }
                                    } else {
                                        cVar = rewardTemplateMode;
                                    }
                                    f6 = cVar.f();
                                    if (f6 != null && f6.size() > 0) {
                                        for (CampaignEx.c.a aVar : f6) {
                                            if (aVar != null && (list = aVar.f16716b) != null && list.size() > 0) {
                                                for (String str3 : aVar.f16716b) {
                                                    if (!TextUtils.isEmpty(str3)) {
                                                        try {
                                                            com.mbridge.msdk.foundation.same.c.b.a(r3).a(str3, new e(c.this.f18085a, 1, r6, r4, r7, campaignEx));
                                                        } catch (Exception e17) {
                                                            if (MBridgeConstans.DEBUG) {
                                                                q.d("RewardCampaignsResourceManager", e17.getLocalizedMessage());
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                                it2 = it;
                            }
                        }
                        it = it2;
                        charSequence = ".zip";
                        String str222 = campaignEx.getendcard_url();
                        isDynamicView = campaignEx.isDynamicView();
                        boolean g6222 = u.g(str222);
                        if (isDynamicView) {
                        }
                        if (!TextUtils.isEmpty(campaignEx.getEndScreenUrl())) {
                            com.mbridge.msdk.videocommon.download.g.a().a(campaignEx.getEndScreenUrl(), null);
                        }
                        iconUrl = campaignEx.getIconUrl();
                        if (!TextUtils.isEmpty(iconUrl)) {
                        }
                        imageUrl = campaignEx.getImageUrl();
                        if (!TextUtils.isEmpty(imageUrl)) {
                        }
                        if (rewardTemplateMode != null) {
                        }
                        it2 = it;
                    }
                }
            }
        }
    }

    final class AnonymousClass3 implements Runnable {

        final boolean f18104a;

        final WindVaneWebView f18105b;

        final CampaignEx f18106c;

        final List f18107d;

        final String f18108e;

        final com.mbridge.msdk.videocommon.d.c f18109f;

        final String f18110g;

        AnonymousClass3(boolean z6, WindVaneWebView windVaneWebView, CampaignEx campaignEx, List list, String str, com.mbridge.msdk.videocommon.d.c cVar, String str2) {
            r2 = z6;
            r3 = windVaneWebView;
            r4 = campaignEx;
            r5 = list;
            r6 = str;
            r7 = cVar;
            r8 = str2;
        }

        @Override
        public final void run() {
            c.a(c.this, r2, r3, r4.getRewardTemplateMode().e(), 0, r4, r5, com.mbridge.msdk.videocommon.download.g.a().b(r4.getRewardTemplateMode().e()), r6, r7, r8, c.this.f18087d);
        }
    }

    public final class AnonymousClass4 implements Runnable {
        AnonymousClass4() {
        }

        @Override
        public final void run() {
            c.this.d();
        }
    }

    public static class a {

        boolean f18113a;

        boolean f18114b;

        int f18115c;

        int f18116d;

        String f18117e;

        String f18118f;

        int f18119g;

        List<CampaignEx> f18120h;

        CopyOnWriteArrayList<CampaignEx> f18121i;

        public a(boolean z6, boolean z7, int i6, int i7, String str, String str2, int i8, List<CampaignEx> list) {
            this.f18113a = z6;
            this.f18114b = z7;
            this.f18115c = i6;
            this.f18116d = i7;
            this.f18117e = str;
            this.f18118f = str2;
            this.f18119g = i8;
            this.f18120h = list;
            this.f18121i = new CopyOnWriteArrayList<>(list);
        }
    }

    public interface InterfaceC0228c {
        void a(String str, String str2, String str3, List<CampaignEx> list);

        void a(String str, String str2, String str3, List<CampaignEx> list, String str4);
    }

    public static final class d implements g.b {

        private int f18143b;

        private final String f18144c;

        private final String f18145d;

        private final String f18146e;

        private CampaignEx f18147f;

        private i f18148g;

        private Handler f18149h;

        private List<CampaignEx> f18150i;

        private boolean f18142a = false;

        private final long f18151j = System.currentTimeMillis();

        public d(int i6, String str, String str2, String str3, CampaignEx campaignEx, i iVar, Handler handler, List<CampaignEx> list) {
            this.f18143b = i6;
            this.f18144c = str;
            this.f18145d = str2;
            this.f18146e = str3;
            this.f18147f = campaignEx;
            this.f18148g = iVar;
            this.f18149h = handler;
            this.f18150i = list;
        }

        public final void a(boolean z6) {
            this.f18142a = z6;
        }

        @Override
        public final void a(String str) {
            com.mbridge.msdk.videocommon.download.i.a().b(str, true);
            int i6 = this.f18143b;
            if (i6 == 313) {
                Message obtain = Message.obtain();
                obtain.what = 101;
                Bundle bundle = new Bundle();
                bundle.putString("unit_id", this.f18145d);
                bundle.putString(MBridgeConstans.PLACEMENT_ID, this.f18144c);
                bundle.putString("request_id", this.f18146e);
                bundle.putString("url", str);
                obtain.setData(bundle);
                this.f18149h.sendMessage(obtain);
                return;
            }
            if (i6 != 497) {
                if (i6 != 859) {
                    return;
                }
                Message obtain2 = Message.obtain();
                obtain2.what = 105;
                Bundle bundle2 = new Bundle();
                bundle2.putString("unit_id", this.f18145d);
                bundle2.putString(MBridgeConstans.PLACEMENT_ID, this.f18144c);
                bundle2.putString("request_id", this.f18146e);
                obtain2.setData(bundle2);
                this.f18149h.sendMessage(obtain2);
                i iVar = this.f18148g;
                if (iVar != null) {
                    iVar.a(this.f18144c, this.f18145d, this.f18146e, str);
                    return;
                }
                return;
            }
            Message obtain3 = Message.obtain();
            obtain3.what = 101;
            Bundle bundle3 = new Bundle();
            bundle3.putString("unit_id", this.f18145d);
            bundle3.putString(MBridgeConstans.PLACEMENT_ID, this.f18144c);
            bundle3.putString("request_id", this.f18146e);
            bundle3.putString("url", str);
            obtain3.setData(bundle3);
            this.f18149h.sendMessage(obtain3);
            if (this.f18142a) {
                try {
                    com.mbridge.msdk.foundation.entity.m mVar = new com.mbridge.msdk.foundation.entity.m(p.f3630k, 20, (System.currentTimeMillis() - this.f18151j) + "", str, this.f18147f.getId(), this.f18145d, "", "2");
                    mVar.k(this.f18147f.getRequestId());
                    mVar.l(this.f18147f.getRequestIdNotice());
                    mVar.n(this.f18147f.getId());
                    mVar.b(this.f18147f.getAdSpaceT());
                    if (this.f18147f.getAdType() == 287) {
                        mVar.h("3");
                    } else if (this.f18147f.getAdType() == 94) {
                        mVar.h("1");
                    }
                    com.mbridge.msdk.foundation.same.report.b.a(mVar, this.f18145d);
                } catch (Exception e6) {
                    if (MBridgeConstans.DEBUG) {
                        q.d("RewardCampaignsResourceManager", e6.getLocalizedMessage());
                    }
                }
            }
        }

        @Override
        public final void a(String str, String str2) {
            com.mbridge.msdk.videocommon.download.i.a().b(str, false);
            int i6 = this.f18143b;
            if (i6 == 313) {
                Message obtain = Message.obtain();
                obtain.what = 201;
                Bundle bundle = new Bundle();
                bundle.putString("unit_id", this.f18145d);
                bundle.putString(MBridgeConstans.PLACEMENT_ID, this.f18144c);
                bundle.putString("request_id", this.f18146e);
                bundle.putString("url", str);
                bundle.putString("message", str2);
                obtain.setData(bundle);
                this.f18149h.sendMessage(obtain);
                return;
            }
            if (i6 != 497) {
                if (i6 != 859) {
                    return;
                }
                Message obtain2 = Message.obtain();
                obtain2.what = HttpStatus.SC_RESET_CONTENT;
                Bundle bundle2 = new Bundle();
                bundle2.putString("unit_id", this.f18145d);
                bundle2.putString(MBridgeConstans.PLACEMENT_ID, this.f18144c);
                bundle2.putString("request_id", this.f18146e);
                bundle2.putString("message", str2);
                obtain2.setData(bundle2);
                this.f18149h.sendMessage(obtain2);
                i iVar = this.f18148g;
                if (iVar != null) {
                    iVar.a(this.f18144c, this.f18145d, this.f18146e, str, str2);
                    return;
                }
                return;
            }
            Message obtain3 = Message.obtain();
            obtain3.what = 201;
            Bundle bundle3 = new Bundle();
            bundle3.putString("unit_id", this.f18145d);
            bundle3.putString(MBridgeConstans.PLACEMENT_ID, this.f18144c);
            bundle3.putString("request_id", this.f18146e);
            bundle3.putString("url", str);
            bundle3.putString("message", str2);
            obtain3.setData(bundle3);
            this.f18149h.sendMessage(obtain3);
            if (this.f18142a) {
                try {
                    com.mbridge.msdk.foundation.entity.m mVar = new com.mbridge.msdk.foundation.entity.m(p.f3630k, 21, (System.currentTimeMillis() - this.f18151j) + "", str, this.f18147f.getId(), this.f18145d, "url download failed", "2");
                    mVar.k(this.f18147f.getRequestId());
                    mVar.l(this.f18147f.getRequestIdNotice());
                    mVar.n(this.f18147f.getId());
                    mVar.b(this.f18147f.getAdSpaceT());
                    if (this.f18147f.getAdType() == 287) {
                        mVar.h("3");
                    } else if (this.f18147f.getAdType() == 94) {
                        mVar.h("1");
                    }
                    com.mbridge.msdk.foundation.same.report.b.a(mVar, this.f18145d);
                } catch (Exception e6) {
                    if (MBridgeConstans.DEBUG) {
                        q.d("RewardCampaignsResourceManager", e6.getLocalizedMessage());
                    }
                }
            }
        }
    }

    private static final class e implements com.mbridge.msdk.foundation.same.c.c {

        private Handler f18152a;

        private int f18153b;

        private String f18154c;

        private String f18155d;

        private String f18156e;

        private CampaignEx f18157f;

        public e(Handler handler, int i6, String str, String str2, String str3, CampaignEx campaignEx) {
            this.f18152a = handler;
            this.f18153b = i6;
            this.f18155d = str;
            this.f18154c = str2;
            this.f18156e = str3;
            this.f18157f = campaignEx;
        }

        @Override
        public final void onFailedLoad(String str, String str2) {
            int i6;
            Message obtain = Message.obtain();
            if (this.f18153b == 0) {
                i6 = HttpStatus.SC_ACCEPTED;
            } else {
                i6 = 204;
            }
            obtain.what = i6;
            Bundle bundle = new Bundle();
            bundle.putString("unit_id", this.f18154c);
            bundle.putString(MBridgeConstans.PLACEMENT_ID, this.f18155d);
            bundle.putString("request_id", this.f18156e);
            obtain.setData(bundle);
            this.f18152a.sendMessage(obtain);
            if (this.f18157f != null) {
                try {
                    com.mbridge.msdk.foundation.db.p a7 = com.mbridge.msdk.foundation.db.p.a(com.mbridge.msdk.foundation.db.g.a(com.mbridge.msdk.foundation.controller.a.e().g()));
                    q.a("RewardCampaignsResourceManager", "campaign is null");
                    com.mbridge.msdk.foundation.entity.m mVar = new com.mbridge.msdk.foundation.entity.m();
                    mVar.o(p.f3631l);
                    mVar.c(com.mbridge.msdk.foundation.tools.m.n(com.mbridge.msdk.foundation.controller.a.e().g()));
                    mVar.n(this.f18157f.getId());
                    mVar.d(this.f18157f.getImageUrl());
                    mVar.k(this.f18157f.getRequestId());
                    mVar.l(this.f18157f.getRequestIdNotice());
                    mVar.m(this.f18154c);
                    mVar.p(str);
                    a7.a(mVar);
                } catch (Exception e6) {
                    if (MBridgeConstans.DEBUG) {
                        q.d("RewardCampaignsResourceManager", e6.getLocalizedMessage());
                    }
                }
            }
        }

        @Override
        public final void onSuccessLoad(Bitmap bitmap, String str) {
            int i6;
            com.mbridge.msdk.videocommon.download.i.a().c(str, true);
            Message obtain = Message.obtain();
            if (this.f18153b == 0) {
                i6 = 102;
            } else {
                i6 = 104;
            }
            obtain.what = i6;
            Bundle bundle = new Bundle();
            bundle.putString("unit_id", this.f18154c);
            bundle.putString(MBridgeConstans.PLACEMENT_ID, this.f18155d);
            bundle.putString("request_id", this.f18156e);
            obtain.setData(bundle);
            this.f18152a.sendMessage(obtain);
        }
    }

    public static final class g implements g.d {

        private Context f18163b;

        private String f18164c;

        private String f18165d;

        private String f18166e;

        private CampaignEx f18167f;

        private int f18168g;

        private Handler f18169h;

        private i f18170i;

        private List<CampaignEx> f18171j;

        private boolean f18162a = false;

        private long f18172k = System.currentTimeMillis();

        public g(Context context, String str, String str2, String str3, CampaignEx campaignEx, int i6, Handler handler, i iVar, List<CampaignEx> list) {
            this.f18163b = context;
            this.f18165d = str;
            this.f18164c = str2;
            this.f18166e = str3;
            this.f18167f = campaignEx;
            this.f18168g = i6;
            this.f18169h = handler;
            this.f18170i = iVar;
            this.f18171j = list;
        }

        public final void a(boolean z6) {
            this.f18162a = z6;
        }

        @Override
        public final void a(String str) {
            com.mbridge.msdk.videocommon.download.i.a().b(str, true);
            long currentTimeMillis = System.currentTimeMillis() - this.f18172k;
            int i6 = this.f18168g;
            if (i6 == 313) {
                Message obtain = Message.obtain();
                obtain.what = 101;
                Bundle bundle = new Bundle();
                bundle.putString("unit_id", this.f18164c);
                bundle.putString(MBridgeConstans.PLACEMENT_ID, this.f18165d);
                bundle.putString("request_id", this.f18166e);
                bundle.putString("url", str);
                obtain.setData(bundle);
                this.f18169h.sendMessage(obtain);
                return;
            }
            if (i6 == 497) {
                Message obtain2 = Message.obtain();
                obtain2.what = 101;
                Bundle bundle2 = new Bundle();
                bundle2.putString("unit_id", this.f18164c);
                bundle2.putString(MBridgeConstans.PLACEMENT_ID, this.f18165d);
                bundle2.putString("request_id", this.f18166e);
                bundle2.putString("url", str);
                obtain2.setData(bundle2);
                this.f18169h.sendMessage(obtain2);
                if (this.f18162a) {
                    try {
                        com.mbridge.msdk.foundation.entity.m mVar = new com.mbridge.msdk.foundation.entity.m(p.f3630k, 14, currentTimeMillis + "", str, this.f18167f.getId(), this.f18164c, "", "1");
                        mVar.k(this.f18167f.getRequestId());
                        mVar.l(this.f18167f.getRequestIdNotice());
                        mVar.n(this.f18167f.getId());
                        mVar.b(this.f18167f.getAdSpaceT());
                        if (this.f18167f.getAdType() == 287) {
                            mVar.h("3");
                        } else if (this.f18167f.getAdType() == 94) {
                            mVar.h("1");
                        }
                        com.mbridge.msdk.foundation.same.report.b.a(mVar, this.f18164c);
                        return;
                    } catch (Exception e6) {
                        if (MBridgeConstans.DEBUG) {
                            q.d("RewardCampaignsResourceManager", e6.getLocalizedMessage());
                            return;
                        }
                        return;
                    }
                }
                return;
            }
            if (i6 != 859) {
                return;
            }
            Message obtain3 = Message.obtain();
            obtain3.what = 103;
            Bundle bundle3 = new Bundle();
            bundle3.putString("unit_id", this.f18164c);
            bundle3.putString(MBridgeConstans.PLACEMENT_ID, this.f18165d);
            bundle3.putString("request_id", this.f18166e);
            obtain3.setData(bundle3);
            this.f18169h.sendMessage(obtain3);
            i iVar = this.f18170i;
            if (iVar != null) {
                iVar.a(this.f18165d, this.f18164c, this.f18166e, str);
            }
            try {
                com.mbridge.msdk.foundation.entity.m mVar2 = new com.mbridge.msdk.foundation.entity.m();
                mVar2.o(p.f3632m);
                Context context = this.f18163b;
                if (context != null) {
                    mVar2.c(com.mbridge.msdk.foundation.tools.m.n(context.getApplicationContext()));
                }
                mVar2.d(1);
                CampaignEx campaignEx = this.f18167f;
                if (campaignEx != null) {
                    mVar2.n(campaignEx.getId());
                    mVar2.k(this.f18167f.getRequestId());
                    mVar2.l(this.f18167f.getRequestIdNotice());
                }
                mVar2.i(str);
                mVar2.p("");
                mVar2.m(this.f18164c);
                com.mbridge.msdk.foundation.db.p.a(com.mbridge.msdk.foundation.db.g.a(com.mbridge.msdk.foundation.controller.a.e().g())).a(mVar2);
            } catch (Exception e7) {
                if (MBridgeConstans.DEBUG) {
                    q.d("RewardCampaignsResourceManager", e7.getLocalizedMessage());
                }
            }
        }

        @Override
        public final void a(String str, String str2) {
            com.mbridge.msdk.videocommon.download.i.a().b(str2, false);
            long currentTimeMillis = System.currentTimeMillis() - this.f18172k;
            int i6 = this.f18168g;
            if (i6 == 313) {
                Message obtain = Message.obtain();
                obtain.what = 101;
                Bundle bundle = new Bundle();
                bundle.putString("unit_id", this.f18164c);
                bundle.putString(MBridgeConstans.PLACEMENT_ID, this.f18165d);
                bundle.putString("request_id", this.f18166e);
                bundle.putString("url", str2);
                bundle.putString("message", str);
                obtain.setData(bundle);
                this.f18169h.sendMessage(obtain);
                return;
            }
            if (i6 == 497) {
                Message obtain2 = Message.obtain();
                obtain2.what = 201;
                Bundle bundle2 = new Bundle();
                bundle2.putString("unit_id", this.f18164c);
                bundle2.putString(MBridgeConstans.PLACEMENT_ID, this.f18165d);
                bundle2.putString("request_id", this.f18166e);
                bundle2.putString("url", str2);
                bundle2.putString("message", str);
                obtain2.setData(bundle2);
                this.f18169h.sendMessage(obtain2);
                if (this.f18162a) {
                    try {
                        com.mbridge.msdk.foundation.entity.m mVar = new com.mbridge.msdk.foundation.entity.m(p.f3630k, 3, currentTimeMillis + "", str2, this.f18167f.getId(), this.f18164c, "zip download failed", "1");
                        mVar.k(this.f18167f.getRequestId());
                        mVar.l(this.f18167f.getRequestIdNotice());
                        mVar.n(this.f18167f.getId());
                        mVar.b(this.f18167f.getAdSpaceT());
                        if (this.f18167f.getAdType() == 287) {
                            mVar.h("3");
                        } else if (this.f18167f.getAdType() == 94) {
                            mVar.h("1");
                        }
                        com.mbridge.msdk.foundation.same.report.b.a(mVar, this.f18164c);
                        return;
                    } catch (Exception e6) {
                        if (MBridgeConstans.DEBUG) {
                            q.d("RewardCampaignsResourceManager", e6.getLocalizedMessage());
                            return;
                        }
                        return;
                    }
                }
                return;
            }
            if (i6 != 859) {
                return;
            }
            Message obtain3 = Message.obtain();
            obtain3.what = HttpStatus.SC_NON_AUTHORITATIVE_INFORMATION;
            Bundle bundle3 = new Bundle();
            bundle3.putString("unit_id", this.f18164c);
            bundle3.putString(MBridgeConstans.PLACEMENT_ID, this.f18165d);
            bundle3.putString("request_id", this.f18166e);
            bundle3.putString("url", str2);
            bundle3.putString("message", str);
            obtain3.setData(bundle3);
            this.f18169h.sendMessage(obtain3);
            i iVar = this.f18170i;
            if (iVar != null) {
                iVar.a(this.f18165d, this.f18164c, this.f18166e, str2, str);
            }
            try {
                com.mbridge.msdk.foundation.entity.m mVar2 = new com.mbridge.msdk.foundation.entity.m();
                mVar2.o(p.f3632m);
                Context context = this.f18163b;
                if (context != null) {
                    mVar2.c(com.mbridge.msdk.foundation.tools.m.n(context.getApplicationContext()));
                }
                mVar2.d(3);
                CampaignEx campaignEx = this.f18167f;
                if (campaignEx != null) {
                    mVar2.n(campaignEx.getId());
                    mVar2.k(this.f18167f.getRequestId());
                    mVar2.l(this.f18167f.getRequestIdNotice());
                }
                mVar2.i(str2);
                mVar2.p(str);
                mVar2.m(this.f18164c);
                com.mbridge.msdk.foundation.db.p.a(com.mbridge.msdk.foundation.db.g.a(com.mbridge.msdk.foundation.controller.a.e().g())).a(mVar2);
            } catch (Exception e7) {
                if (MBridgeConstans.DEBUG) {
                    q.d("RewardCampaignsResourceManager", e7.getLocalizedMessage());
                }
            }
        }
    }

    public static final class h extends Handler {

        private Context f18173a;

        private ConcurrentHashMap<String, InterfaceC0228c> f18174b;

        private ConcurrentHashMap<String, List<CampaignEx>> f18175c;

        public h(Looper looper) {
            super(looper);
            this.f18174b = new ConcurrentHashMap<>();
            this.f18175c = new ConcurrentHashMap<>();
        }

        public final void a(String str, String str2, String str3, InterfaceC0228c interfaceC0228c) {
            this.f18174b.put(str2 + "_" + str3, interfaceC0228c);
        }

        @Override
        public final void handleMessage(Message message) {
            boolean z6;
            String str;
            CampaignEx campaignEx;
            String str2;
            List<CampaignEx> list;
            Bundle bundle;
            ?? r8;
            Bundle data = message.getData();
            String string = data.getString(MBridgeConstans.PLACEMENT_ID);
            String string2 = data.getString("unit_id");
            String string3 = data.getString("request_id");
            String str3 = string2 + "_" + string3;
            a aVar = (a) c.f18084c.get(str3);
            InterfaceC0228c interfaceC0228c = this.f18174b.get(str3);
            List<CampaignEx> list2 = this.f18175c.get(str3);
            int i6 = message.what;
            switch (i6) {
                case 100:
                case 101:
                case 102:
                case 103:
                case 104:
                case 105:
                    break;
                default:
                    switch (i6) {
                        case 200:
                        case 201:
                        case HttpStatus.SC_NON_AUTHORITATIVE_INFORMATION:
                        case HttpStatus.SC_RESET_CONTENT:
                            if (aVar != null && interfaceC0228c != null) {
                                String string4 = data.getString("message");
                                if (string4 == null) {
                                    string4 = "";
                                }
                                StringBuilder sb = new StringBuilder();
                                sb.append("resource download failed ");
                                int i7 = message.what;
                                if (i7 != 200) {
                                    if (i7 != 201) {
                                        if (i7 != 203) {
                                            if (i7 != 205) {
                                                str = "unknown";
                                            } else {
                                                str = "tpl";
                                            }
                                        } else {
                                            str = "temp";
                                        }
                                    } else {
                                        str = "zip/html";
                                    }
                                } else {
                                    str = "video";
                                }
                                sb.append(str);
                                sb.append(" ");
                                sb.append(string4);
                                String sb2 = sb.toString();
                                List<CampaignEx> list3 = aVar.f18120h;
                                if (list3 != null && list3.size() > 0) {
                                    campaignEx = aVar.f18120h.get(0);
                                } else {
                                    campaignEx = null;
                                }
                                try {
                                    try {
                                        if (aVar.f18113a && aVar.f18121i != null) {
                                            if (aVar.f18115c == 1) {
                                                if (campaignEx != null && campaignEx.getRsIgnoreCheckRule() != null && campaignEx.getRsIgnoreCheckRule().size() > 0) {
                                                    int i8 = message.what;
                                                    if (i8 != 200) {
                                                        if (i8 != 201) {
                                                            if (i8 != 203) {
                                                                if (i8 == 205) {
                                                                    if (campaignEx.getRsIgnoreCheckRule().contains(3)) {
                                                                        return;
                                                                    }
                                                                    List<CampaignEx> list4 = aVar.f18120h;
                                                                    if (list4 != null && list4.size() > 0) {
                                                                        CampaignEx campaignEx2 = aVar.f18120h.get(0);
                                                                        if (campaignEx2.getCMPTEntryUrl().equals(campaignEx2.getendcard_url()) && campaignEx.getRsIgnoreCheckRule().contains(2)) {
                                                                            return;
                                                                        }
                                                                    }
                                                                }
                                                            } else if (campaignEx.getRsIgnoreCheckRule().contains(1)) {
                                                                return;
                                                            }
                                                        } else if (campaignEx.getRsIgnoreCheckRule().contains(2)) {
                                                            return;
                                                        }
                                                    } else if (campaignEx.getRsIgnoreCheckRule().contains(0)) {
                                                        return;
                                                    }
                                                }
                                                interfaceC0228c.a(string, string2, string3, aVar.f18120h, sb2);
                                                this.f18174b.remove(str3);
                                                c.f18084c.remove(str3);
                                                this.f18175c.remove(str3);
                                                return;
                                            }
                                            String string5 = data.getString("url");
                                            int i9 = message.what;
                                            if (i9 != 200) {
                                                if (i9 != 201) {
                                                    if (i9 != 203) {
                                                        if (i9 == 205) {
                                                            if (campaignEx != null && campaignEx.getRsIgnoreCheckRule() != null && campaignEx.getRsIgnoreCheckRule().size() > 0 && campaignEx.getRsIgnoreCheckRule().contains(3)) {
                                                                q.b("RewardCampaignsResourceManager", "Is TPL but download BTL Template fail but hit ignoreCheckRule");
                                                                return;
                                                            } else {
                                                                aVar.f18121i.clear();
                                                                c.f18084c.remove(str3);
                                                                c.f18084c.put(str3, aVar);
                                                            }
                                                        }
                                                    } else {
                                                        if (campaignEx != null && campaignEx.getRsIgnoreCheckRule() != null && campaignEx.getRsIgnoreCheckRule().size() > 0 && campaignEx.getRsIgnoreCheckRule().contains(1)) {
                                                            q.b("RewardCampaignsResourceManager", "Is TPL but download template fail but hit ignoreCheckRule");
                                                            return;
                                                        }
                                                        for (int i10 = 0; i10 < aVar.f18121i.size(); i10++) {
                                                            CampaignEx campaignEx3 = aVar.f18121i.get(i10);
                                                            if (campaignEx3.getRewardTemplateMode() != null && campaignEx3.getRewardTemplateMode().e().equals(string5)) {
                                                                aVar.f18121i.remove(i10);
                                                            }
                                                        }
                                                        c.f18084c.remove(str3);
                                                        c.f18084c.put(str3, aVar);
                                                    }
                                                } else {
                                                    if (campaignEx != null && campaignEx.getRsIgnoreCheckRule() != null && campaignEx.getRsIgnoreCheckRule().size() > 0 && campaignEx.getRsIgnoreCheckRule().contains(2)) {
                                                        q.b("RewardCampaignsResourceManager", "Is TPL but download endcard fail but hit ignoreCheckRule");
                                                        return;
                                                    }
                                                    for (int i11 = 0; i11 < aVar.f18121i.size(); i11++) {
                                                        CampaignEx campaignEx4 = aVar.f18121i.get(i11);
                                                        if (campaignEx4.getRewardTemplateMode() != null && campaignEx4.getRewardTemplateMode().d().equals(string5)) {
                                                            aVar.f18121i.remove(i11);
                                                        }
                                                        if (campaignEx4.getendcard_url().equals(string5)) {
                                                            aVar.f18121i.remove(i11);
                                                        }
                                                    }
                                                    c.f18084c.remove(str3);
                                                    c.f18084c.put(str3, aVar);
                                                }
                                            } else {
                                                if (campaignEx != null && campaignEx.getRsIgnoreCheckRule() != null && campaignEx.getRsIgnoreCheckRule().size() > 0 && campaignEx.getRsIgnoreCheckRule().contains(0)) {
                                                    q.b("RewardCampaignsResourceManager", "Is TPL but  video download fail but hit ignoreCheckRule");
                                                    return;
                                                }
                                                for (int i12 = 0; i12 < aVar.f18121i.size(); i12++) {
                                                    if (aVar.f18121i.get(i12).getVideoUrlEncode().equals(string5)) {
                                                        aVar.f18121i.remove(i12);
                                                    }
                                                }
                                                c.f18084c.remove(str3);
                                                c.f18084c.put(str3, aVar);
                                            }
                                            r8 = "resource download failed ";
                                            try {
                                                if (com.mbridge.msdk.videocommon.download.c.getInstance().a(94, aVar.f18117e, aVar.f18114b, aVar.f18116d, aVar.f18113a, aVar.f18115c, list2)) {
                                                    interfaceC0228c.a(string, string2, string3, aVar.f18120h);
                                                    this.f18174b.remove(str3);
                                                    c.f18084c.remove(str3);
                                                    this.f18175c.remove(str3);
                                                } else if (aVar.f18121i.size() == 0) {
                                                    data = r8;
                                                    List<CampaignEx> list5 = aVar.f18120h;
                                                    interfaceC0228c.a(string, string2, string3, list5, sb2);
                                                    this.f18174b.remove(str3);
                                                    c.f18084c.remove(str3);
                                                    this.f18175c.remove(str3);
                                                    r8 = list5;
                                                }
                                                return;
                                            } catch (Exception e6) {
                                                e = e6;
                                                str2 = r8;
                                                interfaceC0228c.a(string, string2, string3, aVar.f18120h, str2 + e.getMessage());
                                                return;
                                            }
                                        }
                                        ?? cVar = com.mbridge.msdk.videocommon.download.c.getInstance();
                                        String str4 = aVar.f18117e;
                                        boolean z7 = aVar.f18114b;
                                        ?? r82 = aVar.f18116d;
                                        str2 = "resource download failed ";
                                        try {
                                            ?? a7 = cVar.a(94, str4, z7, r82, aVar.f18113a, aVar.f18115c, list2);
                                            ?? r22 = a7;
                                            if (a7 != 0) {
                                                interfaceC0228c.a(string, string2, string3, aVar.f18120h);
                                                bundle = a7;
                                                list = r82;
                                            } else {
                                                if (campaignEx != null) {
                                                    ArrayList<Integer> rsIgnoreCheckRule = campaignEx.getRsIgnoreCheckRule();
                                                    r22 = rsIgnoreCheckRule;
                                                    if (rsIgnoreCheckRule != null) {
                                                        int size = campaignEx.getRsIgnoreCheckRule().size();
                                                        r22 = size;
                                                        if (size > 0) {
                                                            int i13 = message.what;
                                                            if (i13 != 200) {
                                                                if (i13 != 201) {
                                                                    if (i13 != 203) {
                                                                        r22 = 205;
                                                                        if (i13 == 205) {
                                                                            r22 = 3;
                                                                            if (campaignEx.getRsIgnoreCheckRule().contains(3)) {
                                                                                return;
                                                                            }
                                                                        }
                                                                    } else {
                                                                        r22 = 1;
                                                                        if (campaignEx.getRsIgnoreCheckRule().contains(1)) {
                                                                            return;
                                                                        }
                                                                    }
                                                                } else {
                                                                    r22 = 2;
                                                                    if (campaignEx.getRsIgnoreCheckRule().contains(2)) {
                                                                        return;
                                                                    }
                                                                }
                                                            } else {
                                                                r22 = 0;
                                                                if (campaignEx.getRsIgnoreCheckRule().contains(0)) {
                                                                    return;
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                                List<CampaignEx> list6 = aVar.f18120h;
                                                interfaceC0228c.a(string, string2, string3, list6, sb2);
                                                bundle = r22;
                                                list = list6;
                                            }
                                            this.f18174b.remove(str3);
                                            c.f18084c.remove(str3);
                                            this.f18175c.remove(str3);
                                            data = bundle;
                                            r8 = list;
                                        } catch (Exception e7) {
                                            e = e7;
                                            interfaceC0228c.a(string, string2, string3, aVar.f18120h, str2 + e.getMessage());
                                            return;
                                        }
                                        return;
                                    } catch (Exception e8) {
                                        e = e8;
                                        str2 = data;
                                    }
                                } catch (Exception e9) {
                                    e = e9;
                                    str2 = "resource download failed ";
                                }
                            } else {
                                return;
                            }
                            break;
                        case HttpStatus.SC_ACCEPTED:
                        case 204:
                            break;
                        default:
                            return;
                    }
            }
            if (aVar != null && interfaceC0228c != null) {
                try {
                    z6 = com.mbridge.msdk.videocommon.download.c.getInstance().a(94, aVar.f18117e, aVar.f18114b, aVar.f18116d, aVar.f18113a, aVar.f18115c, list2);
                } catch (Exception e10) {
                    if (MBridgeConstans.DEBUG) {
                        q.d("RewardCampaignsResourceManager", e10.getLocalizedMessage());
                    }
                    z6 = false;
                }
                if (z6) {
                    interfaceC0228c.a(string, string2, string3, aVar.f18120h);
                    this.f18174b.remove(str3);
                    c.f18084c.remove(str3);
                    this.f18175c.remove(str3);
                }
            }
        }

        public final void a(Context context) {
            this.f18173a = context;
        }

        public final void a(String str, List<CampaignEx> list) {
            this.f18175c.put(str, list);
        }
    }

    public interface i {
        void a(String str, String str2, String str3, String str4);

        void a(String str, String str2, String str3, String str4, String str5);
    }

    public interface j {
        void a(String str, String str2, String str3, String str4, String str5, a.C0239a c0239a);

        void a(String str, String str2, String str3, String str4, String str5, a.C0239a c0239a, String str6);
    }

    public static final class m {

        private static final c f18225a = new c();

        public static c a() {
            return f18225a;
        }
    }

    c(AnonymousClass1 anonymousClass1) {
        this();
    }

    public void d() {
        try {
            if (this.f18088e == null) {
                this.f18088e = new ArrayList();
            }
            Context g6 = com.mbridge.msdk.foundation.controller.a.e().g();
            if (g6 != null) {
                this.f18088e.add(new WindVaneWebView(g6));
            }
        } catch (Exception e6) {
            e6.printStackTrace();
        }
    }

    private c() {
        this.f18088e = new ArrayList(6);
        HandlerThread handlerThread = new HandlerThread("mb-reward-load-thread");
        f18084c = new HashMap();
        handlerThread.start();
        this.f18085a = new h(handlerThread.getLooper());
        this.f18086b = new ConcurrentHashMap<>();
    }

    public static c a() {
        return m.f18225a;
    }

    public final synchronized void b() {
        if (Looper.myLooper() != Looper.getMainLooper()) {
            new Handler(Looper.getMainLooper()).post(new Runnable() {
                AnonymousClass4() {
                }

                @Override
                public final void run() {
                    c.this.d();
                }
            });
        } else {
            d();
        }
    }

    public final synchronized void a(Context context, boolean z6, int i6, boolean z7, int i7, String str, String str2, String str3, List<CampaignEx> list, InterfaceC0228c interfaceC0228c, i iVar) {
        String str4 = str2 + "_" + str3;
        f18084c.put(str4, new a(z6, z7, i6, list.size(), str2, str3, i7, list));
        this.f18085a.a(str, str2, str3, interfaceC0228c);
        this.f18085a.a(context);
        this.f18085a.a(str4, list);
        this.f18085a.post(new Runnable() {

            final List f18089a;

            final Context f18090b;

            final String f18091c;

            final int f18092d;

            final String f18093e;

            final String f18094f;

            final i f18095g;

            AnonymousClass1(List list2, Context context2, String str22, int i72, String str5, String str32, i iVar2) {
                r2 = list2;
                r3 = context2;
                r4 = str22;
                r5 = i72;
                r6 = str5;
                r7 = str32;
                r8 = iVar2;
            }

            @Override
            public final void run() {
                Iterator it;
                CharSequence charSequence;
                boolean isDynamicView;
                String iconUrl;
                String imageUrl;
                CampaignEx.c cVar;
                List<CampaignEx.c.a> f6;
                List<String> list2;
                CharSequence charSequence2;
                List list22 = r2;
                if (list22 != null && list22.size() > 0) {
                    try {
                        com.mbridge.msdk.videocommon.download.i.a().a(r2);
                        com.mbridge.msdk.videocommon.download.c.getInstance().createUnitCache(r3, r4, r2, r5, new f(c.this.f18085a, r6, r4, r7));
                        com.mbridge.msdk.videocommon.download.c.getInstance().load(r4);
                    } catch (Exception e6) {
                        if (MBridgeConstans.DEBUG) {
                            q.d("RewardCampaignsResourceManager", e6.getLocalizedMessage());
                        }
                    }
                    Iterator it2 = r2.iterator();
                    while (it2.hasNext()) {
                        CampaignEx campaignEx = (CampaignEx) it2.next();
                        if (campaignEx != null) {
                            CampaignEx.c rewardTemplateMode = campaignEx.getRewardTemplateMode();
                            if (rewardTemplateMode != null && !campaignEx.isDynamicView()) {
                                String e7 = rewardTemplateMode.e();
                                if (!TextUtils.isEmpty(e7) && !e7.contains(CampaignEx.KEY_IS_CMPT_ENTRY)) {
                                    if (e7.contains(".zip")) {
                                        try {
                                            it = it2;
                                            charSequence2 = ".zip";
                                        } catch (Exception e8) {
                                            e = e8;
                                            it = it2;
                                            charSequence2 = ".zip";
                                        }
                                        try {
                                            com.mbridge.msdk.videocommon.download.g.a().b(e7, new g(r3, r6, r4, r7, campaignEx, 859, c.this.f18085a, r8, r2));
                                        } catch (Exception e9) {
                                            e = e9;
                                            if (MBridgeConstans.DEBUG) {
                                                q.d("RewardCampaignsResourceManager", e.getLocalizedMessage());
                                            }
                                            charSequence = charSequence2;
                                            String str222 = campaignEx.getendcard_url();
                                            isDynamicView = campaignEx.isDynamicView();
                                            boolean g6222 = u.g(str222);
                                            if (isDynamicView) {
                                            }
                                            if (!TextUtils.isEmpty(campaignEx.getEndScreenUrl())) {
                                            }
                                            iconUrl = campaignEx.getIconUrl();
                                            if (!TextUtils.isEmpty(iconUrl)) {
                                            }
                                            imageUrl = campaignEx.getImageUrl();
                                            if (!TextUtils.isEmpty(imageUrl)) {
                                            }
                                            if (rewardTemplateMode != null) {
                                            }
                                            it2 = it;
                                        }
                                        charSequence = charSequence2;
                                    } else {
                                        it = it2;
                                        try {
                                            charSequence = ".zip";
                                            try {
                                                com.mbridge.msdk.videocommon.download.g.a().b(e7, new d(859, r6, r4, r7, campaignEx, r8, c.this.f18085a, r2));
                                            } catch (Exception e10) {
                                                e = e10;
                                                if (MBridgeConstans.DEBUG) {
                                                    q.d("RewardCampaignsResourceManager", e.getLocalizedMessage());
                                                }
                                                String str2222 = campaignEx.getendcard_url();
                                                isDynamicView = campaignEx.isDynamicView();
                                                boolean g62222 = u.g(str2222);
                                                if (isDynamicView) {
                                                }
                                                if (!TextUtils.isEmpty(campaignEx.getEndScreenUrl())) {
                                                }
                                                iconUrl = campaignEx.getIconUrl();
                                                if (!TextUtils.isEmpty(iconUrl)) {
                                                }
                                                imageUrl = campaignEx.getImageUrl();
                                                if (!TextUtils.isEmpty(imageUrl)) {
                                                }
                                                if (rewardTemplateMode != null) {
                                                }
                                                it2 = it;
                                            }
                                        } catch (Exception e11) {
                                            e = e11;
                                            charSequence = ".zip";
                                        }
                                    }
                                    String str22222 = campaignEx.getendcard_url();
                                    isDynamicView = campaignEx.isDynamicView();
                                    boolean g622222 = u.g(str22222);
                                    if (isDynamicView) {
                                        c.a(c.this, r3, r6, r4, r7, campaignEx, str22222, r8, r2);
                                    } else if (g622222) {
                                        c.a(c.this, r3, r6, r4, r7, campaignEx, str22222, r8, r2);
                                    }
                                    if (!TextUtils.isEmpty(campaignEx.getEndScreenUrl()) && !campaignEx.isDynamicView()) {
                                        com.mbridge.msdk.videocommon.download.g.a().a(campaignEx.getEndScreenUrl(), null);
                                    }
                                    iconUrl = campaignEx.getIconUrl();
                                    if (!TextUtils.isEmpty(iconUrl)) {
                                        try {
                                            com.mbridge.msdk.foundation.same.c.b.a(r3).a(iconUrl, new e(c.this.f18085a, 0, r6, r4, r7, campaignEx));
                                        } catch (Exception e12) {
                                            if (MBridgeConstans.DEBUG) {
                                                q.d("RewardCampaignsResourceManager", e12.getLocalizedMessage());
                                            }
                                        }
                                    }
                                    imageUrl = campaignEx.getImageUrl();
                                    if (!TextUtils.isEmpty(imageUrl)) {
                                        try {
                                            com.mbridge.msdk.foundation.same.c.b.a(r3).a(imageUrl, new e(c.this.f18085a, 0, r6, r4, r7, campaignEx));
                                        } catch (Exception e13) {
                                            if (MBridgeConstans.DEBUG) {
                                                q.d("RewardCampaignsResourceManager", e13.getLocalizedMessage());
                                            }
                                        }
                                    }
                                    if (rewardTemplateMode != null) {
                                        String d6 = rewardTemplateMode.d();
                                        if (!TextUtils.isEmpty(d6) && !campaignEx.isDynamicView()) {
                                            if (d6.contains(charSequence)) {
                                                try {
                                                    cVar = rewardTemplateMode;
                                                } catch (Exception e14) {
                                                    e = e14;
                                                    cVar = rewardTemplateMode;
                                                }
                                                try {
                                                    com.mbridge.msdk.videocommon.download.g.a().b(d6, new g(r3, r6, r4, r7, campaignEx, 313, c.this.f18085a, r8, r2));
                                                } catch (Exception e15) {
                                                    e = e15;
                                                    if (MBridgeConstans.DEBUG) {
                                                        q.d("RewardCampaignsResourceManager", e.getLocalizedMessage());
                                                    }
                                                    f6 = cVar.f();
                                                    if (f6 != null) {
                                                        while (r3.hasNext()) {
                                                        }
                                                    }
                                                    it2 = it;
                                                }
                                            } else {
                                                cVar = rewardTemplateMode;
                                                try {
                                                    com.mbridge.msdk.videocommon.download.g.a().b(d6, new d(313, r6, r4, r7, campaignEx, r8, c.this.f18085a, r2));
                                                } catch (Exception e16) {
                                                    if (MBridgeConstans.DEBUG) {
                                                        q.d("RewardCampaignsResourceManager", e16.getLocalizedMessage());
                                                    }
                                                }
                                            }
                                        } else {
                                            cVar = rewardTemplateMode;
                                        }
                                        f6 = cVar.f();
                                        if (f6 != null && f6.size() > 0) {
                                            for (CampaignEx.c.a aVar : f6) {
                                                if (aVar != null && (list2 = aVar.f16716b) != null && list2.size() > 0) {
                                                    for (String str32 : aVar.f16716b) {
                                                        if (!TextUtils.isEmpty(str32)) {
                                                            try {
                                                                com.mbridge.msdk.foundation.same.c.b.a(r3).a(str32, new e(c.this.f18085a, 1, r6, r4, r7, campaignEx));
                                                            } catch (Exception e17) {
                                                                if (MBridgeConstans.DEBUG) {
                                                                    q.d("RewardCampaignsResourceManager", e17.getLocalizedMessage());
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                    it2 = it;
                                }
                            }
                            it = it2;
                            charSequence = ".zip";
                            String str222222 = campaignEx.getendcard_url();
                            isDynamicView = campaignEx.isDynamicView();
                            boolean g6222222 = u.g(str222222);
                            if (isDynamicView) {
                            }
                            if (!TextUtils.isEmpty(campaignEx.getEndScreenUrl())) {
                                com.mbridge.msdk.videocommon.download.g.a().a(campaignEx.getEndScreenUrl(), null);
                            }
                            iconUrl = campaignEx.getIconUrl();
                            if (!TextUtils.isEmpty(iconUrl)) {
                            }
                            imageUrl = campaignEx.getImageUrl();
                            if (!TextUtils.isEmpty(imageUrl)) {
                            }
                            if (rewardTemplateMode != null) {
                            }
                            it2 = it;
                        }
                    }
                }
            }
        });
    }

    private static final class f implements com.mbridge.msdk.videocommon.listener.a {

        private Handler f18158a;

        private final String f18159b;

        private final String f18160c;

        private final String f18161d;

        public f(Handler handler, String str, String str2, String str3) {
            this.f18158a = handler;
            this.f18160c = str;
            this.f18159b = str2;
            this.f18161d = str3;
        }

        @Override
        public final void a(String str) {
            com.mbridge.msdk.videocommon.download.i.a().a(str, true);
            Message obtain = Message.obtain();
            obtain.what = 100;
            Bundle bundle = new Bundle();
            bundle.putString("unit_id", this.f18159b);
            bundle.putString(MBridgeConstans.PLACEMENT_ID, this.f18160c);
            bundle.putString("request_id", this.f18161d);
            bundle.putString("url", str);
            obtain.setData(bundle);
            this.f18158a.sendMessage(obtain);
        }

        @Override
        public final void a(String str, String str2) {
            com.mbridge.msdk.videocommon.download.i.a().a(str2, false);
            Message obtain = Message.obtain();
            obtain.what = 200;
            Bundle bundle = new Bundle();
            bundle.putString("unit_id", this.f18159b);
            bundle.putString(MBridgeConstans.PLACEMENT_ID, this.f18160c);
            bundle.putString("request_id", this.f18161d);
            bundle.putString("url", str2);
            bundle.putString("message", str);
            obtain.setData(bundle);
            this.f18158a.sendMessage(obtain);
        }
    }

    public final synchronized void a(Context context, CampaignEx campaignEx, String str, String str2, String str3, i iVar) {
        this.f18085a.a(context);
        if (campaignEx != null) {
            String cMPTEntryUrl = campaignEx.getCMPTEntryUrl();
            if (campaignEx.isDynamicView()) {
                com.mbridge.msdk.videocommon.download.i.a().b(cMPTEntryUrl, true);
                Message obtain = Message.obtain();
                obtain.what = 105;
                Bundle bundle = new Bundle();
                bundle.putString("unit_id", str2);
                bundle.putString(MBridgeConstans.PLACEMENT_ID, str);
                bundle.putString("request_id", str3);
                bundle.putString("url", cMPTEntryUrl);
                obtain.setData(bundle);
                this.f18085a.sendMessage(obtain);
                if (iVar != null) {
                    iVar.a(str, str2, str3, cMPTEntryUrl);
                }
                return;
            }
        }
        if (campaignEx != null && !TextUtils.isEmpty(campaignEx.getCMPTEntryUrl())) {
            try {
                com.mbridge.msdk.videocommon.download.g.a().b(campaignEx.getCMPTEntryUrl(), new g.d() {

                    final String f18097a;

                    final String f18098b;

                    final String f18099c;

                    final i f18100d;

                    final Context f18101e;

                    final CampaignEx f18102f;

                    AnonymousClass2(String str22, String str4, String str32, i iVar2, Context context2, CampaignEx campaignEx2) {
                        r2 = str22;
                        r3 = str4;
                        r4 = str32;
                        r5 = iVar2;
                        r6 = context2;
                        r7 = campaignEx2;
                    }

                    @Override
                    public final void a(String str4) {
                        try {
                            com.mbridge.msdk.videocommon.download.i.a().b(str4, true);
                            Message obtain2 = Message.obtain();
                            obtain2.what = 105;
                            Bundle bundle2 = new Bundle();
                            bundle2.putString("unit_id", r2);
                            bundle2.putString(MBridgeConstans.PLACEMENT_ID, r3);
                            bundle2.putString("request_id", r4);
                            bundle2.putString("url", str4);
                            obtain2.setData(bundle2);
                            c.this.f18085a.sendMessage(obtain2);
                            i iVar2 = r5;
                            if (iVar2 != null) {
                                iVar2.a(r3, r2, r4, str4);
                            }
                            com.mbridge.msdk.foundation.entity.m mVar = new com.mbridge.msdk.foundation.entity.m();
                            mVar.o(p.f3632m);
                            Context context2 = r6;
                            if (context2 != null) {
                                mVar.c(com.mbridge.msdk.foundation.tools.m.n(context2.getApplicationContext()));
                            }
                            mVar.d(1);
                            CampaignEx campaignEx2 = r7;
                            if (campaignEx2 != null) {
                                mVar.n(campaignEx2.getId());
                                mVar.k(r7.getRequestId());
                                mVar.l(r7.getRequestIdNotice());
                            }
                            mVar.i(str4);
                            mVar.p("");
                            mVar.m(r2);
                            com.mbridge.msdk.foundation.db.p.a(com.mbridge.msdk.foundation.db.g.a(com.mbridge.msdk.foundation.controller.a.e().g())).a(mVar);
                        } catch (Exception e6) {
                            com.mbridge.msdk.videocommon.download.i.a().b(str4, false);
                            Message obtain3 = Message.obtain();
                            obtain3.what = HttpStatus.SC_RESET_CONTENT;
                            Bundle bundle3 = new Bundle();
                            bundle3.putString("unit_id", r2);
                            bundle3.putString(MBridgeConstans.PLACEMENT_ID, r3);
                            bundle3.putString("request_id", r4);
                            bundle3.putString("url", str4);
                            obtain3.setData(bundle3);
                            c.this.f18085a.sendMessage(obtain3);
                            i iVar3 = r5;
                            if (iVar3 != null) {
                                iVar3.a(r3, r2, r4, str4, e6.getLocalizedMessage());
                            }
                            com.mbridge.msdk.foundation.entity.m mVar2 = new com.mbridge.msdk.foundation.entity.m();
                            mVar2.o(p.f3632m);
                            Context context3 = r6;
                            if (context3 != null) {
                                mVar2.c(com.mbridge.msdk.foundation.tools.m.n(context3.getApplicationContext()));
                            }
                            mVar2.d(3);
                            CampaignEx campaignEx3 = r7;
                            if (campaignEx3 != null) {
                                mVar2.n(campaignEx3.getId());
                                mVar2.k(r7.getRequestId());
                                mVar2.l(r7.getRequestIdNotice());
                            }
                            mVar2.i(str4);
                            mVar2.p(e6.getLocalizedMessage());
                            mVar2.m(r2);
                            com.mbridge.msdk.foundation.db.p.a(com.mbridge.msdk.foundation.db.g.a(com.mbridge.msdk.foundation.controller.a.e().g())).a(mVar2);
                            if (MBridgeConstans.DEBUG) {
                                q.d("RewardCampaignsResourceManager", e6.getLocalizedMessage());
                            }
                        }
                    }

                    @Override
                    public final void a(String str4, String str5) {
                        try {
                            com.mbridge.msdk.videocommon.download.i.a().b(str5, false);
                            Message obtain2 = Message.obtain();
                            obtain2.what = HttpStatus.SC_RESET_CONTENT;
                            Bundle bundle2 = new Bundle();
                            bundle2.putString("unit_id", r2);
                            bundle2.putString(MBridgeConstans.PLACEMENT_ID, r3);
                            bundle2.putString("request_id", r4);
                            bundle2.putString("url", str5);
                            bundle2.putString("message", str4);
                            obtain2.setData(bundle2);
                            c.this.f18085a.sendMessage(obtain2);
                            i iVar2 = r5;
                            if (iVar2 != null) {
                                iVar2.a(r3, r2, r4, str5, str4);
                            }
                            com.mbridge.msdk.foundation.entity.m mVar = new com.mbridge.msdk.foundation.entity.m();
                            mVar.o(p.f3632m);
                            Context context2 = r6;
                            if (context2 != null) {
                                mVar.c(com.mbridge.msdk.foundation.tools.m.n(context2.getApplicationContext()));
                            }
                            mVar.d(3);
                            CampaignEx campaignEx2 = r7;
                            if (campaignEx2 != null) {
                                mVar.n(campaignEx2.getId());
                                mVar.k(r7.getRequestId());
                                mVar.l(r7.getRequestIdNotice());
                            }
                            mVar.i(str5);
                            mVar.p(str4);
                            mVar.m(r2);
                            com.mbridge.msdk.foundation.db.p.a(com.mbridge.msdk.foundation.db.g.a(com.mbridge.msdk.foundation.controller.a.e().g())).a(mVar);
                        } catch (Exception e6) {
                            com.mbridge.msdk.videocommon.download.i.a().b(str5, false);
                            Message obtain3 = Message.obtain();
                            obtain3.what = 105;
                            Bundle bundle3 = new Bundle();
                            bundle3.putString("unit_id", r2);
                            bundle3.putString(MBridgeConstans.PLACEMENT_ID, r3);
                            bundle3.putString("request_id", r4);
                            bundle3.putString("url", str5);
                            bundle3.putString("message", e6.getMessage());
                            obtain3.setData(bundle3);
                            c.this.f18085a.sendMessage(obtain3);
                            i iVar3 = r5;
                            if (iVar3 != null) {
                                iVar3.a(r3, r2, r4, str5, str4);
                            }
                            if (MBridgeConstans.DEBUG) {
                                q.d("RewardCampaignsResourceManager", e6.getLocalizedMessage());
                            }
                        }
                    }
                });
            } catch (Exception e6) {
                if (MBridgeConstans.DEBUG) {
                    q.d("RewardCampaignsResourceManager", e6.getLocalizedMessage());
                }
            }
        }
    }

    public static class b extends com.mbridge.msdk.mbsignalcommon.b.a {

        private final Handler f18122a;

        private final Runnable f18123b;

        private final boolean f18124c;

        private final boolean f18125d;

        private int f18126e;

        private String f18127f;

        private String f18128g;

        private String f18129h;

        private String f18130i;

        private a.C0239a f18131j;

        private CampaignEx f18132k;

        private List<CampaignEx> f18133l;

        private com.mbridge.msdk.videocommon.d.c f18134m;

        private final j f18135n;

        private boolean f18136o;

        private boolean f18137p;

        private boolean f18138q;

        private int f18139r = 0;

        private boolean f18140s;

        private long f18141t;

        public b(boolean z6, Handler handler, Runnable runnable, boolean z7, boolean z8, int i6, String str, String str2, String str3, String str4, a.C0239a c0239a, CampaignEx campaignEx, List<CampaignEx> list, com.mbridge.msdk.videocommon.d.c cVar, j jVar, boolean z9, long j6) {
            this.f18122a = handler;
            this.f18123b = runnable;
            this.f18124c = z7;
            this.f18125d = z8;
            this.f18126e = i6;
            this.f18127f = str;
            this.f18129h = str2;
            this.f18128g = str3;
            this.f18130i = str4;
            this.f18131j = c0239a;
            this.f18132k = campaignEx;
            this.f18133l = list;
            this.f18134m = cVar;
            this.f18135n = jVar;
            this.f18136o = z9;
            this.f18140s = z6;
            this.f18141t = j6;
        }

        @Override
        public final void a(WebView webView, int i6) {
            Runnable runnable;
            if (this.f18138q) {
                return;
            }
            try {
                com.mbridge.msdk.reward.b.a.a(this.f18132k, com.mbridge.msdk.foundation.controller.a.e().g(), "preload tpl readyState: " + i6, this.f18128g, this.f18125d, this.f18130i, this.f18132k.getRequestIdNotice(), System.currentTimeMillis() - this.f18141t);
            } catch (Exception unused) {
            }
            String str = this.f18128g + "_" + this.f18127f;
            if (i6 == 1) {
                if (this.f18136o) {
                    com.mbridge.msdk.videocommon.a.d(this.f18128g + "_" + this.f18130i);
                } else {
                    com.mbridge.msdk.videocommon.a.c(this.f18128g + "_" + this.f18130i);
                }
                com.mbridge.msdk.videocommon.a.a(this.f18128g + "_" + this.f18130i + "_" + this.f18127f, this.f18131j, true, this.f18136o);
                Handler handler = this.f18122a;
                if (handler != null && (runnable = this.f18123b) != null) {
                    handler.removeCallbacks(runnable);
                }
                com.mbridge.msdk.videocommon.download.i.a().d(this.f18128g + "_" + this.f18130i + "_" + this.f18127f, true);
                a.C0239a c0239a = this.f18131j;
                if (c0239a != null) {
                    c0239a.a(true);
                }
                j jVar = this.f18135n;
                if (jVar != null) {
                    jVar.a(str, this.f18129h, this.f18128g, this.f18130i, this.f18127f, this.f18131j);
                }
            } else {
                com.mbridge.msdk.videocommon.download.i.a().d(this.f18128g + "_" + this.f18130i + "_" + this.f18127f, false);
                a.C0239a c0239a2 = this.f18131j;
                if (c0239a2 != null) {
                    c0239a2.a(false);
                }
                j jVar2 = this.f18135n;
                if (jVar2 != null) {
                    jVar2.a(str, this.f18129h, this.f18128g, this.f18130i, this.f18127f, this.f18131j, "state 2");
                }
            }
            this.f18138q = true;
        }

        @Override
        public final void a(WebView webView, String str, String str2, int i6, int i7) {
            boolean z6 = true;
            if (i6 == 1) {
                try {
                    com.mbridge.msdk.reward.a.a aVar = new com.mbridge.msdk.reward.a.a();
                    aVar.b(false);
                    if (i7 != 2) {
                        z6 = false;
                    }
                    aVar.a(z6);
                    aVar.b(str, str2);
                    aVar.a(new com.mbridge.msdk.video.bt.module.b.a(null));
                    aVar.d(false);
                } catch (Exception unused) {
                }
            }
        }

        @Override
        public final void a(Object obj, String str) {
            if (obj == null) {
                return;
            }
            try {
                if (TextUtils.isEmpty(str)) {
                    return;
                }
                String optString = new JSONObject(str).optString("id");
                com.mbridge.msdk.video.bt.a.c.a().a(obj, optString);
                String c6 = com.mbridge.msdk.video.bt.a.c.a().c(optString);
                CampaignEx a7 = com.mbridge.msdk.video.bt.a.c.a().a(optString);
                com.mbridge.msdk.videocommon.d.c b6 = com.mbridge.msdk.video.bt.a.c.a().b(optString);
                ArrayList arrayList = new ArrayList();
                arrayList.add(a7);
                WindVaneWebView windVaneWebView = ((com.mbridge.msdk.mbsignalcommon.windvane.a) obj).f17834a;
                if (windVaneWebView instanceof WindVaneWebView) {
                    c cVar = m.f18225a;
                    boolean z6 = this.f18140s;
                    int i6 = this.f18139r == 0 ? 3 : 6;
                    if (windVaneWebView != null) {
                        if (a7 != null && b6 != null) {
                            try {
                                if (a7.getRewardTemplateMode() != null && !TextUtils.isEmpty(c6)) {
                                    if (TextUtils.isEmpty(a7.getRewardTemplateMode().e())) {
                                        JSONObject jSONObject = new JSONObject();
                                        try {
                                            jSONObject.put("id", optString);
                                            JSONObject jSONObject2 = new JSONObject();
                                            jSONObject2.put("result", 1);
                                            jSONObject2.put("error", "data is null");
                                            jSONObject.put("data", jSONObject2);
                                            com.mbridge.msdk.mbsignalcommon.windvane.g.a().a((WebView) windVaneWebView, "onSubPlayTemplateViewLoad", Base64.encodeToString(jSONObject.toString().getBytes(), 2));
                                        } catch (Exception e6) {
                                            if (MBridgeConstans.DEBUG) {
                                                q.d("RewardCampaignsResourceManager", e6.getLocalizedMessage());
                                            }
                                        }
                                    } else if (!TextUtils.isEmpty(a7.getRewardTemplateMode().e()) && a7.getRewardTemplateMode().e().contains(CampaignEx.KEY_IS_CMPT_ENTRY)) {
                                        q.a("RewardCampaignsResourceManager", "getTeamplateUrl contains cmpt=1");
                                    } else {
                                        new Handler(Looper.getMainLooper()).postDelayed(new Runnable() {

                                            final boolean f18104a;

                                            final WindVaneWebView f18105b;

                                            final CampaignEx f18106c;

                                            final List f18107d;

                                            final String f18108e;

                                            final com.mbridge.msdk.videocommon.d.c f18109f;

                                            final String f18110g;

                                            AnonymousClass3(boolean z62, WindVaneWebView windVaneWebView2, CampaignEx a72, List arrayList2, String c62, com.mbridge.msdk.videocommon.d.c b62, String optString2) {
                                                r2 = z62;
                                                r3 = windVaneWebView2;
                                                r4 = a72;
                                                r5 = arrayList2;
                                                r6 = c62;
                                                r7 = b62;
                                                r8 = optString2;
                                            }

                                            @Override
                                            public final void run() {
                                                c.a(c.this, r2, r3, r4.getRewardTemplateMode().e(), 0, r4, r5, com.mbridge.msdk.videocommon.download.g.a().b(r4.getRewardTemplateMode().e()), r6, r7, r8, c.this.f18087d);
                                            }
                                        }, i6 * 1000);
                                    }
                                }
                            } catch (Throwable th) {
                                th = th;
                                q.d("RVWindVaneWebView", th.getMessage());
                                return;
                            }
                        }
                        JSONObject jSONObject3 = new JSONObject();
                        jSONObject3.put("id", optString2);
                        JSONObject jSONObject4 = new JSONObject();
                        jSONObject4.put("result", 2);
                        jSONObject4.put("error", "data is null");
                        jSONObject3.put("data", jSONObject4);
                        com.mbridge.msdk.mbsignalcommon.windvane.g.a().a((WebView) windVaneWebView2, "onSubPlayTemplateViewLoad", Base64.encodeToString(jSONObject3.toString().getBytes(), 2));
                    }
                    this.f18139r++;
                }
            } catch (Throwable th2) {
                th = th2;
            }
        }

        @Override
        public final void a(WebView webView, String str) {
            Runnable runnable;
            super.a(webView, str);
            if (this.f18137p) {
                return;
            }
            try {
                com.mbridge.msdk.reward.b.a.a(this.f18132k, com.mbridge.msdk.foundation.controller.a.e().g(), "preload tpl onPageFinish", this.f18128g, this.f18125d, this.f18130i, this.f18132k.getRequestIdNotice(), System.currentTimeMillis() - this.f18141t);
            } catch (Exception unused) {
            }
            String str2 = this.f18128g + "_" + this.f18127f;
            if (!str.contains("wfr=1")) {
                com.mbridge.msdk.videocommon.download.i.a().d(this.f18128g + "_" + this.f18130i + "_" + this.f18127f, true);
                Handler handler = this.f18122a;
                if (handler != null && (runnable = this.f18123b) != null) {
                    handler.removeCallbacks(runnable);
                }
                a.C0239a c0239a = this.f18131j;
                if (c0239a != null) {
                    c0239a.a(true);
                }
                j jVar = this.f18135n;
                if (jVar != null) {
                    jVar.a(str2, this.f18129h, this.f18128g, this.f18130i, this.f18127f, this.f18131j);
                }
            }
            com.mbridge.msdk.mbsignalcommon.windvane.g.a().a(webView);
            this.f18137p = true;
        }

        @Override
        public final void a(WebView webView, int i6, String str, String str2) {
            super.a(webView, i6, str, str2);
            com.mbridge.msdk.videocommon.download.i.a().d(this.f18128g + "_" + this.f18130i + "_" + this.f18127f, false);
            if (this.f18135n != null) {
                String str3 = this.f18128g + "_" + this.f18127f;
                a.C0239a c0239a = this.f18131j;
                if (c0239a != null) {
                    c0239a.a(false);
                }
                this.f18135n.a(str3, this.f18129h, this.f18128g, this.f18130i, this.f18127f, this.f18131j, str);
            }
        }
    }

    public static class k extends com.mbridge.msdk.mbsignalcommon.b.b {

        private Handler f18176a;

        private Runnable f18177b;

        private final boolean f18178c;

        private final boolean f18179d;

        private String f18180e;

        private final j f18181f;

        private final WindVaneWebView f18182g;

        private final String f18183h;

        private final String f18184i;

        private final String f18185j;

        private final a.C0239a f18186k;

        private final CampaignEx f18187l;

        private List<CampaignEx> f18188m;

        private long f18189n;

        private boolean f18190o;

        private boolean f18191p;

        private final Runnable f18192q;

        private final Runnable f18193r;

        public final class AnonymousClass1 implements Runnable {

            final j f18194a;

            final a.C0239a f18195b;

            final String f18196c;

            final String f18197d;

            final String f18198e;

            final CampaignEx f18199f;

            final boolean f18200g;

            final long f18201h;

            final String f18202i;

            AnonymousClass1(j jVar, a.C0239a c0239a, String str, String str2, String str3, CampaignEx campaignEx, boolean z6, long j6, String str4) {
                r2 = jVar;
                r3 = c0239a;
                r4 = str;
                r5 = str2;
                r6 = str3;
                r7 = campaignEx;
                r8 = z6;
                r9 = j6;
                r11 = str4;
            }

            @Override
            public final void run() {
                WindVaneWebView a7;
                a.C0239a c0239a;
                if (r2 != null && (c0239a = r3) != null) {
                    c0239a.a(true);
                    com.mbridge.msdk.videocommon.download.i.a().d(r4 + "_" + r5 + "_" + r6, true);
                    try {
                        com.mbridge.msdk.reward.b.a.a(r7, com.mbridge.msdk.foundation.controller.a.e().g(), "WebView onPageFinish timeout exception after 5s", r4, r8, r5, r7.getRequestIdNotice(), System.currentTimeMillis() - r9);
                    } catch (Exception unused) {
                    }
                    r2.a(r4 + "_" + r6, r11, r4, r5, r6, r3);
                }
                a.C0239a c0239a2 = r3;
                if (c0239a2 != null && (a7 = c0239a2.a()) != null) {
                    try {
                        a7.release();
                    } catch (Exception unused2) {
                    }
                }
            }
        }

        public final class AnonymousClass2 implements Runnable {

            final j f18204a;

            final a.C0239a f18205b;

            final String f18206c;

            final String f18207d;

            final String f18208e;

            final CampaignEx f18209f;

            final boolean f18210g;

            final long f18211h;

            final String f18212i;

            AnonymousClass2(j jVar, a.C0239a c0239a, String str, String str2, String str3, CampaignEx campaignEx, boolean z6, long j6, String str4) {
                r2 = jVar;
                r3 = c0239a;
                r4 = str;
                r5 = str2;
                r6 = str3;
                r7 = campaignEx;
                r8 = z6;
                r9 = j6;
                r11 = str4;
            }

            @Override
            public final void run() {
                WindVaneWebView a7;
                a.C0239a c0239a;
                if (r2 != null && (c0239a = r3) != null) {
                    c0239a.a(true);
                    com.mbridge.msdk.videocommon.download.i.a().d(r4 + "_" + r5 + "_" + r6, true);
                    try {
                        com.mbridge.msdk.reward.b.a.a(r7, com.mbridge.msdk.foundation.controller.a.e().g(), "WebView readyState timeout exception after 5s", r4, r8, r5, r7.getRequestIdNotice(), System.currentTimeMillis() - r9);
                    } catch (Exception unused) {
                    }
                    r2.a(r4 + "_" + r6, r11, r4, r5, r6, r3);
                }
                a.C0239a c0239a2 = r3;
                if (c0239a2 != null && (a7 = c0239a2.a()) != null) {
                    try {
                        a7.release();
                    } catch (Exception unused2) {
                    }
                }
            }
        }

        public k(Handler handler, Runnable runnable, boolean z6, boolean z7, String str, j jVar, WindVaneWebView windVaneWebView, String str2, String str3, String str4, a.C0239a c0239a, CampaignEx campaignEx, List<CampaignEx> list, long j6) {
            this.f18176a = handler;
            this.f18177b = runnable;
            this.f18178c = z6;
            this.f18179d = z7;
            this.f18180e = str;
            this.f18181f = jVar;
            this.f18182g = windVaneWebView;
            this.f18183h = str2;
            this.f18184i = str4;
            this.f18185j = str3;
            this.f18186k = c0239a;
            this.f18187l = campaignEx;
            this.f18188m = list;
            this.f18189n = j6;
            AnonymousClass1 anonymousClass1 = new Runnable() {

                final j f18194a;

                final a.C0239a f18195b;

                final String f18196c;

                final String f18197d;

                final String f18198e;

                final CampaignEx f18199f;

                final boolean f18200g;

                final long f18201h;

                final String f18202i;

                AnonymousClass1(j jVar2, a.C0239a c0239a2, String str42, String str5, String str22, CampaignEx campaignEx2, boolean z72, long j62, String str32) {
                    r2 = jVar2;
                    r3 = c0239a2;
                    r4 = str42;
                    r5 = str5;
                    r6 = str22;
                    r7 = campaignEx2;
                    r8 = z72;
                    r9 = j62;
                    r11 = str32;
                }

                @Override
                public final void run() {
                    WindVaneWebView a7;
                    a.C0239a c0239a2;
                    if (r2 != null && (c0239a2 = r3) != null) {
                        c0239a2.a(true);
                        com.mbridge.msdk.videocommon.download.i.a().d(r4 + "_" + r5 + "_" + r6, true);
                        try {
                            com.mbridge.msdk.reward.b.a.a(r7, com.mbridge.msdk.foundation.controller.a.e().g(), "WebView onPageFinish timeout exception after 5s", r4, r8, r5, r7.getRequestIdNotice(), System.currentTimeMillis() - r9);
                        } catch (Exception unused) {
                        }
                        r2.a(r4 + "_" + r6, r11, r4, r5, r6, r3);
                    }
                    a.C0239a c0239a22 = r3;
                    if (c0239a22 != null && (a7 = c0239a22.a()) != null) {
                        try {
                            a7.release();
                        } catch (Exception unused2) {
                        }
                    }
                }
            };
            this.f18193r = anonymousClass1;
            this.f18192q = new Runnable() {

                final j f18204a;

                final a.C0239a f18205b;

                final String f18206c;

                final String f18207d;

                final String f18208e;

                final CampaignEx f18209f;

                final boolean f18210g;

                final long f18211h;

                final String f18212i;

                AnonymousClass2(j jVar2, a.C0239a c0239a2, String str42, String str5, String str22, CampaignEx campaignEx2, boolean z72, long j62, String str32) {
                    r2 = jVar2;
                    r3 = c0239a2;
                    r4 = str42;
                    r5 = str5;
                    r6 = str22;
                    r7 = campaignEx2;
                    r8 = z72;
                    r9 = j62;
                    r11 = str32;
                }

                @Override
                public final void run() {
                    WindVaneWebView a7;
                    a.C0239a c0239a2;
                    if (r2 != null && (c0239a2 = r3) != null) {
                        c0239a2.a(true);
                        com.mbridge.msdk.videocommon.download.i.a().d(r4 + "_" + r5 + "_" + r6, true);
                        try {
                            com.mbridge.msdk.reward.b.a.a(r7, com.mbridge.msdk.foundation.controller.a.e().g(), "WebView readyState timeout exception after 5s", r4, r8, r5, r7.getRequestIdNotice(), System.currentTimeMillis() - r9);
                        } catch (Exception unused) {
                        }
                        r2.a(r4 + "_" + r6, r11, r4, r5, r6, r3);
                    }
                    a.C0239a c0239a22 = r3;
                    if (c0239a22 != null && (a7 = c0239a22.a()) != null) {
                        try {
                            a7.release();
                        } catch (Exception unused2) {
                        }
                    }
                }
            };
            if (handler != null) {
                handler.postDelayed(anonymousClass1, DefaultRenderersFactory.DEFAULT_ALLOWED_VIDEO_JOINING_TIME_MS);
            }
        }

        @Override
        public final void a(WebView webView, int i6) {
            Handler handler;
            Runnable runnable;
            Runnable runnable2;
            super.a(webView, i6);
            Handler handler2 = this.f18176a;
            if (handler2 != null && (runnable2 = this.f18192q) != null) {
                handler2.removeCallbacks(runnable2);
            }
            Handler handler3 = this.f18176a;
            if (handler3 != null && (runnable = this.f18193r) != null) {
                handler3.removeCallbacks(runnable);
            }
            if (this.f18191p) {
                return;
            }
            try {
                com.mbridge.msdk.reward.b.a.a(this.f18187l, com.mbridge.msdk.foundation.controller.a.e().g(), "preload temp readState: " + i6, this.f18184i, this.f18179d, this.f18180e, this.f18187l.getRequestIdNotice(), System.currentTimeMillis() - this.f18189n);
            } catch (Exception unused) {
            }
            String str = this.f18184i + "_" + this.f18183h;
            if (i6 == 1) {
                Runnable runnable3 = this.f18177b;
                if (runnable3 != null && (handler = this.f18176a) != null) {
                    handler.removeCallbacks(runnable3);
                }
                com.mbridge.msdk.videocommon.download.i.a().d(this.f18184i + "_" + this.f18180e + "_" + this.f18183h, true);
                a.C0239a c0239a = this.f18186k;
                if (c0239a != null) {
                    c0239a.a(true);
                }
                if (this.f18178c) {
                    if (this.f18179d) {
                        com.mbridge.msdk.videocommon.a.a(com.anythink.expressad.foundation.f.a.f3675x, this.f18187l.getRequestIdNotice(), this.f18186k);
                    } else {
                        com.mbridge.msdk.videocommon.a.b(com.anythink.expressad.foundation.f.a.f3675x, this.f18187l.getRequestIdNotice(), this.f18186k);
                    }
                } else if (this.f18179d) {
                    com.mbridge.msdk.videocommon.a.a(94, this.f18187l.getRequestIdNotice(), this.f18186k);
                } else {
                    com.mbridge.msdk.videocommon.a.b(94, this.f18187l.getRequestIdNotice(), this.f18186k);
                }
                j jVar = this.f18181f;
                if (jVar != null) {
                    jVar.a(str, this.f18185j, this.f18184i, this.f18180e, this.f18183h, this.f18186k);
                }
            } else {
                j jVar2 = this.f18181f;
                if (jVar2 != null) {
                    jVar2.a(str, this.f18185j, this.f18184i, this.f18180e, this.f18183h, this.f18186k, "state " + i6);
                }
            }
            this.f18191p = true;
        }

        @Override
        public final void a(WebView webView, int i6, String str, String str2) {
            super.a(webView, i6, str, str2);
            com.mbridge.msdk.videocommon.download.i.a().d(this.f18184i + "_" + this.f18180e + "_" + this.f18183h, false);
            try {
                com.mbridge.msdk.reward.b.a.a(this.f18187l, com.mbridge.msdk.foundation.controller.a.e().g(), "WebView onReceivedError exception: " + str, this.f18184i, this.f18179d, this.f18180e, this.f18187l.getRequestIdNotice(), System.currentTimeMillis() - this.f18189n);
            } catch (Exception unused) {
            }
            Handler handler = this.f18176a;
            if (handler != null) {
                if (this.f18192q != null) {
                    handler.removeCallbacks(this.f18193r);
                }
                Runnable runnable = this.f18192q;
                if (runnable != null) {
                    this.f18176a.removeCallbacks(runnable);
                }
            }
            try {
                String str3 = this.f18184i + "_" + this.f18183h;
                a.C0239a c0239a = this.f18186k;
                if (c0239a != null) {
                    c0239a.a(false);
                }
                j jVar = this.f18181f;
                if (jVar != null) {
                    jVar.a(str3, this.f18185j, this.f18184i, this.f18180e, str2, this.f18186k, str);
                }
            } catch (Exception e6) {
                if (MBridgeConstans.DEBUG) {
                    q.d("WindVaneWebView", e6.getLocalizedMessage());
                }
            }
        }

        @Override
        public final void a(WebView webView, SslErrorHandler sslErrorHandler, SslError sslError) {
            super.a(webView, sslErrorHandler, sslError);
            com.mbridge.msdk.videocommon.download.i.a().d(this.f18184i + "_" + this.f18180e + "_" + this.f18183h, false);
            try {
                CampaignEx campaignEx = this.f18187l;
                Context g6 = com.mbridge.msdk.foundation.controller.a.e().g();
                StringBuilder sb = new StringBuilder();
                sb.append("WebView onReceivedSslError exception: ");
                sb.append(sslError == null ? "SSLError" : Integer.toString(sslError.getPrimaryError()));
                com.mbridge.msdk.reward.b.a.a(campaignEx, g6, sb.toString(), this.f18184i, this.f18179d, this.f18180e, this.f18187l.getRequestIdNotice(), System.currentTimeMillis() - this.f18189n);
            } catch (Exception unused) {
            }
            Handler handler = this.f18176a;
            if (handler != null) {
                if (this.f18192q != null) {
                    handler.removeCallbacks(this.f18193r);
                }
                Runnable runnable = this.f18192q;
                if (runnable != null) {
                    this.f18176a.removeCallbacks(runnable);
                }
            }
            try {
                String str = this.f18184i + "_" + this.f18183h;
                a.C0239a c0239a = this.f18186k;
                if (c0239a != null) {
                    c0239a.a(false);
                }
                j jVar = this.f18181f;
                if (jVar != null) {
                    jVar.a(str, this.f18185j, this.f18184i, this.f18180e, this.f18183h, this.f18186k, sslError == null ? "" : Integer.toString(sslError.getPrimaryError()));
                }
            } catch (Exception e6) {
                if (MBridgeConstans.DEBUG) {
                    q.d("WindVaneWebView", e6.getLocalizedMessage());
                }
            }
        }

        @Override
        public final void a(WebView webView, String str) {
            Runnable runnable;
            Handler handler;
            Runnable runnable2;
            super.a(webView, str);
            Handler handler2 = this.f18176a;
            if (handler2 != null && (runnable2 = this.f18193r) != null) {
                handler2.removeCallbacks(runnable2);
            }
            if (this.f18190o) {
                return;
            }
            try {
                com.mbridge.msdk.reward.b.a.a(this.f18187l, com.mbridge.msdk.foundation.controller.a.e().g(), "preload temp onPageFinish", this.f18184i, this.f18179d, this.f18180e, this.f18187l.getRequestIdNotice(), System.currentTimeMillis() - this.f18189n);
            } catch (Exception unused) {
            }
            if (!str.contains("wfr=1")) {
                String str2 = this.f18184i + "_" + this.f18183h;
                com.mbridge.msdk.videocommon.download.i.a().d(this.f18184i + "_" + this.f18180e + "_" + this.f18183h, true);
                Runnable runnable3 = this.f18177b;
                if (runnable3 != null && (handler = this.f18176a) != null) {
                    handler.removeCallbacks(runnable3);
                }
                a.C0239a c0239a = this.f18186k;
                if (c0239a != null) {
                    c0239a.a(true);
                }
                if (this.f18178c) {
                    if (this.f18187l.isBidCampaign()) {
                        com.mbridge.msdk.videocommon.a.a(com.anythink.expressad.foundation.f.a.f3675x, this.f18187l.getRequestIdNotice(), this.f18186k);
                    } else {
                        com.mbridge.msdk.videocommon.a.b(com.anythink.expressad.foundation.f.a.f3675x, this.f18187l.getRequestIdNotice(), this.f18186k);
                    }
                } else if (this.f18187l.isBidCampaign()) {
                    com.mbridge.msdk.videocommon.a.a(94, this.f18187l.getRequestIdNotice(), this.f18186k);
                } else {
                    com.mbridge.msdk.videocommon.a.b(94, this.f18187l.getRequestIdNotice(), this.f18186k);
                }
                j jVar = this.f18181f;
                if (jVar != null) {
                    jVar.a(str2, this.f18185j, this.f18184i, this.f18180e, this.f18183h, this.f18186k);
                }
            } else {
                Handler handler3 = this.f18176a;
                if (handler3 != null && (runnable = this.f18192q) != null) {
                    handler3.postDelayed(runnable, DefaultRenderersFactory.DEFAULT_ALLOWED_VIDEO_JOINING_TIME_MS);
                }
            }
            com.mbridge.msdk.mbsignalcommon.windvane.g.a().a(webView);
            this.f18190o = true;
        }
    }

    public static class l extends com.mbridge.msdk.mbsignalcommon.b.b {

        private String f18214a;

        private final boolean f18215b;

        private final WindVaneWebView f18216c;

        private final String f18217d;

        private final String f18218e;

        private final a.C0239a f18219f;

        private final CampaignEx f18220g;

        private boolean f18221h;

        private String f18222i;

        private boolean f18223j;

        private boolean f18224k;

        public l(String str, boolean z6, WindVaneWebView windVaneWebView, String str2, String str3, a.C0239a c0239a, CampaignEx campaignEx, boolean z7, String str4) {
            this.f18215b = z6;
            this.f18216c = windVaneWebView;
            this.f18217d = str2;
            this.f18218e = str3;
            this.f18219f = c0239a;
            this.f18220g = campaignEx;
            this.f18214a = str;
            this.f18221h = z7;
            this.f18222i = str4;
        }

        @Override
        public final void a(WebView webView, int i6) {
            if (this.f18224k) {
                return;
            }
            if (this.f18216c != null) {
                JSONObject jSONObject = new JSONObject();
                try {
                    jSONObject.put("id", this.f18214a);
                    JSONObject jSONObject2 = new JSONObject();
                    jSONObject2.put("result", i6);
                    jSONObject2.put("error", "");
                    jSONObject.put("data", jSONObject2);
                    com.mbridge.msdk.mbsignalcommon.windvane.g.a().a((WebView) this.f18216c, "onSubPlayTemplateViewLoad", Base64.encodeToString(jSONObject.toString().getBytes(), 2));
                } catch (Exception e6) {
                    if (MBridgeConstans.DEBUG) {
                        q.d("WindVaneWebView", e6.getLocalizedMessage());
                    }
                }
            }
            String str = this.f18218e + "_" + this.f18220g.getId() + "_" + this.f18220g.getRequestId() + "_" + this.f18217d;
            if (i6 == 1) {
                com.mbridge.msdk.videocommon.download.i.a().d(this.f18218e + "_" + this.f18222i + "_" + this.f18217d, true);
                a.C0239a c0239a = this.f18219f;
                if (c0239a != null) {
                    c0239a.a(true);
                }
                if (this.f18215b) {
                    if (this.f18220g.isBidCampaign()) {
                        com.mbridge.msdk.videocommon.a.a(str, this.f18219f, false, this.f18221h);
                    } else {
                        com.mbridge.msdk.videocommon.a.a(str, this.f18219f, false, this.f18221h);
                    }
                } else if (this.f18220g.isBidCampaign()) {
                    com.mbridge.msdk.videocommon.a.a(str, this.f18219f, false, this.f18221h);
                } else {
                    com.mbridge.msdk.videocommon.a.a(str, this.f18219f, false, this.f18221h);
                }
            } else {
                com.mbridge.msdk.videocommon.download.i.a().d(this.f18218e + "_" + this.f18222i + "_" + this.f18217d, false);
                a.C0239a c0239a2 = this.f18219f;
                if (c0239a2 != null) {
                    c0239a2.a(false);
                }
            }
            this.f18224k = true;
        }

        @Override
        public final void a(WebView webView, int i6, String str, String str2) {
            com.mbridge.msdk.videocommon.download.i.a().d(this.f18218e + "_" + this.f18222i + "_" + this.f18217d, false);
            a.C0239a c0239a = this.f18219f;
            if (c0239a != null) {
                c0239a.a(false);
            }
            if (this.f18216c != null) {
                JSONObject jSONObject = new JSONObject();
                try {
                    jSONObject.put("id", this.f18214a);
                    JSONObject jSONObject2 = new JSONObject();
                    jSONObject2.put("result", 2);
                    jSONObject2.put("error", str);
                    jSONObject.put("data", jSONObject2);
                    com.mbridge.msdk.mbsignalcommon.windvane.g.a().a((WebView) this.f18216c, "onSubPlayTemplateViewLoad", Base64.encodeToString(jSONObject.toString().getBytes(), 2));
                } catch (Exception e6) {
                    if (MBridgeConstans.DEBUG) {
                        q.d("WindVaneWebView", e6.getLocalizedMessage());
                    }
                }
            }
        }

        @Override
        public final void a(WebView webView, String str) {
            if (this.f18223j) {
                return;
            }
            if (!str.contains("wfr=1")) {
                if (this.f18216c != null) {
                    JSONObject jSONObject = new JSONObject();
                    try {
                        jSONObject.put("id", this.f18214a);
                        JSONObject jSONObject2 = new JSONObject();
                        jSONObject2.put("result", 1);
                        jSONObject2.put("error", "");
                        jSONObject.put("data", jSONObject2);
                        com.mbridge.msdk.mbsignalcommon.windvane.g.a().a((WebView) this.f18216c, "componentReact", Base64.encodeToString(jSONObject.toString().getBytes(), 2));
                    } catch (Exception e6) {
                        if (MBridgeConstans.DEBUG) {
                            q.d("WindVaneWebView", e6.getLocalizedMessage());
                        }
                    }
                }
                com.mbridge.msdk.videocommon.download.i.a().d(this.f18218e + "_" + this.f18222i + "_" + this.f18217d, true);
                a.C0239a c0239a = this.f18219f;
                if (c0239a != null) {
                    c0239a.a(true);
                }
                String str2 = this.f18218e + "_" + this.f18220g.getId() + "_" + this.f18220g.getRequestId() + "_" + this.f18217d;
                if (this.f18215b) {
                    if (this.f18220g.isBidCampaign()) {
                        com.mbridge.msdk.videocommon.a.a(com.anythink.expressad.foundation.f.a.f3675x, this.f18220g.getRequestIdNotice(), this.f18219f);
                    } else {
                        com.mbridge.msdk.videocommon.a.a(str2, this.f18219f, false, this.f18221h);
                    }
                } else if (this.f18220g.isBidCampaign()) {
                    com.mbridge.msdk.videocommon.a.a(94, this.f18220g.getRequestIdNotice(), this.f18219f);
                } else {
                    com.mbridge.msdk.videocommon.a.a(str2, this.f18219f, false, this.f18221h);
                }
            }
            com.mbridge.msdk.mbsignalcommon.windvane.g.a().a(webView);
            this.f18223j = true;
        }
    }

    public final synchronized void a(boolean z6, Handler handler, boolean z7, boolean z8, WindVaneWebView windVaneWebView, String str, int i6, CampaignEx campaignEx, List<CampaignEx> list, String str2, String str3, String str4, String str5, String str6, com.mbridge.msdk.videocommon.d.c cVar, j jVar) {
        WindVaneWebView windVaneWebView2;
        com.mbridge.msdk.video.signal.a.j jVar2;
        String str7 = str4 + "_" + str;
        long currentTimeMillis = System.currentTimeMillis();
        try {
        } catch (Exception e6) {
            e = e6;
        }
        if (u.f(str)) {
            if (jVar != null) {
                jVar.a(str7, str3, str4, str5, str, null);
            }
            return;
        }
        try {
            com.mbridge.msdk.reward.b.a.a(campaignEx, com.mbridge.msdk.foundation.controller.a.e().g(), "start preload template ", str4, z8, str5, str6, System.currentTimeMillis() - currentTimeMillis);
        } catch (Exception unused) {
        }
        a.C0239a c0239a = new a.C0239a();
        WindVaneWebView a7 = m.f18225a.a(false);
        if (a7 == null) {
            try {
                windVaneWebView2 = new WindVaneWebView(com.mbridge.msdk.foundation.controller.a.e().g());
            } catch (Exception e7) {
                if (jVar != null) {
                    c0239a.a(true);
                    com.mbridge.msdk.videocommon.download.i.a().d(str4 + "_" + str5 + "_" + str, true);
                    try {
                        com.mbridge.msdk.reward.b.a.a(campaignEx, com.mbridge.msdk.foundation.controller.a.e().g(), "WebView exception: " + e7.getMessage(), str4, z8, str5, str6, System.currentTimeMillis() - currentTimeMillis);
                    } catch (Exception unused2) {
                    }
                    jVar.a(str4 + "_" + str, str3, str4, str5, str, c0239a);
                    return;
                }
                return;
            } catch (Throwable th) {
                if (jVar != null) {
                    c0239a.a(true);
                    com.mbridge.msdk.videocommon.download.i.a().d(str4 + "_" + str5 + "_" + str, true);
                    try {
                        com.mbridge.msdk.reward.b.a.a(campaignEx, com.mbridge.msdk.foundation.controller.a.e().g(), "WebView exception: " + th.getMessage(), str4, z8, str5, str6, System.currentTimeMillis() - currentTimeMillis);
                    } catch (Exception unused3) {
                    }
                    jVar.a(str4 + "_" + str, str3, str4, str5, str, c0239a);
                    return;
                }
                return;
            }
        } else {
            windVaneWebView2 = a7;
        }
        c0239a.a(windVaneWebView2);
        if (list != null && list.size() > 0) {
            jVar2 = new com.mbridge.msdk.video.signal.a.j(null, campaignEx, list);
        } else {
            jVar2 = new com.mbridge.msdk.video.signal.a.j(null, campaignEx);
        }
        com.mbridge.msdk.video.signal.a.j jVar3 = jVar2;
        jVar3.a(i6);
        jVar3.a(str4);
        jVar3.a(cVar);
        jVar3.d(z6);
        WindVaneWebView windVaneWebView3 = windVaneWebView2;
        try {
            windVaneWebView3.setWebViewListener(new k(handler, null, z7, z8, str5, jVar, windVaneWebView, str, str3, str4, c0239a, campaignEx, list, currentTimeMillis));
            windVaneWebView3.setObject(jVar3);
            windVaneWebView3.loadUrl(str2);
            try {
                windVaneWebView3.setRid(str5);
            } catch (Exception e8) {
                e = e8;
                if (MBridgeConstans.DEBUG) {
                    q.d("RewardCampaignsResourceManager", e.getLocalizedMessage());
                }
                if (jVar != null) {
                    jVar.a(str7, str3, str4, str5, str, null, e.getLocalizedMessage());
                }
            }
        } catch (Exception e9) {
            e = e9;
        }
    }

    public final class AnonymousClass2 implements g.d {

        final String f18097a;

        final String f18098b;

        final String f18099c;

        final i f18100d;

        final Context f18101e;

        final CampaignEx f18102f;

        AnonymousClass2(String str22, String str4, String str32, i iVar2, Context context2, CampaignEx campaignEx2) {
            r2 = str22;
            r3 = str4;
            r4 = str32;
            r5 = iVar2;
            r6 = context2;
            r7 = campaignEx2;
        }

        @Override
        public final void a(String str4) {
            try {
                com.mbridge.msdk.videocommon.download.i.a().b(str4, true);
                Message obtain2 = Message.obtain();
                obtain2.what = 105;
                Bundle bundle2 = new Bundle();
                bundle2.putString("unit_id", r2);
                bundle2.putString(MBridgeConstans.PLACEMENT_ID, r3);
                bundle2.putString("request_id", r4);
                bundle2.putString("url", str4);
                obtain2.setData(bundle2);
                c.this.f18085a.sendMessage(obtain2);
                i iVar2 = r5;
                if (iVar2 != null) {
                    iVar2.a(r3, r2, r4, str4);
                }
                com.mbridge.msdk.foundation.entity.m mVar = new com.mbridge.msdk.foundation.entity.m();
                mVar.o(p.f3632m);
                Context context2 = r6;
                if (context2 != null) {
                    mVar.c(com.mbridge.msdk.foundation.tools.m.n(context2.getApplicationContext()));
                }
                mVar.d(1);
                CampaignEx campaignEx2 = r7;
                if (campaignEx2 != null) {
                    mVar.n(campaignEx2.getId());
                    mVar.k(r7.getRequestId());
                    mVar.l(r7.getRequestIdNotice());
                }
                mVar.i(str4);
                mVar.p("");
                mVar.m(r2);
                com.mbridge.msdk.foundation.db.p.a(com.mbridge.msdk.foundation.db.g.a(com.mbridge.msdk.foundation.controller.a.e().g())).a(mVar);
            } catch (Exception e6) {
                com.mbridge.msdk.videocommon.download.i.a().b(str4, false);
                Message obtain3 = Message.obtain();
                obtain3.what = HttpStatus.SC_RESET_CONTENT;
                Bundle bundle3 = new Bundle();
                bundle3.putString("unit_id", r2);
                bundle3.putString(MBridgeConstans.PLACEMENT_ID, r3);
                bundle3.putString("request_id", r4);
                bundle3.putString("url", str4);
                obtain3.setData(bundle3);
                c.this.f18085a.sendMessage(obtain3);
                i iVar3 = r5;
                if (iVar3 != null) {
                    iVar3.a(r3, r2, r4, str4, e6.getLocalizedMessage());
                }
                com.mbridge.msdk.foundation.entity.m mVar2 = new com.mbridge.msdk.foundation.entity.m();
                mVar2.o(p.f3632m);
                Context context3 = r6;
                if (context3 != null) {
                    mVar2.c(com.mbridge.msdk.foundation.tools.m.n(context3.getApplicationContext()));
                }
                mVar2.d(3);
                CampaignEx campaignEx3 = r7;
                if (campaignEx3 != null) {
                    mVar2.n(campaignEx3.getId());
                    mVar2.k(r7.getRequestId());
                    mVar2.l(r7.getRequestIdNotice());
                }
                mVar2.i(str4);
                mVar2.p(e6.getLocalizedMessage());
                mVar2.m(r2);
                com.mbridge.msdk.foundation.db.p.a(com.mbridge.msdk.foundation.db.g.a(com.mbridge.msdk.foundation.controller.a.e().g())).a(mVar2);
                if (MBridgeConstans.DEBUG) {
                    q.d("RewardCampaignsResourceManager", e6.getLocalizedMessage());
                }
            }
        }

        @Override
        public final void a(String str4, String str5) {
            try {
                com.mbridge.msdk.videocommon.download.i.a().b(str5, false);
                Message obtain2 = Message.obtain();
                obtain2.what = HttpStatus.SC_RESET_CONTENT;
                Bundle bundle2 = new Bundle();
                bundle2.putString("unit_id", r2);
                bundle2.putString(MBridgeConstans.PLACEMENT_ID, r3);
                bundle2.putString("request_id", r4);
                bundle2.putString("url", str5);
                bundle2.putString("message", str4);
                obtain2.setData(bundle2);
                c.this.f18085a.sendMessage(obtain2);
                i iVar2 = r5;
                if (iVar2 != null) {
                    iVar2.a(r3, r2, r4, str5, str4);
                }
                com.mbridge.msdk.foundation.entity.m mVar = new com.mbridge.msdk.foundation.entity.m();
                mVar.o(p.f3632m);
                Context context2 = r6;
                if (context2 != null) {
                    mVar.c(com.mbridge.msdk.foundation.tools.m.n(context2.getApplicationContext()));
                }
                mVar.d(3);
                CampaignEx campaignEx2 = r7;
                if (campaignEx2 != null) {
                    mVar.n(campaignEx2.getId());
                    mVar.k(r7.getRequestId());
                    mVar.l(r7.getRequestIdNotice());
                }
                mVar.i(str5);
                mVar.p(str4);
                mVar.m(r2);
                com.mbridge.msdk.foundation.db.p.a(com.mbridge.msdk.foundation.db.g.a(com.mbridge.msdk.foundation.controller.a.e().g())).a(mVar);
            } catch (Exception e6) {
                com.mbridge.msdk.videocommon.download.i.a().b(str5, false);
                Message obtain3 = Message.obtain();
                obtain3.what = 105;
                Bundle bundle3 = new Bundle();
                bundle3.putString("unit_id", r2);
                bundle3.putString(MBridgeConstans.PLACEMENT_ID, r3);
                bundle3.putString("request_id", r4);
                bundle3.putString("url", str5);
                bundle3.putString("message", e6.getMessage());
                obtain3.setData(bundle3);
                c.this.f18085a.sendMessage(obtain3);
                i iVar3 = r5;
                if (iVar3 != null) {
                    iVar3.a(r3, r2, r4, str5, str4);
                }
                if (MBridgeConstans.DEBUG) {
                    q.d("RewardCampaignsResourceManager", e6.getLocalizedMessage());
                }
            }
        }
    }

    public final synchronized void a(boolean z6, Handler handler, boolean z7, boolean z8, String str, String str2, String str3, String str4, String str5, int i6, CampaignEx campaignEx, List<CampaignEx> list, String str6, String str7, com.mbridge.msdk.videocommon.d.c cVar, j jVar, boolean z9) {
        WindVaneWebView windVaneWebView;
        String b6;
        String b7;
        com.mbridge.msdk.video.signal.a.j jVar2;
        MBridgeBTRootLayout mBridgeBTRootLayout;
        this.f18087d = z9;
        long currentTimeMillis = System.currentTimeMillis();
        String str8 = str4 + "_" + str5;
        this.f18087d = z9;
        if (u.f(str5)) {
            if (jVar != null) {
                jVar.a(str8, str3, str4, str, str5, null);
            }
            return;
        }
        try {
            com.mbridge.msdk.reward.b.a.a(campaignEx, com.mbridge.msdk.foundation.controller.a.e().g(), "start preload tpl", str7, z8, str, str2, System.currentTimeMillis() - currentTimeMillis);
        } catch (Exception unused) {
        }
        try {
            a.C0239a c0239a = new a.C0239a();
            WindVaneWebView a7 = m.f18225a.a(true);
            if (a7 == null) {
                a7 = new WindVaneWebView(com.mbridge.msdk.foundation.controller.a.e().g());
            }
            windVaneWebView = a7;
            c0239a.a(windVaneWebView);
            b6 = com.mbridge.msdk.video.bt.a.c.a().b();
            b7 = com.mbridge.msdk.video.bt.a.c.a().b();
            c0239a.a(b7);
            if (list != null && list.size() > 0) {
                List<CampaignEx> a8 = com.mbridge.msdk.videocommon.download.c.getInstance().a(str4);
                if (a8 != null && a8.size() > 0) {
                    for (int i7 = 0; i7 < list.size(); i7++) {
                        CampaignEx campaignEx2 = list.get(i7);
                        for (CampaignEx campaignEx3 : a8) {
                            if (campaignEx3.getId().equals(campaignEx2.getId()) && campaignEx3.getRequestId().equals(campaignEx2.getRequestId())) {
                                campaignEx2.setReady(true);
                                list.set(i7, campaignEx2);
                            }
                        }
                    }
                }
                jVar2 = new com.mbridge.msdk.video.signal.a.j(null, campaignEx, list);
            } else {
                jVar2 = new com.mbridge.msdk.video.signal.a.j(null, campaignEx);
            }
            com.mbridge.msdk.video.signal.a.j jVar3 = jVar2;
            jVar3.a(i6);
            jVar3.a(str7);
            jVar3.c(b7);
            jVar3.d(b6);
            jVar3.c(true);
            jVar3.a(cVar);
            jVar3.d(z6);
            try {
                windVaneWebView.setWebViewListener(new b(z6, handler, null, z7, z8, i6, str5, str3, str4, str, c0239a, campaignEx, list, cVar, jVar, z9, currentTimeMillis));
                windVaneWebView.setObject(jVar3);
                windVaneWebView.loadUrl(str6);
            } catch (Exception e6) {
                e = e6;
            }
        } catch (Exception e7) {
            e = e7;
        }
        try {
            windVaneWebView.setRid(str);
            mBridgeBTRootLayout = new MBridgeBTRootLayout(com.mbridge.msdk.foundation.controller.a.e().g());
            mBridgeBTRootLayout.setLayoutParams(new FrameLayout.LayoutParams(-1, -1));
            mBridgeBTRootLayout.setInstanceId(b6);
        } catch (Exception e8) {
            e = e8;
            if (jVar != null) {
                jVar.a(str8, str3, str4, str, str5, null, e.getMessage());
            }
            if (MBridgeConstans.DEBUG) {
                q.d("RewardCampaignsResourceManager", e.getLocalizedMessage());
            }
        }
        try {
            mBridgeBTRootLayout.setUnitId(str4);
            MBridgeBTLayout mBridgeBTLayout = new MBridgeBTLayout(com.mbridge.msdk.foundation.controller.a.e().g());
            mBridgeBTLayout.setLayoutParams(new FrameLayout.LayoutParams(-1, -1));
            mBridgeBTLayout.setInstanceId(b7);
            mBridgeBTLayout.setUnitId(str4);
            mBridgeBTLayout.setWebView(windVaneWebView);
            AbstractMap b8 = com.mbridge.msdk.video.bt.a.c.a().b(str4, str);
            b8.put(b7, mBridgeBTLayout);
            b8.put(b6, mBridgeBTRootLayout);
            mBridgeBTRootLayout.addView(mBridgeBTLayout, new FrameLayout.LayoutParams(-1, -1));
        } catch (Exception e9) {
            e = e9;
            if (jVar != null) {
            }
            if (MBridgeConstans.DEBUG) {
            }
        }
    }

    private synchronized WindVaneWebView a(boolean z6) {
        if (this.f18088e != null && this.f18088e.size() > 0) {
            return this.f18088e.remove(0);
        }
        Context g6 = com.mbridge.msdk.foundation.controller.a.e().g();
        if (g6 != null) {
            this.f18088e.add(new WindVaneWebView(g6));
            if (z6) {
                this.f18088e.add(new WindVaneWebView(g6));
            }
        }
        return null;
    }

    static void a(c cVar, Context context, String str, String str2, String str3, CampaignEx campaignEx, String str4, i iVar, List list) {
        if (TextUtils.isEmpty(str4) || campaignEx.isMraid()) {
            return;
        }
        if (str4.contains(".zip") && str4.contains(com.anythink.expressad.videocommon.b.k.f5481b)) {
            boolean isEmpty = TextUtils.isEmpty(com.mbridge.msdk.videocommon.download.g.a().b(str4));
            try {
                g gVar = new g(context, str, str2, str3, campaignEx, 497, cVar.f18085a, iVar, list);
                gVar.a(isEmpty);
                com.mbridge.msdk.videocommon.download.g.a().b(str4, gVar);
                return;
            } catch (Exception e6) {
                if (MBridgeConstans.DEBUG) {
                    q.d("RewardCampaignsResourceManager", e6.getLocalizedMessage());
                    return;
                }
                return;
            }
        }
        boolean isEmpty2 = TextUtils.isEmpty(com.mbridge.msdk.videocommon.download.h.a().b(str4));
        try {
            d dVar = new d(497, str, str2, str3, campaignEx, iVar, cVar.f18085a, list);
            dVar.a(isEmpty2);
            com.mbridge.msdk.videocommon.download.g.a().b(str4, dVar);
        } catch (Exception e7) {
            if (MBridgeConstans.DEBUG) {
                q.d("RewardCampaignsResourceManager", e7.getLocalizedMessage());
            }
        }
    }

    static void a(c cVar, boolean z6, WindVaneWebView windVaneWebView, String str, int i6, CampaignEx campaignEx, List list, String str2, String str3, com.mbridge.msdk.videocommon.d.c cVar2, String str4, boolean z7) {
        com.mbridge.msdk.video.signal.a.j jVar;
        String requestId;
        try {
            a.C0239a c0239a = new a.C0239a();
            WindVaneWebView a7 = m.f18225a.a(false);
            if (a7 == null) {
                a7 = new WindVaneWebView(com.mbridge.msdk.foundation.controller.a.e().g());
            }
            WindVaneWebView windVaneWebView2 = a7;
            c0239a.a(windVaneWebView2);
            if (list != null && list.size() > 0) {
                List<CampaignEx> a8 = com.mbridge.msdk.videocommon.download.c.getInstance().a(str3);
                if (a8 != null && a8.size() > 0) {
                    for (int i7 = 0; i7 < list.size(); i7++) {
                        CampaignEx campaignEx2 = (CampaignEx) list.get(i7);
                        for (CampaignEx campaignEx3 : a8) {
                            if (campaignEx3.getId().equals(campaignEx2.getId()) && campaignEx3.getRequestId().equals(campaignEx2.getRequestId())) {
                                campaignEx2.setReady(true);
                                list.set(i7, campaignEx2);
                            }
                        }
                    }
                }
                jVar = new com.mbridge.msdk.video.signal.a.j(null, campaignEx, list);
                requestId = ((CampaignEx) list.get(0)).getRequestId();
            } else {
                jVar = new com.mbridge.msdk.video.signal.a.j(null, campaignEx);
                requestId = campaignEx.getRequestId();
            }
            String str5 = requestId;
            com.mbridge.msdk.video.signal.a.j jVar2 = jVar;
            jVar2.a(i6);
            jVar2.a(str3);
            jVar2.c(str4);
            jVar2.a(cVar2);
            jVar2.d(z6);
            windVaneWebView2.setWebViewListener(new l(str4, false, windVaneWebView, str, str3, c0239a, campaignEx, z7, str5));
            windVaneWebView2.setObject(jVar2);
            windVaneWebView2.loadUrl(str2);
            windVaneWebView2.setRid(str5);
        } catch (Exception e6) {
            if (MBridgeConstans.DEBUG) {
                q.d("RewardCampaignsResourceManager", e6.getLocalizedMessage());
            }
        }
    }
}