TikTok.apk(点击下载) / CrossPlatformWebView.java


package com.ss.android.ugc.aweme.crossplatform.view;

import X.AbstractC23460wR;
import X.AbstractC24850yg;
import X.AbstractC24860yh;
import X.AbstractC47603Ime;
import X.AbstractC47907IrY;
import X.AbstractC47918Irj;
import X.AbstractC48125Iv4;
import X.AbstractC48129Iv8;
import X.AbstractC48266IxL;
import X.AbstractC48272IxR;
import X.AbstractC48274IxT;
import X.AbstractC48325IyI;
import X.AbstractC56922Mf;
import X.AnonymousClass0E3;
import X.AnonymousClass0ED;
import X.AnonymousClass0EJ;
import X.AnonymousClass0NL;
import X.AnonymousClass0WJ;
import X.AnonymousClass1IL;
import X.AnonymousClass1IM;
import X.AnonymousClass1IX;
import X.AnonymousClass1PN;
import X.AnonymousClass1ZS;
import X.AnonymousClass2XL;
import X.AnonymousClass2XM;
import X.AnonymousClass2XN;
import X.AnonymousClass3EF;
import X.AnonymousClass3JV;
import X.AnonymousClass3JW;
import X.AnonymousClass8RJ;
import X.C017906e;
import X.C12740f9;
import X.C13380gB;
import X.C14300hf;
import X.C16400l3;
import X.C19050pK;
import X.C21090sc;
import X.C23790wy;
import X.C23800wz;
import X.C23860x5;
import X.C37858Etr;
import X.C38141f1;
import X.C40404Ftp;
import X.C41651GXg;
import X.C45916I1h;
import X.C46317IGs;
import X.C46318IGt;
import X.C46319IGu;
import X.C47905IrW;
import X.C48119Iuy;
import X.C48121Iv0;
import X.C48123Iv2;
import X.C48131IvA;
import X.C48135IvE;
import X.C48164Ivh;
import X.C48254Ix9;
import X.C48255IxA;
import X.C48258IxD;
import X.C48259IxE;
import X.C48260IxF;
import X.C48262IxH;
import X.C48263IxI;
import X.C48265IxK;
import X.C48269IxO;
import X.C48271IxQ;
import X.C48283Ixc;
import X.C48289Ixi;
import X.C48308Iy1;
import X.C48327IyK;
import X.C49369Ja2;
import X.C54252By;
import X.C57772Pm;
import X.C60462Zv;
import X.C68942nb;
import X.C69292oA;
import X.C69672om;
import X.C96713rI;
import X.EnumC46226IDf;
import X.JDR;
import X.NRR;
import X.RunnableC30721Jl;
import X.View$OnClickListenerC48261IxG;
import X.View$OnTouchListenerC48267IxM;
import android.app.Activity;
import android.content.Context;
import android.content.ContextWrapper;
import android.content.res.TypedArray;
import android.net.Uri;
import android.os.Looper;
import android.os.SystemClock;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.util.SparseArray;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.widget.FrameLayout;
import com.bytedance.covode.number.Covode;
import com.bytedance.ies.dmt.ui.widget.DmtStatusView;
import com.ss.android.ugc.aweme.ad.preload.AdLandPagePreloadServiceImpl;
import com.ss.android.ugc.aweme.ad.preload.IAdLandPagePreloadService;
import com.ss.android.ugc.aweme.crossplatform.activity.AbsActivityContainer;
import com.ss.android.ugc.aweme.crossplatform.business.AdWebStatBusiness;
import com.ss.android.ugc.aweme.crossplatform.platform.webview.CWebViewInterceptor;
import com.ss.android.ugc.aweme.crossplatform.platform.webview.SingleWebView;
import com.ss.android.ugc.aweme.feed.widget.LineProgressBarView;
import com.zhiliaoapp.musically.R;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.Callable;
import kotlin.g.b.m;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.ThreadMode;
import org.json.JSONObject;

public class CrossPlatformWebView extends FrameLayout implements AbstractC48125Iv4, AbstractC24850yg, AbstractC24860yh {
    public SingleWebView LIZ;
    public final Set<AnonymousClass3JW> LIZIZ;
    public int LIZJ;
    public boolean LIZLLL;
    public AbstractC48266IxL LJ;
    public C69292oA LJFF;
    public String LJI;
    public boolean LJII;
    public final C48260IxF LJIIIIZZ;
    public C19050pK LJIIIZ;
    public final AnonymousClass3JV LJIIJ;
    public boolean LJIIJJI;
    public final AbstractC23460wR LJIIL;
    public boolean LJIILIIL;
    public AbstractC48272IxR LJIILJJIL;
    public final AbstractC47907IrY LJIILL;
    public AbstractC48325IyI LJIILLIIL;
    public AbstractC48129Iv8 LJIIZILJ;
    public final String LJIJ;
    public final C48255IxA LJIJI;
    public Map<String, String> LJIJJ;
    public C48131IvA LJIJJLI;
    public AbstractC47918Irj LJIL;
    public boolean LJJ;
    public Throwable LJJI;
    public long LJJIFFI;
    public final Set<AnonymousClass1IM<Boolean, C23860x5>> LJJII;
    public SparseArray LJJIII;

    static {
        Covode.recordClassIndex(55681);
    }

    public CrossPlatformWebView(Context context, AttributeSet attributeSet) {
        this(context, attributeSet, 4);
    }

    /* JADX INFO: super call moved to the top of the method (can break code semantics) */
    public CrossPlatformWebView(Context context, AttributeSet attributeSet, byte b) {
        super(context, attributeSet, 0);
        C21090sc.LIZ(context);
        this.LJIIIIZZ = new C48260IxF();
        this.LJIIL = AnonymousClass1PN.LIZ((AnonymousClass1IL) C48271IxQ.LIZ);
        this.LIZIZ = new HashSet();
        this.LJIILL = new C48262IxH(this);
        this.LIZJ = 1;
        this.LJIJ = "RN_VIEW";
        C48255IxA ixA = new C48255IxA();
        this.LJIJI = ixA;
        TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, new int[]{R.attr.st});
        m.LIZIZ(obtainStyledAttributes, "");
        boolean z = obtainStyledAttributes.getBoolean(0, false);
        ixA.LIZ(AbsActivityContainer.class, new C48254Ix9(this));
        ixA.LIZ(C69292oA.class, new C48258IxD(this));
        AnonymousClass0EJ.LIZ(getLayoutInflater(), R.layout.a0z, this, true);
        EventBus.LIZ(EventBus.LIZ(), this);
        LJFF();
        this.LJIIJ = new AnonymousClass3JV(this);
        getTimeStatisticsUtils().LIZ = System.currentTimeMillis();
        WebViewFrameLayout webViewFrameLayout = (WebViewFrameLayout) LIZ(R.id.gp_);
        m.LIZIZ(webViewFrameLayout, "");
        if (webViewFrameLayout.getChildCount() == 0) {
            Thread currentThread = Thread.currentThread();
            Looper mainLooper = Looper.getMainLooper();
            m.LIZIZ(mainLooper, "");
            if (m.LIZ(currentThread, mainLooper.getThread())) {
                LIZ(context, z);
            }
        } else {
            View childAt = ((WebViewFrameLayout) LIZ(R.id.gp_)).getChildAt(0);
            if (childAt != null) {
                SingleWebView singleWebView = (SingleWebView) childAt;
                this.LIZ = singleWebView;
                if (singleWebView == null) {
                    m.LIZ("");
                }
                singleWebView.setOverScrollMode(2);
                SingleWebView singleWebView2 = this.LIZ;
                if (singleWebView2 == null) {
                    m.LIZ("");
                }
                singleWebView2.setVisibility(8);
                LJIIIIZZ();
            } else {
                throw new NullPointerException("null cannot be cast to non-null type com.ss.android.ugc.aweme.crossplatform.platform.webview.SingleWebView");
            }
        }
        this.LJJIFFI = -1;
        this.LJJII = new HashSet();
    }

    /* JADX INFO: this call moved to the top of the method (can break code semantics) */
    public /* synthetic */ CrossPlatformWebView(Context context, AttributeSet attributeSet, int i2) {
        this(context, (i2 & 2) != 0 ? null : attributeSet, (byte) 0);
    }

    /* JADX DEBUG: Multi-variable search result rejected for r1v0, resolved type: com.ss.android.ugc.aweme.crossplatform.view.CrossPlatformWebView */
    /* JADX WARN: Multi-variable type inference failed */
    public static /* synthetic */ void LIZ(CrossPlatformWebView crossPlatformWebView, String str, boolean z, Map map, int i2) {
        if ((i2 & 2) != 0) {
            z = false;
        }
        if ((i2 & 4) != 0) {
            map = null;
        }
        crossPlatformWebView.LIZ(str, z, map);
    }

    private void LIZ(String str, String str2, String str3, String str4) {
        C21090sc.LIZ(str);
        C14300hf.LIZ("crossplatform_view", new C12740f9().LIZ("platform", str2).LIZ("status", str).LIZ("module_name", str3).LIZ("url", str4).LIZ);
    }

    /* JADX WARNING: Removed duplicated region for block: B:75:0x0135  */
    /* JADX WARNING: Removed duplicated region for block: B:78:0x013e  */
    /* JADX WARNING: Removed duplicated region for block: B:88:? A[RETURN, SYNTHETIC] */
    private void LIZ(String str, boolean z, Map<String, String> map) {
        C48119Iuy iuy;
        AbstractC48272IxR ixR;
        SingleWebView singleWebView;
        C48283Ixc singleWebViewClient;
        String str2;
        String str3;
        AdWebStatBusiness webStatBusiness;
        C48131IvA crossPlatformParams;
        C48131IvA crossPlatformParams2;
        C48119Iuy iuy2;
        C48119Iuy iuy3;
        C48119Iuy iuy4;
        C48119Iuy iuy5;
        String str4;
        IAdLandPagePreloadService LJFF2;
        AbstractC56922Mf LIZ2;
        C21090sc.LIZ(str);
        this.LJI = str;
        C68942nb LIZ3 = C68942nb.LJII.LIZ();
        this.LJFF = LIZ3.LIZ(getParent() == null ? false : LIZ3.LIZ(str));
        C48131IvA crossPlatformParams3 = getCrossPlatformParams();
        if (!(crossPlatformParams3 == null || (iuy5 = crossPlatformParams3.LIZIZ) == null || (str4 = iuy5.LJIJJ) == null || (LJFF2 = AdLandPagePreloadServiceImpl.LJFF()) == null || (LIZ2 = LJFF2.LIZ()) == null)) {
            LIZ2.LIZIZ(str4);
        }
        C48131IvA crossPlatformParams4 = getCrossPlatformParams();
        boolean z2 = crossPlatformParams4 == null || (iuy4 = crossPlatformParams4.LIZIZ) == null || iuy4.LIZ != 0;
        C54252By.LIZ().LIZ(z2, str);
        C57772Pm.LJIIJJI = z2 && !(((crossPlatformParams = getCrossPlatformParams()) == null || (iuy3 = crossPlatformParams.LIZIZ) == null || iuy3.LJIL != 4) && ((crossPlatformParams2 = getCrossPlatformParams()) == null || (iuy2 = crossPlatformParams2.LIZIZ) == null || iuy2.LJJIFFI != 1));
        if (z2 && (webStatBusiness = getWebStatBusiness()) != null) {
            webStatBusiness.LIZIZ(str);
        }
        if (z) {
            LIZ(Uri.parse(str).buildUpon().appendQueryParameter("reactId", getReactId()).toString(), map);
        } else {
            LIZ(str, map);
        }
        Context context = getContext();
        m.LIZIZ(context, "");
        JDR jdr = new JDR();
        C21090sc.LIZ(context);
        if (C48263IxI.LIZ.compareAndSet(false, true)) {
            C48263IxI.LIZIZ.put(AbstractC48274IxT.class, jdr);
            jdr.LIZ();
        }
        C48131IvA crossPlatformParams5 = getCrossPlatformParams();
        if (crossPlatformParams5 != null && (iuy = crossPlatformParams5.LIZIZ) != null) {
            long j = iuy.LIZ;
            if (j > 0 && iuy.LJJII == 1) {
                if (this.LJIILJJIL == null) {
                    C48265IxK ixK = new C48265IxK();
                    String valueOf = String.valueOf(j);
                    C21090sc.LIZ(valueOf);
                    ixK.LIZIZ = valueOf;
                    String str5 = iuy.LJIIIIZZ;
                    if (str5 == null) {
                        str5 = "";
                    }
                    C21090sc.LIZ(str5);
                    ixK.LIZJ = str5;
                    SingleWebView singleWebView2 = this.LIZ;
                    if (singleWebView2 == null) {
                        m.LIZ("");
                    }
                    C21090sc.LIZ(singleWebView2);
                    ixK.LIZ = singleWebView2;
                    C21090sc.LIZ(str);
                    ixK.LIZLLL = str;
                    ixK.LJ = new NRR();
                    C21090sc.LIZ(ixK);
                    WebView webView = ixK.LIZ;
                    if (!(webView == null || (str2 = ixK.LIZIZ) == null || (str3 = ixK.LIZJ) == null)) {
                        C21090sc.LIZ(AbstractC48274IxT.class);
                        AbstractC48274IxT ixT = (AbstractC48274IxT) C48263IxI.LIZIZ.get(AbstractC48274IxT.class);
                        if (ixT != null) {
                            ixR = ixT.LIZ(webView, str2, str3, ixK.LIZLLL, ixK.LJ);
                            if (ixR != null) {
                                ixR.LIZ();
                            }
                            this.LJIILJJIL = ixR;
                            singleWebView = this.LIZ;
                            if (singleWebView == null) {
                                m.LIZ("");
                            }
                            singleWebViewClient = singleWebView.getSingleWebViewClient();
                            if (singleWebViewClient == null) {
                                singleWebViewClient.LJIIIZ = this.LJIILJJIL;
                                return;
                            }
                            return;
                        }
                    }
                    ixR = null;
                    this.LJIILJJIL = ixR;
                    singleWebView = this.LIZ;
                    if (singleWebView == null) {
                    }
                    singleWebViewClient = singleWebView.getSingleWebViewClient();
                    if (singleWebViewClient == null) {
                    }
                } else if (m.LIZ((Object) "about:blank", (Object) str)) {
                    LJIIIZ();
                }
            }
        }
    }

    private final void LIZ(JSONObject jSONObject, String str, Object obj) {
        if (!AnonymousClass0NL.LIZ(str) && obj != null) {
            try {
                jSONObject.put(str, obj);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    private final Map<String, String> LIZIZ(String str, Map<String, String> map) {
        C48119Iuy iuy;
        C48131IvA crossPlatformParams = getCrossPlatformParams();
        boolean z = true;
        if (!(crossPlatformParams == null || (iuy = crossPlatformParams.LIZIZ) == null || iuy.LIZ == 0 || !(!m.LIZ((Object) str, (Object) "about:blank")))) {
            CWebViewInterceptor.LIZ = str;
            if (C48269IxO.LIZIZ.LIZ() && iuy.LJJJJJ) {
                SingleWebView singleWebView = this.LIZ;
                if (singleWebView == null) {
                    m.LIZ("");
                }
                WebSettings settings = singleWebView.getSettings();
                m.LIZIZ(settings, "");
                String userAgentString = settings.getUserAgentString();
                m.LIZIZ(userAgentString, "");
                String LIZ2 = AnonymousClass1ZS.LIZ(userAgentString, "wv", "", false);
                SingleWebView singleWebView2 = this.LIZ;
                if (singleWebView2 == null) {
                    m.LIZ("");
                }
                WebSettings settings2 = singleWebView2.getSettings();
                m.LIZIZ(settings2, "");
                AnonymousClass0EJ.LIZ(settings2, LIZ2);
            }
        }
        try {
            Boolean enableReferer = C38141f1.LIZ.LIZIZ.getAdLandingPageConfig().getEnableReferer();
            m.LIZIZ(enableReferer, "");
            z = enableReferer.booleanValue();
        } catch (Exception unused) {
        }
        if (!z) {
            return null;
        }
        LinkedHashMap linkedHashMap = new LinkedHashMap();
        if (map != null) {
            linkedHashMap.putAll(map);
        }
        linkedHashMap.put("referer", "https://www.tiktok.com");
        return linkedHashMap;
    }

    private final void LJFF() {
        ((DmtStatusView) LIZ(R.id.d38)).setBuilder(C45916I1h.LIZ(getContext()));
        C46319IGu iGu = new C46318IGt(getContext()).LIZ(R.drawable.ayl).LIZIZ(R.string.ige).LIZJ(R.string.igd).LIZ(EnumC46226IDf.BORDER, R.string.igk, new View$OnClickListenerC48261IxG(this)).LIZ;
        C46317IGs iGs = new C46317IGs(getContext());
        iGs.setStatus(iGu);
        if (AnonymousClass8RJ.LIZIZ(getContext())) {
            iGs.setBackgroundColor(C017906e.LIZJ(getContext(), R.color.l));
        } else {
            iGs.setBackgroundColor(C017906e.LIZJ(getContext(), R.color.c1));
        }
        ((DmtStatusView) LIZ(R.id.b9j)).setBuilder(C45916I1h.LIZ(getContext()).LIZJ(iGs));
    }

    private final void LJIIIIZZ() {
        SingleWebView singleWebView = this.LIZ;
        if (singleWebView == null) {
            m.LIZ("");
        }
        singleWebView.addOnSingleWebViewStatus(new CrossPlatformWebView$initWebView$1(this));
        SingleWebView singleWebView2 = this.LIZ;
        if (singleWebView2 == null) {
            m.LIZ("");
        }
        singleWebView2.addOnWebChromeStatus(new C48259IxE(this));
        ((LineProgressBarView) LIZ(R.id.dpr)).setColor(C017906e.LIZJ(getContext(), R.color.a59));
    }

    private final void LJIIIZ() {
        AbstractC48272IxR ixR = this.LJIILJJIL;
        if (ixR != null) {
            ixR.LIZJ();
        }
        SingleWebView singleWebView = this.LIZ;
        if (singleWebView == null) {
            m.LIZ("");
        }
        C48283Ixc singleWebViewClient = singleWebView.getSingleWebViewClient();
        if (singleWebViewClient != null) {
            singleWebViewClient.LJIIIZ = null;
        }
        this.LJIILJJIL = null;
    }

    private final View getCurrentContainer() {
        if (this.LIZJ != 1) {
            return null;
        }
        SingleWebView singleWebView = this.LIZ;
        if (singleWebView == null) {
            m.LIZ("");
        }
        return singleWebView;
    }

    @Override // X.AbstractC48125Iv4
    public final <T extends AbstractC47603Ime> T LIZ(Class<T> cls) {
        C21090sc.LIZ(cls);
        if (!m.LIZ(cls, AbstractC47907IrY.class)) {
            return new C48308Iy1();
        }
        AbstractC47907IrY irY = this.LJIILL;
        Objects.requireNonNull(irY, "null cannot be cast to non-null type T");
        return irY;
    }

    public View LIZ(int i2) {
        if (this.LJJIII == null) {
            this.LJJIII = new SparseArray();
        }
        View view = (View) this.LJJIII.get(i2);
        if (view != null) {
            return view;
        }
        View findViewById = findViewById(i2);
        this.LJJIII.put(i2, findViewById);
        return findViewById;
    }

    public final void LIZ(int i2, int i3) {
        DmtStatusView dmtStatusView = (DmtStatusView) LIZ(R.id.d38);
        m.LIZIZ(dmtStatusView, "");
        ViewGroup.LayoutParams layoutParams = dmtStatusView.getLayoutParams();
        Objects.requireNonNull(layoutParams, "null cannot be cast to non-null type android.widget.FrameLayout.LayoutParams");
        FrameLayout.LayoutParams layoutParams2 = (FrameLayout.LayoutParams) layoutParams;
        layoutParams2.leftMargin = 0;
        layoutParams2.rightMargin = 0;
        layoutParams2.topMargin = i3;
        layoutParams2.bottomMargin = 0;
        layoutParams2.gravity = i2;
        DmtStatusView dmtStatusView2 = (DmtStatusView) LIZ(R.id.d38);
        m.LIZIZ(dmtStatusView2, "");
        dmtStatusView2.setLayoutParams(layoutParams2);
    }

    @Override // X.AbstractC48125Iv4
    public final void LIZ(Activity activity) {
        C21090sc.LIZ(activity);
        LIZ("onCreate");
    }

    public final void LIZ(Context context, boolean z) {
        C21090sc.LIZ(context);
        if (!C40404Ftp.LIZIZ || !z) {
            this.LIZ = new SingleWebView(context, null, 0, 6, null);
        } else {
            C96713rI LIZ2 = C96713rI.LIZ();
            m.LIZIZ(LIZ2, "");
            SingleWebView LIZIZ2 = LIZ2.LIZIZ();
            if (LIZIZ2 == null) {
                LIZIZ2 = new SingleWebView(context, null, 0, 6, null);
            }
            this.LIZ = LIZIZ2;
        }
        FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(-1, -1);
        SingleWebView singleWebView = this.LIZ;
        if (singleWebView == null) {
            m.LIZ("");
        }
        singleWebView.setOverScrollMode(2);
        SingleWebView singleWebView2 = this.LIZ;
        if (singleWebView2 == null) {
            m.LIZ("");
        }
        singleWebView2.setVisibility(8);
        WebViewFrameLayout webViewFrameLayout = (WebViewFrameLayout) LIZ(R.id.gp_);
        SingleWebView singleWebView3 = this.LIZ;
        if (singleWebView3 == null) {
            m.LIZ("");
        }
        webViewFrameLayout.addView(singleWebView3, layoutParams);
        LJIIIIZZ();
    }

    /* JADX DEBUG: Multi-variable search result rejected for r13v0, resolved type: boolean */
    /* JADX WARN: Multi-variable type inference failed */
    public final void LIZ(Integer num, String str, String str2, boolean z) {
        C48119Iuy iuy;
        C48119Iuy iuy2;
        JSONObject jSONObject = new JSONObject();
        LIZ(jSONObject, "errorCode", num);
        if (!TextUtils.isEmpty(str)) {
            LIZ(jSONObject, "errorDesc", str);
        }
        if (!TextUtils.isEmpty(str2)) {
            Uri parse = Uri.parse(str2);
            LIZ(jSONObject, "url", str2);
            m.LIZIZ(parse, "");
            LIZ(jSONObject, "host", parse.getHost());
            LIZ(jSONObject, "path", parse.getPath());
            if (str2 != null && !AnonymousClass1ZS.LIZIZ(str2, "about:blank", false)) {
                JSONObject jSONObject2 = new JSONObject();
                try {
                    if (m.LIZ((Object) parse.getQueryParameter("_enable_loading_duration_report"), (Object) "1")) {
                        if (!TextUtils.isEmpty(parse.getQueryParameter("_project_name"))) {
                            LIZ(jSONObject2, "project_name", parse.getQueryParameter("_project_name"));
                        }
                        if (!TextUtils.isEmpty(parse.getQueryParameter("_enter_from"))) {
                            LIZ(jSONObject2, "enter_from", parse.getQueryParameter("_enter_from"));
                        }
                        jSONObject2.put("duration", SystemClock.elapsedRealtime() - this.LJJIFFI);
                        C14300hf.LIZ("client_loading_duration", jSONObject2);
                    }
                } catch (Exception unused) {
                }
            }
        }
        C48131IvA crossPlatformParams = getCrossPlatformParams();
        if (((crossPlatformParams == null || (iuy2 = crossPlatformParams.LIZIZ) == null) ? 0 : iuy2.LIZ) > 0) {
            C48131IvA crossPlatformParams2 = getCrossPlatformParams();
            LIZ(jSONObject, "creativeId", (crossPlatformParams2 == null || (iuy = crossPlatformParams2.LIZIZ) == null) ? null : Long.valueOf(iuy.LIZ));
            if (z == 0) {
                C13380gB.LIZ("aweme_ad_landingpage_open_error", 1, jSONObject);
            } else if (this.LJJIFFI > 0) {
                LIZ(jSONObject, "duration", Long.valueOf(SystemClock.elapsedRealtime() - this.LJJIFFI));
            }
            C13380gB.LIZ("aweme_ad_landingpage_open_error_rate", !z, jSONObject);
        }
        C13380gB.LIZ("aweme_webview_open_error_rate", 1 ^ (z ? 1 : 0), jSONObject);
    }

    public final void LIZ(String str) {
        C48123Iv2 iv2;
        C48123Iv2 iv22;
        Integer num;
        C21090sc.LIZ(str);
        C48131IvA crossPlatformParams = getCrossPlatformParams();
        String str2 = null;
        String LIZ2 = (crossPlatformParams == null || (iv22 = crossPlatformParams.LIZ) == null || (num = iv22.LIZ) == null) ? null : AnonymousClass3EF.LIZ(num.intValue());
        String str3 = this.LJI;
        if (str3 != null) {
            str2 = str3;
        } else {
            C48131IvA crossPlatformParams2 = getCrossPlatformParams();
            if (!(crossPlatformParams2 == null || (iv2 = crossPlatformParams2.LIZ) == null)) {
                str2 = iv2.LIZJ;
            }
        }
        LIZ(str, LIZ2, "null", str2);
    }

    /* JADX WARNING: Code restructure failed: missing block: B:79:0x012e, code lost:
        if (r3 == null) goto L_0x0130;
     */
    public void LIZ(String str, Map<String, String> map) {
        String str2;
        Object obj;
        Uri build;
        C48135IvE ivE;
        C48119Iuy iuy;
        AbstractC48266IxL ixL;
        C48123Iv2 iv2;
        C48121Iv0 iv0;
        C48121Iv0 iv02;
        boolean z = true;
        this.LIZJ = 1;
        if (C69672om.LIZ(str)) {
            C48131IvA crossPlatformParams = getCrossPlatformParams();
            if (crossPlatformParams == null || (iv02 = crossPlatformParams.LIZJ) == null || !iv02.LJJIIZ) {
                C48131IvA crossPlatformParams2 = getCrossPlatformParams();
                if (crossPlatformParams2 == null || (iv0 = crossPlatformParams2.LIZJ) == null || iv0.LJJIIJ) {
                    ((DmtStatusView) LIZ(R.id.d38)).LJFF();
                }
            } else {
                LineProgressBarView lineProgressBarView = (LineProgressBarView) LIZ(R.id.dpr);
                m.LIZIZ(lineProgressBarView, "");
                lineProgressBarView.setVisibility(0);
                LJ();
            }
        }
        C48131IvA crossPlatformParams3 = getCrossPlatformParams();
        if (!(crossPlatformParams3 == null || (iv2 = crossPlatformParams3.LIZ) == null)) {
            iv2.LIZ = 1;
        }
        if (!(getActivity() instanceof AnonymousClass0WJ) && (ixL = this.LJ) != null) {
            ixL.LIZJ();
        }
        C54252By LIZ2 = C54252By.LIZ();
        C48131IvA crossPlatformParams4 = getCrossPlatformParams();
        LIZ2.LIZ(crossPlatformParams4 == null || (iuy = crossPlatformParams4.LIZIZ) == null || iuy.LIZ != 0, str);
        SingleWebView singleWebView = this.LIZ;
        if (singleWebView == null) {
            m.LIZ("");
        }
        singleWebView.setVisibility(0);
        SingleWebView singleWebView2 = this.LIZ;
        if (singleWebView2 == null) {
            m.LIZ("");
        }
        singleWebView2.transparentBackground();
        C48131IvA crossPlatformParams5 = getCrossPlatformParams();
        if (!(crossPlatformParams5 == null || (ivE = crossPlatformParams5.LIZLLL) == null || !ivE.LIZIZ)) {
            SingleWebView singleWebView3 = this.LIZ;
            if (singleWebView3 == null) {
                m.LIZ("");
            }
            singleWebView3.setOnTouchListener(View$OnTouchListenerC48267IxM.LIZ);
        }
        this.LJJIFFI = SystemClock.elapsedRealtime();
        String LIZ3 = C60462Zv.LIZ.LIZ(str);
        if (LIZ3 != null) {
            C21090sc.LIZ(LIZ3);
            Iterator it = ((List) ((C37858Etr) C37858Etr.LIZIZ.getValue()).LIZ.getValue()).iterator();
            while (true) {
                if (it.hasNext()) {
                    if (AnonymousClass1ZS.LIZ((CharSequence) LIZ3, (CharSequence) ((String) it.next()), false)) {
                        break;
                    }
                } else {
                    z = false;
                    break;
                }
            }
            if (z && LIZ3 != null) {
                try {
                    Uri parse = Uri.parse(LIZ3);
                    obj = C23790wy.m3constructorimpl((parse == null || !parse.isHierarchical() || parse == null || (build = parse.buildUpon().appendQueryParameter("prefetch_enabled", "1").build()) == null) ? null : build.toString());
                } catch (Throwable th) {
                    obj = C23790wy.m3constructorimpl(C23800wz.LIZ(th));
                }
                if (C23790wy.m8isFailureimpl(obj)) {
                    obj = null;
                }
                str2 = (String) obj;
            }
            str2 = LIZ3;
            if (str2 != null) {
                C69292oA r1 = this.LJFF;
                if (!(r1 == null || !r1.LIZJ || r1 == null)) {
                    SingleWebView singleWebView4 = this.LIZ;
                    if (singleWebView4 == null) {
                        m.LIZ("");
                    }
                    singleWebView4.setMonitorSession(r1);
                }
                SingleWebView singleWebView5 = this.LIZ;
                if (singleWebView5 == null) {
                    m.LIZ("");
                }
                singleWebView5.setAdditionalReportParams(this.LJIJJ);
                m.LIZIZ(str2, "");
                Map<String, String> LIZIZ2 = LIZIZ(str2, map);
                if (LIZIZ2 != null) {
                    SingleWebView singleWebView6 = this.LIZ;
                    if (singleWebView6 == null) {
                        m.LIZ("");
                    }
                    singleWebView6.loadUrl(str2, LIZIZ2);
                } else if (map == null) {
                    SingleWebView singleWebView7 = this.LIZ;
                    if (singleWebView7 == null) {
                        m.LIZ("");
                    }
                    singleWebView7.loadUrl(str2);
                } else {
                    SingleWebView singleWebView8 = this.LIZ;
                    if (singleWebView8 == null) {
                        m.LIZ("");
                    }
                    singleWebView8.loadUrl(str2, map);
                }
                AnonymousClass2XL r12 = AnonymousClass2XL.LJ;
                SingleWebView singleWebView9 = this.LIZ;
                if (singleWebView9 == null) {
                    m.LIZ("");
                }
                C49369Ja2 jsBridge2 = singleWebView9.getJsBridge2();
                if (!(jsBridge2 == null || LIZ3 == null || jsBridge2.LJFF)) {
                    if (AnonymousClass2XL.LIZIZ) {
                        r12.LIZ(jsBridge2, LIZ3);
                    } else {
                        AnonymousClass0ED.LIZ((Callable) AnonymousClass2XM.LIZ).LIZ(new AnonymousClass2XN(jsBridge2, LIZ3), AnonymousClass0ED.LIZIZ, (AnonymousClass0E3) null);
                    }
                }
            }
        }
        C16400l3.LIZIZ(LIZ3);
    }

    public final void LIZ(String str, JSONObject jSONObject) {
        C21090sc.LIZ(str);
        SingleWebView singleWebView = this.LIZ;
        if (singleWebView == null) {
            m.LIZ("");
        }
        if (singleWebView.getVisibility() == 0) {
            SingleWebView singleWebView2 = this.LIZ;
            if (singleWebView2 == null) {
                m.LIZ("");
            }
            singleWebView2.sendEventToWebView(str, jSONObject);
        }
    }

    public void LIZ(String str, boolean z, boolean z2) {
        C21090sc.LIZ(str);
        Uri parse = Uri.parse(str);
        m.LIZIZ(parse, "");
        if (m.LIZ((Object) parse.getScheme(), (Object) "http") || m.LIZ((Object) parse.getScheme(), (Object) "https")) {
            LIZ(this, str, z2, null, 4);
            return;
        }
        String queryParameter = parse.getQueryParameter("url");
        if (queryParameter != null && queryParameter.length() != 0) {
            String queryParameter2 = parse.getQueryParameter("url");
            if (queryParameter2 == null) {
                m.LIZIZ();
            }
            m.LIZIZ(queryParameter2, "");
            LIZ(this, queryParameter2, z2, null, 4);
        }
    }

    public final void LIZ(boolean z) {
        if (z) {
            View LIZ2 = LIZ(R.id.af3);
            m.LIZIZ(LIZ2, "");
            LIZ2.setVisibility(0);
            ((DmtStatusView) LIZ(R.id.d38)).LJFF();
            return;
        }
        View LIZ3 = LIZ(R.id.af3);
        m.LIZIZ(LIZ3, "");
        LIZ3.setVisibility(8);
        ((DmtStatusView) LIZ(R.id.d38)).LIZLLL();
    }

    @Override // X.AbstractC48125Iv4
    public final boolean LIZ() {
        SingleWebView singleWebView = this.LIZ;
        if (singleWebView == null) {
            m.LIZ("");
        }
        if (!singleWebView.canGoBack()) {
            return false;
        }
        SingleWebView singleWebView2 = this.LIZ;
        if (singleWebView2 == null) {
            m.LIZ("");
        }
        singleWebView2.goBack();
        return true;
    }

    @Override // X.AbstractC48125Iv4
    public final void LIZIZ(Activity activity) {
        C21090sc.LIZ(activity);
        C48289Ixi.LIZIZ.LIZ().LIZ(getCurrentContainer(), this.LJI, 1);
        LIZ("viewAppeared", (JSONObject) null);
        JSONObject jSONObject = new JSONObject();
        jSONObject.put("code", this.LJJ ? 2 : 0);
        LIZ("visible", jSONObject);
        this.LJJ = false;
        SingleWebView singleWebView = this.LIZ;
        if (singleWebView == null) {
            m.LIZ("");
        }
        singleWebView.contextResume();
        LIZ("onResume");
    }

    public final boolean LIZIZ() {
        if (this.LIZJ != 1) {
            return false;
        }
        SingleWebView singleWebView = this.LIZ;
        if (singleWebView == null) {
            m.LIZ("");
        }
        return singleWebView.canGoBack();
    }

    @Override // X.AbstractC48125Iv4
    public final void LIZJ() {
        this.LJJ = true;
    }

    @Override // X.AbstractC48125Iv4
    public final void LIZJ(Activity activity) {
        C21090sc.LIZ(activity);
        C48289Ixi.LIZIZ.LIZ().LIZIZ(getCurrentContainer(), this.LJI, 1);
        LIZ("viewDisappeared", (JSONObject) null);
        LIZ("invisible", (JSONObject) null);
        SingleWebView singleWebView = this.LIZ;
        if (singleWebView == null) {
            m.LIZ("");
        }
        singleWebView.contextPause();
        LIZ("onPause");
    }

    public final void LIZLLL() {
        ((DmtStatusView) LIZ(R.id.d38)).LIZLLL();
        ((DmtStatusView) LIZ(R.id.b9j)).LJII();
        DmtStatusView dmtStatusView = (DmtStatusView) LIZ(R.id.b9j);
        m.LIZIZ(dmtStatusView, "");
        dmtStatusView.setVisibility(0);
    }

    @Override // X.AbstractC48125Iv4
    public void LIZLLL(Activity activity) {
        C48289Ixi.LIZIZ.LIZ().LIZIZ(getCurrentContainer(), this.LJI, 2);
        SingleWebView singleWebView = this.LIZ;
        if (singleWebView == null) {
            m.LIZ("");
        }
        singleWebView.contextDestroy();
        LIZ("onDestroy");
        C69292oA r2 = this.LJFF;
        if (!(r2 == null || !r2.LIZJ || r2 == null)) {
            C68942nb.LJII.LIZ().LIZIZ(r2.cj_());
        }
        EventBus.LIZ().LIZIZ(this);
        AnonymousClass3JV r1 = this.LJIIJ;
        CrossPlatformWebView crossPlatformWebView = r1.LIZIZ;
        C21090sc.LIZ(r1);
        crossPlatformWebView.LIZIZ.remove(r1);
        EventBus.LIZ().LIZIZ(r1);
        LJIIIZ();
    }

    public final void LJ() {
        if (this.LJIILIIL) {
            View LIZ2 = LIZ(R.id.zg);
            m.LIZIZ(LIZ2, "");
            LIZ2.setVisibility(0);
        }
    }

    @Override // X.AbstractC44922HkV
    public final void LJI() {
        SingleWebView singleWebView = this.LIZ;
        if (singleWebView == null) {
            m.LIZ("");
        }
        singleWebView.reload();
    }

    @Override // X.AbstractC44922HkV
    public final boolean LJII() {
        return this.LIZLLL;
    }

    public Activity getActivity() {
        Context context = getContext();
        m.LIZIZ(context, "");
        while (context instanceof ContextWrapper) {
            if (context instanceof Activity) {
                return (Activity) context;
            }
            context = ((ContextWrapper) context).getBaseContext();
            m.LIZIZ(context, "");
        }
        return null;
    }

    @Override // X.AbstractC44922HkV
    public AbstractC47918Irj getCrossPlatformBusiness() {
        AbstractC48266IxL ixL = this.LJ;
        if (ixL != null) {
            if (ixL == null) {
                m.LIZIZ();
            }
            AbstractC47918Irj crossPlatformBusiness = ixL.getCrossPlatformBusiness();
            m.LIZIZ(crossPlatformBusiness, "");
            return crossPlatformBusiness;
        }
        if (this.LJIL == null) {
            this.LJIL = C47905IrW.LIZ(this);
        }
        AbstractC47918Irj irj = this.LJIL;
        if (irj == null) {
            m.LIZIZ();
        }
        return irj;
    }

    @Override // X.AbstractC44922HkV
    public C48131IvA getCrossPlatformParams() {
        AbstractC48266IxL ixL = this.LJ;
        if (ixL == null) {
            return this.LJIJJLI;
        }
        if (ixL == null) {
            m.LIZIZ();
        }
        return ixL.getCrossPlatformParams();
    }

    public final int getCurrentMode() {
        return this.LIZJ;
    }

    @Override // X.AbstractC48125Iv4
    public String getCurrentUrl() {
        String str = this.LJI;
        if (str == null) {
            str = "";
        }
        if (AnonymousClass1ZS.LIZ((CharSequence) str, (CharSequence) "wallet/home", false)) {
            return this.LJI;
        }
        SingleWebView singleWebView = this.LIZ;
        if (singleWebView == null) {
            m.LIZ("");
        }
        String url = singleWebView.getUrl();
        return url == null ? "" : url;
    }

    public final AbstractC48129Iv8 getCustomWebViewStatus() {
        return this.LJIIZILJ;
    }

    public final boolean getDisplayed() {
        return this.LJIIJJI;
    }

    public final Throwable getError() {
        return this.LJJI;
    }

    public final AbstractC48325IyI getIFullScreen() {
        return this.LJIILLIIL;
    }

    public LayoutInflater getLayoutInflater() {
        LayoutInflater from = LayoutInflater.from(getContext());
        m.LIZIZ(from, "");
        return from;
    }

    public final String getLogTag() {
        return this.LJIJ;
    }

    public final AnonymousClass3JV getMDidMountHandler() {
        return this.LJIIJ;
    }

    @Override // X.AbstractC48125Iv4
    public C69292oA getMonitorSession() {
        return this.LJFF;
    }

    public String getReactId() {
        C69292oA r0 = this.LJFF;
        if (r0 != null) {
            return r0.cj_();
        }
        return null;
    }

    public final C48260IxF getRegistry() {
        return this.LJIIIIZZ;
    }

    public final C19050pK getSearchEnterParam() {
        return this.LJIIIZ;
    }

    public final boolean getShouldShowProgressBarBg() {
        return this.LJIILIIL;
    }

    public final SingleWebView getSingleWebView() {
        SingleWebView singleWebView = this.LIZ;
        if (singleWebView == null) {
            m.LIZ("");
        }
        return singleWebView;
    }

    @Override // X.AbstractC24850yg
    public Map<Integer, Object> getSubscriberEventTypes() {
        HashMap hashMap = new HashMap();
        hashMap.put(227, new RunnableC30721Jl(CrossPlatformWebView.class, "onEvent", C48164Ivh.class, ThreadMode.POSTING, 0, false));
        hashMap.put(228, new RunnableC30721Jl(CrossPlatformWebView.class, "onJsBroadcastEvent", C41651GXg.class, ThreadMode.MAIN, 0, false));
        return hashMap;
    }

    public final C48327IyK getTimeStatisticsUtils() {
        return (C48327IyK) this.LJIIL.getValue();
    }

    @Override // X.AbstractC48125Iv4
    public C48260IxF getViewStatusRegistry() {
        return this.LJIIIIZZ;
    }

    public final AdWebStatBusiness getWebStatBusiness() {
        AbstractC47918Irj crossPlatformBusiness;
        AbstractC48266IxL ixL = this.LJ;
        if (ixL == null || (crossPlatformBusiness = ixL.getCrossPlatformBusiness()) == null) {
            return null;
        }
        return (AdWebStatBusiness) crossPlatformBusiness.LIZ(AdWebStatBusiness.class);
    }

    public void onDetachedFromWindow() {
        super.onDetachedFromWindow();
        this.LJIIIIZZ.LIZ.clear();
    }

    public final void onEvent(C48164Ivh ivh) {
        String str;
        Activity activity;
        if (ivh != null && (str = ivh.LIZ) != null && str.length() != 0 && AnonymousClass1ZS.LIZ(ivh.LIZ, getReactId(), true) && 1 != 0 && ivh != null && (activity = getActivity()) != null && (!activity.isFinishing()) && activity != null) {
            activity.finish();
        }
    }

    public final void onJsBroadcastEvent(C41651GXg gXg) {
        C21090sc.LIZ(gXg);
        String str = gXg.LIZ;
        JSONObject jSONObject = gXg.LIZIZ;
        m.LIZIZ(str, "");
        LIZ(str, jSONObject);
    }

    public final void setAdditionalReportParams(Map<String, String> map) {
        this.LJIJJ = map;
    }

    @Override // X.AbstractC48125Iv4
    public void setCrossPlatformActivityContainer(AbstractC48266IxL ixL) {
        C21090sc.LIZ(ixL);
        this.LJ = ixL;
        SingleWebView singleWebView = this.LIZ;
        if (singleWebView == null) {
            m.LIZ("");
        }
        singleWebView.setCrossPlatformActivityContainer(ixL);
    }

    public final void setCurrentMode(int i2) {
        this.LIZJ = i2;
    }

    public final void setCustomWebViewStatus(AbstractC48129Iv8 iv8) {
        this.LJIIZILJ = iv8;
    }

    public final void setDisplayed(boolean z) {
        this.LJIIJJI = z;
    }

    @Override // X.AbstractC48125Iv4
    public void setFullScreen(AbstractC48325IyI iyI) {
        C21090sc.LIZ(iyI);
        this.LJIILLIIL = iyI;
    }

    public final void setIFullScreen(AbstractC48325IyI iyI) {
        this.LJIILLIIL = iyI;
    }

    public final void setSearchEnterParam(C19050pK r1) {
        this.LJIIIZ = r1;
    }

    public final void setShouldOverrideInterceptor(AnonymousClass1IX<? super WebView, ? super String, Boolean> r3) {
        C21090sc.LIZ(r3);
        SingleWebView singleWebView = this.LIZ;
        if (singleWebView == null) {
            m.LIZ("");
        }
        singleWebView.setShouldOverrideInterceptor(r3);
    }

    public final void setShouldShowProgressBarBg(boolean z) {
        this.LJIILIIL = z;
    }

    public final void setSingleWebView(SingleWebView singleWebView) {
        C21090sc.LIZ(singleWebView);
        this.LIZ = singleWebView;
    }

    public final void setWebViewTouchListener(View.OnTouchListener onTouchListener) {
        SingleWebView LIZ2 = this.LJIILL.LIZ();
        if (LIZ2 != null) {
            LIZ2.setWebviewTouchListener(onTouchListener);
        }
    }
}