package com.bytedance.sdk.openadsdk.core.vt;

import android.app.Activity;
import android.content.Context;
import android.os.SystemClock;
import android.text.TextUtils;
import android.util.SparseArray;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.widget.FrameLayout;
import androidx.annotation.NonNull;
import com.bytedance.sdk.component.adexpress.ro.dsz;
import com.bytedance.sdk.component.adexpress.ro.vt;
import com.bytedance.sdk.openadsdk.AdSlot;
import com.bytedance.sdk.openadsdk.TTDislikeDialogAbstract;
import com.bytedance.sdk.openadsdk.activity.single.IABLandingPageActivity;
import com.bytedance.sdk.openadsdk.activity.single.TTDelegateActivity;
import com.bytedance.sdk.openadsdk.activity.single.TTWebsiteActivity;
import com.bytedance.sdk.openadsdk.api.PAGExpressAdWrapperListener;
import com.bytedance.sdk.openadsdk.core.dsz.ajl.fm;
import com.bytedance.sdk.openadsdk.core.gc;
import com.bytedance.sdk.openadsdk.core.hxv;
import com.bytedance.sdk.openadsdk.core.lb.fm;
import com.bytedance.sdk.openadsdk.core.lb.lb;
import com.bytedance.sdk.openadsdk.core.model.ai;
import com.bytedance.sdk.openadsdk.core.model.lse;
import com.bytedance.sdk.openadsdk.core.xgn;
import com.bytedance.sdk.openadsdk.core.yz.wsy;
import com.bytedance.sdk.openadsdk.hi.ro.jnr;
import com.bytedance.sdk.openadsdk.utils.bx;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.atomic.AtomicBoolean;
import org.json.JSONException;
import org.json.JSONObject;

/* JADX INFO: loaded from: classes2.dex */
public class sds extends com.bytedance.sdk.openadsdk.core.ajl.lb implements com.bytedance.sdk.component.adexpress.dynamic.yz, com.bytedance.sdk.component.adexpress.ro.fhx, com.bytedance.sdk.component.adexpress.ro.wu, fm.InterfaceC0078fm, irt {
    private com.bytedance.sdk.openadsdk.core.dsz.ajl.yz ado;
    public com.bytedance.sdk.component.adexpress.ro.yz<? extends View> ai;
    private ef ajl;
    private float aws;
    private vt.fm bkb;
    private com.bytedance.sdk.component.adexpress.ro.ef bwv;
    private boolean bx;
    public FrameLayout dsz;
    protected com.bytedance.sdk.openadsdk.core.model.lse duv;

    /* JADX INFO: renamed from: ef, reason: collision with root package name */
    protected final Context f7314ef;
    protected boolean fhx;
    private boolean fm;

    /* JADX INFO: renamed from: gc, reason: collision with root package name */
    private boolean f7315gc;
    boolean gof;
    protected int gqi;
    protected com.bytedance.sdk.component.adexpress.ro.ro gzf;

    /* JADX INFO: renamed from: ha, reason: collision with root package name */
    private float f7316ha;
    boolean hi;
    int hlt;
    private com.bytedance.sdk.openadsdk.core.dsz.lb.ro hxv;

    /* JADX INFO: renamed from: ib, reason: collision with root package name */
    private final Runnable f7317ib;
    protected com.bytedance.sdk.component.adexpress.ro.lb irt;
    private float jm;
    private PAGExpressAdWrapperListener jnr;
    protected AdSlot ku;
    private mq kwx;

    /* JADX INFO: renamed from: lb, reason: collision with root package name */
    private com.bytedance.sdk.openadsdk.lb.lb f7318lb;
    private com.bytedance.sdk.openadsdk.core.yz.ef lcp;
    private List<com.bytedance.sdk.component.adexpress.ro.vt> lmk;
    public boolean lse;
    private lb lz;
    protected ViewGroup maa;
    private com.bytedance.sdk.openadsdk.core.dsz.ro.wsy mj;
    private wsy.fm mon;
    private com.bytedance.sdk.component.adexpress.ro.irt mpp;
    long mq;

    /* JADX INFO: renamed from: ne, reason: collision with root package name */
    private final Runnable f7319ne;
    private long no;
    public com.bytedance.sdk.openadsdk.yz.wsy nt;
    protected Activity ol;
    protected boolean onz;
    private float pbk;
    private int pcm;
    private String pkk;

    /* JADX INFO: renamed from: qf, reason: collision with root package name */
    private final ViewTreeObserver.OnScrollChangedListener f7320qf;
    protected com.bytedance.sdk.openadsdk.yz.yz.jnr qhl;
    private float rka;
    private int ro;
    protected HashSet<String> sds;
    private final Runnable si;
    private final SparseArray<lb.fm> so;
    private final AtomicBoolean tzk;
    protected String vt;
    private com.bytedance.sdk.component.adexpress.ro.ajl vvj;
    private float wbw;
    protected String wey;
    private vt wsy;
    private String wu;
    private String xgn;
    private com.bytedance.sdk.component.adexpress.ro.dsz ywr;
    private TTDislikeDialogAbstract yz;
    private lse zan;

    public sds(Activity activity, @NonNull Context context, com.bytedance.sdk.openadsdk.core.model.lse lseVar, AdSlot adSlot, String str) {
        super(context);
        this.fm = true;
        this.ro = 0;
        this.vt = "embeded_ad";
        this.wu = null;
        this.fhx = false;
        this.gof = true;
        this.gqi = -1;
        this.pkk = "";
        this.lse = false;
        this.bx = true;
        this.hlt = -1;
        this.nt = new com.bytedance.sdk.openadsdk.yz.wsy();
        this.mq = 0L;
        this.tzk = new AtomicBoolean(false);
        this.f7320qf = new ViewTreeObserver.OnScrollChangedListener() { // from class: com.bytedance.sdk.openadsdk.core.vt.sds.1
            @Override // android.view.ViewTreeObserver.OnScrollChangedListener
            public void onScrollChanged() {
                sds sdsVar = sds.this;
                if (sdsVar.gof && sdsVar.vt()) {
                    sds.this.ai();
                    sds sdsVar2 = sds.this;
                    sdsVar2.removeCallbacks(sdsVar2.si);
                    sds sdsVar3 = sds.this;
                    sdsVar3.postDelayed(sdsVar3.si, 500L);
                }
            }
        };
        this.si = new Runnable() { // from class: com.bytedance.sdk.openadsdk.core.vt.sds.2
            @Override // java.lang.Runnable
            public void run() {
                if (!gc.fm(sds.this, 0, 5, false)) {
                    sds.this.ajl(8);
                } else {
                    sds sdsVar = sds.this;
                    sdsVar.ajl(sdsVar.getVisibility());
                }
            }
        };
        this.f7317ib = new Runnable() { // from class: com.bytedance.sdk.openadsdk.core.vt.sds.3
            @Override // java.lang.Runnable
            public void run() {
                sds.this.ajl(0);
            }
        };
        this.f7319ne = new Runnable() { // from class: com.bytedance.sdk.openadsdk.core.vt.sds.4
            @Override // java.lang.Runnable
            public void run() {
                sds.this.ajl(8);
            }
        };
        this.pcm = 8;
        this.so = new SparseArray<>();
        this.aws = -1.0f;
        this.rka = -1.0f;
        this.pbk = -1.0f;
        this.jm = -1.0f;
        this.no = 0L;
        this.ol = activity;
        this.vt = str;
        this.f7314ef = context;
        this.duv = lseVar;
        this.ku = adSlot;
        this.lse = false;
        wsy();
    }

    /* JADX INFO: Access modifiers changed from: private */
    public void ai() {
        if (this.tzk.get()) {
            this.nt.fm(System.currentTimeMillis(), gc.fm(this));
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:16:0x0054  */
    /* JADX WARN: Removed duplicated region for block: B:26:0x007c  */
    /* JADX WARN: Removed duplicated region for block: B:9:0x003b  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    private void fhx() {
        long jOptLong;
        boolean z10;
        dsz.fm fmVar;
        lse.fm fmVarZzn;
        wu();
        this.bwv = new onz(this.qhl, this.vt, this.duv, this.wu, this.f7315gc);
        final boolean zHm = this.duv.hm();
        try {
            fmVarZzn = this.duv.zzn();
        } catch (Exception unused) {
        }
        if (fmVarZzn != null) {
            String strEf = fmVarZzn.ef();
            jOptLong = !TextUtils.isEmpty(strEf) ? new JSONObject(strEf).optLong("render_delay_time") : 0L;
        }
        try {
            if (!com.bytedance.sdk.openadsdk.core.model.lse.jnr(this.duv)) {
                z10 = com.bytedance.sdk.openadsdk.core.gof.yz().onz(this.wu) == 1;
                try {
                    if (!com.bytedance.sdk.openadsdk.core.settings.ku.ro().fhx(this.wu) || this.duv.ywr() == 5 || this.duv.ywr() == 6) {
                        z10 = true;
                    } else if (this.duv.tmm() == 3) {
                    }
                } catch (Exception unused2) {
                }
            }
        } catch (Exception unused3) {
            z10 = false;
        }
        long jMin = Math.min(Math.max(jOptLong, 0L), 10000L);
        int renderTimeout = getRenderTimeout();
        double d10 = this.duv.ex() != null ? this.duv.ex().f5924d * ((double) this.duv.ex().f5938r) : 0.0d;
        int i10 = this.hlt;
        this.hi = i10 != -1 && i10 < ((int) d10);
        if (com.bytedance.sdk.openadsdk.core.dsz.jnr.fm(this.duv) || com.bytedance.sdk.openadsdk.core.dsz.jnr.ro(this.duv) || com.bytedance.sdk.openadsdk.core.dsz.ajl.fm.ajl.fm(this.vt)) {
            fm.C0055fm c0055fm = new fm.C0055fm();
            if (com.bytedance.sdk.openadsdk.core.dsz.jnr.fm(this.duv)) {
                c0055fm.fm(com.bytedance.sdk.openadsdk.core.dsz.jnr.fm(this.duv, this.vt));
            }
            c0055fm.fm((com.bytedance.adsdk.ugeno.core.gof) this.bwv);
            c0055fm.fm(this.wbw);
            c0055fm.ro(this.f7316ha);
            c0055fm.wsy(this.f7315gc);
            fmVar = c0055fm;
        } else {
            fmVar = new dsz.fm();
        }
        fmVar.jnr(zHm);
        fmVar.fm(this.vt).ro(this.duv.eo()).lb(this.duv.uuz()).yz(this.duv.gt()).fm(this.bwv).yz(this.duv.dnd()).fm(renderTimeout).ro(this.duv.qvb()).lb(this.bx).ro(this.duv.ttj()).fm(jMin).lb(this.duv.oy()).fm(com.bytedance.sdk.openadsdk.core.vt.ro.lb.ro(this.duv)).yz(z10).jnr(this.hlt).fm(this.hi).fm(d10).ajl(com.bytedance.sdk.openadsdk.core.settings.ku.ro().gqi()).ajl(com.bytedance.sdk.openadsdk.hlt.jnr.fm("inject_data_reuse_open", 0)).wsy(this.duv.dwu().fm()).wu(this.duv.dwu().ro()).fm(new com.bytedance.sdk.component.adexpress.ro.jnr() { // from class: com.bytedance.sdk.openadsdk.core.vt.sds.5
            @Override // com.bytedance.sdk.component.adexpress.ro.jnr
            public JSONObject fm() {
                try {
                    sds sdsVar = sds.this;
                    com.bytedance.sdk.openadsdk.core.model.lse lseVar = sdsVar.duv;
                    if (lseVar == null) {
                        sdsVar.pkk = "material is null";
                        return null;
                    }
                    if (zHm) {
                        sdsVar.zan = new lse();
                        float f10 = sds.this.wbw;
                        float f11 = sds.this.f7316ha;
                        sds sdsVar2 = sds.this;
                        JSONObject jSONObjectFm = com.bytedance.sdk.openadsdk.core.vt.ro.lb.fm(f10, f11, sdsVar2.fhx, sdsVar2.duv, sdsVar2.vt, sdsVar2.zan);
                        sds.this.pkk = com.bytedance.sdk.openadsdk.core.vt.ro.lb.fm();
                        return jSONObjectFm;
                    }
                    if (!com.bytedance.sdk.openadsdk.core.dsz.jnr.fm(lseVar)) {
                        float f12 = sds.this.wbw;
                        float f13 = sds.this.f7316ha;
                        sds sdsVar3 = sds.this;
                        JSONObject jSONObjectFm2 = com.bytedance.sdk.openadsdk.core.vt.ro.lb.fm(f12, f13, sdsVar3.fhx, sdsVar3.duv);
                        sds.this.lb(jSONObjectFm2);
                        return jSONObjectFm2;
                    }
                    sds.this.zan = new lse();
                    sds sdsVar4 = sds.this;
                    JSONObject jSONObjectFm3 = com.bytedance.sdk.openadsdk.core.dsz.jnr.fm(sdsVar4.duv, sdsVar4.zan);
                    sds.this.pkk = com.bytedance.sdk.openadsdk.core.dsz.jnr.fm();
                    return jSONObjectFm3;
                } catch (Throwable unused4) {
                    return null;
                }
            }
        });
        fm(fmVar);
        this.ywr = fmVar.fm();
    }

    private void gof() {
        if (com.bytedance.sdk.openadsdk.core.dsz.ajl.fm.ajl.fm(this.vt)) {
            com.bytedance.sdk.openadsdk.core.dsz.ajl.fm.ajl ajlVar = new com.bytedance.sdk.openadsdk.core.dsz.ajl.fm.ajl(this.f7314ef, this.duv, this.lse, (com.bytedance.sdk.openadsdk.core.dsz.ajl.fm) this.ywr, this, this.wbw, this.f7316ha, this.fhx, this.vt);
            com.bytedance.sdk.openadsdk.core.dsz.ro.wsy wsyVar = new com.bytedance.sdk.openadsdk.core.dsz.ro.wsy(this.f7314ef, ajlVar, this, this.ywr);
            ajlVar.fm((irt) this);
            this.lmk.add(wsyVar);
            return;
        }
        com.bytedance.sdk.component.adexpress.ro.ajl ajlVar2 = new com.bytedance.sdk.component.adexpress.ro.ajl(this.f7314ef, this.ywr, new maa(this, this.ywr));
        this.vvj = ajlVar2;
        this.lmk.add(ajlVar2);
    }

    private void gzf() {
        com.bytedance.sdk.openadsdk.core.dsz.ajl.yz yzVar;
        com.bytedance.sdk.openadsdk.core.model.lse lseVar;
        com.bytedance.sdk.openadsdk.core.model.lse lseVar2 = this.duv;
        if (lseVar2 == null || lseVar2.ie() != 1 || this.duv.no() == 2) {
            if (!com.bytedance.sdk.openadsdk.core.dsz.ajl.fm.ajl.fm(this.vt) || (lseVar = this.duv) == null || lseVar.no() == 2) {
                com.bytedance.sdk.openadsdk.core.wu.fm.fm fmVar = new com.bytedance.sdk.openadsdk.core.wu.fm.fm();
                int i10 = this.ro;
                if (i10 != 0) {
                    if (i10 == 3) {
                        com.bytedance.sdk.component.adexpress.dynamic.jnr.wsy wsyVar = new com.bytedance.sdk.component.adexpress.dynamic.jnr.wsy();
                        Context applicationContext = this.f7314ef.getApplicationContext();
                        com.bytedance.sdk.component.adexpress.ro.dsz dszVar = this.ywr;
                        boolean z10 = this.lse;
                        com.bytedance.sdk.component.adexpress.ro.ro roVar = new com.bytedance.sdk.component.adexpress.ro.ro(applicationContext, dszVar, z10, wsyVar, this, fmVar, new wsy(this.f7314ef, z10, wsyVar, dszVar, fmVar));
                        this.gzf = roVar;
                        this.lmk.add(roVar);
                        return;
                    }
                    if (i10 == 7) {
                        com.bytedance.sdk.openadsdk.core.dsz.ajl.yz yzVar2 = new com.bytedance.sdk.openadsdk.core.dsz.ajl.yz(this.f7314ef, this.duv, this.lse, (com.bytedance.sdk.openadsdk.core.dsz.ajl.fm) this.ywr, this);
                        this.ado = yzVar2;
                        com.bytedance.sdk.openadsdk.core.dsz.ro.wsy wsyVar2 = new com.bytedance.sdk.openadsdk.core.dsz.ro.wsy(this.f7314ef, yzVar2, this, this.ywr);
                        this.mj = wsyVar2;
                        wsyVar2.fm(this);
                        this.lmk.add(this.mj);
                        return;
                    }
                    switch (i10) {
                        case 10:
                            if (!this.f7315gc || (yzVar = this.ado) == null) {
                                this.ado = new com.bytedance.sdk.openadsdk.core.dsz.ajl.wsy(this.f7314ef, this.duv, this.lse, (com.bytedance.sdk.openadsdk.core.dsz.ajl.fm) this.ywr, this);
                            } else {
                                yzVar.fm(this.duv, this.lse, (com.bytedance.sdk.openadsdk.core.dsz.ajl.fm) this.ywr, this);
                            }
                            com.bytedance.sdk.openadsdk.core.dsz.ro.wsy wsyVar3 = new com.bytedance.sdk.openadsdk.core.dsz.ro.wsy(this.f7314ef, this.ado, this, this.ywr);
                            this.mj = wsyVar3;
                            wsyVar3.fm(this);
                            this.lmk.add(this.mj);
                            break;
                        case 11:
                            hi hiVar = new hi(this.f7314ef, this.ywr, this.qhl, this.duv);
                            this.kwx = hiVar;
                            hiVar.ro(this.ol);
                            com.bytedance.sdk.component.adexpress.ro.irt irtVar = new com.bytedance.sdk.component.adexpress.ro.irt(this.f7314ef, this.ywr, this.kwx, this);
                            this.mpp = irtVar;
                            this.lmk.add(irtVar);
                            break;
                    }
                }
                mq mqVar = new mq(this.f7314ef, this.ywr, this.qhl, this.duv);
                this.kwx = mqVar;
                com.bytedance.sdk.component.adexpress.ro.irt irtVar2 = new com.bytedance.sdk.component.adexpress.ro.irt(this.f7314ef, this.ywr, mqVar, this);
                this.mpp = irtVar2;
                this.lmk.add(irtVar2);
            }
        }
    }

    private void ha() {
        List<com.bytedance.sdk.component.adexpress.ro.vt> list = this.lmk;
        if (list == null) {
            return;
        }
        Iterator<com.bytedance.sdk.component.adexpress.ro.vt> it = list.iterator();
        while (it.hasNext()) {
            it.next();
        }
    }

    private void irt() {
        if (this.duv.ie() == 1 && this.duv.zn()) {
            gof();
            this.bkb = new com.bytedance.sdk.component.adexpress.ro.duv(this.lmk, this.bwv);
            return;
        }
        if (pkk()) {
            qhl();
            return;
        }
        try {
            mq();
            mq mqVar = new mq(this.f7314ef, this.ywr, this.qhl, this.duv);
            this.kwx = mqVar;
            com.bytedance.sdk.component.adexpress.ro.irt irtVar = new com.bytedance.sdk.component.adexpress.ro.irt(this.f7314ef, this.ywr, mqVar, this);
            this.mpp = irtVar;
            this.lmk.add(irtVar);
        } catch (Exception e10) {
            com.bytedance.sdk.component.utils.wey.fm("NativeExpressView", "NativeExpressView dynamicRender fail", e10);
        }
        gof();
        this.bkb = new com.bytedance.sdk.component.adexpress.ro.duv(this.lmk, this.bwv);
    }

    private void mq() {
        if (com.bytedance.sdk.openadsdk.core.fhx.jnr()) {
            return;
        }
        dsz.fm();
    }

    private boolean ol() {
        return com.bytedance.sdk.openadsdk.core.model.lse.jnr(this.duv);
    }

    private void onz() {
        lse.fm fmVarZzn = this.duv.zzn();
        if (!TextUtils.equals(this.vt, "embeded_ad") || fmVarZzn == null) {
            return;
        }
        String strVt = fmVarZzn.vt();
        if (TextUtils.isEmpty(strVt)) {
            return;
        }
        try {
            JSONObject jSONObject = new JSONObject(strVt);
            int iOptInt = jSONObject.optInt("width");
            int iOptInt2 = jSONObject.optInt("height");
            if (iOptInt == 0 || iOptInt2 == 0) {
                return;
            }
            this.f7316ha = iOptInt2;
            this.wbw = iOptInt;
        } catch (Exception unused) {
        }
    }

    private boolean pkk() {
        return TextUtils.equals(this.vt, "fullscreen_interstitial_ad") || TextUtils.equals(this.vt, "rewarded_video") || TextUtils.equals("open_ad", this.vt) || mq.ro(this.vt) || TextUtils.equals(this.vt, "embeded_ad");
    }

    private void qhl() {
        this.ro = this.duv.te();
        try {
            mq();
            gzf();
        } catch (Exception e10) {
            com.bytedance.sdk.component.utils.wey.fm("NativeExpressView", "NativeExpressView dynamicRender fail", e10);
        }
        this.fm = this.duv.cg() == 1;
        boolean zFm = com.bytedance.sdk.openadsdk.component.reward.lb.wu.fm(this.duv);
        if (this.fm && !zFm) {
            gof();
        }
        Objects.toString(this.lmk);
        this.bkb = new com.bytedance.sdk.component.adexpress.ro.duv(this.lmk, this.bwv);
    }

    private void wbw() {
        List<com.bytedance.sdk.component.adexpress.ro.vt> list = this.lmk;
        if (list == null) {
            return;
        }
        Iterator<com.bytedance.sdk.component.adexpress.ro.vt> it = list.iterator();
        while (it.hasNext()) {
            it.next();
        }
    }

    @Override // com.bytedance.sdk.component.adexpress.ro.fhx
    public void a_(int i10) {
        com.bytedance.sdk.component.adexpress.ro.ef efVar = this.bwv;
        if (efVar != null) {
            if (!this.fm) {
                efVar.wsy();
            }
            this.bwv.wu();
            ((onz) this.bwv).vt();
        }
        PAGExpressAdWrapperListener pAGExpressAdWrapperListener = this.jnr;
        if (pAGExpressAdWrapperListener != null) {
            pAGExpressAdWrapperListener.onRenderFail(this, com.bytedance.sdk.openadsdk.core.ef.fm(i10), i10);
        }
        lse lseVar = this.zan;
        if (lseVar != null) {
            lseVar.fm(this.duv, this.vt);
        }
    }

    public void ajl() {
    }

    @Override // android.view.ViewGroup, android.view.View
    public boolean dispatchTouchEvent(MotionEvent motionEvent) {
        int i10;
        ef efVar = this.ajl;
        if (efVar != null) {
            efVar.ro(motionEvent.getDeviceId());
            this.ajl.fm(motionEvent.getSource());
            this.ajl.lb(motionEvent.getToolType(0));
        }
        vt vtVar = this.wsy;
        if (vtVar != null) {
            vtVar.ro(motionEvent.getDeviceId());
            this.wsy.fm(motionEvent.getSource());
            this.wsy.lb(motionEvent.getToolType(0));
        }
        int actionMasked = motionEvent.getActionMasked();
        if (actionMasked != 0) {
            int i11 = 3;
            if (actionMasked == 1) {
                i10 = i11;
            } else if (actionMasked != 2) {
                i11 = actionMasked != 3 ? -1 : 4;
                i10 = i11;
            } else {
                this.pbk = Math.abs(motionEvent.getX() - this.aws) + this.pbk;
                this.jm = Math.abs(motionEvent.getY() - this.rka) + this.jm;
                this.aws = motionEvent.getX();
                this.rka = motionEvent.getY();
                i10 = (System.currentTimeMillis() - this.no <= 200 || (this.pbk <= 8.0f && this.jm <= 8.0f)) ? 2 : 1;
            }
        } else {
            this.aws = motionEvent.getRawX();
            this.rka = motionEvent.getRawY();
            this.no = System.currentTimeMillis();
            com.bytedance.sdk.openadsdk.core.duv.lb.fm(motionEvent);
            i10 = 0;
        }
        SparseArray<lb.fm> sparseArray = this.so;
        if (sparseArray != null) {
            sparseArray.put(motionEvent.getActionMasked(), new lb.fm(i10, motionEvent.getSize(), motionEvent.getPressure(), System.currentTimeMillis()));
        }
        try {
            return super.dispatchTouchEvent(motionEvent);
        } catch (Exception unused) {
            return false;
        }
    }

    public void dsz() {
        try {
            lb lbVar = this.lz;
            if (lbVar != null) {
                lbVar.ro();
            }
            hlt();
            removeAllViews();
            if (getParent() != null) {
                ((ViewGroup) getParent()).removeView(this);
            }
            List<com.bytedance.sdk.component.adexpress.ro.vt> list = this.lmk;
            if (list != null) {
                Iterator<com.bytedance.sdk.component.adexpress.ro.vt> it = list.iterator();
                while (it.hasNext()) {
                    it.next().fm();
                }
            }
            com.bytedance.sdk.openadsdk.hi.ro.jnr.fm(this.duv);
            com.bytedance.sdk.openadsdk.hi.fm.lb.ro(this.duv);
            this.f7318lb = null;
            this.yz = null;
            this.ku = null;
            this.duv = null;
            this.jnr = null;
            this.ajl = null;
            this.irt = null;
            this.wsy = null;
            com.bytedance.sdk.openadsdk.core.dsz.lb.ro roVar = this.hxv;
            if (roVar != null) {
                roVar.yz();
            }
        } catch (Throwable th) {
            com.bytedance.sdk.component.utils.wey.fm("NativeExpressView", "detach error", th);
        }
    }

    public void duv() {
        mq mqVar = this.kwx;
        if (mqVar == null || mqVar.jnr() == null) {
            return;
        }
        this.kwx.gof();
    }

    public boolean ef() {
        return true;
    }

    public void fm() {
    }

    public com.bytedance.sdk.openadsdk.yz.wsy getAdShowTime() {
        return this.nt;
    }

    public lb getBrandBannerController() {
        return this.lz;
    }

    public ef getClickCreativeListener() {
        return this.ajl;
    }

    public vt getClickListener() {
        return this.wsy;
    }

    public String getClosedListenerKey() {
        return this.xgn;
    }

    public int getDynamicShowType() {
        com.bytedance.sdk.component.adexpress.ro.yz<? extends View> yzVar = this.ai;
        if (yzVar != null) {
            return yzVar.lb();
        }
        return 0;
    }

    public int getExpectExpressHeight() {
        return Float.valueOf(this.f7316ha).intValue();
    }

    public int getExpectExpressWidth() {
        return Float.valueOf(this.wbw).intValue();
    }

    public PAGExpressAdWrapperListener getExpressInteractionListener() {
        return this.jnr;
    }

    public hxv getJsObject() {
        mq mqVar = this.kwx;
        if (mqVar != null) {
            return mqVar.hlt();
        }
        return null;
    }

    public int getRenderEngineCacheType() {
        ku kuVarLse;
        com.bytedance.sdk.component.adexpress.ro.yz<? extends View> yzVar = this.ai;
        if (!(yzVar instanceof mq) || (kuVarLse = ((mq) yzVar).lse()) == null) {
            return 0;
        }
        return kuVarLse.fm();
    }

    public int getRenderTimeout() {
        return com.bytedance.sdk.openadsdk.core.gof.yz().pkk();
    }

    public String getUgenTemplateErrorReason() {
        return this.pkk;
    }

    @Override // com.bytedance.sdk.openadsdk.core.lb.fm.InterfaceC0078fm
    public long getVideoProgress() {
        com.bytedance.sdk.openadsdk.core.yz.ef efVar = this.lcp;
        if (efVar != null) {
            return efVar.getVideoProgress();
        }
        return 0L;
    }

    public com.bytedance.sdk.component.ef.wsy getWebView() {
        mq mqVar = this.kwx;
        if (mqVar == null) {
            return null;
        }
        return mqVar.yz();
    }

    public void gqi() {
        com.bytedance.sdk.openadsdk.core.model.yz yzVarKl;
        com.bytedance.sdk.openadsdk.core.onz.yz yzVarFm;
        com.bytedance.sdk.component.adexpress.ro.yz<? extends View> yzVar = this.ai;
        if (yzVar instanceof mq) {
            if (yzVar == null) {
                return;
            }
            ((mq) yzVar).ku();
            com.bytedance.sdk.openadsdk.core.model.lse lseVar = this.duv;
            com.bytedance.sdk.component.utils.ef.ro().postDelayed(new Runnable() { // from class: com.bytedance.sdk.openadsdk.core.vt.sds.6
                @Override // java.lang.Runnable
                public void run() {
                    sds.this.jnr(1);
                }
            }, ((long) (lseVar != null ? lseVar.nt().yz() : 5)) * 1000);
        } else if (yzVar instanceof com.bytedance.sdk.openadsdk.core.dsz.ajl.wsy) {
            ((com.bytedance.sdk.openadsdk.core.dsz.ajl.wsy) yzVar).ku();
        }
        com.bytedance.sdk.openadsdk.core.model.lse lseVar2 = this.duv;
        if (lseVar2 != null && (yzVarKl = lseVar2.kl()) != null && (yzVarFm = yzVarKl.fm()) != null) {
            yzVarFm.fm(0L);
        }
        if ((this.ai instanceof com.bytedance.sdk.openadsdk.core.dsz.ajl.wsy) && com.bytedance.sdk.openadsdk.core.model.qhl.fm(this.duv)) {
            fm(this.ai);
        }
    }

    public boolean hi() {
        return this.tzk.get();
    }

    public void hlt() {
        com.bytedance.sdk.openadsdk.core.model.yz yzVarKl;
        com.bytedance.sdk.openadsdk.core.onz.yz yzVarFm;
        com.bytedance.sdk.openadsdk.core.model.lse lseVar = this.duv;
        if (lseVar == null || (yzVarKl = lseVar.kl()) == null || (yzVarFm = yzVarKl.fm()) == null) {
            return;
        }
        yzVarFm.jnr(getVideoProgress());
    }

    public int jnr() {
        return 0;
    }

    public void ku() {
        mq mqVar = this.kwx;
        if (mqVar == null || mqVar.jnr() == null) {
            return;
        }
        this.kwx.ef();
    }

    public long lb() {
        return 0L;
    }

    public boolean lse() {
        com.bytedance.sdk.component.adexpress.ro.yz<? extends View> yzVar = this.ai;
        return yzVar != null && (yzVar instanceof maa);
    }

    public void maa() {
        try {
            FrameLayout frameLayout = this.dsz;
            if (frameLayout == null || frameLayout.getParent() == null) {
                return;
            }
            removeView(this.dsz);
        } catch (Throwable unused) {
        }
    }

    public void nt() {
        com.bytedance.sdk.openadsdk.core.dsz.lb.ro roVar = new com.bytedance.sdk.openadsdk.core.dsz.lb.ro(this.f7314ef, this.duv);
        this.hxv = roVar;
        roVar.fm(this);
        this.hxv.fm(new com.bytedance.sdk.openadsdk.core.dsz.lb.fm() { // from class: com.bytedance.sdk.openadsdk.core.vt.sds.7
            @Override // com.bytedance.sdk.openadsdk.core.dsz.lb.fm
            public void fm(View view, int i10, com.bytedance.sdk.component.adexpress.lb lbVar) {
                fm(view, i10, lbVar);
            }
        });
    }

    @Override // android.view.ViewGroup, android.view.View
    public void onAttachedToWindow() {
        super.onAttachedToWindow();
        ai();
        wbw();
        getViewTreeObserver().addOnScrollChangedListener(this.f7320qf);
        com.bytedance.sdk.openadsdk.core.vt.ro().fm(this.xgn, this.mon);
    }

    @Override // android.view.ViewGroup, android.view.View
    public void onDetachedFromWindow() {
        super.onDetachedFromWindow();
        getViewTreeObserver().removeOnScrollChangedListener(this.f7320qf);
        com.bytedance.sdk.openadsdk.core.vt.ro().ajl(this.xgn);
        ha();
        fm(8, true, true);
    }

    @Override // android.view.View
    public void onFinishTemporaryDetach() {
        super.onFinishTemporaryDetach();
    }

    @Override // android.widget.FrameLayout, android.view.ViewGroup, android.view.View
    public void onLayout(boolean z10, int i10, int i11, int i12, int i13) {
        super.onLayout(z10, i10, i11, i12, i13);
        ai();
    }

    @Override // android.view.View
    public void onStartTemporaryDetach() {
        super.onStartTemporaryDetach();
    }

    @Override // android.view.View
    public void onWindowFocusChanged(boolean z10) {
        super.onWindowFocusChanged(z10);
        onWindowVisibilityChanged(z10 ? getVisibility() : 8);
        ai();
        com.bytedance.sdk.openadsdk.hi.fm.lb.fm(this.duv, z10);
        if (com.bytedance.sdk.openadsdk.component.reward.lb.wu.fm(this.duv)) {
            return;
        }
        if (z10) {
            com.bytedance.sdk.openadsdk.hi.ro.jnr.fm(this.duv, 4);
        } else {
            com.bytedance.sdk.openadsdk.hi.ro.jnr.fm(this.duv, 8);
        }
    }

    @Override // android.view.View
    public void onWindowVisibilityChanged(int i10) {
        super.onWindowVisibilityChanged(i10);
        if (wey()) {
            fm(i10, true, false);
        }
    }

    @Override // com.bytedance.sdk.component.adexpress.dynamic.yz
    public void onvideoComplate() {
    }

    public void ro() {
    }

    public void sds() {
        if (this.duv == null) {
            return;
        }
        this.mq = SystemClock.elapsedRealtime();
        if (this.duv.yur()) {
            lb lbVar = this.lz;
            if (lbVar == null) {
                a_(106);
                return;
            } else {
                lbVar.fm((com.bytedance.sdk.component.adexpress.ro.fhx) this);
                this.lz.fm();
                return;
            }
        }
        this.qhl.fm();
        vt.fm fmVar = this.bkb;
        if (fmVar != null) {
            fmVar.fm(this);
        }
        try {
            this.bkb.fm();
        } catch (Throwable unused) {
        }
    }

    public void setActivity(Activity activity) {
        this.ol = activity;
    }

    public void setBackupListener(com.bytedance.sdk.component.adexpress.ro.lb lbVar) {
        this.irt = lbVar;
        com.bytedance.sdk.component.adexpress.ro.ajl ajlVar = this.vvj;
        if (ajlVar != null) {
            ajlVar.fm(lbVar);
        }
    }

    public void setBannerClickClosedListener(wsy.fm fmVar) {
        this.mon = fmVar;
    }

    public void setClickCreativeListener(ef efVar) {
        this.ajl = efVar;
        if (efVar != null) {
            efVar.fm((fm.InterfaceC0078fm) this);
        }
    }

    public void setClickListener(vt vtVar) {
        this.wsy = vtVar;
    }

    public void setClosedListenerKey(String str) {
        this.xgn = str;
        lb lbVar = this.lz;
        if (lbVar != null) {
            lbVar.fm(str);
        }
    }

    public void setDirectDestroyWebView(boolean z10) {
        com.bytedance.sdk.component.adexpress.ro.yz<? extends View> yzVar = this.ai;
        if (yzVar instanceof com.bytedance.sdk.component.adexpress.jnr.fm) {
            ((com.bytedance.sdk.component.adexpress.jnr.fm) yzVar).ro(z10);
        }
    }

    public void setDislike(com.bytedance.sdk.openadsdk.lb.lb lbVar) {
        fm fmVar;
        com.bytedance.sdk.component.adexpress.ro.yz<? extends View> yzVar = this.ai;
        if (yzVar != null && (yzVar instanceof maa) && (fmVar = (fm) yzVar.jnr()) != null) {
            fmVar.setDislikeInner(lbVar);
        }
        lb lbVar2 = this.lz;
        if (lbVar2 != null) {
            lbVar2.fm(lbVar);
        }
        this.f7318lb = lbVar;
    }

    public void setExpressInteractionListener(PAGExpressAdWrapperListener pAGExpressAdWrapperListener) {
        this.jnr = pAGExpressAdWrapperListener;
        lb lbVar = this.lz;
        if (lbVar != null) {
            lbVar.fm(pAGExpressAdWrapperListener);
        }
    }

    public void setJsbLandingPageOpenListener(com.bytedance.sdk.openadsdk.core.widget.jnr jnrVar) {
        if (this.kwx != null && getJsObject() != null) {
            getJsObject().fm(jnrVar);
        }
        com.bytedance.sdk.openadsdk.core.dsz.ajl.yz yzVar = this.ado;
        if (yzVar != null) {
            yzVar.fm(jnrVar);
        }
    }

    public void setOuterDislike(TTDislikeDialogAbstract tTDislikeDialogAbstract) {
        fm fmVar;
        com.bytedance.sdk.component.adexpress.ro.yz<? extends View> yzVar = this.ai;
        if (yzVar != null && (yzVar instanceof maa) && (fmVar = (fm) yzVar.jnr()) != null) {
            fmVar.setDislikeOuter(tTDislikeDialogAbstract);
        }
        lb lbVar = this.lz;
        if (lbVar != null) {
            lbVar.fm(tTDislikeDialogAbstract);
        }
        this.yz = tTDislikeDialogAbstract;
    }

    public void setSoundMute(boolean z10) {
        this.lse = z10;
        com.bytedance.sdk.component.adexpress.ro.ro roVar = this.gzf;
        if (roVar != null && roVar.ro() != null) {
            this.gzf.ro().setSoundMute(z10);
        }
        com.bytedance.sdk.component.adexpress.ro.yz<? extends View> yzVar = this.ai;
        if (yzVar instanceof com.bytedance.sdk.openadsdk.core.dsz.ajl.yz) {
            ((com.bytedance.sdk.openadsdk.core.dsz.ajl.yz) yzVar).setSoundMute(z10);
        }
    }

    @Override // com.bytedance.sdk.component.adexpress.dynamic.yz
    public void setTime(CharSequence charSequence, int i10, int i11, boolean z10) {
        try {
            int i12 = Integer.parseInt(String.valueOf(charSequence));
            ro(i12, i10);
            com.bytedance.sdk.openadsdk.core.dsz.lb.ro roVar = this.hxv;
            if (roVar != null) {
                roVar.fm(i12);
            }
        } catch (NumberFormatException unused) {
        }
    }

    @Override // com.bytedance.sdk.component.adexpress.dynamic.yz
    public void setTimeUpdate(int i10) {
    }

    public void setVastVideoHelper(com.bytedance.sdk.openadsdk.core.yz.ef efVar) {
        this.lcp = efVar;
    }

    public void setVideoBusiness(com.bytedance.sdk.openadsdk.core.fhx.yz.ro roVar) {
        mq mqVar = this.kwx;
        if (mqVar != null) {
            mqVar.fm(roVar);
        }
    }

    public void setVideoFrameChangeListener(com.bytedance.sdk.openadsdk.dsz.wu wuVar) {
        if (this.kwx == null || getJsObject() == null) {
            return;
        }
        getJsObject().fm(wuVar);
    }

    public boolean vt() {
        return true;
    }

    public boolean wey() {
        return true;
    }

    public void wsy() {
        this.sds = new HashSet<>();
        AdSlot adSlot = this.ku;
        if (adSlot != null) {
            this.wbw = adSlot.getExpressViewAcceptedWidth();
            this.f7316ha = this.ku.getExpressViewAcceptedHeight();
            onz();
            this.wu = this.ku.getCodeId();
            if (TextUtils.equals(this.vt, "fullscreen_interstitial_ad")) {
                this.hlt = this.duv.mxq();
            } else if (TextUtils.equals(this.vt, "rewarded_video")) {
                this.hlt = this.duv.we();
            } else if (TextUtils.equals(this.vt, "open_ad")) {
                com.bytedance.sdk.openadsdk.core.model.lse lseVar = this.duv;
                if (lseVar == null || lseVar.ro() < 0) {
                    this.hlt = com.bytedance.sdk.openadsdk.core.gof.yz().lse(this.wu);
                } else {
                    this.hlt = this.duv.ro();
                }
                if (this.hlt < 0) {
                    this.hlt = 5;
                }
            }
        }
        setBackgroundColor(0);
        if (this.duv.yur()) {
            this.lz = new lb(this.f7314ef, this, this.duv, this.vt);
            return;
        }
        fhx();
        this.lmk = new ArrayList();
        irt();
        com.bytedance.sdk.component.adexpress.ro.irt irtVar = this.mpp;
        if (irtVar != null) {
            this.kwx = (mq) irtVar.ro();
        }
        hxv jsObject = getJsObject();
        if (jsObject != null) {
            jsObject.ajl(this.vt);
        }
    }

    public void wu() {
        this.qhl = new com.bytedance.sdk.openadsdk.yz.gqi(1, this.vt, this.duv);
    }

    public long yz() {
        return 0L;
    }

    public void ajl(int i10) {
        com.bytedance.sdk.component.adexpress.ro.yz<? extends View> yzVar = this.ai;
        if (yzVar == null || !(yzVar instanceof mq)) {
            return;
        }
        ((mq) yzVar).fm(i10);
        this.pcm = i10;
    }

    public void fm(int i10) {
    }

    public void lb(JSONObject jSONObject) {
    }

    public void ro(int i10) {
    }

    public void fm(int i10, com.bytedance.sdk.component.adexpress.ro.onz onzVar) {
    }

    public void jnr(int i10) {
        if (com.bytedance.sdk.openadsdk.core.model.wey.lb(this.duv)) {
            com.bytedance.sdk.component.adexpress.ro.yz<? extends View> yzVar = this.ai;
            if (yzVar instanceof mq) {
                ((mq) yzVar).ro(i10);
            }
        }
    }

    public boolean ro(com.bytedance.sdk.component.adexpress.ro.onz onzVar) {
        return true;
    }

    public void fm(int i10, String str) {
    }

    public jnr.fm lb(int i10) {
        return new jnr.fm(i10);
    }

    public boolean ro(JSONObject jSONObject) {
        return false;
    }

    public void fm(dsz.fm fmVar) {
    }

    public void fm(String str, JSONObject jSONObject) {
    }

    public void ro(int i10, int i11) {
        int iMin;
        if (TextUtils.equals(this.vt, "banner_ad")) {
            return;
        }
        String str = this.vt;
        int i12 = this.hlt;
        int i13 = ((i11 < i12 || i12 < 0 || !(this.hi || TextUtils.equals(str, "open_ad"))) && !((i10 == 0 && TextUtils.equals(this.vt, "open_ad")) || jnr() == 5)) ? 0 : 1;
        if (i11 <= this.hlt) {
            com.bytedance.sdk.openadsdk.core.model.lse lseVar = this.duv;
            iMin = (lseVar == null || lseVar.ex() == null) ? this.hlt - i11 : (int) (Math.min(this.hlt, this.duv.ex().f5924d * ((double) this.duv.ex().f5938r)) - ((double) i11));
        } else {
            iMin = 0;
        }
        com.bytedance.sdk.component.adexpress.ro.ro roVar = this.gzf;
        if (roVar != null && roVar.ro() != null) {
            this.gzf.ro().setTime(String.valueOf(i10), i13, iMin, false);
        }
        com.bytedance.sdk.component.adexpress.ro.yz<? extends View> yzVar = this.ai;
        if (yzVar instanceof com.bytedance.sdk.openadsdk.core.dsz.ajl.yz) {
            ((com.bytedance.sdk.openadsdk.core.dsz.ajl.yz) yzVar).setTime(String.valueOf(i10), i13, iMin, false);
        }
    }

    public void fm(boolean z10, String str) {
    }

    public boolean fm(JSONObject jSONObject) {
        return false;
    }

    public sds(@NonNull Context context, com.bytedance.sdk.openadsdk.core.model.lse lseVar, AdSlot adSlot, String str) {
        super(context);
        this.fm = true;
        this.ro = 0;
        this.vt = "embeded_ad";
        this.wu = null;
        this.fhx = false;
        this.gof = true;
        this.gqi = -1;
        this.pkk = "";
        this.lse = false;
        this.bx = true;
        this.hlt = -1;
        this.nt = new com.bytedance.sdk.openadsdk.yz.wsy();
        this.mq = 0L;
        this.tzk = new AtomicBoolean(false);
        this.f7320qf = new ViewTreeObserver.OnScrollChangedListener() { // from class: com.bytedance.sdk.openadsdk.core.vt.sds.1
            @Override // android.view.ViewTreeObserver.OnScrollChangedListener
            public void onScrollChanged() {
                sds sdsVar = sds.this;
                if (sdsVar.gof && sdsVar.vt()) {
                    sds.this.ai();
                    sds sdsVar2 = sds.this;
                    sdsVar2.removeCallbacks(sdsVar2.si);
                    sds sdsVar3 = sds.this;
                    sdsVar3.postDelayed(sdsVar3.si, 500L);
                }
            }
        };
        this.si = new Runnable() { // from class: com.bytedance.sdk.openadsdk.core.vt.sds.2
            @Override // java.lang.Runnable
            public void run() {
                if (!gc.fm(sds.this, 0, 5, false)) {
                    sds.this.ajl(8);
                } else {
                    sds sdsVar = sds.this;
                    sdsVar.ajl(sdsVar.getVisibility());
                }
            }
        };
        this.f7317ib = new Runnable() { // from class: com.bytedance.sdk.openadsdk.core.vt.sds.3
            @Override // java.lang.Runnable
            public void run() {
                sds.this.ajl(0);
            }
        };
        this.f7319ne = new Runnable() { // from class: com.bytedance.sdk.openadsdk.core.vt.sds.4
            @Override // java.lang.Runnable
            public void run() {
                sds.this.ajl(8);
            }
        };
        this.pcm = 8;
        this.so = new SparseArray<>();
        this.aws = -1.0f;
        this.rka = -1.0f;
        this.pbk = -1.0f;
        this.jm = -1.0f;
        this.no = 0L;
        this.vt = str;
        this.f7314ef = context;
        this.duv = lseVar;
        this.ku = adSlot;
        this.lse = false;
        wsy();
    }

    public void fm(int i10, boolean z10, boolean z11) {
        this.gof = z10;
        removeCallbacks(this.f7319ne);
        removeCallbacks(this.f7317ib);
        if (i10 == 0) {
            if (z11) {
                this.f7317ib.run();
                return;
            } else {
                postDelayed(this.f7317ib, 50L);
                return;
            }
        }
        if (z11) {
            this.f7319ne.run();
        } else {
            postDelayed(this.f7319ne, 50L);
        }
    }

    public void fm(View view, int i10, com.bytedance.sdk.component.adexpress.lb lbVar) {
        View view2;
        JSONObject jSONObject;
        com.bytedance.sdk.component.utils.wey.fm("ClickCreativeListener", "trigger Class2 method1", Integer.valueOf(i10));
        if (i10 == -1 || lbVar == null) {
            return;
        }
        HashMap map = new HashMap();
        if (ai.lb(this.duv)) {
            map.put("click_scence", 3);
        } else {
            map.put("click_scence", 1);
        }
        map.put("dynamic_show_type", Integer.valueOf(getDynamicShowType()));
        com.bytedance.sdk.openadsdk.core.model.irt irtVar = (com.bytedance.sdk.openadsdk.core.model.irt) lbVar;
        if (com.bytedance.sdk.openadsdk.component.reward.lb.wu.fm(this.duv)) {
            map.put("duration", Integer.valueOf(irtVar.qhl));
        }
        if (com.bytedance.sdk.openadsdk.core.model.wey.lb(this.duv)) {
            try {
                JSONObject jSONObject2 = irtVar.dsz;
                if (jSONObject2 != null) {
                    int iOptInt = jSONObject2.optInt("click_type", 0);
                    JSONObject jSONObject3 = new JSONObject();
                    jSONObject3.put("click_type", iOptInt);
                    map.put("pag_json_data", jSONObject3.toString());
                }
            } catch (Throwable th) {
                com.bytedance.sdk.component.utils.wey.lb(th.toString(), new Object[0]);
            }
        }
        ef efVar = this.ajl;
        if (efVar != null) {
            efVar.yz(getDynamicShowType());
            this.ajl.fm(map);
        }
        vt vtVar = this.wsy;
        if (vtVar != null) {
            vtVar.yz(getDynamicShowType());
            this.wsy.fm(map);
        }
        float f10 = irtVar.fm;
        float f11 = irtVar.ro;
        float f12 = irtVar.f7178lb;
        float f13 = irtVar.yz;
        boolean z10 = irtVar.ku;
        SparseArray<lb.fm> sparseArray = irtVar.vt;
        if (sparseArray == null || sparseArray.size() == 0) {
            sparseArray = this.so;
        }
        SparseArray<lb.fm> sparseArray2 = sparseArray;
        String str = irtVar.wsy;
        if (view == null) {
            view2 = this;
        } else {
            jSONObjectFm = view != this ? fm(view) : null;
            view2 = view;
        }
        irtVar.wu = i10;
        if (jSONObjectFm != null && irtVar.f7177ef == null) {
            irtVar.f7177ef = jSONObjectFm;
        }
        if (i10 != 13) {
            switch (i10) {
                case 1:
                    FrameLayout frameLayout = this.dsz;
                    if (frameLayout != null) {
                        frameLayout.dispatchTouchEvent(MotionEvent.obtain(0L, 0L, 0, 0.0f, 0.0f, 0));
                    }
                    com.bytedance.sdk.openadsdk.core.model.lse lseVar = this.duv;
                    if (lseVar == null || lseVar.aws() != 1 || z10) {
                        vt vtVar2 = this.wsy;
                        if (vtVar2 != null) {
                            vtVar2.fm(irtVar);
                            this.wsy.fm(str);
                            this.wsy.fm(view2, f10, f11, f12, f13, sparseArray2, z10);
                        }
                        PAGExpressAdWrapperListener pAGExpressAdWrapperListener = this.jnr;
                        if (pAGExpressAdWrapperListener != null && !irtVar.onz) {
                            pAGExpressAdWrapperListener.onAdClicked();
                            break;
                        }
                    }
                    break;
                case 2:
                    if (irtVar.duv > 0) {
                        xgn.fm(true);
                    }
                    ef efVar2 = this.ajl;
                    if (efVar2 != null) {
                        efVar2.fm(irtVar);
                        this.ajl.fm(str);
                        if (com.bytedance.sdk.openadsdk.core.model.wey.lb(this.duv) && (jSONObject = irtVar.dsz) != null) {
                            this.ajl.yz(jSONObject.optBoolean("is_ceiling_page", false));
                        }
                        this.ajl.fm(view2, f10, f11, f12, f13, sparseArray2, z10);
                    }
                    PAGExpressAdWrapperListener pAGExpressAdWrapperListener2 = this.jnr;
                    if (pAGExpressAdWrapperListener2 != null && !irtVar.onz) {
                        pAGExpressAdWrapperListener2.onAdClicked();
                    }
                    xgn.fm(false);
                    if (!com.bytedance.sdk.openadsdk.component.reward.lb.wu.fm(this.duv)) {
                        com.bytedance.sdk.openadsdk.hi.ro.jnr.fm(this.duv, 9);
                    }
                    break;
                case 3:
                    TTDislikeDialogAbstract tTDislikeDialogAbstract = this.yz;
                    if (tTDislikeDialogAbstract == null) {
                        com.bytedance.sdk.openadsdk.lb.lb lbVar2 = this.f7318lb;
                        if (lbVar2 != null) {
                            lbVar2.fm();
                        } else {
                            TTDelegateActivity.fm(this.duv, this.xgn);
                        }
                    } else {
                        tTDislikeDialogAbstract.show();
                    }
                    break;
                case 4:
                    FrameLayout frameLayout2 = this.dsz;
                    if (frameLayout2 != null) {
                        frameLayout2.dispatchTouchEvent(MotionEvent.obtain(0L, 0L, 0, 0.0f, 0.0f, 0));
                    }
                    com.bytedance.sdk.openadsdk.core.model.lse lseVar2 = this.duv;
                    if (lseVar2 == null || lseVar2.aws() != 1 || z10) {
                        bx.lb(this.duv);
                        if ("embeded_ad".equals(this.vt) && ol() && !this.onz && bx.lb(this.duv)) {
                            ef efVar3 = this.ajl;
                            if (efVar3 != null) {
                                efVar3.fm(irtVar);
                                this.ajl.fm(str);
                                this.ajl.fm(view2, f10, f11, f12, f13, sparseArray2, z10);
                            }
                        } else {
                            vt vtVar3 = this.wsy;
                            if (vtVar3 != null) {
                                vtVar3.fm(irtVar);
                                this.wsy.fm(str);
                                this.wsy.fm(view2, f10, f11, f12, f13, sparseArray2, z10);
                            }
                        }
                        PAGExpressAdWrapperListener pAGExpressAdWrapperListener3 = this.jnr;
                        if (pAGExpressAdWrapperListener3 != null && !irtVar.onz) {
                            pAGExpressAdWrapperListener3.onAdClicked();
                            break;
                        }
                    }
                    break;
                case 5:
                    fm(!this.lse, "dynamicClick");
                    break;
                case 6:
                    fm();
                    break;
                case 7:
                    if (com.bytedance.sdk.openadsdk.utils.ro.jnr() && com.bytedance.sdk.openadsdk.core.gof.yz().ai()) {
                        IABLandingPageActivity.fm(this.f7314ef, this.duv, this.vt);
                    } else {
                        TTWebsiteActivity.fm(this.f7314ef, this.duv, this.vt);
                    }
                    break;
            }
            return;
        }
        int i11 = irtVar.fhx;
        if (i11 >= 0) {
            JSONObject jSONObject4 = new JSONObject();
            try {
                jSONObject4.put("switch", i11);
                fm(jSONObject4);
            } catch (Throwable unused) {
            }
        }
    }

    public sds(@NonNull Context context, com.bytedance.sdk.openadsdk.core.model.lse lseVar, AdSlot adSlot, String str, boolean z10, boolean z11) {
        super(context);
        this.fm = true;
        this.ro = 0;
        this.vt = "embeded_ad";
        this.wu = null;
        this.fhx = false;
        this.gof = true;
        this.gqi = -1;
        this.pkk = "";
        this.lse = false;
        this.bx = true;
        this.hlt = -1;
        this.nt = new com.bytedance.sdk.openadsdk.yz.wsy();
        this.mq = 0L;
        this.tzk = new AtomicBoolean(false);
        this.f7320qf = new ViewTreeObserver.OnScrollChangedListener() { // from class: com.bytedance.sdk.openadsdk.core.vt.sds.1
            @Override // android.view.ViewTreeObserver.OnScrollChangedListener
            public void onScrollChanged() {
                sds sdsVar = sds.this;
                if (sdsVar.gof && sdsVar.vt()) {
                    sds.this.ai();
                    sds sdsVar2 = sds.this;
                    sdsVar2.removeCallbacks(sdsVar2.si);
                    sds sdsVar3 = sds.this;
                    sdsVar3.postDelayed(sdsVar3.si, 500L);
                }
            }
        };
        this.si = new Runnable() { // from class: com.bytedance.sdk.openadsdk.core.vt.sds.2
            @Override // java.lang.Runnable
            public void run() {
                if (!gc.fm(sds.this, 0, 5, false)) {
                    sds.this.ajl(8);
                } else {
                    sds sdsVar = sds.this;
                    sdsVar.ajl(sdsVar.getVisibility());
                }
            }
        };
        this.f7317ib = new Runnable() { // from class: com.bytedance.sdk.openadsdk.core.vt.sds.3
            @Override // java.lang.Runnable
            public void run() {
                sds.this.ajl(0);
            }
        };
        this.f7319ne = new Runnable() { // from class: com.bytedance.sdk.openadsdk.core.vt.sds.4
            @Override // java.lang.Runnable
            public void run() {
                sds.this.ajl(8);
            }
        };
        this.pcm = 8;
        this.so = new SparseArray<>();
        this.aws = -1.0f;
        this.rka = -1.0f;
        this.pbk = -1.0f;
        this.jm = -1.0f;
        this.no = 0L;
        this.vt = str;
        this.f7314ef = context;
        this.duv = lseVar;
        this.ku = adSlot;
        this.lse = z10;
        this.bx = z11;
        wsy();
    }

    public void ro(int i10, String str) {
        hxv hxvVarHlt;
        com.bytedance.sdk.component.adexpress.ro.yz<? extends View> yzVar = this.ai;
        if (yzVar == null || !(yzVar instanceof mq) || (hxvVarHlt = ((mq) yzVar).hlt()) == null) {
            return;
        }
        JSONObject jSONObject = new JSONObject();
        try {
            jSONObject.put("time", i10);
            jSONObject.put("flag", str);
            hxvVarHlt.fm("onVideoPaused", jSONObject);
        } catch (JSONException unused) {
        }
    }

    public void wsy(int i10) {
        com.bytedance.sdk.component.adexpress.ro.yz<? extends View> yzVar = this.ai;
        if ((yzVar instanceof com.bytedance.sdk.openadsdk.core.dsz.ajl.wsy) && i10 == 4) {
            ((com.bytedance.sdk.openadsdk.core.dsz.ajl.wsy) yzVar).vt();
        }
    }

    public static JSONObject fm(View view) {
        try {
            int[] iArr = new int[2];
            view.getLocationOnScreen(iArr);
            JSONObject jSONObject = new JSONObject();
            jSONObject.put("width", view.getWidth());
            jSONObject.put("height", view.getHeight());
            jSONObject.put("left", iArr[0]);
            jSONObject.put("top", iArr[1]);
            return jSONObject;
        } catch (Exception unused) {
            return null;
        }
    }

    public void fm(com.bytedance.sdk.component.adexpress.ro.yz<? extends View> yzVar, com.bytedance.sdk.component.adexpress.ro.onz onzVar) {
        com.bytedance.sdk.openadsdk.core.model.lse lseVar;
        this.tzk.set(true);
        this.ai = yzVar;
        yzVar.lb();
        if (this.pcm != getWindowVisibility() && ef()) {
            ajl(getWindowVisibility());
        }
        if (yzVar.lb() == 3 && (lseVar = this.duv) != null && lseVar.ywr() == 1) {
            this.duv.duv(0);
        }
        if (yzVar.lb() != 1 || (yzVar instanceof com.bytedance.sdk.openadsdk.core.dsz.ajl.yz)) {
            View viewJnr = yzVar.jnr();
            if (viewJnr.getParent() != null) {
                ((ViewGroup) viewJnr.getParent()).removeView(viewJnr);
            }
            ArrayList arrayList = new ArrayList();
            for (int i10 = 0; i10 < getChildCount(); i10++) {
                arrayList.add(getChildAt(i10));
            }
            for (int i11 = 0; i11 < arrayList.size(); i11++) {
                if (arrayList.get(i11) instanceof com.bytedance.sdk.component.ef.wsy) {
                    removeView((View) arrayList.get(i11));
                }
            }
            if (com.bytedance.sdk.openadsdk.core.model.wey.lb(this.duv)) {
                addView(yzVar.jnr(), new FrameLayout.LayoutParams(-1, -1));
            } else {
                addView(yzVar.jnr());
            }
        }
        com.bytedance.sdk.openadsdk.core.model.lse lseVar2 = this.duv;
        if (lseVar2 != null) {
            com.bytedance.sdk.openadsdk.irt.yz.fm(lseVar2.ef(), this.mq, this.vt, yzVar.lb());
        }
        com.bytedance.sdk.component.adexpress.ro.ef efVar = this.bwv;
        if (efVar != null) {
            ((onz) efVar).vt();
        }
        PAGExpressAdWrapperListener pAGExpressAdWrapperListener = this.jnr;
        if (pAGExpressAdWrapperListener != null) {
            pAGExpressAdWrapperListener.onRenderSuccess(this, (float) onzVar.lb(), (float) onzVar.yz());
        }
        if ((this.ai instanceof com.bytedance.sdk.openadsdk.core.dsz.ajl.wsy) && com.bytedance.sdk.openadsdk.core.model.qhl.fm(this.duv)) {
            nt();
        }
        if (!com.bytedance.sdk.openadsdk.component.reward.lb.wu.fm(this.duv) && ro(onzVar)) {
            com.bytedance.sdk.openadsdk.hi.ro.jnr.fm(this, this.duv, lb(getDynamicShowType()));
        }
        lse lseVar3 = this.zan;
        if (lseVar3 != null) {
            lseVar3.fm(this.duv, this.vt);
        }
        com.bytedance.sdk.openadsdk.core.model.lse lseVar4 = this.duv;
        if (lseVar4 != null) {
            lseVar4.rka(yzVar.lb());
        }
    }

    public JSONObject fm(JSONObject jSONObject, com.bytedance.sdk.openadsdk.core.model.lse lseVar) {
        if (!(this.ai instanceof mq)) {
            return null;
        }
        if (jSONObject == null) {
            jSONObject = new JSONObject();
        }
        try {
            int renderEngineCacheType = getRenderEngineCacheType();
            if (lseVar != null) {
                if (lseVar.zzn() != null && lseVar.zzn().duv()) {
                    jSONObject.put("engine_version", lseVar.zzn().ku());
                } else if (lseVar.po() != null) {
                    if (com.bytedance.sdk.openadsdk.component.reward.lb.wu.fm(lseVar)) {
                        jSONObject.put("engine_version", "v4");
                    } else {
                        jSONObject.put("engine_version", "v3");
                    }
                } else if (com.bytedance.sdk.openadsdk.component.reward.lb.wu.fm(lseVar) && com.bytedance.sdk.openadsdk.core.model.wey.jnr(lseVar)) {
                    jSONObject.put("engine_version", "v4");
                } else {
                    jSONObject.put("engine_version", "v1");
                }
            }
            jSONObject.put("engine_type", renderEngineCacheType);
        } catch (Exception e10) {
            e10.getMessage();
        }
        return jSONObject;
    }

    public void fm(com.bytedance.sdk.component.adexpress.ro.yz yzVar) {
        if (this.hxv == null) {
            return;
        }
        try {
            if (yzVar instanceof com.bytedance.sdk.openadsdk.core.dsz.ajl.wsy) {
                ViewGroup viewGroup = (ViewGroup) ((com.bytedance.sdk.openadsdk.core.dsz.ajl.wsy) yzVar).ajl().ku();
                this.maa = viewGroup;
                if (viewGroup != null) {
                    this.hxv.ro();
                    View viewLb = this.hxv.lb();
                    if (viewLb != null) {
                        ViewGroup viewGroup2 = (ViewGroup) viewLb.getParent();
                        if (viewGroup2 != null) {
                            viewGroup2.removeView(viewLb);
                        }
                        this.maa.addView(viewLb, new ViewGroup.LayoutParams(-1, -1));
                    }
                }
            }
        } catch (Throwable unused) {
        }
    }

    public void fm(com.bytedance.sdk.openadsdk.core.model.lse lseVar, AdSlot adSlot, String str, boolean z10, boolean z11) {
        if (lseVar == null) {
            return;
        }
        this.vt = str;
        this.duv = lseVar;
        this.ku = adSlot;
        this.lse = z10;
        this.bx = z11;
        int iTe = lseVar.te();
        this.ro = iTe;
        if (iTe != 10) {
            return;
        }
        this.f7315gc = true;
        wsy();
        sds();
        this.f7315gc = false;
    }
}
