package com.bytedance.sdk.openadsdk.core.fhx.ro;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.text.TextUtils;
import android.util.Pair;
import android.view.SurfaceView;
import android.view.TextureView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout;
import androidx.annotation.WorkerThread;
import androidx.media3.exoplayer.rtsp.RtspMediaSource;
import b6.e;
import b6.g;
import com.bytedance.sdk.component.utils.ef;
import com.bytedance.sdk.component.utils.gof;
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.api.nativeAd.PAGNativeAd;
import com.bytedance.sdk.openadsdk.core.fhx.ro.ajl;
import com.bytedance.sdk.openadsdk.core.model.lse;
import com.bytedance.sdk.openadsdk.core.vt.mq;
import com.bytedance.sdk.openadsdk.utils.xgn;
import com.bytedance.sdk.openadsdk.yz.jnr.ro.fhx;
import com.bytedance.sdk.openadsdk.yz.wsy;
import com.iab.omid.library.bytedance2.adsession.FriendlyObstructionPurpose;
import java.lang.ref.WeakReference;
import java.util.List;
import java.util.Objects;
import v5.a;
import v5.b;
import w5.d;

/* JADX INFO: loaded from: classes2.dex */
public class lb extends com.bytedance.sdk.openadsdk.core.fhx.fm.fm {
    private final nt.fm ado;
    private ro bkb;
    private int bwv;
    private final String bx;

    /* JADX INFO: renamed from: gc, reason: collision with root package name */
    private long f7100gc;

    /* JADX INFO: renamed from: ib, reason: collision with root package name */
    private int f7101ib;
    private wsy kwx;
    private int lmk;
    private boolean lz;
    private final Runnable mj;
    private final boolean mon;
    private final a mpp;

    /* JADX INFO: renamed from: ne, reason: collision with root package name */
    private int f7102ne;

    /* JADX INFO: renamed from: qf, reason: collision with root package name */
    private WeakReference<e> f7103qf;
    private WeakReference<fm> si;
    private final boolean tzk;
    private int vvj;
    private long xgn;
    private boolean ywr;
    private final boolean zan;

    public interface fm {
        void ajl();

        void fm(int i10);
    }

    public lb(Context context, ViewGroup viewGroup, lse lseVar, String str, boolean z10, boolean z11, boolean z12, wsy wsyVar) {
        super(context, lseVar, viewGroup);
        this.f7100gc = 0L;
        this.xgn = 0L;
        this.lz = true;
        this.f7101ib = 0;
        this.f7102ne = 0;
        this.mpp = new a() { // from class: com.bytedance.sdk.openadsdk.core.fhx.ro.lb.1
            @Override // v5.a
            public void fm(b bVar) {
                com.bytedance.sdk.openadsdk.core.onz.yz yzVarFm;
                ((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) lb.this).f7085lb.post(new Runnable() { // from class: com.bytedance.sdk.openadsdk.core.fhx.ro.lb.1.1
                    @Override // java.lang.Runnable
                    public void run() {
                        try {
                            com.bytedance.sdk.openadsdk.hi.ro.jnr.fm(((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) lb.this).wu, 5);
                            com.bytedance.sdk.openadsdk.hi.fm.lb.fm(((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) lb.this).wu, 5);
                            if (((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) lb.this).gzf != null) {
                                ((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) lb.this).gzf.fm(9);
                            }
                        } catch (Exception unused) {
                        }
                        lb.this.bx();
                    }
                });
                com.bytedance.sdk.openadsdk.core.model.yz yzVarKl = ((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) lb.this).wu.kl();
                if (yzVarKl == null || (yzVarFm = yzVarKl.fm()) == null) {
                    return;
                }
                yzVarFm.yz(((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) lb.this).f7082ef);
            }

            @Override // v5.a
            public void jnr(b bVar) {
                com.bytedance.sdk.openadsdk.core.onz.yz yzVarFm;
                com.bytedance.sdk.openadsdk.core.model.yz yzVarKl = ((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) lb.this).wu.kl();
                if (yzVarKl != null && (yzVarFm = yzVarKl.fm()) != null) {
                    yzVarFm.lb(((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) lb.this).f7082ef);
                }
                if (((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) lb.this).gzf != null) {
                    ((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) lb.this).gzf.fm(1);
                }
            }

            @Override // v5.a
            public void lb(b bVar) {
            }

            @Override // v5.a
            public void ro(b bVar, int i10) {
            }

            @Override // v5.a
            public void yz(b bVar) {
                com.bytedance.sdk.openadsdk.core.onz.yz yzVarFm;
                com.bytedance.sdk.openadsdk.core.model.yz yzVarKl = ((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) lb.this).wu.kl();
                if (yzVarKl != null && (yzVarFm = yzVarKl.fm()) != null) {
                    yzVarFm.ro(((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) lb.this).f7082ef);
                }
                com.bytedance.sdk.openadsdk.hi.ro.jnr.fm(((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) lb.this).wu, 3);
                if (((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) lb.this).gzf != null) {
                    ((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) lb.this).gzf.fm(0);
                }
            }

            @Override // v5.a
            public void ro(b bVar) {
                ((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) lb.this).f7085lb.removeCallbacks(lb.this.mj);
                ((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) lb.this).f7085lb.post(new Runnable() { // from class: com.bytedance.sdk.openadsdk.core.fhx.ro.lb.1.3
                    @Override // java.lang.Runnable
                    public void run() {
                        if (lb.this.f7103qf != null && lb.this.f7103qf.get() != null) {
                            lb.this.f7103qf.get();
                        }
                        if (((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) lb.this).wsy != null) {
                            ((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) lb.this).wsy.ro();
                        }
                    }
                });
                if (lb.this.mon) {
                    return;
                }
                lb lbVar = lb.this;
                lbVar.fm(lbVar.kwx);
            }

            @Override // v5.a
            public void fm(b bVar, long j10) {
                ((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) lb.this).hlt = false;
                ((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) lb.this).f7085lb.removeCallbacks(lb.this.mj);
                ((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) lb.this).f7085lb.post(new Runnable() { // from class: com.bytedance.sdk.openadsdk.core.fhx.ro.lb.1.2
                    @Override // java.lang.Runnable
                    public void run() {
                        if (((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) lb.this).wsy != null) {
                            ((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) lb.this).wsy.ro();
                        }
                        if (!((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) lb.this).fhx || lb.this.si == null || lb.this.si.get() == null) {
                            return;
                        }
                        ((fm) lb.this.si.get()).ajl();
                    }
                });
                lb.this.pkk();
                com.bytedance.sdk.openadsdk.hi.ro.jnr.fm(((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) lb.this).wu, 0);
                if (((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) lb.this).gzf != null) {
                    ((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) lb.this).gzf.lb();
                }
                lb lbVar = lb.this;
                lbVar.fm(lbVar.kwx);
            }

            @Override // v5.a
            public void fm(b bVar, final com.bykv.vk.openvk.fm.fm.fm.lb.a aVar) {
                com.bytedance.sdk.openadsdk.core.onz.yz yzVarFm;
                String unused = ((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) lb.this).fm;
                int i10 = aVar.f5918a;
                ((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) lb.this).f7085lb.post(new Runnable() { // from class: com.bytedance.sdk.openadsdk.core.fhx.ro.lb.1.4
                    @Override // java.lang.Runnable
                    public void run() {
                        com.bykv.vk.openvk.fm.fm.fm.lb.a aVar2 = aVar;
                        int i11 = aVar2.f5918a;
                        int i12 = aVar2.f5919b;
                        if (!lb.this.mq() || i12 == -1004) {
                            if (lb.this.yz(i11, i12)) {
                                String unused2 = ((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) lb.this).fm;
                                ((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) lb.this).wsy.fm(((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) lb.this).wu, (WeakReference<Context>) null, false);
                                lb.this.ro(true);
                                lb.this.jnr();
                            }
                            if (((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) lb.this).wsy != null) {
                                ((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) lb.this).wsy.ro();
                            }
                            if (((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) lb.this).mq != null) {
                                ((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) lb.this).mq.ro(lb.this.xgn, i6.a.a(((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) lb.this).f7082ef, ((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) lb.this).pkk));
                            }
                            if (lb.this.f7103qf == null || lb.this.f7103qf.get() == null || lb.this.mq()) {
                                return;
                            }
                            ((e) lb.this.f7103qf.get()).fm(i11, i12);
                        }
                    }
                });
                lb.this.fm(aVar);
                com.bytedance.sdk.openadsdk.core.model.yz yzVarKl = ((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) lb.this).wu.kl();
                if (yzVarKl != null && (yzVarFm = yzVarKl.fm()) != null) {
                    yzVarFm.fm(com.bytedance.sdk.openadsdk.core.onz.fm.fm.GENERAL_LINEAR_AD_ERROR);
                }
                com.bytedance.sdk.openadsdk.hi.ro.jnr.fm(((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) lb.this).wu, 6);
                com.bytedance.sdk.openadsdk.hi.fm.lb.ro(((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) lb.this).wu);
                if (((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) lb.this).gzf != null) {
                    ((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) lb.this).gzf.fm(14);
                }
            }

            @Override // v5.a
            public void fm(b bVar, boolean z13) {
                ((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) lb.this).f7085lb.post(new Runnable() { // from class: com.bytedance.sdk.openadsdk.core.fhx.ro.lb.1.5
                    @Override // java.lang.Runnable
                    public void run() {
                        if (((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) lb.this).wsy != null) {
                            ((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) lb.this).wsy.ro();
                        }
                    }
                });
            }

            @Override // v5.a
            public void fm(b bVar, int i10, int i11) {
                ef.fm().post(new Runnable() { // from class: com.bytedance.sdk.openadsdk.core.fhx.ro.lb.1.6
                    @Override // java.lang.Runnable
                    public void run() {
                        lb.this.tzk();
                    }
                });
            }

            @Override // v5.a
            public void fm(b bVar, int i10, int i11, int i12) {
                ((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) lb.this).hlt = true;
                ((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) lb.this).f7085lb.post(new Runnable() { // from class: com.bytedance.sdk.openadsdk.core.fhx.ro.lb.1.7
                    @Override // java.lang.Runnable
                    public void run() {
                        if (((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) lb.this).wsy != null) {
                            ((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) lb.this).wsy.qhl();
                            ((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) lb.this).f7085lb.postDelayed(lb.this.mj, RtspMediaSource.DEFAULT_TIMEOUT_MS);
                        }
                    }
                });
                com.bytedance.sdk.openadsdk.hi.ro.jnr.fm(((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) lb.this).wu, 2);
                if (((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) lb.this).gzf != null) {
                    ((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) lb.this).gzf.fm(4);
                }
            }

            @Override // v5.a
            public void fm(b bVar, int i10) {
                ((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) lb.this).hlt = false;
                ((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) lb.this).f7085lb.removeCallbacks(lb.this.mj);
                ((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) lb.this).f7085lb.post(new Runnable() { // from class: com.bytedance.sdk.openadsdk.core.fhx.ro.lb.1.8
                    @Override // java.lang.Runnable
                    public void run() {
                        ((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) lb.this).wsy.ro();
                    }
                });
                com.bytedance.sdk.openadsdk.hi.ro.jnr.fm(((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) lb.this).wu, 0);
                if (((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) lb.this).gzf != null) {
                    ((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) lb.this).gzf.fm(5);
                }
            }

            @Override // v5.a
            public void fm(b bVar, final long j10, final long j11) {
                if (Math.abs(j10 - ((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) lb.this).f7082ef) < 50) {
                    return;
                }
                lb lbVar = lb.this;
                lbVar.fm(lbVar.kwx);
                ((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) lb.this).f7085lb.post(new Runnable() { // from class: com.bytedance.sdk.openadsdk.core.fhx.ro.lb.1.9
                    @Override // java.lang.Runnable
                    public void run() {
                        lb.this.fm(j10, j11);
                        lb.this.ro(j10, j11);
                    }
                });
            }
        };
        this.vvj = 0;
        this.mj = new Runnable() { // from class: com.bytedance.sdk.openadsdk.core.fhx.ro.lb.4
            @Override // java.lang.Runnable
            public void run() {
                if (((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) lb.this).wsy != null) {
                    ((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) lb.this).wsy.fm(((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) lb.this).wu, (WeakReference<Context>) null, false);
                    ((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) lb.this).wsy.ro();
                    lb.this.ro(true);
                    String unused = ((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) lb.this).fm;
                }
            }
        };
        this.ado = new nt.fm() { // from class: com.bytedance.sdk.openadsdk.core.fhx.ro.lb.6
            @Override // com.bytedance.sdk.component.utils.nt.fm
            @WorkerThread
            public void fm(Context context2, Intent intent, boolean z13, final int i10) {
                xgn.fm(new Runnable() { // from class: com.bytedance.sdk.openadsdk.core.fhx.ro.lb.6.1
                    @Override // java.lang.Runnable
                    public void run() {
                        lb.this.ajl(i10);
                    }
                });
            }
        };
        this.ywr = false;
        this.bwv = gof.lb(context);
        fm(z10);
        this.bx = str;
        try {
            this.f7101ib = viewGroup.getWidth();
            this.f7102ne = viewGroup.getHeight();
        } catch (Throwable unused) {
        }
        fm(context);
        this.mon = true;
        this.zan = z11;
        this.tzk = z12;
        if (wsyVar != null) {
            this.kwx = wsyVar;
        }
    }

    public void ajl(boolean z10) {
        this.lz = z10;
    }

    public void fm(int i10, int i11) {
        if (i10 == 0 || i11 == 0) {
            return;
        }
        this.f7101ib = i10;
        this.f7102ne = i11;
    }

    public int mon() {
        return this.lmk;
    }

    public void yz(int i10) {
        this.lmk = i10;
    }

    /* JADX INFO: Access modifiers changed from: private */
    public void bx() {
        this.vvj++;
        jnr jnrVar = this.wsy;
        if (jnrVar == null) {
            return;
        }
        jnrVar.ro();
        b6.b bVar = this.mq;
        if (bVar != null) {
            bVar.fm(this.xgn, i6.a.a(this.f7082ef, this.pkk));
        }
        this.xgn = System.currentTimeMillis() - this.f7100gc;
        if (this.lz) {
            this.wsy.fm(this.wu, (WeakReference<Context>) null, true);
        }
        if (!this.sds) {
            this.sds = true;
            long j10 = this.pkk;
            ro(j10, j10);
            long j11 = this.pkk;
            this.f7082ef = j11;
            this.vt = j11;
            ro(this.kwx);
        }
        if (!this.fhx && this.gqi) {
            jnr(this.wsy, null);
        }
        this.onz = true;
    }

    /* JADX INFO: Access modifiers changed from: private */
    public d lz() {
        jnr jnrVar;
        if (this.ku.getResources().getConfiguration().orientation != 1 || (jnrVar = this.wsy) == null) {
            return null;
        }
        return jnrVar.dsz();
    }

    /* JADX INFO: Access modifiers changed from: private */
    public void tzk() {
        com.bytedance.sdk.openadsdk.core.fhx.yz.lb lbVar;
        int i10;
        int i11;
        try {
            if (lz() != null && (lbVar = this.ajl) != null && this.hi != null) {
                int iYz = lbVar.yz();
                int iJnr = this.ajl.jnr();
                final int width = this.hi.getWidth();
                final int height = this.hi.getHeight();
                if (width > 0 && height > 0 && iJnr > 0 && iYz > 0) {
                    if (iYz == iJnr) {
                        i11 = width > height ? height : width;
                        i10 = i11;
                    } else if (iYz > iJnr) {
                        i11 = (int) ((((double) width) * 1.0d) / ((double) ((iYz * 1.0f) / iJnr)));
                        i10 = width;
                    } else {
                        i10 = (int) ((((double) height) * 1.0d) / ((double) ((iJnr * 1.0f) / iYz)));
                        i11 = height;
                    }
                    if (i11 <= height && i11 > 0) {
                        height = i11;
                    }
                    if (i10 <= width && i10 > 0) {
                        width = i10;
                    }
                    this.f7085lb.post(new Runnable() { // from class: com.bytedance.sdk.openadsdk.core.fhx.ro.lb.5
                        @Override // java.lang.Runnable
                        public void run() {
                            try {
                                RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(width, height);
                                layoutParams.addRule(13);
                                if (lb.this.lz() instanceof TextureView) {
                                    ((TextureView) lb.this.lz()).setLayoutParams(layoutParams);
                                    String unused = ((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) lb.this).fm;
                                } else if (lb.this.lz() instanceof SurfaceView) {
                                    ((SurfaceView) lb.this.lz()).setLayoutParams(layoutParams);
                                    String unused2 = ((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) lb.this).fm;
                                }
                            } catch (Throwable unused3) {
                                String unused4 = ((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) lb.this).fm;
                            }
                        }
                    });
                    return;
                }
                return;
            }
            Objects.toString(this.ku);
            Objects.toString(lz());
        } catch (Throwable th) {
            th.toString();
        }
    }

    /* JADX INFO: Access modifiers changed from: private */
    public boolean yz(int i10, int i11) {
        boolean z10 = i10 == -1010 || i10 == -1007 || i10 == -1004 || i10 == -110 || i10 == 100 || i10 == 200;
        if (i11 == 1 || i11 == 700 || i11 == 800) {
            return true;
        }
        return z10;
    }

    private void zan() {
        com.bytedance.sdk.openadsdk.core.fhx.yz.lb lbVar = this.ajl;
        if (lbVar != null) {
            if (!lbVar.wsy()) {
                this.ajl.fm(false, this.f7082ef, this.irt);
            } else if (this.dsz) {
                wey();
            } else {
                ro(this.hxv);
            }
        }
        if (this.wey.get()) {
            gzf();
        }
    }

    public void fm(ro roVar) {
        this.bkb = roVar;
    }

    public void gc() {
        com.bytedance.sdk.openadsdk.core.onz.ajl ajlVar = this.gzf;
        if (ajlVar != null) {
            ajlVar.fm(13);
        }
    }

    public void hxv() {
        if (this.ywr && this.maa) {
            this.ywr = false;
            nt.fm(this.ado);
        }
    }

    public void irt() {
        if (this.ywr || !this.maa) {
            return;
        }
        Context applicationContext = com.bytedance.sdk.openadsdk.core.gof.fm().getApplicationContext();
        this.ywr = true;
        nt.fm(this.ado, applicationContext);
    }

    @Override // com.bytedance.sdk.openadsdk.core.fhx.fm.fm, b6.f
    public void jnr() {
        com.bytedance.sdk.openadsdk.core.fhx.yz.lb lbVar = this.ajl;
        if (lbVar != null) {
            lbVar.duv();
            this.ajl = null;
        }
        if (this.lz) {
            if ("embeded_ad".equals(this.bx)) {
                this.wsy.wey();
            } else {
                this.wsy.fm(this.wu, (WeakReference<Context>) null, true);
            }
            this.f7085lb.removeCallbacksAndMessages(null);
            this.duv.clear();
            if (this.fhx) {
                hxv();
            }
        }
    }

    public void wsy(boolean z10) {
        jnr jnrVar = this.wsy;
        if (jnrVar != null) {
            jnrVar.fm();
        }
        jnr jnrVar2 = this.wsy;
        if (jnrVar2 != null && z10) {
            jnrVar2.gof();
        }
        zan();
    }

    public void xgn() {
        if (this.ajl != null) {
            ro(false);
            ol();
            this.wey.set(false);
            this.sds = false;
            fm(this.kwx);
            this.ajl.ef();
        }
    }

    /* JADX INFO: Access modifiers changed from: private */
    public void ajl(int i10) {
        jnr(i10);
        if (i10 == 4) {
            this.qhl = false;
        }
    }

    private void lb(com.bykv.vk.openvk.fm.fm.fm.lb.lb lbVar) {
        lbVar.yz(0);
        this.ajl.fm(lbVar);
        this.f7100gc = System.currentTimeMillis();
        this.wsy.lb(8);
        this.wsy.lb(0);
        fm(new Runnable() { // from class: com.bytedance.sdk.openadsdk.core.fhx.ro.lb.3
            @Override // java.lang.Runnable
            public void run() {
                if (((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) lb.this).ajl == null) {
                    return;
                }
                lb.this.f7100gc = System.currentTimeMillis();
                ((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) lb.this).wsy.yz(0);
                ((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) lb.this).ajl.fm(true, ((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) lb.this).f7082ef, ((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) lb.this).irt);
            }
        });
        if (this.fhx) {
            irt();
        }
    }

    @Override // com.bytedance.sdk.openadsdk.core.fhx.fm.fm, b6.f
    public void yz() {
        fm(true, 3);
    }

    public void ro(int i10, int i11) {
        fm(i10, i11);
        jnr jnrVar = this.wsy;
        if (jnrVar == null || i10 <= 0 || i11 <= 0) {
            return;
        }
        jnrVar.lb(i10, i11);
        this.wsy.fm(i10, i11);
        tzk();
    }

    private void jnr(int i10) {
        if (this.bwv == i10) {
            return;
        }
        this.bwv = i10;
        if (i10 != 4 && i10 != 0) {
            this.gof = false;
        }
        if (!this.gof && !dsz() && this.zan) {
            lb(2, i10);
        }
        WeakReference<fm> weakReference = this.si;
        if (weakReference == null || weakReference.get() == null) {
            return;
        }
        this.si.get().fm(this.bwv);
    }

    /* JADX INFO: Access modifiers changed from: private */
    public void ro(long j10, long j11) {
        com.bytedance.sdk.openadsdk.core.onz.yz yzVarFm;
        this.wu.yz(j10);
        this.f7082ef = j10;
        this.pkk = j11;
        this.wsy.fm(j10, j11);
        this.wsy.fm(i6.a.a(j10, j11));
        try {
            b6.b bVar = this.mq;
            if (bVar != null) {
                bVar.fm(j10, j11);
            }
        } catch (Throwable th) {
            wey.fm(this.fm, "onProgressUpdate error: ", th);
        }
        com.bytedance.sdk.openadsdk.core.model.yz yzVarKl = this.wu.kl();
        if (yzVarKl == null || (yzVarFm = yzVarKl.fm()) == null) {
            return;
        }
        yzVarFm.fm(j10, j11, this.gzf);
    }

    public void fm(final ajl.fm fmVar) {
        jnr jnrVar;
        if (!this.fhx || (jnrVar = this.wsy) == null) {
            return;
        }
        jnrVar.fm(new ajl.fm() { // from class: com.bytedance.sdk.openadsdk.core.fhx.ro.lb.2
            @Override // com.bytedance.sdk.openadsdk.core.fhx.ro.ajl.fm
            public void fm(View view, int i10) {
                ajl.fm fmVar2 = fmVar;
                if (fmVar2 != null) {
                    fmVar2.fm(view, i10);
                }
            }
        });
    }

    @Override // com.bytedance.sdk.openadsdk.core.fhx.fm.fm, b6.f
    public void lb() {
        jnr jnrVar = this.wsy;
        if (jnrVar != null) {
            jnrVar.fm();
        }
        jnr jnrVar2 = this.wsy;
        if (jnrVar2 != null) {
            jnrVar2.gof();
        }
        zan();
    }

    public void fm(PAGNativeAd pAGNativeAd) {
        jnr jnrVar;
        if (!this.fhx || (jnrVar = this.wsy) == null) {
            return;
        }
        jnrVar.fm(pAGNativeAd);
    }

    private void fm(Context context) {
        ViewGroup lbVar;
        if (this.fhx) {
            lbVar = new com.bytedance.sdk.openadsdk.fhx.yz(context);
        } else {
            lbVar = new com.bytedance.sdk.openadsdk.fhx.lb(context);
        }
        ViewGroup viewGroup = lbVar;
        if (this.fhx) {
            this.wsy = new jnr(context, viewGroup, true, 17, this.wu, this, maa());
        } else {
            this.wsy = new yz(context, viewGroup, true, 17, this.wu, this, false);
        }
        this.wsy.fm(this);
    }

    private boolean lb(int i10, int i11) {
        if (i11 == 0) {
            ro();
            this.qhl = true;
            jnr jnrVar = this.wsy;
            if (jnrVar != null) {
                jnrVar.fm(this.wu, (WeakReference<Context>) null, false);
            }
        }
        if (i11 != 4 && i11 != 0) {
            jnr jnrVar2 = this.wsy;
            if (jnrVar2 != null) {
                jnrVar2.fm();
            }
            ro();
            this.qhl = true;
            this.gof = false;
            jnr jnrVar3 = this.wsy;
            if (jnrVar3 != null) {
                return jnrVar3.fm(i10, this.wu.ex(), this.tzk);
            }
        } else if (i11 == 4) {
            this.qhl = false;
            jnr jnrVar4 = this.wsy;
            if (jnrVar4 != null) {
                jnrVar4.fhx();
            }
        }
        return true;
    }

    public com.bytedance.sdk.openadsdk.core.onz.ajl fm(View view, List<Pair<View, FriendlyObstructionPurpose>> list) {
        if (!this.wu.ej()) {
            return null;
        }
        if (this.gzf == null) {
            this.gzf = com.bytedance.sdk.openadsdk.core.onz.ajl.fm();
        }
        this.gzf.fm(view, this.wu);
        if (list != null && list.size() > 0) {
            for (Pair<View, FriendlyObstructionPurpose> pair : list) {
                if (pair != null) {
                    Object obj = pair.second;
                    this.gzf.fm((View) pair.first, obj == null ? FriendlyObstructionPurpose.OTHER : (FriendlyObstructionPurpose) obj);
                }
            }
        }
        return this.gzf;
    }

    public void lb(int i10) {
        jnr(i10);
        if (i10 == 4) {
            this.qhl = false;
            lb();
        }
    }

    @Override // com.bytedance.sdk.openadsdk.core.fhx.fm.fm
    public void fm(e eVar) {
        this.f7103qf = new WeakReference<>(eVar);
    }

    @Override // com.bytedance.sdk.openadsdk.core.fhx.fm.fm, b6.f
    public void fm() {
        com.bytedance.sdk.openadsdk.core.fhx.yz.lb lbVar = this.ajl;
        if (lbVar != null) {
            lbVar.ef();
        }
    }

    @Override // com.bytedance.sdk.openadsdk.core.fhx.fm.fm, b6.f
    public boolean fm(com.bykv.vk.openvk.fm.fm.fm.lb.lb lbVar) {
        super.fm(lbVar);
        if (this.ajl != null) {
            ApmHelper.reportCustomError("", "twice playVideoUrl", new IllegalStateException());
            return true;
        }
        if (TextUtils.isEmpty(lbVar.irt())) {
            return false;
        }
        ro(false);
        lbVar.irt();
        lbVar.ro(com.bytedance.sdk.openadsdk.hlt.jnr.fm("player_force_raw_url", 0) == 1);
        int i10 = this.lmk + 1;
        this.lmk = i10;
        lbVar.jnr = i10;
        ro(lbVar);
        ol();
        com.bytedance.sdk.openadsdk.core.onz.ajl ajlVar = this.gzf;
        if (ajlVar != null) {
            ajlVar.fm(false, 0.0f);
        }
        if (!mq.ro(this.bx) || this.f7082ef <= 0) {
            this.f7082ef = lbVar.vt();
        }
        if (mq.ro(this.bx) && this.f7082ef == this.pkk) {
            this.f7082ef = 0L;
        }
        if (lbVar.vt() <= 0) {
            this.sds = false;
            this.wey.set(false);
        } else {
            long jVt = lbVar.vt();
            this.f7082ef = jVt;
            this.vt = Math.max(this.vt, jVt);
        }
        jnr jnrVar = this.wsy;
        if (jnrVar != null) {
            jnrVar.fm();
            if (this.vvj == 0) {
                this.wsy.wsy();
            }
            this.wsy.lb(lbVar.wu(), lbVar.ef());
            this.wsy.lb(this.hi);
            this.wsy.fm(lbVar.wu(), lbVar.ef());
        }
        if (this.ajl == null) {
            com.bytedance.sdk.openadsdk.core.fhx.yz.lb lbVar2 = new com.bytedance.sdk.openadsdk.core.fhx.yz.lb();
            this.ajl = lbVar2;
            lbVar2.fm(this.mpp);
        }
        gof();
        this.xgn = 0L;
        try {
            lb(lbVar);
            return true;
        } catch (Exception e10) {
            String message = e10.getMessage();
            com.bykv.vk.openvk.fm.fm.fm.lb.a aVar = new com.bykv.vk.openvk.fm.fm.fm.lb.a();
            aVar.f5918a = -10;
            aVar.f5919b = 0;
            aVar.f5920c = message;
            fm(aVar);
            wey.lb(this.fm, "[video] invoke NativeVideoController#playVideo cause exception :".concat(String.valueOf(e10)));
            return false;
        }
    }

    @Override // com.bytedance.sdk.openadsdk.core.fhx.fm.fm
    public void fm(boolean z10, int i10) {
        if (!this.sds && this.wey.get()) {
            if (z10) {
                fm(i10, false);
                this.sds = false;
            } else {
                ai();
            }
        }
        jnr();
        com.bytedance.sdk.openadsdk.core.onz.ajl ajlVar = this.gzf;
        if (ajlVar != null) {
            ajlVar.yz();
        }
    }

    public final void fm(int i10, boolean z10) {
        if (z10 || this.f7084ha) {
            if (z10) {
                this.f7084ha = false;
            }
            if (this.sds || !this.wey.get()) {
                return;
            }
            fhx.fm fmVar = new fhx.fm();
            fmVar.ro(ajl());
            fmVar.yz(ef());
            fmVar.lb(wsy());
            fmVar.lb(i10);
            fmVar.yz(wu());
            com.bytedance.sdk.openadsdk.yz.jnr.fm.fm.fm(this.wsy, fmVar, this.kwx);
        }
    }

    @Override // com.bytedance.sdk.openadsdk.core.fhx.fm.fm, com.bytedance.sdk.openadsdk.core.fhx.ro.fm
    public void fm(g gVar, View view) {
        com.bytedance.sdk.openadsdk.core.fhx.yz.lb lbVar = this.ajl;
        if (lbVar == null) {
            return;
        }
        if (lbVar.ajl()) {
            ro();
            this.wsy.ro(true, false);
            this.wsy.ajl();
            return;
        }
        if (!this.ajl.wsy()) {
            jnr jnrVar = this.wsy;
            if (jnrVar != null) {
                jnrVar.lb(this.hi);
            }
            jnr(this.f7082ef);
            jnr jnrVar2 = this.wsy;
            if (jnrVar2 != null) {
                jnrVar2.ro(false, false);
                return;
            }
            return;
        }
        wsy(false);
        jnr jnrVar3 = this.wsy;
        if (jnrVar3 != null) {
            jnrVar3.ro(false, false);
        }
    }

    @Override // com.bytedance.sdk.openadsdk.core.fhx.fm.fm
    public void fm(g gVar, View view, boolean z10) {
        lb(!this.gqi);
        if (this.ku instanceof Activity) {
            jnr jnrVar = this.wsy;
            if (jnrVar != null) {
                jnrVar.ro(this.hi);
                this.wsy.lb(false);
            }
            fm(1);
            WeakReference<b6.d> weakReference = this.nt;
            b6.d dVar = weakReference != null ? weakReference.get() : null;
            if (dVar != null) {
                dVar.fm(this.gqi);
            }
        }
    }

    public void fm(fm fmVar) {
        this.si = new WeakReference<>(fmVar);
    }
}
