导航菜单

页面标题

页面副标题

小柿子 v1.3.8 - MBridgeH5EndCardView.java 源代码

正在查看: 小柿子 v1.3.8 应用的 MBridgeH5EndCardView.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package com.mbridge.msdk.video.module;

import android.app.Activity;
import android.content.Context;
import android.content.res.Configuration;
import android.graphics.drawable.ColorDrawable;
import android.net.Uri;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.util.Base64;
import android.util.DisplayMetrics;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebView;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import com.mbridge.msdk.MBridgeConstans;
import com.mbridge.msdk.foundation.download.download.H5DownLoadManager;
import com.mbridge.msdk.foundation.download.download.HTMLResourceManager;
import com.mbridge.msdk.foundation.entity.CampaignEx;
import com.mbridge.msdk.foundation.entity.q;
import com.mbridge.msdk.foundation.same.report.h;
import com.mbridge.msdk.foundation.tools.ab;
import com.mbridge.msdk.foundation.tools.af;
import com.mbridge.msdk.foundation.tools.aj;
import com.mbridge.msdk.foundation.tools.ak;
import com.mbridge.msdk.foundation.tools.ap;
import com.mbridge.msdk.foundation.tools.x;
import com.mbridge.msdk.mbsignalcommon.windvane.WindVaneWebView;
import com.mbridge.msdk.mbsignalcommon.windvane.i;
import com.mbridge.msdk.out.Campaign;
import com.mbridge.msdk.playercommon.exoplayer2.C;
import com.mbridge.msdk.playercommon.exoplayer2.extractor.ts.TsExtractor;
import com.qq.e.comm.managers.setting.GlobalSetting;
import com.sigmob.sdk.base.mta.PointCategory;
import java.io.File;
import java.util.HashMap;
import org.json.JSONObject;

public class MBridgeH5EndCardView extends MBridgeH5EndCardViewDiff {
    private int A;
    private boolean B;
    private boolean C;
    private int D;
    private long E;
    private boolean F;
    private boolean G;
    private boolean H;
    private boolean I;
    private boolean J;
    private boolean K;
    private boolean L;
    private boolean M;
    private String N;
    private boolean O;
    private boolean P;
    public View n;
    public RelativeLayout o;
    public ImageView p;
    public WindVaneWebView q;
    public Handler r;
    public String s;
    public boolean t;
    public boolean u;
    public Handler v;
    public boolean w;
    private boolean x;
    private boolean y;
    private int z;

    public class a implements Runnable {
        private MBridgeH5EndCardView b;

        public a(MBridgeH5EndCardView mBridgeH5EndCardView) {
            this.b = mBridgeH5EndCardView;
        }

        @Override
        public final void run() {
            Handler handler;
            try {
                Thread.sleep(300L);
            } catch (InterruptedException e) {
                af.b("CloseRunnable", e.getMessage());
            }
            MBridgeH5EndCardView mBridgeH5EndCardView = this.b;
            if (mBridgeH5EndCardView == null || (handler = mBridgeH5EndCardView.v) == null) {
                return;
            }
            handler.sendEmptyMessage(100);
        }
    }

    public class b implements Runnable {
        private MBridgeH5EndCardView b;

        public b(MBridgeH5EndCardView mBridgeH5EndCardView) {
            this.b = mBridgeH5EndCardView;
        }

        @Override
        public final void run() {
            MBridgeH5EndCardView mBridgeH5EndCardView = this.b;
            if (mBridgeH5EndCardView == null || mBridgeH5EndCardView.C) {
                return;
            }
            this.b.C = true;
            this.b.t = false;
            MBridgeH5EndCardView.this.reportRenderResult(PointCategory.TIMEOUT, 5);
            this.b.e.a(127, "");
            af.a(MBridgeBaseView.TAG, "notify TYPE_NOTIFY_SHOW_NATIVE_ENDCARD");
        }
    }

    public static class c implements Runnable {
        private MBridgeH5EndCardView a;
        private int b;

        public c(MBridgeH5EndCardView mBridgeH5EndCardView, int i) {
            this.a = mBridgeH5EndCardView;
            this.b = i;
        }

        @Override
        public final void run() {
            MBridgeH5EndCardView mBridgeH5EndCardView = this.a;
            if (mBridgeH5EndCardView == null || mBridgeH5EndCardView.b == null) {
                return;
            }
            try {
                if (mBridgeH5EndCardView.B) {
                    af.c(MBridgeBaseView.TAG, "insertEndCardReadyState hasInsertLoadEndCardReport true return");
                    return;
                }
                this.a.B = true;
                q qVar = new q("m_download_end", 12, (this.b * 1000) + "", this.a.b.getendcard_url(), this.a.b.getId(), this.a.unitId, "ready timeout", (ap.b(this.a.b.getendcard_url()) && this.a.b.getendcard_url().contains(".zip")) ? "1" : "2");
                try {
                    if (this.a.b.getAdType() == 287) {
                        qVar.d(GlobalSetting.SPLASH_AD);
                    } else if (this.a.b.getAdType() == 94) {
                        qVar.d("1");
                    } else if (this.a.b.getAdType() == 42) {
                        qVar.d("2");
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
                qVar.f(this.a.b.getRequestId());
                qVar.s(this.a.b.getCurrentLocalRid());
                qVar.g(this.a.b.getRequestIdNotice());
                qVar.c(this.a.b.getAdSpaceT());
                this.a.isLoadSuccess();
            } catch (Throwable th) {
                af.b(MBridgeBaseView.TAG, th.getMessage(), th);
            }
        }
    }

    public class d implements Runnable {
        private MBridgeH5EndCardView b;

        public d(MBridgeH5EndCardView mBridgeH5EndCardView) {
            this.b = mBridgeH5EndCardView;
        }

        @Override
        public final void run() {
            MBridgeH5EndCardView mBridgeH5EndCardView = this.b;
            if (mBridgeH5EndCardView != null) {
                mBridgeH5EndCardView.J = true;
            }
        }
    }

    public class e implements Runnable {
        private MBridgeH5EndCardView b;

        public e(MBridgeH5EndCardView mBridgeH5EndCardView) {
            this.b = mBridgeH5EndCardView;
        }

        @Override
        public final void run() {
            MBridgeH5EndCardView mBridgeH5EndCardView = this.b;
            if (mBridgeH5EndCardView != null) {
                mBridgeH5EndCardView.K = true;
            }
        }
    }

    public class f implements Runnable {
        private MBridgeH5EndCardView b;

        public f(MBridgeH5EndCardView mBridgeH5EndCardView) {
            this.b = mBridgeH5EndCardView;
        }

        @Override
        public final void run() {
            MBridgeH5EndCardView mBridgeH5EndCardView = this.b;
            if (mBridgeH5EndCardView != null) {
                if (!mBridgeH5EndCardView.L) {
                    MBridgeH5EndCardView.this.setCloseVisible(0);
                }
                this.b.G = true;
            }
        }
    }

    public MBridgeH5EndCardView(Context context) {
        super(context);
        this.x = false;
        this.r = new Handler();
        this.t = false;
        this.u = false;
        this.y = false;
        this.z = 1;
        this.A = 1;
        this.B = false;
        this.C = false;
        this.D = 1;
        this.E = 0L;
        this.F = false;
        this.G = false;
        this.H = false;
        this.I = false;
        this.J = false;
        this.K = false;
        this.L = false;
        this.M = false;
        this.N = "";
        this.v = new Handler(Looper.getMainLooper()) {
            @Override
            public final void handleMessage(Message message) {
                super.handleMessage(message);
                if (message.what != 100) {
                    return;
                }
                if (MBridgeH5EndCardView.this.F) {
                    MBridgeH5EndCardView.this.e.a(122, "");
                }
                MBridgeH5EndCardView.this.e.a(103, "");
            }
        };
        this.O = false;
        this.P = false;
        this.w = false;
    }

    public static void f(MBridgeH5EndCardView mBridgeH5EndCardView) {
        try {
            CampaignEx campaignEx = mBridgeH5EndCardView.b;
            if (campaignEx != null) {
                campaignEx.setCampaignUnitId(mBridgeH5EndCardView.unitId);
                com.mbridge.msdk.foundation.d.b.a().c(mBridgeH5EndCardView.unitId + "_1");
                com.mbridge.msdk.foundation.d.b.a().a(mBridgeH5EndCardView.unitId + "_2", mBridgeH5EndCardView.b);
            }
            CampaignEx campaignEx2 = mBridgeH5EndCardView.b;
            if (campaignEx2 == null || !campaignEx2.isMraid()) {
                return;
            }
            ImageView imageView = new ImageView(com.mbridge.msdk.foundation.controller.c.q().c());
            imageView.setBackgroundResource(x.a(com.mbridge.msdk.foundation.controller.c.q().c(), "mbridge_reward_notice", "drawable"));
            ImageView imageView2 = mBridgeH5EndCardView.p;
            RelativeLayout.LayoutParams layoutParams = imageView2 != null ? (RelativeLayout.LayoutParams) imageView2.getLayoutParams() : null;
            RelativeLayout.LayoutParams layoutParams2 = new RelativeLayout.LayoutParams(ak.a(com.mbridge.msdk.foundation.controller.c.q().c(), 12.0f), ak.a(com.mbridge.msdk.foundation.controller.c.q().c(), 12.0f));
            layoutParams2.addRule(9);
            layoutParams2.addRule(10);
            if (layoutParams != null) {
                layoutParams2.leftMargin = layoutParams.rightMargin;
                layoutParams2.topMargin = layoutParams.topMargin;
                layoutParams2.width = layoutParams.width;
                layoutParams2.height = layoutParams.height;
            } else {
                layoutParams2.leftMargin = ak.a(com.mbridge.msdk.foundation.controller.c.q().c(), 12.0f);
                layoutParams2.topMargin = ak.a(com.mbridge.msdk.foundation.controller.c.q().c(), 12.0f);
            }
            mBridgeH5EndCardView.addView(imageView, layoutParams2);
            ak.a(4, imageView, mBridgeH5EndCardView.b, com.mbridge.msdk.foundation.controller.c.q().c(), false, new com.mbridge.msdk.foundation.d.a() {
                public final void a() {
                    String str;
                    try {
                        JSONObject jSONObject = new JSONObject();
                        if (com.mbridge.msdk.foundation.controller.c.q().c() != null) {
                            jSONObject.put("status", 1);
                        }
                        str = jSONObject.toString();
                    } catch (Throwable th) {
                        af.b(MBridgeBaseView.TAG, th.getMessage(), th);
                        str = "";
                    }
                    i.a().a((WebView) MBridgeH5EndCardView.this.q, "onFeedbackAlertStatusNotify", Base64.encodeToString(str.getBytes(), 2));
                }

                public final void b() {
                    String str;
                    try {
                        JSONObject jSONObject = new JSONObject();
                        if (com.mbridge.msdk.foundation.controller.c.q().c() != null) {
                            jSONObject.put("status", 2);
                        }
                        str = jSONObject.toString();
                    } catch (Throwable th) {
                        af.b(MBridgeBaseView.TAG, th.getMessage(), th);
                        str = "";
                    }
                    i.a().a((WebView) MBridgeH5EndCardView.this.q, "onFeedbackAlertStatusNotify", Base64.encodeToString(str.getBytes(), 2));
                }

                public final void a(String str) {
                    String str2;
                    try {
                        JSONObject jSONObject = new JSONObject();
                        if (com.mbridge.msdk.foundation.controller.c.q().c() != null) {
                            jSONObject.put("status", 2);
                        }
                        str2 = jSONObject.toString();
                    } catch (Throwable th) {
                        af.b(MBridgeBaseView.TAG, th.getMessage(), th);
                        str2 = "";
                    }
                    i.a().a((WebView) MBridgeH5EndCardView.this.q, "onFeedbackAlertStatusNotify", Base64.encodeToString(str2.getBytes(), 2));
                }
            });
        } catch (Exception e5) {
            e5.printStackTrace();
        }
    }

    public boolean canBackPress() {
        ImageView imageView = this.p;
        return imageView != null && imageView.getVisibility() == 0;
    }

    @Override
    public void close() {
        try {
            onCloseViewClick();
        } catch (Exception e5) {
            af.b(MBridgeBaseView.TAG, e5.getMessage());
        }
    }

    @Override
    public void defaultShow() {
        super.defaultShow();
    }

    public void excuteEndCardShowTask(int i) {
        this.r.postDelayed(new c(this, i), i * 1000);
    }

    public void excuteTask() {
        if (this.y || this.z <= -1) {
            return;
        }
        this.r.postDelayed(new f(this), this.z * 1000);
    }

    public void executeEndCardShow(int i) {
        this.r.postDelayed(new b(this), i * 1000);
    }

    @Override
    public void expand(String str, boolean z) {
    }

    @Override
    public CampaignEx getMraidCampaign() {
        return this.b;
    }

    public void handlerPlayableException(String str) {
        if (this.u) {
            return;
        }
        this.u = true;
        this.t = false;
        if (this.b != null) {
            q qVar = new q();
            qVar.f(this.b.getRequestId());
            qVar.g(this.b.getRequestIdNotice());
            qVar.e(this.b.getId());
            qVar.h(str);
            h.a(qVar, this.a.getApplicationContext(), this.unitId);
        }
    }

    @Override
    public void init(Context context) {
        int findLayout = findLayout("mbridge_reward_endcard_h5");
        if (findLayout >= 0) {
            View inflate = this.c.inflate(findLayout, (ViewGroup) null);
            this.n = inflate;
            try {
                this.p = (ImageView) inflate.findViewById(findID("mbridge_windwv_close"));
                this.o = (RelativeLayout) inflate.findViewById(findID("mbridge_windwv_content_rl"));
                WindVaneWebView windVaneWebView = new WindVaneWebView(getContext());
                this.q = windVaneWebView;
                CampaignEx campaignEx = this.b;
                if (campaignEx != null) {
                    windVaneWebView.setLocalRequestId(campaignEx.getCurrentLocalRid());
                }
                this.q.setLayoutParams(new RelativeLayout.LayoutParams(-1, -1));
                this.o.addView(this.q);
                this.f = isNotNULL(this.p, this.q);
            } catch (Exception unused) {
                this.f = false;
            }
            addView(this.n, b());
            c();
            e();
        }
    }

    public void install(CampaignEx campaignEx) {
    }

    public boolean isLoadSuccess() {
        return this.t;
    }

    public boolean isPlayable() {
        return this.y;
    }

    @Override
    public void notifyCloseBtn(int i) {
        if (i == 0) {
            this.H = true;
        } else {
            if (i != 1) {
                return;
            }
            this.I = true;
        }
    }

    public void onBackPress() {
        boolean z;
        if (this.G || (((z = this.H) && this.I) || (!(z || !this.J || this.w) || (!z && this.K && this.w)))) {
            onCloseViewClick();
        }
    }

    public void onCloseViewClick() {
        try {
            if (this.q != null) {
                i.a().a((WebView) this.q, "onSystemDestory", "");
                new Thread(new a(this)).start();
            } else {
                this.e.a(103, "");
                this.e.a(119, "webview is null when closing webview");
            }
        } catch (Exception e5) {
            this.e.a(103, "");
            this.e.a(119, "close webview exception" + e5.getMessage());
            af.a(MBridgeBaseView.TAG, e5.getMessage());
        }
        try {
            com.mbridge.msdk.foundation.same.report.d.d dVar = new com.mbridge.msdk.foundation.same.report.d.d();
            dVar.a(com.umeng.analytics.pro.d.y, 2);
            com.mbridge.msdk.foundation.same.report.d.c.a().a("2000152", dVar);
            com.mbridge.msdk.foundation.same.report.d.c.a().a("2000134", this.b);
        } catch (Throwable th) {
            if (MBridgeConstans.DEBUG) {
                th.printStackTrace();
            }
        }
    }

    public void onFinishRedirection(Campaign campaign, String str) {
        if (campaign == null) {
            return;
        }
        aj.a(campaign, this);
    }

    public void onRedirectionFailed(Campaign campaign, String str) {
        if (campaign == null) {
            return;
        }
        aj.a(campaign, this);
    }

    @Override
    public void onSelfConfigurationChanged(Configuration configuration) {
        super.onSelfConfigurationChanged(configuration);
        orientation(configuration);
    }

    public void onStartRedirection(Campaign campaign, String str) {
        aj.b(campaign, this);
    }

    @Override
    public void onVisibilityChanged(View view, int i) {
        super.onVisibilityChanged(view, i);
        if (i != 0 || this.M) {
            return;
        }
        this.M = true;
        setFocusableInTouchMode(true);
        requestFocus();
        requestFocusFromTouch();
    }

    @Override
    public void onWindowFocusChanged(boolean z) {
        super.onWindowFocusChanged(z);
        CampaignEx campaignEx = this.b;
        if (campaignEx == null || !campaignEx.isMraid()) {
            return;
        }
        if (z) {
            com.mbridge.msdk.mbsignalcommon.mraid.a.a().b(this.q, "true");
        } else {
            com.mbridge.msdk.mbsignalcommon.mraid.a.a().b(this.q, "false");
        }
    }

    @Override
    public void open(String str) {
        super.open(str);
    }

    public void orientation(Configuration configuration) {
        try {
            JSONObject jSONObject = new JSONObject();
            if (configuration.orientation == 2) {
                jSONObject.put("orientation", "landscape");
            } else {
                jSONObject.put("orientation", "portrait");
            }
            i.a().a((WebView) this.q, "orientation", Base64.encodeToString(jSONObject.toString().getBytes(), 2));
        } catch (Exception e5) {
            e5.printStackTrace();
        }
    }

    public void preLoadData(com.mbridge.msdk.video.signal.factory.b bVar) {
        int o;
        String a5 = a();
        if (!this.f || this.b == null || TextUtils.isEmpty(a5)) {
            reportRenderResult("PL URL IS NULL", 3);
            this.e.a(127, "");
            this.e.a(TsExtractor.TS_STREAM_TYPE_AC3, "");
        } else {
            this.E = System.currentTimeMillis();
            try {
                reportRenderResult("start", 0);
            } catch (Exception unused) {
            }
            com.mbridge.msdk.foundation.same.g.a aVar = new com.mbridge.msdk.foundation.same.g.a(this.b);
            aVar.a(this.b.getAppName());
            this.q.setDownloadListener(aVar);
            this.q.setCampaignId(this.b.getId());
            this.q.setTempTypeForMetrics(3);
            CampaignEx campaignEx = this.b;
            if (campaignEx != null) {
                this.q.setCampaignEx(campaignEx);
            }
            setCloseVisible(8);
            this.q.setApiManagerJSFactory(bVar);
            if (this.b.isMraid()) {
                this.q.setMraidObject(this);
            }
            final boolean z = a5.contains("wfr=1") || a5.contains("wfl=1");
            this.q.setWebViewListener(new com.mbridge.msdk.mbsignalcommon.b.b() {
                @Override
                public final void a(WebView webView, String str) {
                    super.a(webView, str);
                    MBridgeH5EndCardView mBridgeH5EndCardView = MBridgeH5EndCardView.this;
                    if (mBridgeH5EndCardView.u) {
                        return;
                    }
                    mBridgeH5EndCardView.t = true;
                    mBridgeH5EndCardView.e.a(100, "");
                    if (MBridgeH5EndCardView.this.b != null) {
                        q qVar = new q();
                        qVar.f(MBridgeH5EndCardView.this.b.getRequestId());
                        qVar.g(MBridgeH5EndCardView.this.b.getRequestIdNotice());
                        qVar.e(MBridgeH5EndCardView.this.b.getId());
                        qVar.b(1);
                        qVar.l(String.valueOf(System.currentTimeMillis() - MBridgeH5EndCardView.this.E));
                        qVar.h("onPageFinished");
                        String str2 = "2";
                        if (MBridgeH5EndCardView.this.b.getAdType() == 287) {
                            qVar.d(GlobalSetting.SPLASH_AD);
                        } else if (MBridgeH5EndCardView.this.b.getAdType() == 94) {
                            qVar.d("1");
                        } else if (MBridgeH5EndCardView.this.b.getAdType() == 42) {
                            qVar.d("2");
                        }
                        if (MBridgeH5EndCardView.this.b.isMraid()) {
                            qVar.d(q.a);
                        } else {
                            qVar.n(MBridgeH5EndCardView.this.b.getendcard_url());
                            if (ap.b(MBridgeH5EndCardView.this.b.getendcard_url()) && MBridgeH5EndCardView.this.b.getendcard_url().contains(".zip")) {
                                str2 = "1";
                            }
                            qVar.o(str2);
                            qVar.d(q.b);
                        }
                        MBridgeH5EndCardView mBridgeH5EndCardView2 = MBridgeH5EndCardView.this;
                        h.b(qVar, mBridgeH5EndCardView2.unitId, mBridgeH5EndCardView2.b);
                    }
                    MBridgeH5EndCardView.this.e.a(120, "");
                    if (z) {
                        return;
                    }
                    try {
                        com.mbridge.msdk.foundation.same.report.d.d dVar = new com.mbridge.msdk.foundation.same.report.d.d();
                        dVar.a(com.umeng.analytics.pro.d.y, 3);
                        dVar.a("result", 1);
                        com.mbridge.msdk.foundation.same.report.d.c.a().a("2000155", MBridgeH5EndCardView.this.b, dVar);
                    } catch (Throwable th) {
                        af.b("WindVaneWebView", th.getMessage());
                    }
                }

                @Override
                public final void c(WebView webView, int i) {
                    super.c(webView, i);
                    MBridgeH5EndCardView.this.D = i;
                    if (MBridgeH5EndCardView.this.C) {
                        return;
                    }
                    MBridgeH5EndCardView.this.C = true;
                    if (i == 1) {
                        MBridgeH5EndCardView.this.reportRenderResult("success", 4);
                    } else {
                        MBridgeH5EndCardView.this.e.a(127, "");
                        MBridgeH5EndCardView.this.reportRenderResult("failed", 6);
                    }
                }

                @Override
                public final void a(WebView webView, int i, String str, String str2) {
                    super.a(webView, i, str, str2);
                    MBridgeH5EndCardView mBridgeH5EndCardView = MBridgeH5EndCardView.this;
                    if (mBridgeH5EndCardView.u) {
                        return;
                    }
                    mBridgeH5EndCardView.e.a(118, "onReceivedError " + i + str);
                    MBridgeH5EndCardView.this.reportRenderResult(str, 3);
                    MBridgeH5EndCardView.this.e.a(127, "");
                    MBridgeH5EndCardView.this.e.a(TsExtractor.TS_STREAM_TYPE_AC3, "");
                    MBridgeH5EndCardView.this.u = true;
                }

                @Override
                public final void a(WebView webView, int i) {
                    super.a(webView, i);
                    af.c("WindVaneWebView", "h5EncardView readyStatus:" + i + "- isError" + MBridgeH5EndCardView.this.u);
                    MBridgeH5EndCardView.this.D = i;
                    if (!MBridgeH5EndCardView.this.u) {
                        MBridgeH5EndCardView.a(MBridgeH5EndCardView.this, System.currentTimeMillis() - MBridgeH5EndCardView.this.E, false);
                    }
                    if (z) {
                        try {
                            com.mbridge.msdk.foundation.same.report.d.d dVar = new com.mbridge.msdk.foundation.same.report.d.d();
                            dVar.a(com.umeng.analytics.pro.d.y, 3);
                            dVar.a("result", Integer.valueOf(i));
                            com.mbridge.msdk.foundation.same.report.d.c.a().a("2000155", MBridgeH5EndCardView.this.b, dVar);
                        } catch (Throwable th) {
                            af.b("WindVaneWebView", th.getMessage());
                        }
                    }
                }

                @Override
                public final void a(WebView webView) {
                    super.a(webView);
                    MBridgeH5EndCardView.this.setCloseVisible(0);
                }
            });
            if (TextUtils.isEmpty(this.b.getMraid())) {
                try {
                    this.E = System.currentTimeMillis();
                    String str = this.b.getendcard_url();
                    com.mbridge.msdk.videocommon.d.c a6 = com.mbridge.msdk.videocommon.d.b.a().a(com.mbridge.msdk.foundation.controller.c.q().k(), this.unitId);
                    if (this.y && ap.b(str) && (str.contains("wfr=1") || (a6 != null && a6.o() > 0))) {
                        if (str.contains("wfr=1")) {
                            String[] split = str.split("&");
                            if (split != null && split.length > 0) {
                                for (String str2 : split) {
                                    if (ap.b(str2) && str2.contains("to") && str2.split("=") != null && str2.split("=").length > 0) {
                                        o = ak.a((Object) str2.split("=")[1]);
                                        break;
                                    }
                                }
                            }
                            o = 20;
                        } else {
                            if (a6 != null && a6.o() > 0) {
                                o = a6.o();
                            }
                            o = 20;
                        }
                        if (o >= 0) {
                            excuteEndCardShowTask(o);
                        } else {
                            excuteEndCardShowTask(20);
                        }
                    }
                } catch (Throwable th) {
                    af.b(MBridgeBaseView.TAG, th.getMessage(), th);
                }
            }
            setHtmlSource(HTMLResourceManager.getInstance().getHtmlContentFromUrl(a5));
            if (TextUtils.isEmpty(this.s)) {
                this.q.loadUrl(a5);
            } else {
                this.q.loadDataWithBaseURL(a5, this.s, "text/html", C.UTF8_NAME, null);
            }
        }
        this.w = false;
    }

    public void readyStatus(int i) {
    }

    public void release() {
        Handler handler = this.r;
        if (handler != null) {
            handler.removeCallbacksAndMessages(null);
            this.r = null;
        }
        Handler handler2 = this.v;
        if (handler2 != null) {
            handler2.removeCallbacksAndMessages(null);
            this.v = null;
        }
        this.o.removeAllViews();
        this.q.release();
        this.q = null;
    }

    @Override
    public void reportOpen(String str) {
        CampaignEx mraidCampaign = getMraidCampaign();
        if (mraidCampaign != null) {
            new com.mbridge.msdk.foundation.same.report.i(getContext()).a(mraidCampaign.getRequestId(), mraidCampaign.getRequestIdNotice(), mraidCampaign.getId(), this.unitId, str, this.b.isBidCampaign());
        }
    }

    public void reportRenderResult(String str, int i) {
        if (this.b == null || this.u) {
            return;
        }
        q qVar = new q();
        qVar.f(this.b.getRequestId());
        qVar.g(this.b.getRequestIdNotice());
        qVar.e(this.b.getId());
        qVar.b(i);
        qVar.l(String.valueOf(System.currentTimeMillis() - this.E));
        qVar.h(str);
        String str2 = "2";
        if (this.b.getAdType() == 287) {
            qVar.d(GlobalSetting.SPLASH_AD);
        } else if (this.b.getAdType() == 94) {
            qVar.d("1");
        } else if (this.b.getAdType() == 42) {
            qVar.d("2");
        }
        if (this.b.isMraid()) {
            qVar.d(q.a);
        } else {
            qVar.n(this.b.getendcard_url());
            if (ap.b(this.b.getendcard_url()) && this.b.getendcard_url().contains(".zip")) {
                str2 = "1";
            }
            qVar.o(str2);
            qVar.d(q.b);
        }
        h.b(qVar, this.unitId, this.b);
    }

    public void setCloseDelayShowTime(int i) {
        this.z = i;
    }

    public void setCloseVisible(int i) {
        if (this.f) {
            this.p.setVisibility(i);
        }
    }

    public void setCloseVisibleForMraid(int i) {
        if (this.f) {
            this.L = true;
            if (i == 4) {
                this.p.setImageDrawable(new ColorDrawable(16711680));
            } else {
                this.p.setImageResource(findDrawable("mbridge_reward_close"));
            }
            this.p.setVisibility(0);
        }
    }

    public void setError(boolean z) {
        this.u = z;
    }

    public void setHtmlSource(String str) {
        this.s = str;
    }

    public void setLoadPlayable(boolean z) {
        this.w = z;
    }

    public void setNotchValue(String str, int i, int i5, int i6, int i7) {
        this.N = str;
        CampaignEx campaignEx = this.b;
        if (campaignEx == null || campaignEx.getAdSpaceT() == 2) {
            return;
        }
        af.b(MBridgeBaseView.TAG, "NOTCH H5ENDCARD " + String.format("%1s-%2s-%3s-%4s", Integer.valueOf(i), Integer.valueOf(i5), Integer.valueOf(i6), Integer.valueOf(i7)));
        RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) this.p.getLayoutParams();
        int a5 = ak.a(getContext(), 20.0f);
        layoutParams.setMargins(i + a5, i6 + a5, i5 + a5, i7 + a5);
        this.p.setLayoutParams(layoutParams);
    }

    public void setPlayCloseBtnTm(int i) {
        this.A = i;
    }

    public void setUnitId(String str) {
        this.unitId = str;
    }

    public void startCounterEndCardShowTimer() {
        try {
            String str = this.b.getendcard_url();
            int i = 15;
            if (ap.b(str) && str.contains("wfl=1")) {
                String[] split = str.split("&");
                if (split != null && split.length > 0) {
                    for (String str2 : split) {
                        if (ap.b(str2) && str2.contains(PointCategory.TIMEOUT) && str2.split("=") != null && str2.split("=").length > 0) {
                            i = ak.a((Object) str2.split("=")[1]);
                        }
                    }
                }
                executeEndCardShow(i);
            }
        } catch (Throwable th) {
            af.a(MBridgeBaseView.TAG, th.getMessage());
        }
    }

    @Override
    public void toggleCloseBtn(int i) {
        int visibility = this.p.getVisibility();
        if (i == 1) {
            this.G = true;
            visibility = 0;
        } else if (i == 2) {
            this.G = false;
            visibility = 8;
            if (this.w) {
                if (!this.P && !this.H) {
                    this.P = true;
                    int i5 = this.A;
                    if (i5 == 0) {
                        this.K = true;
                    } else {
                        this.K = false;
                        if (i5 > -1) {
                            this.r.postDelayed(new e(this), this.A * 1000);
                        }
                    }
                }
            } else if (!this.O && !this.H) {
                this.O = true;
                int i6 = this.z;
                if (i6 == 0) {
                    this.J = true;
                } else {
                    this.J = false;
                    if (i6 > -1) {
                        this.r.postDelayed(new d(this), this.z * 1000);
                    }
                }
            }
        }
        setCloseVisible(visibility);
    }

    @Override
    public void unload() {
        close();
    }

    @Override
    public void useCustomClose(boolean z) {
        try {
            setCloseVisibleForMraid(z ? 4 : 0);
        } catch (Exception e5) {
            af.b(MBridgeBaseView.TAG, e5.getMessage());
        }
    }

    public void volumeChange(double d5) {
        com.mbridge.msdk.mbsignalcommon.mraid.a.a().a(this.q, d5);
    }

    public void webviewshow() {
        WindVaneWebView windVaneWebView = this.q;
        if (windVaneWebView != null) {
            windVaneWebView.post(new Runnable() {
                @Override
                public final void run() {
                    String str;
                    try {
                        af.a(MBridgeBaseView.TAG, "webviewshow");
                        try {
                            int[] iArr = new int[2];
                            MBridgeH5EndCardView.this.q.getLocationOnScreen(iArr);
                            af.b(MBridgeBaseView.TAG, "coordinate:" + iArr[0] + "--" + iArr[1]);
                            JSONObject jSONObject = new JSONObject();
                            Context c5 = com.mbridge.msdk.foundation.controller.c.q().c();
                            if (c5 != null) {
                                jSONObject.put("startX", ak.b(c5, iArr[0]));
                                jSONObject.put("startY", ak.b(c5, iArr[1]));
                                jSONObject.put(com.mbridge.msdk.foundation.same.a.l, ak.d(c5));
                            }
                            str = jSONObject.toString();
                        } catch (Throwable th) {
                            af.b(MBridgeBaseView.TAG, th.getMessage(), th);
                            str = "";
                        }
                        i.a().a((WebView) MBridgeH5EndCardView.this.q, "webviewshow", Base64.encodeToString(str.toString().getBytes(), 2));
                        MBridgeH5EndCardView.this.e.a(109, "");
                        MBridgeH5EndCardView.d(MBridgeH5EndCardView.this);
                        MBridgeH5EndCardView.this.startCounterEndCardShowTimer();
                        i a5 = i.a();
                        MBridgeH5EndCardView mBridgeH5EndCardView = MBridgeH5EndCardView.this;
                        a5.a((WebView) mBridgeH5EndCardView.q, "oncutoutfetched", Base64.encodeToString(mBridgeH5EndCardView.N.getBytes(), 0));
                        MBridgeH5EndCardView.f(MBridgeH5EndCardView.this);
                    } catch (Exception e5) {
                        e5.printStackTrace();
                    }
                }
            });
        }
    }

    public static void d(MBridgeH5EndCardView mBridgeH5EndCardView) {
        CampaignEx campaignEx = mBridgeH5EndCardView.b;
        if (campaignEx == null || !campaignEx.isMraid()) {
            return;
        }
        int i = mBridgeH5EndCardView.getResources().getConfiguration().orientation;
        String str = "undefined";
        if (i != 0) {
            if (i == 1) {
                str = "portrait";
            } else if (i == 2) {
                str = "landscape";
            }
        }
        JSONObject jSONObject = new JSONObject();
        try {
            jSONObject.put("orientation", str);
            jSONObject.put(PointCategory.LOCKED, "true");
        } catch (Exception e5) {
            e5.printStackTrace();
        }
        HashMap hashMap = new HashMap();
        hashMap.put("placementType", "Interstitial");
        hashMap.put("state", "default");
        hashMap.put("viewable", "true");
        hashMap.put("currentAppOrientation", jSONObject);
        if (mBridgeH5EndCardView.getContext() instanceof Activity) {
            float t = ab.t(mBridgeH5EndCardView.getContext());
            float r = ab.r(mBridgeH5EndCardView.getContext());
            DisplayMetrics displayMetrics = new DisplayMetrics();
            ((Activity) mBridgeH5EndCardView.getContext()).getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
            float f5 = displayMetrics.widthPixels;
            float f6 = displayMetrics.heightPixels;
            com.mbridge.msdk.mbsignalcommon.mraid.a.a().b(mBridgeH5EndCardView.q, t, r);
            com.mbridge.msdk.mbsignalcommon.mraid.a.a().c(mBridgeH5EndCardView.q, f5, f6);
        }
        com.mbridge.msdk.mbsignalcommon.mraid.a.a().a(mBridgeH5EndCardView.q, r7.getLeft(), mBridgeH5EndCardView.q.getTop(), mBridgeH5EndCardView.q.getWidth(), mBridgeH5EndCardView.q.getHeight());
        com.mbridge.msdk.mbsignalcommon.mraid.a.a().b(mBridgeH5EndCardView.q, r13.getLeft(), mBridgeH5EndCardView.q.getTop(), mBridgeH5EndCardView.q.getWidth(), mBridgeH5EndCardView.q.getHeight());
        com.mbridge.msdk.mbsignalcommon.mraid.a.a().a(mBridgeH5EndCardView.q, hashMap);
        com.mbridge.msdk.mbsignalcommon.mraid.a.a().a(mBridgeH5EndCardView.q, com.mbridge.msdk.mbsignalcommon.mraid.d.a);
        com.mbridge.msdk.mbsignalcommon.mraid.a.a().a(mBridgeH5EndCardView.q);
    }

    public RelativeLayout.LayoutParams b() {
        return new RelativeLayout.LayoutParams(-1, -1);
    }

    @Override
    public final void c() {
        super.c();
        if (this.f) {
            this.p.setOnClickListener(new View.OnClickListener() {
                @Override
                public final void onClick(View view) {
                    MBridgeH5EndCardView.this.onCloseViewClick();
                }
            });
        }
    }

    public void e() {
        if (this.f) {
            setMatchParent();
        }
    }

    public String a() {
        CampaignEx campaignEx = this.b;
        if (campaignEx != null) {
            this.F = true;
            if (campaignEx.isMraid()) {
                this.y = false;
                String mraid = this.b.getMraid();
                if (!TextUtils.isEmpty(mraid)) {
                    File file = new File(mraid);
                    try {
                        if (file.exists() && file.isFile() && file.canRead()) {
                            mraid = "file:////" + mraid;
                        } else {
                            mraid = this.b.getEndScreenUrl();
                        }
                        return mraid;
                    } catch (Throwable th) {
                        if (!MBridgeConstans.DEBUG) {
                            return mraid;
                        }
                        th.printStackTrace();
                        return mraid;
                    }
                }
                return this.b.getEndScreenUrl();
            }
            String str = this.b.getendcard_url();
            if (!ap.a(str)) {
                this.y = true;
                String h5ResAddress = H5DownLoadManager.getInstance().getH5ResAddress(str);
                if (TextUtils.isEmpty(h5ResAddress)) {
                    try {
                        String path = Uri.parse(str).getPath();
                        if (!TextUtils.isEmpty(path) && path.toLowerCase().endsWith(".zip")) {
                            String endScreenUrl = this.b.getEndScreenUrl();
                            if (TextUtils.isEmpty(endScreenUrl)) {
                                return null;
                            }
                            this.y = false;
                            excuteTask();
                            return endScreenUrl;
                        }
                    } catch (Throwable th2) {
                        af.b(MBridgeBaseView.TAG, th2.getMessage());
                    }
                    return str + "&native_adtype=" + this.b.getAdType();
                }
                return h5ResAddress + "&native_adtype=" + this.b.getAdType();
            }
            this.y = false;
            return this.b.getEndScreenUrl();
        }
        this.F = false;
        return null;
    }

    public MBridgeH5EndCardView(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
        this.x = false;
        this.r = new Handler();
        this.t = false;
        this.u = false;
        this.y = false;
        this.z = 1;
        this.A = 1;
        this.B = false;
        this.C = false;
        this.D = 1;
        this.E = 0L;
        this.F = false;
        this.G = false;
        this.H = false;
        this.I = false;
        this.J = false;
        this.K = false;
        this.L = false;
        this.M = false;
        this.N = "";
        this.v = new Handler(Looper.getMainLooper()) {
            @Override
            public final void handleMessage(Message message) {
                super.handleMessage(message);
                if (message.what != 100) {
                    return;
                }
                if (MBridgeH5EndCardView.this.F) {
                    MBridgeH5EndCardView.this.e.a(122, "");
                }
                MBridgeH5EndCardView.this.e.a(103, "");
            }
        };
        this.O = false;
        this.P = false;
        this.w = false;
    }

    public static void a(MBridgeH5EndCardView mBridgeH5EndCardView, long j, boolean z) {
        String str;
        int i;
        int i5;
        try {
            if (mBridgeH5EndCardView.B) {
                return;
            }
            mBridgeH5EndCardView.B = true;
            String str2 = (ap.b(mBridgeH5EndCardView.b.getendcard_url()) && mBridgeH5EndCardView.b.getendcard_url().contains(".zip")) ? "1" : "2";
            if (z) {
                str = "ready timeout";
                i = 12;
                i5 = 2;
            } else if (mBridgeH5EndCardView.D == 2) {
                str = "ready no";
                i = 11;
                i5 = 3;
            } else {
                str = "ready yes";
                i = 10;
                i5 = 1;
            }
            int i6 = i5;
            String str3 = str;
            q qVar = new q("m_download_end", i, j + "", mBridgeH5EndCardView.b.getendcard_url(), mBridgeH5EndCardView.b.getId(), mBridgeH5EndCardView.unitId, str, str2);
            try {
                if (mBridgeH5EndCardView.b.getAdType() == 287) {
                    qVar.d(GlobalSetting.SPLASH_AD);
                } else if (mBridgeH5EndCardView.b.getAdType() == 94) {
                    qVar.d("1");
                } else if (mBridgeH5EndCardView.b.getAdType() == 42) {
                    qVar.d("2");
                }
            } catch (NullPointerException e5) {
                e5.printStackTrace();
            }
            qVar.f(mBridgeH5EndCardView.b.getRequestId());
            qVar.s(mBridgeH5EndCardView.b.getCurrentLocalRid());
            qVar.g(mBridgeH5EndCardView.b.getRequestIdNotice());
            qVar.c(mBridgeH5EndCardView.b.getAdSpaceT());
            try {
                com.mbridge.msdk.videocommon.d.c a5 = com.mbridge.msdk.videocommon.d.b.a().a(com.mbridge.msdk.foundation.controller.c.q().k(), mBridgeH5EndCardView.b.getCampaignUnitId());
                if (a5 != null) {
                    qVar.v(a5.l());
                }
                com.mbridge.msdk.videocommon.d.a b5 = com.mbridge.msdk.videocommon.d.b.a().b();
                if (b5 != null) {
                    qVar.u(b5.c());
                }
            } catch (Exception e6) {
                af.b(MBridgeBaseView.TAG, e6.getMessage());
            }
            if (mBridgeH5EndCardView.isLoadSuccess() || i6 != 1) {
                return;
            }
            qVar.b(i6);
            qVar.l(String.valueOf(j));
            qVar.e(mBridgeH5EndCardView.b.getId());
            qVar.h(str3);
            if (mBridgeH5EndCardView.b.isMraid()) {
                qVar.d(q.a);
            } else {
                qVar.n(mBridgeH5EndCardView.b.getendcard_url());
                qVar.o(str2);
                qVar.d(q.b);
            }
            h.b(qVar, mBridgeH5EndCardView.unitId, mBridgeH5EndCardView.b);
        } catch (Throwable th) {
            af.b(MBridgeBaseView.TAG, th.getMessage(), th);
        }
    }
}