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

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.content.res.Configuration;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.SystemClock;
import android.text.TextUtils;
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 android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import b6.d;
import b6.f;
import b6.g;
import com.bykv.vk.openvk.preload.falconx.loader.ILoader;
import com.bykv.vk.openvk.preload.geckox.model.WebResourceResponseModel;
import com.bytedance.sdk.component.jnr.irt;
import com.bytedance.sdk.component.jnr.ku;
import com.bytedance.sdk.component.utils.maa;
import com.bytedance.sdk.component.utils.nt;
import com.bytedance.sdk.component.utils.wey;
import com.bytedance.sdk.openadsdk.ApmHelper;
import com.bytedance.sdk.openadsdk.BuildConfig;
import com.bytedance.sdk.openadsdk.TTAdConstant;
import com.bytedance.sdk.openadsdk.common.fhx;
import com.bytedance.sdk.openadsdk.core.ai;
import com.bytedance.sdk.openadsdk.core.bx;
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.utils.qhl;
import com.bytedance.sdk.openadsdk.utils.xgn;
import com.bytedance.sdk.openadsdk.utils.zan;
import com.bytedance.sdk.openadsdk.yz.dsz;
import com.bytedance.sdk.openadsdk.yz.duv;
import com.bytedance.sdk.openadsdk.yz.lb;
import java.lang.ref.WeakReference;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import okhttp3.internal.http2.Http2Connection;
import org.json.JSONArray;
import org.json.JSONObject;

/* JADX INFO: loaded from: classes2.dex */
public abstract class TTVideoLandingPageActivity extends TTBaseLandingPageActivity implements com.bytedance.sdk.openadsdk.ku.yz {
    protected String ai;
    protected String ajl;
    protected dsz bx;
    protected long dsz;
    protected com.bytedance.sdk.openadsdk.core.fhx.ro.ajl duv;

    /* JADX INFO: renamed from: ef, reason: collision with root package name */
    protected int f6769ef;
    protected com.bytedance.sdk.component.ef.wsy fm;
    protected fhx hi;
    protected TextView hlt;
    protected Context jnr;

    /* JADX INFO: renamed from: lb, reason: collision with root package name */
    protected ImageView f6773lb;
    protected TextView lse;
    protected String lz;
    protected com.bytedance.sdk.openadsdk.core.widget.fm maa;
    protected com.bytedance.sdk.openadsdk.gqi.lb.fm mon;
    private int mpp;
    protected com.bytedance.sdk.openadsdk.sds.fm.fm.lb mq;

    /* JADX INFO: renamed from: ne, reason: collision with root package name */
    private ILoader f6774ne;
    protected Button nt;
    protected lse onz;

    /* JADX INFO: renamed from: qf, reason: collision with root package name */
    protected wsy.fm f6775qf;
    protected ImageView ro;
    protected TextView sds;
    protected FrameLayout vt;
    private int vvj;
    protected RelativeLayout wey;
    protected String wsy;
    protected hxv wu;
    protected int xgn;
    protected TextView yz;
    protected int ku = -1;
    protected int fhx = 0;
    protected int irt = 0;
    protected int qhl = 0;
    protected int gof = 0;
    protected String gqi = "ダウンロード";
    protected boolean gzf = false;
    protected boolean ol = false;
    protected boolean wbw = true;

    /* JADX INFO: renamed from: ha, reason: collision with root package name */
    protected boolean f6771ha = false;

    /* JADX INFO: renamed from: gc, reason: collision with root package name */
    protected String f6770gc = null;
    protected AtomicBoolean zan = new AtomicBoolean(true);
    protected JSONArray tzk = null;
    private final AtomicInteger kwx = new AtomicInteger(0);
    private final AtomicInteger bkb = new AtomicInteger(0);
    private final AtomicInteger lmk = new AtomicInteger(0);
    int si = -1;

    /* JADX INFO: renamed from: ib, reason: collision with root package name */
    protected com.bytedance.sdk.openadsdk.core.lb.fm f6772ib = null;
    private final d mj = new d() { // from class: com.bytedance.sdk.openadsdk.activity.single.TTVideoLandingPageActivity.11
        @Override // b6.d
        public void fm(boolean z10) {
            TTVideoLandingPageActivity tTVideoLandingPageActivity = TTVideoLandingPageActivity.this;
            tTVideoLandingPageActivity.gzf = z10;
            if (tTVideoLandingPageActivity.isFinishing()) {
                return;
            }
            if (!z10) {
                zan.fm((View) TTVideoLandingPageActivity.this.fm, 0);
                ViewGroup.MarginLayoutParams marginLayoutParams = (ViewGroup.MarginLayoutParams) TTVideoLandingPageActivity.this.vt.getLayoutParams();
                TTVideoLandingPageActivity tTVideoLandingPageActivity2 = TTVideoLandingPageActivity.this;
                marginLayoutParams.width = tTVideoLandingPageActivity2.qhl;
                marginLayoutParams.height = tTVideoLandingPageActivity2.gof;
                marginLayoutParams.leftMargin = tTVideoLandingPageActivity2.irt;
                marginLayoutParams.topMargin = tTVideoLandingPageActivity2.fhx;
                tTVideoLandingPageActivity2.vt.setLayoutParams(marginLayoutParams);
                return;
            }
            zan.fm((View) TTVideoLandingPageActivity.this.fm, 8);
            ViewGroup.MarginLayoutParams marginLayoutParams2 = (ViewGroup.MarginLayoutParams) TTVideoLandingPageActivity.this.vt.getLayoutParams();
            TTVideoLandingPageActivity tTVideoLandingPageActivity3 = TTVideoLandingPageActivity.this;
            tTVideoLandingPageActivity3.irt = marginLayoutParams2.leftMargin;
            tTVideoLandingPageActivity3.fhx = marginLayoutParams2.topMargin;
            tTVideoLandingPageActivity3.qhl = marginLayoutParams2.width;
            tTVideoLandingPageActivity3.gof = marginLayoutParams2.height;
            marginLayoutParams2.width = -1;
            marginLayoutParams2.height = -1;
            marginLayoutParams2.topMargin = 0;
            marginLayoutParams2.leftMargin = 0;
            tTVideoLandingPageActivity3.vt.setLayoutParams(marginLayoutParams2);
        }
    };
    private final nt.fm ado = new nt.fm() { // from class: com.bytedance.sdk.openadsdk.activity.single.TTVideoLandingPageActivity.2
        @Override // com.bytedance.sdk.component.utils.nt.fm
        public void fm(Context context, Intent intent, boolean z10, final int i10) {
            xgn.fm(new Runnable() { // from class: com.bytedance.sdk.openadsdk.activity.single.TTVideoLandingPageActivity.2.1
                @Override // java.lang.Runnable
                public void run() {
                    fm(i10);
                }
            });
        }

        /* JADX INFO: Access modifiers changed from: private */
        public void fm(int i10) {
            com.bytedance.sdk.component.ef.wsy wsyVar;
            String str;
            TTVideoLandingPageActivity tTVideoLandingPageActivity = TTVideoLandingPageActivity.this;
            if (tTVideoLandingPageActivity.xgn == 0 && i10 != 0 && (wsyVar = tTVideoLandingPageActivity.fm) != null && (str = tTVideoLandingPageActivity.f6770gc) != null) {
                wsyVar.a_(str);
            }
            com.bytedance.sdk.openadsdk.core.fhx.ro.ajl ajlVar = TTVideoLandingPageActivity.this.duv;
            if (ajlVar != null && ajlVar.getNativeVideoController() != null) {
                TTVideoLandingPageActivity tTVideoLandingPageActivity2 = TTVideoLandingPageActivity.this;
                if (!tTVideoLandingPageActivity2.ol && tTVideoLandingPageActivity2.xgn != i10) {
                    tTVideoLandingPageActivity2.duv.getNativeVideoController().lb(i10);
                }
            }
            TTVideoLandingPageActivity.this.xgn = i10;
        }
    };

    @SuppressLint({"StaticFieldLeak"})
    public static class fm extends AsyncTask<Void, Void, Drawable> {
        private final Bitmap fm;
        private final WeakReference<g> ro;

        @Override // android.os.AsyncTask
        /* JADX INFO: renamed from: fm, reason: merged with bridge method [inline-methods] */
        public Drawable doInBackground(Void... voidArr) {
            try {
                Bitmap bitmapFm = com.bytedance.sdk.component.adexpress.yz.fm.fm(gof.fm(), this.fm, 25);
                if (bitmapFm == null) {
                    return null;
                }
                return new BitmapDrawable(gof.fm().getResources(), bitmapFm);
            } catch (Throwable th) {
                wey.lb("TTVideoLandingPage", th.getMessage());
                return null;
            }
        }

        private fm(Bitmap bitmap, g gVar) {
            this.fm = bitmap;
            this.ro = new WeakReference<>(gVar);
        }

        @Override // android.os.AsyncTask
        /* JADX INFO: renamed from: fm, reason: merged with bridge method [inline-methods] */
        public void onPostExecute(Drawable drawable) {
            WeakReference<g> weakReference;
            if (drawable == null || (weakReference = this.ro) == null || weakReference.get() == null) {
                return;
            }
            this.ro.get().fm(drawable);
        }
    }

    @NonNull
    private com.bytedance.sdk.openadsdk.core.widget.fm.ajl dsz() {
        com.bytedance.sdk.openadsdk.core.widget.fm.ajl ajlVar = new com.bytedance.sdk.openadsdk.core.widget.fm.ajl(this.jnr, this.wu, this.ajl, this.bx, true) { // from class: com.bytedance.sdk.openadsdk.activity.single.TTVideoLandingPageActivity.6
            @Override // com.bytedance.sdk.openadsdk.core.widget.fm.ajl, android.webkit.WebViewClient
            public WebResourceResponse shouldInterceptRequest(WebView webView, String str) {
                try {
                    if (TextUtils.isEmpty(TTVideoLandingPageActivity.this.lz)) {
                        return super.shouldInterceptRequest(webView, str);
                    }
                    TTVideoLandingPageActivity.this.kwx.incrementAndGet();
                    WebResourceResponseModel webResourceResponseModelFm = com.bytedance.sdk.openadsdk.wsy.ro.fm().fm(TTVideoLandingPageActivity.this.f6774ne, TTVideoLandingPageActivity.this.lz, str);
                    if (webResourceResponseModelFm != null && webResourceResponseModelFm.getWebResourceResponse() != null) {
                        TTVideoLandingPageActivity.this.bkb.incrementAndGet();
                        return webResourceResponseModelFm.getWebResourceResponse();
                    }
                    if (webResourceResponseModelFm != null && webResourceResponseModelFm.getMsg() == 2) {
                        TTVideoLandingPageActivity.this.lmk.incrementAndGet();
                    }
                    return super.shouldInterceptRequest(webView, str);
                } catch (Throwable th) {
                    wey.fm("TTVideoLandingPage", "shouldInterceptRequest url error", th);
                    return super.shouldInterceptRequest(webView, str);
                }
            }
        };
        ajlVar.fm(this.onz);
        return ajlVar;
    }

    @SuppressLint({"ClickableViewAccessibility"})
    private void fhx() {
        lse lseVar = this.onz;
        if (lseVar == null || lseVar.oy() != 4) {
            return;
        }
        this.hi.setVisibility(0);
        Button button = (Button) findViewById(qhl.zzn);
        this.nt = button;
        if (button != null) {
            fm(ro());
            this.nt.setOnClickListener(this.f6772ib);
            this.nt.setOnTouchListener(this.f6772ib);
        }
    }

    private void gqi() {
        com.bytedance.sdk.openadsdk.core.fhx.ro.ajl ajlVar = this.duv;
        if (ajlVar == null || ajlVar.getNativeVideoController() == null || sds()) {
            return;
        }
        this.duv.onz();
    }

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

    private void lse() {
        try {
            JSONObject jSONObject = new JSONObject();
            jSONObject.put("isBackIntercept", true);
            this.wu.fm("temai_back_event", jSONObject);
        } catch (Exception unused) {
        }
    }

    /* JADX INFO: Access modifiers changed from: private */
    public boolean maa() {
        return !TextUtils.isEmpty(this.f6770gc) && this.f6770gc.contains("__luban_sdk");
    }

    private void qhl() {
        com.bytedance.sdk.openadsdk.core.fhx.ro.ajl ajlVar;
        if (this.gzf && (ajlVar = this.duv) != null && ajlVar.getNativeVideoController() != null) {
            this.duv.getNativeVideoController().jnr(null, null);
            this.gzf = false;
        } else if (!maa() || this.zan.getAndSet(true)) {
            super.onBackPressed();
        } else {
            lse();
            fm(0);
        }
    }

    private boolean sds() {
        com.bytedance.sdk.openadsdk.core.fhx.ro.ajl ajlVar = this.duv;
        if (ajlVar == null || ajlVar.getNativeVideoController() == null) {
            return true;
        }
        return this.duv.getNativeVideoController().dsz();
    }

    private void wey() {
        if (this.duv == null || sds()) {
            return;
        }
        this.duv.onz();
    }

    public abstract boolean ajl();

    public void duv() {
        try {
            nt.fm(this.ado);
        } catch (Exception unused) {
        }
    }

    public void ef() {
        lse lseVar = this.onz;
        if (lseVar == null || lseVar.oy() != 4) {
            return;
        }
        zan.fm((View) this.wey, 0);
        String strQlg = !TextUtils.isEmpty(this.onz.qlg()) ? this.onz.qlg() : !TextUtils.isEmpty(this.onz.nn()) ? this.onz.nn() : !TextUtils.isEmpty(this.onz.wjb()) ? this.onz.wjb() : "";
        if (this.onz.ff() != null && this.onz.ff().fm() != null) {
            zan.fm((View) this.maa, 0);
            zan.fm((View) this.sds, 4);
            com.bytedance.sdk.openadsdk.wey.ro.ro().fm(this.onz.ff(), this.maa, this.onz);
        } else if (!TextUtils.isEmpty(strQlg)) {
            zan.fm((View) this.maa, 4);
            zan.fm((View) this.sds, 0);
            this.sds.setText(strQlg.substring(0, 1));
        }
        if (!TextUtils.isEmpty(this.onz.eys())) {
            this.hlt.setText(this.onz.eys());
        }
        if (!TextUtils.isEmpty(strQlg)) {
            this.lse.setText(strQlg);
        }
        zan.fm((View) this.lse, 0);
        zan.fm((View) this.hlt, 0);
    }

    public abstract View fm();

    public void ku() {
        nt.fm(this.ado, this.jnr);
    }

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

    @Override // android.app.Activity, android.content.ComponentCallbacks
    public void onConfigurationChanged(Configuration configuration) {
        super.onConfigurationChanged(configuration);
        fhx();
    }

    @Override // com.bytedance.sdk.openadsdk.activity.single.TTBaseActivity, android.app.Activity
    public void onCreate(@Nullable Bundle bundle) {
        String strFm;
        super.onCreate(bundle);
        if (!com.bytedance.sdk.openadsdk.core.fhx.jnr()) {
            finish();
            return;
        }
        long jElapsedRealtime = SystemClock.elapsedRealtime();
        try {
            getWindow().addFlags(Http2Connection.OKHTTP_CLIENT_WINDOW_SIZE);
        } catch (Throwable unused) {
        }
        try {
            gof.ro(this);
        } catch (Throwable unused2) {
        }
        this.xgn = com.bytedance.sdk.component.utils.gof.lb(getApplicationContext());
        try {
            setContentView(fm());
            this.jnr = this;
            Intent intent = getIntent();
            this.f6771ha = intent.getBooleanExtra("video_is_auto_play", true);
            if (bundle != null && bundle.getLong("video_play_position") > 0) {
                this.dsz = bundle.getLong("video_play_position", 0L);
            }
            String stringExtra = intent.getStringExtra(TTAdConstant.MULTI_PROCESS_DATA);
            lse lseVarFm = ai.fm().fm(ai.fm(intent));
            this.onz = lseVarFm;
            if (lseVarFm != null) {
                this.ku = lseVarFm.siu();
                this.ajl = this.onz.eo();
                this.wsy = this.onz.gt();
                strFm = this.onz.qlg();
                this.lz = this.onz.kec();
                this.f6770gc = this.onz.ku();
                this.f6769ef = this.onz.dsz();
                this.ai = this.onz.duv();
            } else {
                strFm = null;
            }
            if (this.onz == null) {
                finish();
                return;
            }
            if (!TextUtils.isEmpty(this.lz)) {
                this.f6774ne = com.bytedance.sdk.openadsdk.wsy.ro.fm().ro();
                int iFm = com.bytedance.sdk.openadsdk.wsy.ro.fm().fm(this.f6774ne, this.lz);
                this.mpp = iFm;
                this.vvj = iFm > 0 ? 2 : 0;
            }
            if (stringExtra != null) {
                try {
                    this.mon = com.bytedance.sdk.openadsdk.gqi.lb.fm.fm(new JSONObject(stringExtra));
                } catch (Exception unused3) {
                }
                com.bytedance.sdk.openadsdk.gqi.lb.fm fmVar = this.mon;
                if (fmVar != null) {
                    this.dsz = fmVar.wsy;
                }
            }
            if (bundle != null) {
                this.onz = ai.fm().fm(bundle.getInt("meta_index", -1));
                long j10 = bundle.getLong("video_play_position");
                if (j10 > 0) {
                    this.dsz = j10;
                }
            }
            lb();
            vt();
            irt();
            fm(4);
            if (this.fm != null) {
                com.bytedance.sdk.openadsdk.core.widget.fm.yz.fm(this.jnr).fm(true).ro(false).fm(this.fm.getWebView());
                dsz dszVarRo = new dsz(this.onz, this.fm.getWebView(), new duv() { // from class: com.bytedance.sdk.openadsdk.activity.single.TTVideoLandingPageActivity.1
                    @Override // com.bytedance.sdk.openadsdk.yz.duv
                    public void fm(int i10) {
                        lb.fm.fm(TTVideoLandingPageActivity.this.mpp, TTVideoLandingPageActivity.this.lmk.get(), TTVideoLandingPageActivity.this.bkb.get(), TTVideoLandingPageActivity.this.kwx.get() - TTVideoLandingPageActivity.this.bkb.get(), TTVideoLandingPageActivity.this.onz, "landingpage_split_screen", i10);
                    }
                }, this.vvj).ro(true);
                this.bx = dszVarRo;
                this.f6775qf = dszVarRo.fm;
                dszVarRo.fm("landingpage_split_screen");
            }
            com.bytedance.sdk.component.ef.wsy wsyVar = this.fm;
            if (wsyVar != null) {
                wsyVar.setLandingPage(true);
                this.fm.setTag("landingpage_split_screen");
                this.fm.setMaterialMeta(this.onz.ooo());
                this.fm.setWebViewClient(dsz());
                com.bytedance.sdk.component.ef.wsy wsyVar2 = this.fm;
                wsyVar2.setUserAgentString(com.bytedance.sdk.openadsdk.utils.wey.fm(wsyVar2.getWebView(), BuildConfig.VERSION_CODE));
            }
            com.bytedance.sdk.component.ef.wsy wsyVar3 = this.fm;
            if (wsyVar3 != null) {
                wsyVar3.setMixedContentMode(0);
            }
            com.bytedance.sdk.openadsdk.yz.lb.fm(this.onz, "landingpage_split_screen", this.vvj);
            com.bytedance.sdk.openadsdk.utils.lse.fm(this.fm, this.f6770gc);
            this.fm.setWebChromeClient(new com.bytedance.sdk.openadsdk.core.widget.fm.jnr(this.wu, this.bx) { // from class: com.bytedance.sdk.openadsdk.activity.single.TTVideoLandingPageActivity.4
                @Override // com.bytedance.sdk.openadsdk.core.widget.fm.jnr, android.webkit.WebChromeClient
                public void onProgressChanged(WebView webView, int i10) {
                    super.onProgressChanged(webView, i10);
                }
            });
            this.fm.setDownloadListener(new DownloadListener() { // from class: com.bytedance.sdk.openadsdk.activity.single.TTVideoLandingPageActivity.5
                @Override // android.webkit.DownloadListener
                public void onDownloadStart(String str, String str2, String str3, String str4, long j11) {
                    TTVideoLandingPageActivity tTVideoLandingPageActivity = TTVideoLandingPageActivity.this;
                    com.bytedance.sdk.openadsdk.sds.fm.fm.lb lbVar = tTVideoLandingPageActivity.mq;
                    if (lbVar != null) {
                        lbVar.fm(tTVideoLandingPageActivity.onz);
                    }
                }
            });
            TextView textView = this.yz;
            if (textView != null) {
                if (TextUtils.isEmpty(strFm)) {
                    strFm = maa.fm(this, "tt_web_title_default");
                }
                textView.setText(strFm);
            }
            ku();
            jnr();
            fhx();
            lb.fm.fm(SystemClock.elapsedRealtime() - jElapsedRealtime, this.onz, "landingpage_split_screen", this.f6774ne, this.lz);
        } catch (Throwable unused4) {
            finish();
        }
    }

    @Override // com.bytedance.sdk.openadsdk.activity.single.TTBaseLandingPageActivity, com.bytedance.sdk.openadsdk.activity.single.TTBaseActivity, android.app.Activity
    public void onDestroy() {
        super.onDestroy();
        duv();
        try {
            if (getWindow() != null) {
                ((ViewGroup) getWindow().getDecorView()).removeAllViews();
            }
            this.onz.onz(false);
        } catch (Throwable unused) {
        }
        com.bytedance.sdk.component.ef.wsy wsyVar = this.fm;
        if (wsyVar != null) {
            bx.fm(wsyVar.getWebView());
        }
        this.fm = null;
        hxv hxvVar = this.wu;
        if (hxvVar != null) {
            hxvVar.duv();
        }
        com.bytedance.sdk.openadsdk.core.fhx.ro.ajl ajlVar = this.duv;
        if (ajlVar != null && ajlVar.getNativeVideoController() != null) {
            this.duv.getNativeVideoController().jnr();
        }
        this.duv = null;
        this.onz = null;
        dsz dszVar = this.bx;
        if (dszVar != null) {
            dszVar.yz(true);
        }
        if (!TextUtils.isEmpty(this.lz)) {
            lb.fm.fm(this.bkb.get(), this.kwx.get(), this.onz);
        }
        com.bytedance.sdk.openadsdk.wsy.ro.fm().fm(this.f6774ne);
    }

    @Override // com.bytedance.sdk.openadsdk.activity.single.TTBaseLandingPageActivity, com.bytedance.sdk.openadsdk.activity.single.TTBaseActivity, android.app.Activity
    public void onPause() {
        super.onPause();
        wey();
        com.bytedance.sdk.openadsdk.core.fhx.ro.ajl ajlVar = this.duv;
        if (ajlVar == null || ajlVar.getNativeVideoController() == null) {
            return;
        }
        fm(this.duv.getNativeVideoController());
    }

    @Override // com.bytedance.sdk.openadsdk.activity.single.TTBaseLandingPageActivity, com.bytedance.sdk.openadsdk.activity.single.TTBaseActivity, android.app.Activity
    public void onResume() {
        super.onResume();
        if (!this.wbw) {
            gqi();
        }
        this.wbw = false;
        hxv hxvVar = this.wu;
        if (hxvVar != null) {
            hxvVar.ku();
        }
        dsz dszVar = this.bx;
        if (dszVar != null) {
            dszVar.wsy();
        }
    }

    @Override // android.app.Activity
    public void onSaveInstanceState(Bundle bundle) {
        if (bundle == null) {
            bundle = new Bundle();
        }
        int iFm = this.onz != null ? ai.fm().fm(this.onz) : -1;
        this.si = iFm;
        bundle.putInt("meta_index", iFm);
        bundle.putLong("video_play_position", this.dsz);
        bundle.putBoolean("is_complete", this.ol);
        long jAjl = this.dsz;
        com.bytedance.sdk.openadsdk.core.fhx.ro.ajl ajlVar = this.duv;
        if (ajlVar != null && ajlVar.getNativeVideoController() != null) {
            jAjl = this.duv.getNativeVideoController().ajl();
        }
        bundle.putLong("video_play_position", jAjl);
        super.onSaveInstanceState(bundle);
    }

    @Override // android.app.Activity
    public void onStart() {
        super.onStart();
        if (this.si >= 0) {
            ai.fm().lb(this.si);
            this.si = -1;
        }
        com.bytedance.sdk.openadsdk.utils.yz.fm(this, this.onz);
    }

    @Override // android.app.Activity
    public void onStop() {
        super.onStop();
        dsz dszVar = this.bx;
        if (dszVar != null) {
            dszVar.wu();
        }
    }

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

    @SuppressLint({"ClickableViewAccessibility"})
    public void vt() {
        if (this.onz == null) {
            return;
        }
        this.mq = com.bytedance.sdk.openadsdk.sds.fm.fm.yz.fm(this, this.ai);
        com.bytedance.sdk.openadsdk.core.lb.fm fmVar = new com.bytedance.sdk.openadsdk.core.lb.fm(this, this.onz, this.ai, this.f6769ef);
        this.f6772ib = fmVar;
        fmVar.fm(false);
        this.f6772ib.lb(true);
        this.hlt.setOnClickListener(this.f6772ib);
        this.hlt.setOnTouchListener(this.f6772ib);
        this.f6772ib.fm(this.mq);
    }

    public long wsy() {
        com.bytedance.sdk.openadsdk.core.fhx.ro.ajl ajlVar = this.duv;
        if (ajlVar == null || ajlVar.getNativeVideoController() == null) {
            return 0L;
        }
        return this.duv.getNativeVideoController().ef();
    }

    public int wu() {
        com.bytedance.sdk.openadsdk.core.fhx.ro.ajl ajlVar = this.duv;
        if (ajlVar == null || ajlVar.getNativeVideoController() == null) {
            return 0;
        }
        return this.duv.getNativeVideoController().vt();
    }

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

    private void fm(final String str) {
        Button button;
        if (TextUtils.isEmpty(str) || (button = this.nt) == null) {
            return;
        }
        button.post(new Runnable() { // from class: com.bytedance.sdk.openadsdk.activity.single.TTVideoLandingPageActivity.7
            @Override // java.lang.Runnable
            public void run() {
                TTVideoLandingPageActivity tTVideoLandingPageActivity = TTVideoLandingPageActivity.this;
                if (tTVideoLandingPageActivity.nt == null || tTVideoLandingPageActivity.isFinishing()) {
                    return;
                }
                TTVideoLandingPageActivity.this.nt.setText(str);
            }
        });
    }

    public void jnr() {
        if (ajl()) {
            try {
                com.bytedance.sdk.openadsdk.core.fhx.ro.ajl ajlVar = new com.bytedance.sdk.openadsdk.core.fhx.ro.ajl(this.jnr, this.onz, true, null);
                this.duv = ajlVar;
                if (ajlVar.getNativeVideoController() != null) {
                    this.duv.getNativeVideoController().fm(false);
                }
                if (this.ol) {
                    this.vt.setVisibility(0);
                    this.vt.removeAllViews();
                    this.vt.addView(this.duv);
                    this.duv.ro(true);
                } else {
                    if (!this.f6771ha) {
                        this.dsz = 0L;
                    }
                    if (this.mon != null && this.duv.getNativeVideoController() != null) {
                        this.duv.getNativeVideoController().lb(this.mon.wsy);
                        this.duv.getNativeVideoController().yz(this.mon.jnr);
                        this.duv.fm(gof.yz().lb(String.valueOf(this.onz.pg())), "landingPageInit");
                    }
                    if (this.duv.fm(this.dsz, this.wbw, this.ol)) {
                        this.vt.setVisibility(0);
                        this.vt.removeAllViews();
                        this.vt.addView(this.duv);
                    }
                    if (this.duv.getNativeVideoController() != null) {
                        this.duv.getNativeVideoController().fm(false);
                        this.duv.getNativeVideoController().fm(this.mj);
                    }
                }
                String strFm = this.onz.pyj().get(0).fm();
                com.bytedance.sdk.openadsdk.vt.yz.fm().fm(strFm).fm(this.onz.pyj().get(0).ro()).ro(this.onz.pyj().get(0).lb()).jnr(zan.jnr(gof.fm())).yz(zan.lb(gof.fm())).lb(2).fm(new com.bytedance.sdk.openadsdk.vt.ro(this.onz, strFm, new irt() { // from class: com.bytedance.sdk.openadsdk.activity.single.TTVideoLandingPageActivity.10
                    @Override // com.bytedance.sdk.component.jnr.irt
                    public void fm(int i10, String str, @Nullable Throwable th) {
                    }

                    @Override // com.bytedance.sdk.component.jnr.irt
                    public void fm(ku kuVar) {
                        try {
                            Object objRo = kuVar.ro();
                            if (objRo instanceof Bitmap) {
                                new fm((Bitmap) objRo, TTVideoLandingPageActivity.this.duv.getNativeVideoController().duv()).execute(new Void[0]);
                            }
                        } catch (Exception unused) {
                        }
                    }
                }), 4);
                this.duv.findViewById(520093726).setOnTouchListener(null);
                this.duv.findViewById(520093726).setOnClickListener(null);
            } catch (Exception e10) {
                wey.lb("TTVideoLandingPage", e10.getMessage());
                if (this.duv == null) {
                    ApmHelper.reportCustomError("mNativeVideoTsView is null", "FUNCTION EXCEPTION", e10);
                }
            }
            if (this.xgn == 0) {
                try {
                    Toast.makeText(this, maa.fm(this, "tt_no_network"), 0).show();
                } catch (Throwable unused) {
                }
            }
        }
    }

    public void lb() {
        this.hi = (fhx) findViewById(qhl.ado);
        this.fm = (com.bytedance.sdk.component.ef.wsy) findViewById(qhl.f7557ib);
        ImageView imageView = (ImageView) findViewById(520093720);
        this.ro = imageView;
        if (imageView != null) {
            imageView.setOnClickListener(new View.OnClickListener() { // from class: com.bytedance.sdk.openadsdk.activity.single.TTVideoLandingPageActivity.8
                @Override // android.view.View.OnClickListener
                public void onClick(View view) {
                    JSONObject jSONObjectFm;
                    TTVideoLandingPageActivity tTVideoLandingPageActivity = TTVideoLandingPageActivity.this;
                    if (tTVideoLandingPageActivity.fm != null) {
                        wsy.fm fmVar = tTVideoLandingPageActivity.f6775qf;
                        if (fmVar != null) {
                            fmVar.fm();
                        }
                        if (TTVideoLandingPageActivity.this.fm.wu()) {
                            TTVideoLandingPageActivity.this.fm.ef();
                            return;
                        }
                        if (TTVideoLandingPageActivity.this.maa()) {
                            TTVideoLandingPageActivity.this.onBackPressed();
                            return;
                        }
                        com.bytedance.sdk.openadsdk.core.fhx.ro.ajl ajlVar = TTVideoLandingPageActivity.this.duv;
                        if (ajlVar == null || ajlVar.getNativeVideoController() == null) {
                            jSONObjectFm = null;
                        } else {
                            TTVideoLandingPageActivity tTVideoLandingPageActivity2 = TTVideoLandingPageActivity.this;
                            jSONObjectFm = com.bytedance.sdk.openadsdk.utils.bx.fm(tTVideoLandingPageActivity2.onz, tTVideoLandingPageActivity2.duv.getNativeVideoController().wsy(), TTVideoLandingPageActivity.this.duv.getNativeVideoController().ku());
                        }
                        JSONObject jSONObject = jSONObjectFm;
                        TTVideoLandingPageActivity tTVideoLandingPageActivity3 = TTVideoLandingPageActivity.this;
                        com.bytedance.sdk.openadsdk.yz.lb.fm(tTVideoLandingPageActivity3.onz, "embeded_ad", "detail_back", tTVideoLandingPageActivity3.wsy(), TTVideoLandingPageActivity.this.wu(), jSONObject, (com.bytedance.sdk.openadsdk.yz.wsy) null);
                        TTVideoLandingPageActivity.this.finish();
                    }
                }
            });
        }
        com.bytedance.sdk.openadsdk.core.fhx.ro.ajl ajlVar = this.duv;
        if (ajlVar != null) {
            ajlVar.setIsAutoPlay(this.f6771ha);
        }
        ImageView imageView2 = (ImageView) findViewById(qhl.bx);
        this.f6773lb = imageView2;
        if (imageView2 != null) {
            imageView2.setOnClickListener(new View.OnClickListener() { // from class: com.bytedance.sdk.openadsdk.activity.single.TTVideoLandingPageActivity.9
                @Override // android.view.View.OnClickListener
                public void onClick(View view) {
                    JSONObject jSONObjectFm;
                    com.bytedance.sdk.openadsdk.core.fhx.ro.ajl ajlVar2 = TTVideoLandingPageActivity.this.duv;
                    if (ajlVar2 != null) {
                        if (ajlVar2.getNativeVideoController() != null) {
                            TTVideoLandingPageActivity tTVideoLandingPageActivity = TTVideoLandingPageActivity.this;
                            jSONObjectFm = com.bytedance.sdk.openadsdk.utils.bx.fm(tTVideoLandingPageActivity.onz, tTVideoLandingPageActivity.duv.getNativeVideoController().wsy(), TTVideoLandingPageActivity.this.duv.getNativeVideoController().ku());
                        } else {
                            jSONObjectFm = null;
                        }
                        JSONObject jSONObject = jSONObjectFm;
                        TTVideoLandingPageActivity tTVideoLandingPageActivity2 = TTVideoLandingPageActivity.this;
                        com.bytedance.sdk.openadsdk.yz.lb.fm(tTVideoLandingPageActivity2.onz, "embeded_ad", "detail_skip", tTVideoLandingPageActivity2.wsy(), TTVideoLandingPageActivity.this.wu(), jSONObject, (com.bytedance.sdk.openadsdk.yz.wsy) null);
                    }
                    TTVideoLandingPageActivity.this.finish();
                }
            });
        }
        this.yz = (TextView) findViewById(qhl.cyr);
        this.vt = (FrameLayout) findViewById(qhl.mon);
        this.wey = (RelativeLayout) findViewById(qhl.zan);
        this.sds = (TextView) findViewById(qhl.lz);
        this.lse = (TextView) findViewById(qhl.f7564qf);
        this.hlt = (TextView) findViewById(qhl.si);
        this.maa = (com.bytedance.sdk.openadsdk.core.widget.fm) findViewById(qhl.tzk);
        ef();
    }

    public String ro() {
        lse lseVar = this.onz;
        if (lseVar != null && !TextUtils.isEmpty(lseVar.eys())) {
            this.gqi = this.onz.eys();
        }
        return this.gqi;
    }

    private void fm(f fVar) {
        this.ol = this.ol || fVar.dsz();
        Boolean bool = Boolean.TRUE;
        com.bytedance.sdk.openadsdk.gqi.yz.fm.fm("sp_multi_native_video_data", "key_video_is_update_flag", bool);
        com.bytedance.sdk.openadsdk.gqi.yz.fm.fm("sp_multi_native_video_data", "key_video_isfromvideodetailpage", bool);
        com.bytedance.sdk.openadsdk.gqi.yz.fm.fm("sp_multi_native_video_data", "key_native_video_complete", Boolean.valueOf(this.ol));
        com.bytedance.sdk.openadsdk.gqi.yz.fm.fm("sp_multi_native_video_data", "key_video_current_play_position", Long.valueOf(fVar.ajl()));
        com.bytedance.sdk.openadsdk.gqi.yz.fm.fm("sp_multi_native_video_data", "key_video_total_play_duration", Long.valueOf(fVar.wsy() + fVar.ef()));
        com.bytedance.sdk.openadsdk.gqi.yz.fm.fm("sp_multi_native_video_data", "key_video_duration", Long.valueOf(fVar.ef()));
    }

    private void fm(final int i10) {
        if (this.f6773lb == null || !maa()) {
            return;
        }
        xgn.fm(new Runnable() { // from class: com.bytedance.sdk.openadsdk.activity.single.TTVideoLandingPageActivity.3
            @Override // java.lang.Runnable
            public void run() {
                zan.fm((View) TTVideoLandingPageActivity.this.f6773lb, i10);
            }
        });
    }

    @Override // com.bytedance.sdk.openadsdk.ku.yz
    public void fm(boolean z10, JSONArray jSONArray) {
        if (!z10 || jSONArray == null || jSONArray.length() <= 0) {
            return;
        }
        this.tzk = jSONArray;
    }
}
