package com.bytedance.sdk.openadsdk.activity.single;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.MutableContextWrapper;
import android.content.res.Configuration;
import android.graphics.Bitmap;
import android.os.Build;
import android.os.Bundle;
import android.os.SystemClock;
import android.text.TextUtils;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.DownloadListener;
import android.webkit.WebResourceResponse;
import android.webkit.WebView;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import androidx.annotation.CallSuper;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import com.bykv.vk.openvk.preload.falconx.loader.ILoader;
import com.bykv.vk.openvk.preload.geckox.model.WebResourceResponseModel;
import com.bytedance.sdk.component.adexpress.dynamic.dynamicview.b;
import com.bytedance.sdk.component.utils.gzf;
import com.bytedance.sdk.component.utils.maa;
import com.bytedance.sdk.openadsdk.BuildConfig;
import com.bytedance.sdk.openadsdk.common.duv;
import com.bytedance.sdk.openadsdk.common.fhx;
import com.bytedance.sdk.openadsdk.core.ai;
import com.bytedance.sdk.openadsdk.core.gof;
import com.bytedance.sdk.openadsdk.core.hxv;
import com.bytedance.sdk.openadsdk.core.model.lse;
import com.bytedance.sdk.openadsdk.core.widget.fm.wsy;
import com.bytedance.sdk.openadsdk.onz.ro;
import com.bytedance.sdk.openadsdk.utils.bx;
import com.bytedance.sdk.openadsdk.utils.onz;
import com.bytedance.sdk.openadsdk.utils.qhl;
import com.bytedance.sdk.openadsdk.utils.sds;
import com.bytedance.sdk.openadsdk.utils.wey;
import com.bytedance.sdk.openadsdk.yz.dsz;
import com.bytedance.sdk.openadsdk.yz.lb;
import java.lang.ref.WeakReference;
import java.net.URLEncoder;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.concurrent.atomic.AtomicInteger;

/* JADX INFO: loaded from: classes2.dex */
public class IABLandingPageActivity extends TTBaseLandingPageActivity {
    private static final LinkedList<WeakReference<Activity>> mon = new LinkedList<>();
    protected boolean ai;
    protected lse ajl;
    private boolean bx;
    protected com.bytedance.sdk.openadsdk.core.widget.fm.ajl dsz;
    protected com.bytedance.sdk.openadsdk.common.jnr duv;

    /* JADX INFO: renamed from: ef, reason: collision with root package name */
    protected com.bytedance.sdk.openadsdk.sds.fm.fm.lb f6724ef;
    protected String fhx;
    protected com.bytedance.sdk.component.ef.wsy fm;

    /* JADX INFO: renamed from: gc, reason: collision with root package name */
    private Button f6725gc;
    protected String gof;
    protected String gqi;
    protected int gzf;

    /* JADX INFO: renamed from: ha, reason: collision with root package name */
    protected int f6726ha;
    protected int irt;
    protected com.bytedance.sdk.openadsdk.onz.ro jnr;
    protected wsy.fm ku;

    /* JADX INFO: renamed from: lb, reason: collision with root package name */
    protected com.bytedance.sdk.openadsdk.core.ajl.ajl f6727lb;
    RelativeLayout maa;
    protected int mq;
    protected String onz;
    protected String qhl;
    protected ImageView ro;
    protected com.bytedance.sdk.openadsdk.onz.fm.fm sds;
    private com.bytedance.sdk.openadsdk.onz.yz tzk;
    protected onz vt;
    protected ILoader wey;
    protected hxv wsy;
    protected dsz wu;
    private fhx xgn;
    protected duv yz;
    int lse = -1;
    protected final AtomicInteger hlt = new AtomicInteger(0);
    protected final AtomicInteger hi = new AtomicInteger(0);
    protected final AtomicInteger nt = new AtomicInteger(0);
    protected boolean ol = false;
    protected long wbw = 0;
    private volatile boolean zan = false;

    public static class fm implements com.bytedance.sdk.openadsdk.yz.duv {
        private final int fm;

        /* JADX INFO: renamed from: lb, reason: collision with root package name */
        private final String f6729lb;
        private final lse ro;
        private final WeakReference<IABLandingPageActivity> yz;

        public fm(int i10, lse lseVar, String str, IABLandingPageActivity iABLandingPageActivity) {
            this.fm = i10;
            this.ro = lseVar;
            this.f6729lb = str;
            this.yz = new WeakReference<>(iABLandingPageActivity);
        }

        @Override // com.bytedance.sdk.openadsdk.yz.duv
        public void fm(int i10) {
            IABLandingPageActivity iABLandingPageActivity = this.yz.get();
            if (iABLandingPageActivity == null || iABLandingPageActivity.zan) {
                return;
            }
            lb.fm.fm(this.fm, iABLandingPageActivity.hi.get(), iABLandingPageActivity.nt.get(), iABLandingPageActivity.hlt.get() - iABLandingPageActivity.nt.get(), this.ro, this.f6729lb, i10);
        }
    }

    public static class lb implements View.OnTouchListener {
        private final WeakReference<dsz> fm;
        private final WeakReference<com.bytedance.sdk.openadsdk.common.jnr> ro;

        public lb(dsz dszVar, com.bytedance.sdk.openadsdk.common.jnr jnrVar) {
            this.fm = new WeakReference<>(dszVar);
            this.ro = new WeakReference<>(jnrVar);
        }

        @Override // android.view.View.OnTouchListener
        @SuppressLint({"ClickableViewAccessibility"})
        public boolean onTouch(View view, MotionEvent motionEvent) {
            dsz dszVar = this.fm.get();
            if (dszVar != null) {
                dszVar.fm(motionEvent);
            }
            com.bytedance.sdk.openadsdk.common.jnr jnrVar = this.ro.get();
            if (jnrVar == null) {
                return false;
            }
            jnrVar.fm(motionEvent);
            return false;
        }
    }

    @RequiresApi(api = 23)
    public static class ro implements View.OnScrollChangeListener {
        private final WeakReference<dsz> fm;

        public ro(dsz dszVar) {
            this.fm = new WeakReference<>(dszVar);
        }

        @Override // android.view.View.OnScrollChangeListener
        public void onScrollChange(View view, int i10, int i11, int i12, int i13) {
            dsz dszVar = this.fm.get();
            if (dszVar != null) {
                dszVar.ro(i11);
            }
        }
    }

    private void gqi() {
        if (TextUtils.isEmpty(this.gqi)) {
            return;
        }
        this.wey = com.bytedance.sdk.openadsdk.wsy.ro.fm().ro();
        int iFm = com.bytedance.sdk.openadsdk.wsy.ro.fm().fm(this.wey, this.gqi);
        this.mq = iFm;
        this.gzf = iFm > 0 ? 2 : 0;
    }

    private void gzf() {
        Iterator<WeakReference<Activity>> it = mon.iterator();
        while (it.hasNext()) {
            Activity activity = it.next().get();
            if (activity == this || activity == null) {
                it.remove();
            }
        }
    }

    private void hi() {
        com.bytedance.sdk.component.ef.wsy wsyVar;
        com.bytedance.sdk.component.ef.wsy wsyVar2;
        if (fm()) {
            lse lseVar = this.ajl;
            if (lseVar != null) {
                lseVar.aws(0);
            }
            dsz dszVar = this.wu;
            if (dszVar != null && (wsyVar2 = this.fm) != null) {
                dszVar.fm(wsyVar2);
            }
        } else {
            dsz dszVar2 = this.wu;
            if (dszVar2 != null && (wsyVar = this.fm) != null) {
                dszVar2.fm(wsyVar);
            }
            com.bytedance.sdk.component.ef.wsy wsyVar3 = this.fm;
            if (wsyVar3 != null) {
                gzf.fm(wsyVar3);
            }
        }
        this.fm = null;
    }

    private void hlt() {
        final com.bytedance.sdk.component.ef.wsy wsyVar = this.fm;
        if (wsyVar == null) {
            return;
        }
        wsyVar.postDelayed(new Runnable() { // from class: com.bytedance.sdk.openadsdk.activity.single.IABLandingPageActivity.2
            @Override // java.lang.Runnable
            public void run() {
                wsyVar.scrollBy(0, 1);
                wsyVar.postDelayed(new Runnable() { // from class: com.bytedance.sdk.openadsdk.activity.single.IABLandingPageActivity.2.1
                    @Override // java.lang.Runnable
                    public void run() {
                        AnonymousClass2 anonymousClass2 = AnonymousClass2.this;
                        if (wsyVar == null || IABLandingPageActivity.this.isFinishing()) {
                            return;
                        }
                        wsyVar.scrollBy(0, -1);
                    }
                }, 10L);
            }
        }, 200L);
    }

    private void lse() {
        Activity activity;
        while (true) {
            LinkedList<WeakReference<Activity>> linkedList = mon;
            if (linkedList.isEmpty()) {
                return;
            }
            WeakReference<Activity> weakReferencePollFirst = linkedList.pollFirst();
            if (weakReferencePollFirst != null && (activity = weakReferencePollFirst.get()) != null && !activity.isFinishing()) {
                activity.finish();
                return;
            }
        }
    }

    private void maa() {
        LinkedList<WeakReference<Activity>> linkedList = mon;
        linkedList.add(new WeakReference<>(this));
        if (linkedList.size() > 30) {
            lse();
        }
    }

    private void mq() {
        if (ro() && this.f6726ha == 0) {
            com.bytedance.sdk.openadsdk.onz.fm.fm.lb.fm().ro();
        }
    }

    private void nt() {
        try {
            ((ViewGroup) getWindow().getDecorView()).removeAllViews();
        } catch (Throwable unused) {
        }
        hxv hxvVar = this.wsy;
        if (hxvVar != null) {
            hxvVar.duv();
        }
        dsz dszVar = this.wu;
        if (dszVar != null) {
            dszVar.yz(true);
        }
        if (!TextUtils.isEmpty(this.gqi)) {
            lb.fm.fm(this.nt.get(), this.hlt.get(), this.ajl);
        }
        com.bytedance.sdk.openadsdk.wsy.ro.fm().fm(this.wey);
        onz onzVar = this.vt;
        if (onzVar != null) {
            onzVar.lb();
        }
    }

    private void qhl() {
        try {
            com.bytedance.sdk.component.ef.wsy wsyVar = this.fm;
            if (wsyVar != null) {
                WebView webView = wsyVar.getWebView();
                this.fm.setJavaScriptEnabled(true);
                this.fm.setDomStorageEnabled(true);
                this.fm.setMixedContentMode(0);
                if (!this.bx) {
                    webView.getSettings().setSavePassword(false);
                    this.fm.setAllowFileAccess(false);
                    return;
                }
                com.bytedance.sdk.openadsdk.core.widget.fm.yz.fm(this).fm(false).ro(false).fm(webView);
                this.fm.setLandingPage(this.bx);
                this.fm.setTag("landingpage");
                this.fm.setMaterialMeta(this.ajl.ooo());
                this.fm.setUserAgentString(wey.fm(webView, BuildConfig.VERSION_CODE));
            }
        } catch (Throwable unused) {
        }
    }

    private void sds() {
        if (TextUtils.isEmpty(this.gof)) {
            return;
        }
        com.bytedance.sdk.openadsdk.gof.lb.fm(new com.bytedance.sdk.openadsdk.gof.yz() { // from class: com.bytedance.sdk.openadsdk.activity.single.IABLandingPageActivity.4
            @Override // com.bytedance.sdk.openadsdk.gof.yz
            public com.bytedance.sdk.openadsdk.gof.ro.fm fm() {
                com.bytedance.sdk.openadsdk.gof.ro.fm fmVarD = b.d("lp_reuse");
                fmVarD.yz(IABLandingPageActivity.this.qhl);
                fmVarD.fm(BuildConfig.VERSION_NAME);
                return fmVarD;
            }
        });
        if (!this.ol) {
            this.ol = false;
            com.bytedance.sdk.openadsdk.irt.yz.fm(false);
            com.bytedance.sdk.openadsdk.gof.lb.lb(new com.bytedance.sdk.openadsdk.gof.yz() { // from class: com.bytedance.sdk.openadsdk.activity.single.IABLandingPageActivity.6
                @Override // com.bytedance.sdk.openadsdk.gof.yz
                public com.bytedance.sdk.openadsdk.gof.ro.fm fm() {
                    com.bytedance.sdk.openadsdk.gof.ro.fm fmVarD = b.d("lp_reuse");
                    fmVarD.yz(IABLandingPageActivity.this.qhl);
                    fmVarD.fm(BuildConfig.VERSION_NAME);
                    return fmVarD;
                }
            });
        } else {
            dsz dszVar = this.wu;
            if (dszVar != null) {
                dszVar.jnr(true);
                this.ajl.gqi(true);
            }
            com.bytedance.sdk.openadsdk.gof.lb.ro(new com.bytedance.sdk.openadsdk.gof.yz() { // from class: com.bytedance.sdk.openadsdk.activity.single.IABLandingPageActivity.5
                @Override // com.bytedance.sdk.openadsdk.gof.yz
                public com.bytedance.sdk.openadsdk.gof.ro.fm fm() {
                    com.bytedance.sdk.openadsdk.gof.ro.fm fmVarD = b.d("lp_reuse");
                    fmVarD.yz(IABLandingPageActivity.this.qhl);
                    fmVarD.fm(BuildConfig.VERSION_NAME);
                    return fmVarD;
                }
            });
            com.bytedance.sdk.openadsdk.irt.yz.fm(true);
        }
    }

    private void wey() {
        hxv hxvVar = new hxv(this);
        this.wsy = hxvVar;
        hxvVar.ro(this.fm).lb(this.onz).yz(this.fhx).fm(this.ajl).ro(this.irt).fm(this.ajl.zh()).jnr(this.ajl.uuz()).fm(this.fm).ro("landingpage");
    }

    public void ajl() {
        if (this.bx) {
            fm fmVar = new fm(this.mq, this.ajl, "landingpage", this);
            dsz dszVarRo = new dsz(this.ajl, this.fm.getWebView(), fmVar, this.gzf).ro(true);
            this.wu = dszVarRo;
            this.ku = dszVarRo.fm;
            this.duv = bx.fm(this.ajl, this.fm, this, this.qhl);
            this.wu.jnr(this.ol);
            this.ajl.gqi(this.ol);
            this.tzk = new com.bytedance.sdk.openadsdk.onz.yz(this.wu);
        }
        com.bytedance.sdk.openadsdk.core.widget.fm.ajl ajlVarWsy = wsy();
        this.dsz = ajlVarWsy;
        ajlVarWsy.fm(this.ajl);
        this.dsz.fm("landingpage");
        com.bytedance.sdk.openadsdk.onz.yz yzVar = this.tzk;
        if (yzVar != null) {
            this.dsz.fm(yzVar);
        }
        com.bytedance.sdk.component.ef.wsy wsyVar = this.fm;
        if (wsyVar != null) {
            wsyVar.setWebViewClient(this.dsz);
        }
        if (this.bx) {
            com.bytedance.sdk.openadsdk.yz.lb.fm(this.ajl, "landingpage", this.gzf);
        }
    }

    public void dsz() {
        dsz dszVar;
        if (this.fm == null || TextUtils.isEmpty(this.gof)) {
            return;
        }
        if (!this.bx) {
            try {
                com.bytedance.sdk.openadsdk.utils.lse.fm(this.fm, this.gof);
                return;
            } catch (Throwable th) {
                th.getMessage();
                this.fm.a_(this.gof);
                return;
            }
        }
        if (!fm()) {
            com.bytedance.sdk.openadsdk.utils.lse.fm(this.fm, this.gof);
            return;
        }
        if (!this.ol || (dszVar = this.wu) == null) {
            com.bytedance.sdk.openadsdk.utils.lse.fm(this.fm, this.gof);
            return;
        }
        dszVar.lb(this.gof);
        this.wu.yz(this.gof);
        this.wu.fm(this.gof, 0L);
        duv duvVar = this.yz;
        if (duvVar != null) {
            duvVar.ro();
        }
    }

    public String duv() {
        lse lseVar = this.ajl;
        return (lseVar == null || TextUtils.isEmpty(lseVar.eys())) ? getString(maa.ro(this, "tt_native_banner_download")) : this.ajl.eys();
    }

    public void ef() {
        com.bytedance.sdk.component.ef.wsy wsyVar = this.fm;
        if (wsyVar == null) {
            return;
        }
        wsyVar.setWebChromeClient(new com.bytedance.sdk.openadsdk.core.widget.fm.jnr(this.wsy, this.wu, this.duv) { // from class: com.bytedance.sdk.openadsdk.activity.single.IABLandingPageActivity.8
            @Override // com.bytedance.sdk.openadsdk.core.widget.fm.jnr, android.webkit.WebChromeClient
            public void onProgressChanged(WebView webView, int i10) {
                super.onProgressChanged(webView, i10);
                IABLandingPageActivity.this.fm(i10);
            }

            @Override // android.webkit.WebChromeClient
            public void onReceivedTitle(WebView webView, String str) {
                super.onReceivedTitle(webView, str);
                IABLandingPageActivity.this.fm(webView, str);
            }
        });
    }

    public void fhx() {
        try {
            super.onBackPressed();
        } catch (Throwable th) {
            th.getMessage();
        }
    }

    public void irt() {
        com.bytedance.sdk.component.ef.wsy wsyVar;
        com.bytedance.sdk.openadsdk.onz.ro roVar = this.jnr;
        if (roVar == null || (wsyVar = this.fm) == null) {
            return;
        }
        roVar.fm(wsyVar.getWebView(), this.ku);
    }

    @SuppressLint({"ClickableViewAccessibility"})
    public void jnr() {
        bx.fm(this.ajl, this.fm);
        duv duvVar = this.yz;
        if (duvVar != null) {
            duvVar.fm(this.ajl);
            this.yz.fm();
        }
        this.ro = (ImageView) findViewById(520093716);
    }

    @SuppressLint({"ClickableViewAccessibility"})
    public void ku() {
        lse lseVar = this.ajl;
        if (lseVar == null || lseVar.oy() != 4) {
            return;
        }
        fhx fhxVar = this.xgn;
        if (fhxVar != null) {
            fhxVar.setVisibility(0);
        }
        Button button = (Button) findViewById(qhl.zzn);
        this.f6725gc = button;
        if (button == null) {
            return;
        }
        fm(duv());
        if (this.f6724ef == null) {
            this.f6724ef = com.bytedance.sdk.openadsdk.sds.fm.fm.yz.fm(this, TextUtils.isEmpty(this.qhl) ? bx.ro(this.irt) : this.qhl);
        }
        com.bytedance.sdk.openadsdk.core.lb.fm fmVar = new com.bytedance.sdk.openadsdk.core.lb.fm(this, this.ajl, this.qhl, this.irt);
        fmVar.fm(false);
        fmVar.lb(true);
        fmVar.fm(this.f6724ef);
        this.f6725gc.setOnClickListener(fmVar);
        this.f6725gc.setOnTouchListener(fmVar);
    }

    public View lb() {
        final Bundle bundleFm;
        com.bytedance.sdk.openadsdk.core.ajl.lb lbVar = new com.bytedance.sdk.openadsdk.core.ajl.lb(this);
        if (Build.VERSION.SDK_INT >= 35) {
            lbVar.setFitsSystemWindows(true);
        }
        com.bytedance.sdk.openadsdk.core.ajl.jnr jnrVar = new com.bytedance.sdk.openadsdk.core.ajl.jnr(this);
        jnrVar.setOrientation(1);
        lbVar.addView(jnrVar, new FrameLayout.LayoutParams(-1, -1));
        if (fm()) {
            String str = System.identityHashCode(this.ajl) + "_" + this.gof;
            bundleFm = sds.fm(str);
            this.fm = sds.fm(new MutableContextWrapper(getApplicationContext()), str);
        } else {
            bundleFm = null;
            this.fm = null;
            this.ol = false;
        }
        this.jnr = new com.bytedance.sdk.openadsdk.onz.ro(this, this.ajl, this.f6726ha);
        if (this.fm != null && bundleFm != null && !bundleFm.isEmpty()) {
            this.jnr.fm(this.fm);
        }
        jnrVar.addView(this.jnr.ajl(), new FrameLayout.LayoutParams(-1, -1));
        this.jnr.fm(new ro.fm() { // from class: com.bytedance.sdk.openadsdk.activity.single.IABLandingPageActivity.1
            @Override // com.bytedance.sdk.openadsdk.onz.ro.fm
            public void fm(com.bytedance.sdk.component.ef.wsy wsyVar) {
                IABLandingPageActivity iABLandingPageActivity = IABLandingPageActivity.this;
                iABLandingPageActivity.fm = wsyVar;
                iABLandingPageActivity.maa = iABLandingPageActivity.jnr.fm();
                IABLandingPageActivity iABLandingPageActivity2 = IABLandingPageActivity.this;
                iABLandingPageActivity2.ro = iABLandingPageActivity2.jnr.jnr();
                IABLandingPageActivity iABLandingPageActivity3 = IABLandingPageActivity.this;
                iABLandingPageActivity3.f6727lb = iABLandingPageActivity3.jnr.yz();
                IABLandingPageActivity.this.ro(bundleFm);
            }
        });
        fhx fhxVar = new fhx(this, new fhx.fm() { // from class: com.bytedance.sdk.openadsdk.activity.single.IABLandingPageActivity.3
            @Override // com.bytedance.sdk.openadsdk.common.fhx.fm
            public View fm(Context context) {
                return new com.bytedance.sdk.openadsdk.common.wu(context);
            }
        });
        fhxVar.setId(qhl.ado);
        this.xgn = fhxVar;
        FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(-1, -2);
        layoutParams.gravity = 81;
        jnrVar.addView(fhxVar, layoutParams);
        if (this.f6726ha == 0) {
            fm(lbVar);
        }
        return lbVar;
    }

    @Override // android.app.Activity
    public void onBackPressed() {
        fhx();
    }

    @Override // android.app.Activity, android.content.ComponentCallbacks
    public void onConfigurationChanged(@NonNull Configuration configuration) {
        try {
            super.onConfigurationChanged(configuration);
        } catch (Throwable unused) {
        }
        ku();
    }

    @Override // com.bytedance.sdk.openadsdk.activity.single.TTBaseActivity, android.app.Activity
    public void onCreate(@Nullable Bundle bundle) {
        super.onCreate(bundle);
        if (!com.bytedance.sdk.openadsdk.core.fhx.jnr()) {
            finish();
            return;
        }
        try {
            gof.ro(this);
        } catch (Throwable unused) {
        }
        long jElapsedRealtime = SystemClock.elapsedRealtime();
        if (!fm(bundle)) {
            finish();
            return;
        }
        com.bytedance.sdk.openadsdk.onz.jnr.fm(this);
        try {
            setContentView(lb());
            if (this.bx) {
                lb.fm.fm(SystemClock.elapsedRealtime() - jElapsedRealtime, this.ajl, "landingpage", this.wey, this.gqi);
            }
        } catch (Throwable unused2) {
            finish();
        }
    }

    @Override // com.bytedance.sdk.openadsdk.activity.single.TTBaseLandingPageActivity, com.bytedance.sdk.openadsdk.activity.single.TTBaseActivity, android.app.Activity
    @CallSuper
    public void onDestroy() {
        hi();
        com.bytedance.sdk.component.ef.wsy wsyVar = this.fm;
        if (wsyVar != null) {
            wsyVar.wsy();
        }
        nt();
        mq();
        com.bytedance.sdk.openadsdk.onz.ro roVar = this.jnr;
        if (roVar != null) {
            roVar.wu();
        }
        if (this.f6726ha == 2) {
            gzf();
        }
        this.fm = null;
        this.zan = true;
        com.bytedance.sdk.openadsdk.onz.yz yzVar = this.tzk;
        if (yzVar != null) {
            yzVar.lb();
        }
        super.onDestroy();
    }

    @Override // com.bytedance.sdk.openadsdk.activity.single.TTBaseLandingPageActivity, com.bytedance.sdk.openadsdk.activity.single.TTBaseActivity, android.app.Activity
    @CallSuper
    public void onPause() {
        super.onPause();
        onz onzVar = this.vt;
        if (onzVar != null) {
            onzVar.ro();
        }
        lse lseVar = this.ajl;
        if (lseVar != null) {
            lseVar.wsy(SystemClock.elapsedRealtime());
            this.ajl.aws(0);
        }
    }

    @Override // com.bytedance.sdk.openadsdk.activity.single.TTBaseLandingPageActivity, com.bytedance.sdk.openadsdk.activity.single.TTBaseActivity, android.app.Activity
    @CallSuper
    public void onResume() {
        super.onResume();
        lse lseVar = this.ajl;
        if (lseVar != null) {
            lseVar.aws(1);
        }
        hxv hxvVar = this.wsy;
        if (hxvVar != null) {
            hxvVar.ku();
        }
        dsz dszVar = this.wu;
        if (dszVar != null) {
            dszVar.wsy();
        }
        onz onzVar = this.vt;
        if (onzVar != null) {
            onzVar.fm();
        }
        com.bytedance.sdk.component.ef.wsy wsyVar = this.fm;
        if (wsyVar != null) {
            wsyVar.duv();
            hlt();
        }
        com.bytedance.sdk.openadsdk.onz.ro roVar = this.jnr;
        if (roVar != null) {
            roVar.wsy();
        }
    }

    @Override // android.app.Activity
    public void onSaveInstanceState(Bundle bundle) {
        if (bundle == null) {
            bundle = new Bundle();
        }
        try {
            int iFm = this.ajl != null ? ai.fm().fm(this.ajl) : -1;
            this.lse = iFm;
            bundle.putInt("meta_index", iFm);
        } catch (Throwable unused) {
        }
        super.onSaveInstanceState(bundle);
    }

    @Override // android.app.Activity
    @CallSuper
    public void onStart() {
        super.onStart();
        if (this.lse >= 0) {
            ai.fm().lb(this.lse);
            this.lse = -1;
        }
        com.bytedance.sdk.openadsdk.utils.yz.fm(this, this.ajl);
        lse lseVar = this.ajl;
        if (lseVar != null) {
            lseVar.aws(1);
        }
    }

    @Override // android.app.Activity
    @CallSuper
    public void onStop() {
        super.onStop();
        lse lseVar = this.ajl;
        if (lseVar != null) {
            lseVar.aws(0);
        }
        dsz dszVar = this.wu;
        if (dszVar != null) {
            dszVar.wu();
        }
    }

    @Override // com.bytedance.sdk.openadsdk.activity.single.TTBaseActivity
    public void onz() {
        fhx();
    }

    @SuppressLint({"ClickableViewAccessibility"})
    public void vt() {
        com.bytedance.sdk.component.ef.wsy wsyVar = this.fm;
        if (wsyVar == null || wsyVar.getWebView() == null) {
            return;
        }
        WebView webView = this.fm.getWebView();
        webView.setOnScrollChangeListener(new ro(this.wu));
        webView.setOnTouchListener(new lb(this.wu, this.duv) { // from class: com.bytedance.sdk.openadsdk.activity.single.IABLandingPageActivity.9

            /* JADX INFO: renamed from: lb, reason: collision with root package name */
            private float f6728lb;
            private final int ro = gof.ro();

            @Override // com.bytedance.sdk.openadsdk.activity.single.IABLandingPageActivity.lb, android.view.View.OnTouchListener
            public boolean onTouch(View view, MotionEvent motionEvent) {
                if (IABLandingPageActivity.this.tzk != null) {
                    IABLandingPageActivity.this.tzk.fm();
                }
                int actionMasked = motionEvent.getActionMasked();
                if (actionMasked == 0) {
                    this.f6728lb = motionEvent.getRawY();
                } else if (actionMasked == 2) {
                    float rawY = motionEvent.getRawY();
                    if (rawY - this.f6728lb > this.ro) {
                        IABLandingPageActivity.this.jnr.ro();
                    }
                    if (rawY - this.f6728lb < (-this.ro)) {
                        IABLandingPageActivity.this.jnr.lb();
                    }
                }
                return super.onTouch(view, motionEvent);
            }
        });
        if (this.bx) {
            this.fm.setDownloadListener(new DownloadListener() { // from class: com.bytedance.sdk.openadsdk.activity.single.IABLandingPageActivity.10
                @Override // android.webkit.DownloadListener
                public void onDownloadStart(String str, String str2, String str3, String str4, long j10) {
                    IABLandingPageActivity iABLandingPageActivity = IABLandingPageActivity.this;
                    com.bytedance.sdk.openadsdk.sds.fm.fm.lb lbVar = iABLandingPageActivity.f6724ef;
                    if (lbVar != null) {
                        lbVar.fm(iABLandingPageActivity.ajl);
                    }
                }
            });
        }
    }

    public com.bytedance.sdk.openadsdk.core.widget.fm.ajl wsy() {
        return new com.bytedance.sdk.openadsdk.core.widget.fm.ajl(this, this.wsy, this.onz, this.duv, this.wu, true) { // from class: com.bytedance.sdk.openadsdk.activity.single.IABLandingPageActivity.7
            @Override // com.bytedance.sdk.openadsdk.core.widget.fm.ajl, android.webkit.WebViewClient
            public void onPageFinished(WebView webView, String str) {
                super.onPageFinished(webView, str);
                IABLandingPageActivity.this.wu();
            }

            @Override // com.bytedance.sdk.openadsdk.core.widget.fm.ajl, android.webkit.WebViewClient
            public void onPageStarted(WebView webView, String str, Bitmap bitmap) {
                super.onPageStarted(webView, str, bitmap);
                com.bytedance.sdk.openadsdk.core.ajl.ajl ajlVar = IABLandingPageActivity.this.f6727lb;
                if (ajlVar != null) {
                    ajlVar.setVisibility(0);
                    IABLandingPageActivity.this.f6727lb.setProgress(0);
                }
            }

            @Override // com.bytedance.sdk.openadsdk.core.widget.fm.ajl, android.webkit.WebViewClient
            public WebResourceResponse shouldInterceptRequest(WebView webView, String str) {
                try {
                    if (TextUtils.isEmpty(IABLandingPageActivity.this.gqi)) {
                        return super.shouldInterceptRequest(webView, str);
                    }
                    WebView webView2 = IABLandingPageActivity.this.fm.getWebView();
                    IABLandingPageActivity.this.hlt.incrementAndGet();
                    com.bytedance.sdk.openadsdk.wsy.ro roVarFm = com.bytedance.sdk.openadsdk.wsy.ro.fm();
                    IABLandingPageActivity iABLandingPageActivity = IABLandingPageActivity.this;
                    WebResourceResponseModel webResourceResponseModelFm = roVarFm.fm(iABLandingPageActivity.wey, iABLandingPageActivity.gqi, str);
                    if (webResourceResponseModelFm != null && webResourceResponseModelFm.getWebResourceResponse() != null) {
                        IABLandingPageActivity.this.nt.incrementAndGet();
                        return webResourceResponseModelFm.getWebResourceResponse();
                    }
                    if (webResourceResponseModelFm != null && webResourceResponseModelFm.getMsg() == 2) {
                        IABLandingPageActivity.this.hi.incrementAndGet();
                    }
                    return super.shouldInterceptRequest(webView2, str);
                } catch (Throwable unused) {
                    return super.shouldInterceptRequest(webView, str);
                }
            }
        };
    }

    public void wu() {
        try {
            if (this.f6727lb != null && !isFinishing()) {
                this.f6727lb.setVisibility(8);
            }
        } catch (Throwable unused) {
        }
        duv duvVar = this.yz;
        if (duvVar != null) {
            duvVar.ro();
        }
    }

    @Override // com.bytedance.sdk.openadsdk.activity.single.TTBaseActivity
    public boolean yz() {
        return true;
    }

    public static void ro(Context context, lse lseVar, String str) {
        fm(context, lseVar, str, 2);
    }

    public static void fm(Context context, lse lseVar, String str) {
        if (lseVar == null) {
            return;
        }
        com.bytedance.sdk.openadsdk.core.model.ro roVarDwu = lseVar.dwu();
        if (!TextUtils.isEmpty(roVarDwu.lb())) {
            fm(context, lseVar, fm(roVarDwu.lb(), lseVar), 1);
        }
        com.bytedance.sdk.openadsdk.yz.lb.fm(System.currentTimeMillis(), lseVar, str, "open_policy");
        com.bytedance.sdk.openadsdk.component.yz.fm.fm(lseVar, lseVar.mv());
    }

    public boolean ro() {
        return com.bytedance.sdk.openadsdk.hlt.jnr.fm("lp_iab_history", true) && this.bx;
    }

    /* JADX INFO: Access modifiers changed from: private */
    public void ro(Bundle bundle) {
        qhl();
        gqi();
        if (this.bx) {
            wey();
            ku();
        }
        ajl();
        ef();
        vt();
        jnr();
        if (this.fm != null && bundle != null && !bundle.isEmpty() && this.fm.getWebView() != null) {
            this.fm.getWebView().restoreState(bundle);
            this.jnr.fm(bundle);
            this.ol = true;
        }
        dsz();
        if (fm()) {
            sds();
        }
    }

    private static void fm(Context context, lse lseVar, String str, int i10) {
        if (context == null || lseVar == null) {
            return;
        }
        Intent intent = new Intent(context, (Class<?>) IABLandingPageActivity.class);
        intent.putExtra("scene", i10);
        intent.putExtra("meta_index", ai.fm().fm(lseVar));
        intent.putExtra("landing_url", str);
        com.bytedance.sdk.component.utils.ro.fm(context, intent, null);
    }

    private boolean fm(Bundle bundle) {
        Intent intent = getIntent();
        this.f6726ha = intent.getIntExtra("scene", 0);
        this.gof = intent.getStringExtra("landing_url");
        int i10 = this.f6726ha;
        this.bx = i10 == 0 || i10 == 2;
        if (bundle != null) {
            try {
                int i11 = bundle.getInt("meta_index", -1);
                this.lse = i11;
                if (i11 >= 0) {
                    this.ajl = ai.fm().fm(this.lse);
                }
            } catch (Throwable unused) {
            }
        }
        if (this.ajl == null) {
            this.ajl = ai.fm().fm(ai.fm(intent));
        }
        if (this.ajl == null || TextUtils.isEmpty(this.gof)) {
            return false;
        }
        fm(this.ajl, this.f6726ha);
        if (this.f6726ha == 2) {
            maa();
        }
        if (fm()) {
            sds.fm(this.ajl);
        }
        return true;
    }

    private void ro(WebView webView, String str) {
        try {
            if (TextUtils.isEmpty(str)) {
                str = this.gof;
            }
            this.sds = new com.bytedance.sdk.openadsdk.onz.fm.fm();
            this.sds.ro(this.ajl.yz().ro());
            this.sds.lb(String.valueOf(System.currentTimeMillis()));
            this.sds.jnr(webView.getUrl());
            this.sds.ro(this.ajl.xio());
            this.sds.fm(com.bytedance.sdk.openadsdk.onz.fm.fm.lb.fm().lb(this.ajl.lo()));
            this.sds.yz(str);
            com.bytedance.sdk.openadsdk.onz.fm.fm.lb.fm().ro(this.sds);
        } catch (Exception unused) {
        }
    }

    private static String fm(String str, lse lseVar) {
        String strGzf = lseVar != null ? lseVar.gzf() : null;
        if (!TextUtils.isEmpty(strGzf) && !TextUtils.isEmpty(str)) {
            try {
                String strEncode = URLEncoder.encode(strGzf);
                if (str.contains("?")) {
                    str = str + "&gdid_encrypted=" + strEncode;
                } else {
                    str = str + "?gdid_encrypted=" + strEncode;
                }
            } catch (Exception unused) {
            }
        }
        return str;
    }

    private void fm(lse lseVar, int i10) {
        if (i10 == 0) {
            this.ai = lseVar.onz();
            lseVar.aws(0);
        }
        this.onz = lseVar.eo();
        this.fhx = lseVar.gt();
        this.gqi = lseVar.kec();
        this.irt = lseVar.dsz();
        this.qhl = lseVar.duv();
    }

    public boolean fm() {
        return com.bytedance.sdk.openadsdk.hlt.jnr.fm("lp_cache_enable", false) && this.f6726ha == 0;
    }

    private void fm(FrameLayout frameLayout) {
        duv duvVar = new duv(this);
        this.yz = duvVar;
        duvVar.setOnlyLoading(this.ai);
        this.yz.setId(520093721);
        frameLayout.addView(this.yz, new FrameLayout.LayoutParams(-1, -1));
    }

    public void fm(WebView webView, String str) {
        this.jnr.fm(str);
        String url = webView.getUrl();
        if (url == null) {
            url = "";
        }
        this.jnr.ro(url);
        if (ro()) {
            ro(webView, str);
        }
    }

    public void fm(int i10) {
        duv duvVar = this.yz;
        if (duvVar != null) {
            duvVar.fm(i10);
        }
        if (this.f6727lb != null && !isFinishing()) {
            if (i10 == 100 && this.f6727lb.isShown()) {
                this.f6727lb.setVisibility(8);
            } else {
                this.f6727lb.setProgress(i10);
            }
        }
        long jCurrentTimeMillis = System.currentTimeMillis();
        if (jCurrentTimeMillis - this.wbw >= 200 || i10 == 100) {
            irt();
            this.wbw = jCurrentTimeMillis;
        }
    }

    public void fm(String str) {
        if (TextUtils.isEmpty(str) || this.f6725gc == null || isFinishing()) {
            return;
        }
        this.f6725gc.setText(str);
    }
}
