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

import android.R;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.Intent;
import android.content.res.Configuration;
import android.graphics.Bitmap;
import android.net.Uri;
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.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.LinearLayout;
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.ef.wsy;
import com.bytedance.sdk.component.utils.wey;
import com.bytedance.sdk.openadsdk.ApmHelper;
import com.bytedance.sdk.openadsdk.BuildConfig;
import com.bytedance.sdk.openadsdk.FilterWord;
import com.bytedance.sdk.openadsdk.common.TTAdDislikeToast;
import com.bytedance.sdk.openadsdk.common.dsz;
import com.bytedance.sdk.openadsdk.common.duv;
import com.bytedance.sdk.openadsdk.common.fhx;
import com.bytedance.sdk.openadsdk.common.qhl;
import com.bytedance.sdk.openadsdk.common.sds;
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.fm.fm.lb;
import com.bytedance.sdk.openadsdk.utils.bx;
import com.bytedance.sdk.openadsdk.utils.ku;
import com.bytedance.sdk.openadsdk.utils.xgn;
import com.bytedance.sdk.openadsdk.utils.zan;
import com.bytedance.sdk.openadsdk.yz.lb;
import java.lang.ref.WeakReference;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import org.json.JSONObject;

/* JADX INFO: loaded from: classes2.dex */
public class TTHistoryLandingPageActivity extends TTBaseLandingPageActivity {
    private static final LinkedList<WeakReference<Activity>> wsy = new LinkedList<>();
    private wsy.fm ai;
    private dsz bx;
    private String dsz;
    private String duv;

    /* JADX INFO: renamed from: ef, reason: collision with root package name */
    private Context f6744ef;
    private int fhx;
    com.bytedance.sdk.openadsdk.yz.dsz fm;

    /* JADX INFO: renamed from: gc, reason: collision with root package name */
    private ImageView f6745gc;
    private com.bytedance.sdk.openadsdk.sds.fm.fm.lb gof;
    private com.bytedance.sdk.openadsdk.core.ajl.ajl gqi;
    private duv gzf;

    /* JADX INFO: renamed from: ha, reason: collision with root package name */
    private boolean f6746ha;
    private int hi;
    private String irt;
    private Button ku;

    /* JADX INFO: renamed from: lb, reason: collision with root package name */
    TTAdDislikeToast f6748lb;
    private ImageView lz;
    private ILoader maa;
    private ImageView mon;
    private int nt;
    private com.bytedance.sdk.openadsdk.common.jnr ol;
    private hxv onz;

    /* JADX INFO: renamed from: qf, reason: collision with root package name */
    private com.bytedance.sdk.openadsdk.onz.fm.fm f6749qf;
    private lse qhl;
    qhl ro;
    private String sds;
    private com.bytedance.sdk.openadsdk.onz.fm si;
    private fhx vt;
    private com.bytedance.sdk.openadsdk.core.widget.fm.ajl wbw;
    private String wey;
    private com.bytedance.sdk.component.ef.wsy wu;
    private ImageView xgn;
    private final AtomicInteger lse = new AtomicInteger(0);
    private final AtomicInteger hlt = new AtomicInteger(0);
    private final AtomicInteger mq = new AtomicInteger(0);
    final AtomicBoolean yz = new AtomicBoolean(false);
    final AtomicBoolean jnr = new AtomicBoolean(false);
    private boolean zan = false;
    private long tzk = 0;
    int ajl = -1;

    /* JADX INFO: renamed from: ib, reason: collision with root package name */
    private String f6747ib = "DOWNLOAD";

    /* JADX INFO: renamed from: com.bytedance.sdk.openadsdk.activity.single.TTHistoryLandingPageActivity$1, reason: invalid class name */
    public class AnonymousClass1 implements lb.InterfaceC0102lb {
        final /* synthetic */ int fm;

        /* JADX INFO: renamed from: lb, reason: collision with root package name */
        final /* synthetic */ long f6750lb;
        final /* synthetic */ Bundle ro;

        public AnonymousClass1(int i10, Bundle bundle, long j10) {
            this.fm = i10;
            this.ro = bundle;
            this.f6750lb = j10;
        }

        @Override // com.bytedance.sdk.openadsdk.onz.fm.fm.lb.InterfaceC0102lb
        public void fm(final String str) {
            xgn.fm(new Runnable() { // from class: com.bytedance.sdk.openadsdk.activity.single.TTHistoryLandingPageActivity.1.1
                @Override // java.lang.Runnable
                public void run() {
                    List<lse> listRo = com.bytedance.sdk.openadsdk.onz.fm.fm.lb.ro(str);
                    TTHistoryLandingPageActivity.this.qhl = (listRo == null || listRo.isEmpty()) ? null : listRo.get(AnonymousClass1.this.fm);
                    AnonymousClass1 anonymousClass1 = AnonymousClass1.this;
                    Bundle bundle = anonymousClass1.ro;
                    if (bundle != null) {
                        try {
                            TTHistoryLandingPageActivity.this.ajl = bundle.getInt("meta_index", -1);
                            TTHistoryLandingPageActivity tTHistoryLandingPageActivity = TTHistoryLandingPageActivity.this;
                            if (tTHistoryLandingPageActivity.ajl >= 0) {
                                tTHistoryLandingPageActivity.qhl = ai.fm().fm(TTHistoryLandingPageActivity.this.ajl);
                            }
                        } catch (Throwable unused) {
                        }
                    }
                    if (TTHistoryLandingPageActivity.this.qhl == null) {
                        TTHistoryLandingPageActivity.this.finish();
                        return;
                    }
                    TTHistoryLandingPageActivity tTHistoryLandingPageActivity2 = TTHistoryLandingPageActivity.this;
                    tTHistoryLandingPageActivity2.duv = tTHistoryLandingPageActivity2.qhl.eo();
                    TTHistoryLandingPageActivity tTHistoryLandingPageActivity3 = TTHistoryLandingPageActivity.this;
                    tTHistoryLandingPageActivity3.dsz = tTHistoryLandingPageActivity3.qhl.gt();
                    TTHistoryLandingPageActivity tTHistoryLandingPageActivity4 = TTHistoryLandingPageActivity.this;
                    tTHistoryLandingPageActivity4.sds = tTHistoryLandingPageActivity4.qhl.kec();
                    TTHistoryLandingPageActivity tTHistoryLandingPageActivity5 = TTHistoryLandingPageActivity.this;
                    tTHistoryLandingPageActivity5.fhx = tTHistoryLandingPageActivity5.qhl.dsz();
                    TTHistoryLandingPageActivity tTHistoryLandingPageActivity6 = TTHistoryLandingPageActivity.this;
                    tTHistoryLandingPageActivity6.irt = tTHistoryLandingPageActivity6.qhl.duv();
                    try {
                        TTHistoryLandingPageActivity tTHistoryLandingPageActivity7 = TTHistoryLandingPageActivity.this;
                        tTHistoryLandingPageActivity7.setContentView(tTHistoryLandingPageActivity7.jnr());
                        TTHistoryLandingPageActivity.this.ro();
                        TTHistoryLandingPageActivity tTHistoryLandingPageActivity8 = TTHistoryLandingPageActivity.this;
                        tTHistoryLandingPageActivity8.f6744ef = tTHistoryLandingPageActivity8;
                        if (TTHistoryLandingPageActivity.this.wu != null) {
                            com.bytedance.sdk.openadsdk.core.widget.fm.yz.fm(TTHistoryLandingPageActivity.this.f6744ef).fm(false).ro(false).fm(TTHistoryLandingPageActivity.this.wu.getWebView());
                        }
                        TTHistoryLandingPageActivity.this.bx.fm(true);
                        if (TTHistoryLandingPageActivity.this.wu != null && TTHistoryLandingPageActivity.this.wu.getWebView() != null) {
                            fm fmVar = new fm(TTHistoryLandingPageActivity.this.hi, TTHistoryLandingPageActivity.this.qhl, "landingpage", TTHistoryLandingPageActivity.this);
                            TTHistoryLandingPageActivity tTHistoryLandingPageActivity9 = TTHistoryLandingPageActivity.this;
                            tTHistoryLandingPageActivity9.fm = new com.bytedance.sdk.openadsdk.yz.dsz(tTHistoryLandingPageActivity9.qhl, TTHistoryLandingPageActivity.this.wu.getWebView(), fmVar, TTHistoryLandingPageActivity.this.nt).ro(true);
                            TTHistoryLandingPageActivity tTHistoryLandingPageActivity10 = TTHistoryLandingPageActivity.this;
                            tTHistoryLandingPageActivity10.ai = tTHistoryLandingPageActivity10.fm.fm;
                            TTHistoryLandingPageActivity tTHistoryLandingPageActivity11 = TTHistoryLandingPageActivity.this;
                            tTHistoryLandingPageActivity11.ol = bx.fm(tTHistoryLandingPageActivity11.qhl, TTHistoryLandingPageActivity.this.wu, TTHistoryLandingPageActivity.this.f6744ef, TTHistoryLandingPageActivity.this.irt);
                            TTHistoryLandingPageActivity tTHistoryLandingPageActivity12 = TTHistoryLandingPageActivity.this;
                            tTHistoryLandingPageActivity12.fm.jnr(tTHistoryLandingPageActivity12.zan);
                            TTHistoryLandingPageActivity.this.qhl.gqi(TTHistoryLandingPageActivity.this.zan);
                        }
                        TTHistoryLandingPageActivity.this.ef();
                        if (TTHistoryLandingPageActivity.this.wu != null) {
                            TTHistoryLandingPageActivity.this.wu.setLandingPage(true);
                            TTHistoryLandingPageActivity.this.wu.setTag("landingpage");
                            TTHistoryLandingPageActivity.this.wu.setMaterialMeta(TTHistoryLandingPageActivity.this.qhl.ooo());
                        }
                        TTHistoryLandingPageActivity.this.lb();
                        TTHistoryLandingPageActivity.this.ajl();
                        if (TTHistoryLandingPageActivity.this.si != null) {
                            TTHistoryLandingPageActivity.this.si.setOnClickListener(new View.OnClickListener() { // from class: com.bytedance.sdk.openadsdk.activity.single.TTHistoryLandingPageActivity.1.1.1
                                @Override // android.view.View.OnClickListener
                                public void onClick(View view) {
                                    TTHistoryLandingPageActivity.this.ro("onSelectPrivacy");
                                    TTHistoryLandingPageActivity tTHistoryLandingPageActivity13 = TTHistoryLandingPageActivity.this;
                                    TTWebsiteActivity.fm(tTHistoryLandingPageActivity13, tTHistoryLandingPageActivity13.qhl, TTHistoryLandingPageActivity.this.irt);
                                }
                            });
                        }
                        long jElapsedRealtime = SystemClock.elapsedRealtime();
                        AnonymousClass1 anonymousClass12 = AnonymousClass1.this;
                        lb.fm.fm(jElapsedRealtime - anonymousClass12.f6750lb, TTHistoryLandingPageActivity.this.qhl, "landingpage", TTHistoryLandingPageActivity.this.maa, TTHistoryLandingPageActivity.this.sds);
                    } catch (Throwable unused2) {
                        TTHistoryLandingPageActivity.this.finish();
                    }
                }
            });
        }

        @Override // com.bytedance.sdk.openadsdk.onz.fm.fm.lb.InterfaceC0102lb
        public void ro(String str) {
            TTHistoryLandingPageActivity.this.finish();
        }
    }

    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 f6752lb;
        private final lse ro;
        private final WeakReference<TTHistoryLandingPageActivity> yz;

        public fm(int i10, lse lseVar, String str, TTHistoryLandingPageActivity tTHistoryLandingPageActivity) {
            this.fm = i10;
            this.ro = lseVar;
            this.f6752lb = str;
            this.yz = new WeakReference<>(tTHistoryLandingPageActivity);
        }

        @Override // com.bytedance.sdk.openadsdk.yz.duv
        public void fm(int i10) {
            TTHistoryLandingPageActivity tTHistoryLandingPageActivity = this.yz.get();
            if (tTHistoryLandingPageActivity != null) {
                lb.fm.fm(this.fm, tTHistoryLandingPageActivity.hlt.get(), tTHistoryLandingPageActivity.mq.get(), tTHistoryLandingPageActivity.lse.get() - tTHistoryLandingPageActivity.mq.get(), this.ro, this.f6752lb, i10);
            }
        }
    }

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

        public lb(com.bytedance.sdk.openadsdk.yz.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) {
            com.bytedance.sdk.openadsdk.yz.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<com.bytedance.sdk.openadsdk.yz.dsz> fm;

        public ro(com.bytedance.sdk.openadsdk.yz.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) {
            com.bytedance.sdk.openadsdk.yz.dsz dszVar = this.fm.get();
            if (dszVar != null) {
                dszVar.ro(i11);
            }
        }
    }

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

    @Override // com.bytedance.sdk.openadsdk.activity.single.TTBaseActivity, android.app.Activity
    @SuppressLint({"ClickableViewAccessibility"})
    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) {
        }
        LinkedList<WeakReference<Activity>> linkedList = wsy;
        linkedList.add(new WeakReference<>(this));
        if (linkedList.size() > 30) {
            wu();
        }
        com.bytedance.sdk.openadsdk.onz.jnr.fm(this);
        long jElapsedRealtime = SystemClock.elapsedRealtime();
        Intent intent = getIntent();
        String stringExtra = intent.getStringExtra("material_key");
        this.wey = intent.getStringExtra("landing_url");
        int intExtra = intent.getIntExtra("landing_index", 0);
        if (stringExtra == null || intExtra < 0) {
            finish();
        } else {
            com.bytedance.sdk.openadsdk.onz.fm.fm.lb.fm().fm(stringExtra, new AnonymousClass1(intExtra, bundle, jElapsedRealtime));
        }
    }

    @Override // com.bytedance.sdk.openadsdk.activity.single.TTBaseLandingPageActivity, com.bytedance.sdk.openadsdk.activity.single.TTBaseActivity, android.app.Activity
    public void onDestroy() {
        super.onDestroy();
        Iterator<WeakReference<Activity>> it = wsy.iterator();
        while (it.hasNext()) {
            Activity activity = it.next().get();
            if (activity == this || activity == null) {
                it.remove();
            }
        }
    }

    @Override // com.bytedance.sdk.openadsdk.activity.single.TTBaseLandingPageActivity, com.bytedance.sdk.openadsdk.activity.single.TTBaseActivity, android.app.Activity
    public void onPause() {
        super.onPause();
    }

    @Override // com.bytedance.sdk.openadsdk.activity.single.TTBaseLandingPageActivity, com.bytedance.sdk.openadsdk.activity.single.TTBaseActivity, android.app.Activity
    public void onResume() {
        super.onResume();
    }

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

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

    /* JADX INFO: Access modifiers changed from: private */
    @SuppressLint({"ClickableViewAccessibility"})
    public void ajl() {
        lse lseVar = this.qhl;
        if (lseVar == null || lseVar.oy() != 4) {
            return;
        }
        fhx fhxVar = this.vt;
        if (fhxVar != null) {
            fhxVar.setVisibility(0);
        }
        Button button = (Button) findViewById(com.bytedance.sdk.openadsdk.utils.qhl.zzn);
        this.ku = button;
        if (button != null) {
            fm(wsy());
            if (this.gof == null) {
                this.gof = com.bytedance.sdk.openadsdk.sds.fm.fm.yz.fm(this, TextUtils.isEmpty(this.irt) ? bx.ro(this.fhx) : this.irt);
            }
            com.bytedance.sdk.openadsdk.core.lb.fm fmVar = new com.bytedance.sdk.openadsdk.core.lb.fm(this, this.qhl, this.irt, this.fhx);
            fmVar.fm(false);
            this.ku.setOnClickListener(fmVar);
            this.ku.setOnTouchListener(fmVar);
            fmVar.lb(true);
            fmVar.fm(this.gof);
        }
    }

    /* JADX INFO: Access modifiers changed from: private */
    public void duv() {
        TTAdDislikeToast tTAdDislikeToast;
        if (isFinishing() || (tTAdDislikeToast = this.f6748lb) == null) {
            return;
        }
        tTAdDislikeToast.show(TTAdDislikeToast.getDislikeSendTip());
    }

    /* JADX INFO: Access modifiers changed from: private */
    public void ef() {
        hxv hxvVar = new hxv(this);
        this.onz = hxvVar;
        hxvVar.ro(this.wu).lb(this.duv).yz(this.dsz).fm(this.qhl).ro(this.fhx).fm(this.qhl.zh()).jnr(this.qhl.uuz()).fm(this.wu).ro("landingpage");
    }

    private void ku() {
        TTAdDislikeToast tTAdDislikeToast = this.f6748lb;
        if (tTAdDislikeToast == null) {
            return;
        }
        tTAdDislikeToast.show(TTAdDislikeToast.getDislikeTip());
    }

    private void vt() {
        try {
            if (this.ro == null) {
                qhl qhlVar = new qhl(this.f6744ef, this.qhl);
                this.ro = qhlVar;
                qhlVar.setDislikeSource("landing_page");
                this.ro.setCallback(new qhl.fm() { // from class: com.bytedance.sdk.openadsdk.activity.single.TTHistoryLandingPageActivity.5
                    @Override // com.bytedance.sdk.openadsdk.common.qhl.fm
                    public void fm(View view) {
                        TTHistoryLandingPageActivity.this.yz.set(true);
                    }

                    @Override // com.bytedance.sdk.openadsdk.common.qhl.fm
                    public void ro(View view) {
                        TTHistoryLandingPageActivity.this.yz.set(false);
                    }

                    @Override // com.bytedance.sdk.openadsdk.common.qhl.fm
                    public void fm(FilterWord filterWord) {
                        if (TTHistoryLandingPageActivity.this.jnr.get() || filterWord == null || filterWord.hasSecondOptions()) {
                            return;
                        }
                        TTHistoryLandingPageActivity.this.jnr.set(true);
                        TTHistoryLandingPageActivity.this.duv();
                    }
                });
            }
            FrameLayout frameLayout = (FrameLayout) findViewById(R.id.content);
            frameLayout.addView(this.ro);
            if (this.f6748lb == null) {
                TTAdDislikeToast tTAdDislikeToast = new TTAdDislikeToast(this.f6744ef);
                this.f6748lb = tTAdDislikeToast;
                frameLayout.addView(tTAdDislikeToast);
            }
        } catch (Throwable th) {
            ApmHelper.reportCustomError("initDislike error", "LandingPageActivity", th);
        }
    }

    private String wsy() {
        lse lseVar = this.qhl;
        if (lseVar != null && !TextUtils.isEmpty(lseVar.eys())) {
            this.f6747ib = this.qhl.eys();
        }
        return this.f6747ib;
    }

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

    /* JADX INFO: Access modifiers changed from: private */
    public View jnr() {
        com.bytedance.sdk.openadsdk.core.model.ro roVarDwu;
        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));
        this.bx = new dsz(this, this.qhl, this.irt, false);
        View fhxVar = new fhx(this, new fhx.fm() { // from class: com.bytedance.sdk.openadsdk.activity.single.TTHistoryLandingPageActivity.3
            @Override // com.bytedance.sdk.openadsdk.common.fhx.fm
            public View fm(Context context) {
                return TTHistoryLandingPageActivity.this.bx.yz();
            }
        });
        fhxVar.setId(com.bytedance.sdk.openadsdk.utils.qhl.ywr);
        jnrVar.addView(fhxVar, new LinearLayout.LayoutParams(-1, -2));
        com.bytedance.sdk.openadsdk.core.ajl.lb lbVar2 = new com.bytedance.sdk.openadsdk.core.ajl.lb(this);
        LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(-1, 0);
        layoutParams.weight = 1.0f;
        jnrVar.addView(lbVar2, layoutParams);
        com.bytedance.sdk.component.ef.wsy wsyVar = new com.bytedance.sdk.component.ef.wsy(this, wsy.lb.LANDING_PAGE);
        this.wu = wsyVar;
        wsyVar.setId(com.bytedance.sdk.openadsdk.utils.qhl.f7557ib);
        lbVar2.addView(wsyVar, new FrameLayout.LayoutParams(-1, -1));
        fhx fhxVar2 = new fhx(this, new fhx.fm() { // from class: com.bytedance.sdk.openadsdk.activity.single.TTHistoryLandingPageActivity.4
            @Override // com.bytedance.sdk.openadsdk.common.fhx.fm
            public View fm(Context context) {
                return new com.bytedance.sdk.openadsdk.common.wu(context);
            }
        });
        fhxVar2.setId(com.bytedance.sdk.openadsdk.utils.qhl.ado);
        FrameLayout.LayoutParams layoutParams2 = new FrameLayout.LayoutParams(-1, -2);
        layoutParams2.gravity = 81;
        lbVar2.addView(fhxVar2, layoutParams2);
        com.bytedance.sdk.openadsdk.core.ajl.ajl ajlVar = new com.bytedance.sdk.openadsdk.core.ajl.ajl(this, null, R.style.Widget.ProgressBar.Horizontal);
        ajlVar.setId(com.bytedance.sdk.openadsdk.utils.qhl.cg);
        ajlVar.setProgress(1);
        ajlVar.setVisibility(8);
        ajlVar.setProgressDrawable(ku.fm(this, "tt_browser_progress_style"));
        FrameLayout.LayoutParams layoutParams3 = new FrameLayout.LayoutParams(-1, zan.ro(this, 3.0f));
        layoutParams3.gravity = 49;
        lbVar2.addView(ajlVar, layoutParams3);
        lse lseVar = this.qhl;
        if (lseVar != null && (roVarDwu = lseVar.dwu()) != null) {
            String strYz = roVarDwu.yz();
            if (!TextUtils.isEmpty(strYz)) {
                com.bytedance.sdk.openadsdk.onz.fm fmVar = new com.bytedance.sdk.openadsdk.onz.fm(this);
                this.si = fmVar;
                fmVar.setId(com.bytedance.sdk.openadsdk.utils.qhl.zow);
                FrameLayout.LayoutParams layoutParams4 = new FrameLayout.LayoutParams(-1, -2);
                this.si.setPadding(zan.ro(this, 16.0f), zan.ro(this, 16.0f), zan.ro(this, 16.0f), zan.ro(this, 16.0f));
                this.si.setPrivacyText(strYz);
                layoutParams4.gravity = 80;
                lbVar2.addView(this.si, layoutParams4);
            }
        }
        duv duvVar = new duv(this);
        duvVar.setOnlyLoading(this.f6746ha);
        duvVar.setId(520093721);
        lbVar.addView(duvVar, new FrameLayout.LayoutParams(-1, -1));
        return lbVar;
    }

    /* JADX INFO: Access modifiers changed from: private */
    @SuppressLint({"ClickableViewAccessibility"})
    public void lb() {
        com.bytedance.sdk.openadsdk.core.widget.fm.ajl ajlVar = new com.bytedance.sdk.openadsdk.core.widget.fm.ajl(this.f6744ef, this.onz, this.duv, this.ol, this.fm, true) { // from class: com.bytedance.sdk.openadsdk.activity.single.TTHistoryLandingPageActivity.12
            @Override // com.bytedance.sdk.openadsdk.core.widget.fm.ajl, android.webkit.WebViewClient
            public void onPageFinished(WebView webView, String str) {
                super.onPageFinished(webView, str);
                try {
                    if (TTHistoryLandingPageActivity.this.gqi != null && !TTHistoryLandingPageActivity.this.isFinishing()) {
                        TTHistoryLandingPageActivity.this.gqi.setVisibility(8);
                    }
                } catch (Throwable unused) {
                }
                if (TTHistoryLandingPageActivity.this.gzf != null) {
                    TTHistoryLandingPageActivity.this.gzf.ro();
                }
            }

            @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);
            }

            @Override // com.bytedance.sdk.openadsdk.core.widget.fm.ajl, android.webkit.WebViewClient
            public WebResourceResponse shouldInterceptRequest(WebView webView, String str) {
                try {
                    if (TextUtils.isEmpty(TTHistoryLandingPageActivity.this.sds)) {
                        return super.shouldInterceptRequest(webView, str);
                    }
                    TTHistoryLandingPageActivity.this.lse.incrementAndGet();
                    WebResourceResponseModel webResourceResponseModelFm = com.bytedance.sdk.openadsdk.wsy.ro.fm().fm(TTHistoryLandingPageActivity.this.maa, TTHistoryLandingPageActivity.this.sds, str);
                    if (webResourceResponseModelFm != null && webResourceResponseModelFm.getWebResourceResponse() != null) {
                        TTHistoryLandingPageActivity.this.mq.incrementAndGet();
                        return webResourceResponseModelFm.getWebResourceResponse();
                    }
                    if (webResourceResponseModelFm != null && webResourceResponseModelFm.getMsg() == 2) {
                        TTHistoryLandingPageActivity.this.hlt.incrementAndGet();
                    }
                    return super.shouldInterceptRequest(webView, str);
                } catch (Throwable th) {
                    wey.fm("TTAD.HistoryLandingPageAct", "shouldInterceptRequest url error", th);
                    return super.shouldInterceptRequest(webView, str);
                }
            }
        };
        this.wbw = ajlVar;
        ajlVar.fm(this.qhl);
        this.wbw.fm("landingpage");
        com.bytedance.sdk.component.ef.wsy wsyVar = this.wu;
        if (wsyVar != null) {
            wsyVar.setWebViewClient(this.wbw);
            com.bytedance.sdk.component.ef.wsy wsyVar2 = this.wu;
            if (wsyVar2 != null) {
                wsyVar2.setUserAgentString(com.bytedance.sdk.openadsdk.utils.wey.fm(wsyVar2.getWebView(), BuildConfig.VERSION_CODE));
            }
            com.bytedance.sdk.component.ef.wsy wsyVar3 = this.wu;
            if (wsyVar3 != null) {
                wsyVar3.setMixedContentMode(0);
            }
        }
        com.bytedance.sdk.openadsdk.yz.lb.fm(this.qhl, "landingpage", this.nt);
        com.bytedance.sdk.component.ef.wsy wsyVar4 = this.wu;
        if (wsyVar4 != null) {
            com.bytedance.sdk.openadsdk.utils.lse.fm(wsyVar4, this.wey);
            this.wu.setWebChromeClient(new com.bytedance.sdk.openadsdk.core.widget.fm.jnr(this.onz, this.fm, this.ol) { // from class: com.bytedance.sdk.openadsdk.activity.single.TTHistoryLandingPageActivity.13
                @Override // com.bytedance.sdk.openadsdk.core.widget.fm.jnr, android.webkit.WebChromeClient
                public void onProgressChanged(WebView webView, int i10) {
                    super.onProgressChanged(webView, i10);
                    if (TTHistoryLandingPageActivity.this.gzf != null) {
                        TTHistoryLandingPageActivity.this.gzf.fm(i10);
                    }
                    if (TTHistoryLandingPageActivity.this.gqi != null && !TTHistoryLandingPageActivity.this.isFinishing()) {
                        if (i10 == 100 && TTHistoryLandingPageActivity.this.gqi.isShown()) {
                            TTHistoryLandingPageActivity.this.gqi.setVisibility(8);
                        } else {
                            TTHistoryLandingPageActivity.this.gqi.setProgress(i10);
                        }
                    }
                    if (TTHistoryLandingPageActivity.this.bx != null) {
                        long jCurrentTimeMillis = System.currentTimeMillis();
                        if (jCurrentTimeMillis - TTHistoryLandingPageActivity.this.tzk >= 200 || i10 == 100) {
                            TTHistoryLandingPageActivity.this.bx.fm(webView, TTHistoryLandingPageActivity.this.ai);
                            TTHistoryLandingPageActivity.this.tzk = jCurrentTimeMillis;
                        }
                    }
                }

                @Override // android.webkit.WebChromeClient
                public void onReceivedTitle(WebView webView, String str) {
                    super.onReceivedTitle(webView, str);
                    TTHistoryLandingPageActivity.this.bx.fm(str);
                    TTHistoryLandingPageActivity.this.bx.ro(webView.getUrl());
                    try {
                        if (TextUtils.isEmpty(str)) {
                            str = TTHistoryLandingPageActivity.this.wey;
                        }
                        TTHistoryLandingPageActivity.this.f6749qf = new com.bytedance.sdk.openadsdk.onz.fm.fm();
                        com.bytedance.sdk.openadsdk.core.model.fm fmVarYz = TTHistoryLandingPageActivity.this.qhl.yz();
                        TTHistoryLandingPageActivity.this.f6749qf.fm(com.bytedance.sdk.openadsdk.onz.fm.fm.lb.fm().lb(TTHistoryLandingPageActivity.this.qhl.lo()));
                        TTHistoryLandingPageActivity.this.f6749qf.ro(fmVarYz.ro());
                        TTHistoryLandingPageActivity.this.f6749qf.lb(String.valueOf(System.currentTimeMillis()));
                        TTHistoryLandingPageActivity.this.f6749qf.jnr(webView.getUrl());
                        TTHistoryLandingPageActivity.this.f6749qf.ro(TTHistoryLandingPageActivity.this.qhl.xio());
                        TTHistoryLandingPageActivity.this.f6749qf.yz(str);
                        com.bytedance.sdk.openadsdk.onz.fm.fm.lb.fm().fm(TTHistoryLandingPageActivity.this.f6749qf);
                    } catch (Exception e10) {
                        wey.fm("TTAD.HistoryLandingPageAct", "page start: miabhistory index = " + TTHistoryLandingPageActivity.this.qhl.xio() + "model = " + TTHistoryLandingPageActivity.this.f6749qf, e10);
                    }
                }
            });
            if (this.wu.getWebView() != null) {
                this.wu.getWebView().setOnScrollChangeListener(new ro(this.fm));
                this.wu.getWebView().setOnTouchListener(new lb(this.fm, this.ol) { // from class: com.bytedance.sdk.openadsdk.activity.single.TTHistoryLandingPageActivity.14
                    private long jnr;

                    /* JADX INFO: renamed from: lb, reason: collision with root package name */
                    private float f6751lb;
                    private float yz;
                    private final int ro = gof.ro();
                    private float ajl = 0.0f;
                    private float wsy = 0.0f;

                    @Override // com.bytedance.sdk.openadsdk.activity.single.TTHistoryLandingPageActivity.lb, android.view.View.OnTouchListener
                    @SuppressLint({"LongLogTag"})
                    public boolean onTouch(View view, MotionEvent motionEvent) {
                        try {
                            int actionMasked = motionEvent.getActionMasked();
                            if (actionMasked == 0) {
                                this.f6751lb = motionEvent.getRawX();
                                this.yz = motionEvent.getRawY();
                                this.jnr = System.currentTimeMillis();
                            } else if (actionMasked == 2) {
                                float rawX = motionEvent.getRawX();
                                float rawY = motionEvent.getRawY();
                                if (Math.abs(rawX - this.f6751lb) < this.ro) {
                                    Math.abs(rawY - this.yz);
                                }
                                this.ajl += Math.abs(motionEvent.getX() - this.f6751lb);
                                this.wsy += Math.abs(motionEvent.getY() - this.yz);
                                System.currentTimeMillis();
                                if (rawY - this.yz > this.ro) {
                                    TTHistoryLandingPageActivity.this.bx.fm();
                                }
                                if (rawY - this.yz < (-this.ro)) {
                                    TTHistoryLandingPageActivity.this.bx.ro();
                                }
                            }
                        } catch (Throwable unused) {
                        }
                        return super.onTouch(view, motionEvent);
                    }
                });
            }
            this.wu.setDownloadListener(new DownloadListener() { // from class: com.bytedance.sdk.openadsdk.activity.single.TTHistoryLandingPageActivity.2
                @Override // android.webkit.DownloadListener
                public void onDownloadStart(String str, String str2, String str3, String str4, long j10) {
                    if (TTHistoryLandingPageActivity.this.gof != null) {
                        TTHistoryLandingPageActivity.this.gof.fm(TTHistoryLandingPageActivity.this.qhl);
                    }
                }
            });
        }
    }

    /* JADX INFO: Access modifiers changed from: private */
    public void ro() {
        bx.fm(this.qhl, this.wu);
        this.vt = (fhx) findViewById(com.bytedance.sdk.openadsdk.utils.qhl.ado);
        fhx fhxVar = (fhx) findViewById(com.bytedance.sdk.openadsdk.utils.qhl.ywr);
        duv duvVar = (duv) findViewById(520093721);
        this.gzf = duvVar;
        if (duvVar != null) {
            duvVar.fm(this.qhl);
            this.gzf.fm();
        }
        if (fhxVar != null) {
            fhxVar.setVisibility(0);
        }
        ImageView imageView = (ImageView) findViewById(com.bytedance.sdk.openadsdk.utils.qhl.zjk);
        this.f6745gc = imageView;
        if (imageView != null) {
            imageView.setOnClickListener(new View.OnClickListener() { // from class: com.bytedance.sdk.openadsdk.activity.single.TTHistoryLandingPageActivity.7
                @Override // android.view.View.OnClickListener
                public void onClick(View view) {
                    if (TTHistoryLandingPageActivity.this.wu != null) {
                        if (TTHistoryLandingPageActivity.this.ai != null) {
                            TTHistoryLandingPageActivity.this.ai.fm();
                        }
                        if (TTHistoryLandingPageActivity.this.wu.wu()) {
                            TTHistoryLandingPageActivity.this.wu.ef();
                            if (TTHistoryLandingPageActivity.this.bx != null) {
                                TTHistoryLandingPageActivity.this.bx.fm(TTHistoryLandingPageActivity.this.wu.getWebView(), TTHistoryLandingPageActivity.this.ai);
                            }
                        }
                    }
                }
            });
        }
        ImageView imageView2 = (ImageView) findViewById(com.bytedance.sdk.openadsdk.utils.qhl.grs);
        this.xgn = imageView2;
        if (imageView2 != null) {
            imageView2.setOnClickListener(new View.OnClickListener() { // from class: com.bytedance.sdk.openadsdk.activity.single.TTHistoryLandingPageActivity.8
                @Override // android.view.View.OnClickListener
                public void onClick(View view) {
                    if (TTHistoryLandingPageActivity.this.wu == null || !TTHistoryLandingPageActivity.this.wu.vt()) {
                        return;
                    }
                    TTHistoryLandingPageActivity.this.wu.ku();
                    if (TTHistoryLandingPageActivity.this.bx != null) {
                        TTHistoryLandingPageActivity.this.bx.fm(TTHistoryLandingPageActivity.this.wu.getWebView(), TTHistoryLandingPageActivity.this.ai);
                    }
                }
            });
        }
        ImageView imageView3 = (ImageView) findViewById(520093716);
        this.lz = imageView3;
        if (imageView3 != null) {
            imageView3.setOnClickListener(new View.OnClickListener() { // from class: com.bytedance.sdk.openadsdk.activity.single.TTHistoryLandingPageActivity.9
                @Override // android.view.View.OnClickListener
                public void onClick(View view) {
                    TTHistoryLandingPageActivity.this.finish();
                }
            });
        }
        com.bytedance.sdk.openadsdk.core.ajl.ajl ajlVar = (com.bytedance.sdk.openadsdk.core.ajl.ajl) findViewById(com.bytedance.sdk.openadsdk.utils.qhl.cg);
        this.gqi = ajlVar;
        if (ajlVar != null) {
            ajlVar.setVisibility(0);
        }
        this.mon = (ImageView) findViewById(520093740);
        final sds sdsVar = new sds(this, false);
        ImageView imageView4 = this.mon;
        if (imageView4 != null) {
            imageView4.setOnClickListener(new View.OnClickListener() { // from class: com.bytedance.sdk.openadsdk.activity.single.TTHistoryLandingPageActivity.10
                @Override // android.view.View.OnClickListener
                public void onClick(View view) {
                    sdsVar.setOnMenuItemClickListener(new sds.fm() { // from class: com.bytedance.sdk.openadsdk.activity.single.TTHistoryLandingPageActivity.10.1
                        @Override // com.bytedance.sdk.openadsdk.common.sds.fm
                        public void ajl() {
                            if (com.bytedance.sdk.openadsdk.utils.ro.jnr()) {
                                TTHistoryLandingPageActivity tTHistoryLandingPageActivity = TTHistoryLandingPageActivity.this;
                                IABLandingPageActivity.fm(tTHistoryLandingPageActivity, tTHistoryLandingPageActivity.qhl, TTHistoryLandingPageActivity.this.irt);
                            } else {
                                TTHistoryLandingPageActivity tTHistoryLandingPageActivity2 = TTHistoryLandingPageActivity.this;
                                TTWebsiteActivity.fm(tTHistoryLandingPageActivity2, tTHistoryLandingPageActivity2.qhl, TTHistoryLandingPageActivity.this.irt);
                            }
                            TTHistoryLandingPageActivity.this.ro("onSelectPrivacy");
                            sdsVar.fm();
                        }

                        @Override // com.bytedance.sdk.openadsdk.common.sds.fm
                        public void fm() {
                            if (TTHistoryLandingPageActivity.this.qhl != null) {
                                com.bytedance.sdk.openadsdk.onz.fm.fm.lb.fm().fm(TTHistoryLandingPageActivity.this.qhl);
                            }
                            com.bytedance.sdk.component.utils.ro.fm(TTHistoryLandingPageActivity.this, new Intent(TTHistoryLandingPageActivity.this, (Class<?>) TTHistoryActivity.class), null);
                            TTHistoryLandingPageActivity.this.ro("onSelectHistory");
                            sdsVar.fm();
                        }

                        @Override // com.bytedance.sdk.openadsdk.common.sds.fm
                        public void jnr() {
                            TTHistoryLandingPageActivity.this.fm();
                            TTHistoryLandingPageActivity.this.ro("onSelectReport");
                            sdsVar.fm();
                        }

                        @Override // com.bytedance.sdk.openadsdk.common.sds.fm
                        public void lb() {
                            ClipboardManager clipboardManager;
                            if (TTHistoryLandingPageActivity.this.wu != null) {
                                String url = TTHistoryLandingPageActivity.this.wu.getUrl();
                                if (!TextUtils.isEmpty(url) && (clipboardManager = (ClipboardManager) TTHistoryLandingPageActivity.this.getSystemService("clipboard")) != null) {
                                    clipboardManager.setPrimaryClip(ClipData.newPlainText("URL", url));
                                }
                            }
                            TTHistoryLandingPageActivity.this.ro("onSelectCopyLink");
                            sdsVar.fm();
                        }

                        @Override // com.bytedance.sdk.openadsdk.common.sds.fm
                        public void ro() {
                            if (TTHistoryLandingPageActivity.this.wu == null || TTHistoryLandingPageActivity.this.wu.getUrl() == null) {
                                return;
                            }
                            if (TTHistoryLandingPageActivity.this.gqi != null) {
                                TTHistoryLandingPageActivity.this.gqi.setVisibility(0);
                                TTHistoryLandingPageActivity.this.gqi.setProgress(0);
                            }
                            TTHistoryLandingPageActivity.this.wu.wsy();
                            TTHistoryLandingPageActivity.this.wu.a_(TTHistoryLandingPageActivity.this.wu.getUrl());
                            TTHistoryLandingPageActivity.this.ro("onSelectRetry");
                            sdsVar.fm();
                        }

                        @Override // com.bytedance.sdk.openadsdk.common.sds.fm
                        public void yz() {
                            if (TTHistoryLandingPageActivity.this.wu != null) {
                                Intent intent = new Intent("android.intent.action.VIEW");
                                String url = TTHistoryLandingPageActivity.this.wu.getUrl();
                                if (!TextUtils.isEmpty(url)) {
                                    intent.setData(Uri.parse(url));
                                    com.bytedance.sdk.component.utils.ro.fm(TTHistoryLandingPageActivity.this, intent, null);
                                }
                                TTHistoryLandingPageActivity.this.ro("onSelectOpenInBrowser");
                                sdsVar.fm();
                            }
                        }
                    });
                    sdsVar.fm(view);
                }
            });
        }
        View viewFindViewById = findViewById(com.bytedance.sdk.openadsdk.utils.qhl.hm);
        if (viewFindViewById != null) {
            viewFindViewById.setOnClickListener(new View.OnClickListener() { // from class: com.bytedance.sdk.openadsdk.activity.single.TTHistoryLandingPageActivity.11
                @Override // android.view.View.OnClickListener
                public void onClick(View view) {
                    TTHistoryLandingPageActivity.this.fm();
                }
            });
        }
    }

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

    public static void fm(Context context, String str, String str2, int i10) {
        if (context == null) {
            return;
        }
        Intent intent = new Intent(context, (Class<?>) TTHistoryLandingPageActivity.class);
        intent.putExtra("material_key", str);
        intent.putExtra("landing_url", str2);
        intent.putExtra("landing_index", i10);
        com.bytedance.sdk.component.utils.ro.fm(context, intent, null);
    }

    public void fm() {
        if (isFinishing()) {
            return;
        }
        if (this.jnr.get()) {
            ku();
            return;
        }
        if (this.ro == null) {
            vt();
        }
        qhl qhlVar = this.ro;
        if (qhlVar != null) {
            qhlVar.fm();
        }
    }

    /* JADX INFO: Access modifiers changed from: private */
    public void ro(final String str) {
        com.bytedance.sdk.openadsdk.irt.yz.fm("iab_more_options", false, new com.bytedance.sdk.openadsdk.irt.ro() { // from class: com.bytedance.sdk.openadsdk.activity.single.TTHistoryLandingPageActivity.6
            @Override // com.bytedance.sdk.openadsdk.irt.ro
            @Nullable
            public com.bytedance.sdk.openadsdk.irt.fm.lb fm() throws Exception {
                JSONObject jSONObject = new JSONObject();
                jSONObject.put("scene", str);
                return com.bytedance.sdk.openadsdk.irt.fm.yz.ro().fm("iab_more_options").ro(jSONObject.toString());
            }
        });
    }
}
