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

import android.content.Context;
import android.text.TextUtils;
import android.view.SurfaceView;
import android.view.TextureView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout;
import androidx.annotation.NonNull;
import b6.g;
import com.bykv.vk.openvk.fm.fm.fm.lb.a;
import com.bytedance.sdk.component.utils.ef;
import com.bytedance.sdk.openadsdk.component.reward.view.wu;
import com.bytedance.sdk.openadsdk.core.fhx.yz.lb;
import com.bytedance.sdk.openadsdk.core.gof;
import com.bytedance.sdk.openadsdk.core.model.lse;
import com.bytedance.sdk.openadsdk.core.model.wey;
import com.bytedance.sdk.openadsdk.core.onz.ajl;
import com.bytedance.sdk.openadsdk.core.onz.yz;
import com.bytedance.sdk.openadsdk.core.vt;
import com.bytedance.sdk.openadsdk.hi.ro.jnr;
import com.bytedance.sdk.openadsdk.utils.qhl;
import com.bytedance.sdk.openadsdk.utils.tzk;
import com.bytedance.sdk.openadsdk.utils.zan;
import com.bytedance.sdk.openadsdk.yz.wsy;
import com.iab.omid.library.bytedance2.adsession.FriendlyObstructionPurpose;
import java.util.Iterator;
import java.util.Objects;
import java.util.concurrent.atomic.AtomicBoolean;
import v5.b;
import w5.d;

/* JADX INFO: loaded from: classes2.dex */
public class fm extends com.bytedance.sdk.openadsdk.core.fhx.fm.fm {
    private final wsy bx;

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

    /* JADX INFO: renamed from: ib, reason: collision with root package name */
    private boolean f7114ib;
    private InterfaceC0073fm kwx;
    private boolean lz;
    final lb.ro mon;

    /* JADX INFO: renamed from: ne, reason: collision with root package name */
    private final Runnable f7115ne;

    /* JADX INFO: renamed from: qf, reason: collision with root package name */
    private final int f7116qf;
    private final AtomicBoolean si;
    private long tzk;
    protected boolean xgn;
    private long zan;

    /* JADX INFO: renamed from: com.bytedance.sdk.openadsdk.core.fhx.yz.fm$1, reason: invalid class name */
    public class AnonymousClass1 implements lb.ro {
        private boolean ro = true;

        public AnonymousClass1() {
        }

        @Override // com.bytedance.sdk.openadsdk.core.fhx.yz.lb.ro, v5.a
        public void fm(b bVar) {
            yz yzVarFm;
            if (fm.this.si.compareAndSet(false, true)) {
                String unused = ((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) fm.this).fm;
                ((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) fm.this).f7085lb.post(new Runnable() { // from class: com.bytedance.sdk.openadsdk.core.fhx.yz.fm.1.1
                    @Override // java.lang.Runnable
                    public void run() {
                        if (((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) fm.this).gzf != null) {
                            try {
                                ((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) fm.this).gzf.fm(9);
                            } catch (Exception unused2) {
                            }
                        }
                        fm.this.qf();
                    }
                });
                com.bytedance.sdk.openadsdk.core.model.yz yzVarKl = ((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) fm.this).wu.kl();
                if (yzVarKl != null && (yzVarFm = yzVarKl.fm()) != null) {
                    long jAjl = fm.this.ajl();
                    yzVarFm.yz(jAjl);
                    yzVarFm.jnr(jAjl);
                }
                jnr.fm(((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) fm.this).wu, 5);
                com.bytedance.sdk.openadsdk.hi.fm.lb.fm(((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) fm.this).wu, 5);
                if (fm.this.kwx != null) {
                    fm.this.kwx.fm(3);
                }
            }
        }

        @Override // com.bytedance.sdk.openadsdk.core.fhx.yz.lb.ro, v5.a
        public void jnr(b bVar) {
            jnr.fm(((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) fm.this).wu, 0);
            if (((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) fm.this).gzf != null) {
                ((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) fm.this).gzf.fm(1);
            }
            if (fm.this.kwx != null) {
                fm.this.kwx.fm(1);
            }
        }

        @Override // com.bytedance.sdk.openadsdk.core.fhx.yz.lb.ro, v5.a
        public void lb(b bVar) {
            String unused = ((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) fm.this).fm;
        }

        @Override // com.bytedance.sdk.openadsdk.core.fhx.yz.lb.ro, v5.a
        public void ro(b bVar, int i10) {
        }

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

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

        @Override // com.bytedance.sdk.openadsdk.core.fhx.yz.lb.ro, v5.a
        public void fm(b bVar, long j10) {
            String unused = ((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) fm.this).fm;
            ((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) fm.this).hlt = false;
            ((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) fm.this).f7085lb.removeCallbacks(fm.this.f7115ne);
            ((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) fm.this).f7085lb.post(new Runnable() { // from class: com.bytedance.sdk.openadsdk.core.fhx.yz.fm.1.2
                @Override // java.lang.Runnable
                public void run() {
                    if (((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) fm.this).wsy != null) {
                        ((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) fm.this).wsy.ro();
                    }
                }
            });
            if (!((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) fm.this).wey.get()) {
                fm fmVar = fm.this;
                fmVar.f7113gc = j10;
                fmVar.fm(fmVar.bx);
                fm.this.pkk();
            }
            if (((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) fm.this).gzf != null) {
                ((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) fm.this).gzf.lb();
            }
            jnr.fm(((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) fm.this).wu, 0);
            if (fm.this.kwx != null) {
                fm.this.kwx.fm(1);
            }
        }

        @Override // com.bytedance.sdk.openadsdk.core.fhx.yz.lb.ro, v5.a
        public void fm(b bVar, a aVar) {
            yz yzVarFm;
            String unused = ((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) fm.this).fm;
            int i10 = aVar.f5918a;
            ((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) fm.this).f7085lb.removeCallbacks(fm.this.f7115ne);
            ((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) fm.this).f7085lb.post(new Runnable() { // from class: com.bytedance.sdk.openadsdk.core.fhx.yz.fm.1.4
                @Override // java.lang.Runnable
                public void run() {
                    if (((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) fm.this).wsy != null) {
                        ((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) fm.this).wsy.ro();
                    }
                    if (((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) fm.this).mq != null) {
                        ((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) fm.this).mq.ro(fm.this.tzk, i6.a.a(((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) fm.this).f7082ef, ((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) fm.this).pkk));
                    }
                }
            });
            fm.this.fm(aVar);
            jnr.fm(((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) fm.this).wu, 6);
            com.bytedance.sdk.openadsdk.hi.fm.lb.ro(((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) fm.this).wu);
            if (((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) fm.this).gzf != null) {
                ((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) fm.this).gzf.fm(14);
            }
            if (fm.this.kwx != null) {
                fm.this.kwx.fm(4);
            }
            com.bytedance.sdk.openadsdk.core.model.yz yzVarKl = ((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) fm.this).wu.kl();
            if (yzVarKl == null || (yzVarFm = yzVarKl.fm()) == null) {
                return;
            }
            yzVarFm.fm(com.bytedance.sdk.openadsdk.core.onz.fm.fm.GENERAL_LINEAR_AD_ERROR);
        }

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

        @Override // com.bytedance.sdk.openadsdk.core.fhx.yz.lb.ro, v5.a
        public void fm(b bVar, int i10, int i11) {
            String unused = ((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) fm.this).fm;
            ef.fm().post(new Runnable() { // from class: com.bytedance.sdk.openadsdk.core.fhx.yz.fm.1.6
                @Override // java.lang.Runnable
                public void run() {
                    if (((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) fm.this).ajl == null) {
                        return;
                    }
                    try {
                        final float fYz = ((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) fm.this).ajl.yz();
                        final float fJnr = ((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) fm.this).ajl.jnr();
                        if (fYz == 0.0f || fJnr == 0.0f) {
                            return;
                        }
                        ((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) fm.this).f7085lb.post(new Runnable() { // from class: com.bytedance.sdk.openadsdk.core.fhx.yz.fm.1.6.1
                            @Override // java.lang.Runnable
                            public void run() {
                                if (!fm.this.si()) {
                                    fm.this.fm(fYz, fJnr);
                                    return;
                                }
                                if (wey.ro(((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) fm.this).wu) || ((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) fm.this).lse.ajl == 4) {
                                    fm.this.fm(true, fYz, fJnr);
                                    return;
                                }
                                if (wey.lb(((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) fm.this).wu)) {
                                    fm.this.fm(true, fYz, fJnr);
                                    return;
                                }
                                if (((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) fm.this).wu.ttj() == 3) {
                                    fm.this.fm(true, fYz, fJnr);
                                } else if (((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) fm.this).wu.ttj() == 0) {
                                    fm.this.lb(fYz, fJnr);
                                } else {
                                    fm.this.ro(fYz, fJnr);
                                }
                            }
                        });
                    } catch (Throwable th) {
                        com.bytedance.sdk.component.utils.wey.lb(((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) fm.this).fm, th.getMessage());
                    }
                }
            });
        }

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

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

        @Override // com.bytedance.sdk.openadsdk.core.fhx.yz.lb.ro, v5.a
        public void fm(final b bVar, long j10, long j11) {
            yz yzVarFm;
            if (Math.abs(j10 - ((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) fm.this).f7082ef) < 50) {
                return;
            }
            fm fmVar = fm.this;
            fmVar.fm(fmVar.bx);
            fm.this.fm(j10, j11);
            fm.this.ro(j10, j11);
            com.bytedance.sdk.openadsdk.core.model.yz yzVarKl = ((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) fm.this).wu.kl();
            if (yzVarKl != null && (yzVarFm = yzVarKl.fm()) != null) {
                yzVarFm.fm(j10, j11, ((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) fm.this).gzf);
            }
            if (!this.ro || j11 - j10 >= 500) {
                return;
            }
            this.ro = false;
            ((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) fm.this).f7085lb.postDelayed(new Runnable() { // from class: com.bytedance.sdk.openadsdk.core.fhx.yz.fm.1.9
                @Override // java.lang.Runnable
                public void run() {
                    AnonymousClass1.this.fm(bVar);
                }
            }, 1000L);
        }

        @Override // com.bytedance.sdk.openadsdk.core.fhx.yz.lb.ro
        public void fm(int i10, int i11) {
            fm.this.zan();
        }
    }

    /* JADX INFO: renamed from: com.bytedance.sdk.openadsdk.core.fhx.yz.fm$fm, reason: collision with other inner class name */
    public interface InterfaceC0073fm {
        void fm(int i10);
    }

    public fm(Context context, ViewGroup viewGroup, lse lseVar, wsy wsyVar) {
        super(context, lseVar, viewGroup);
        this.zan = 0L;
        this.tzk = 0L;
        this.lz = false;
        this.f7113gc = 0L;
        this.xgn = false;
        this.si = new AtomicBoolean(false);
        this.mon = new AnonymousClass1();
        this.f7115ne = new Runnable() { // from class: com.bytedance.sdk.openadsdk.core.fhx.yz.fm.3
            @Override // java.lang.Runnable
            public void run() {
                if (((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) fm.this).mq != null) {
                    fm.this.irt();
                    ((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) fm.this).mq.fm();
                }
            }
        };
        this.bx = wsyVar;
        this.f7116qf = lseVar.pg();
        if (lseVar.ej() && this.hi != null) {
            if (this.gzf == null) {
                this.gzf = ajl.fm();
            }
            this.gzf.fm(this.hi, lseVar);
        }
        com.bytedance.sdk.openadsdk.core.fhx.ro.jnr jnrVar = new com.bytedance.sdk.openadsdk.core.fhx.ro.jnr(context.getApplicationContext(), new com.bytedance.sdk.openadsdk.fhx.yz(context), true, 17, this.wu, this);
        this.wsy = jnrVar;
        jnrVar.fm(this);
    }

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

    public void fm(InterfaceC0073fm interfaceC0073fm) {
        this.kwx = interfaceC0073fm;
    }

    @Override // com.bytedance.sdk.openadsdk.core.fhx.fm.fm
    public boolean hi() {
        return true;
    }

    public void irt() {
    }

    private boolean ib() {
        return xgn() == null || this.ajl == null || (!com.bytedance.sdk.openadsdk.core.dsz.jnr.fm(this.wu.te()) ? this.wu.zzn() != null : this.wu.po() != null) || this.wu.daz() == 1;
    }

    /* JADX INFO: Access modifiers changed from: private */
    public void lz() {
        int i10 = this.lse.ajl;
        int iNe = (i10 == 2 || i10 == 1) ? gof.yz().ne() * 1000 : i10 == 4 ? gof.yz().vt(String.valueOf(this.f7116qf)) : 5000;
        this.f7085lb.removeCallbacks(this.f7115ne);
        this.f7085lb.postDelayed(this.f7115ne, iNe);
    }

    /* JADX INFO: Access modifiers changed from: private */
    public void qf() {
        if (this.wsy == null) {
            return;
        }
        this.f7085lb.removeCallbacks(this.f7115ne);
        this.wsy.ro();
        this.tzk = System.currentTimeMillis() - this.zan;
        if (!this.lz) {
            this.lz = true;
            long j10 = this.pkk;
            ro(j10, j10);
            long j11 = this.pkk;
            this.f7082ef = j11;
            this.vt = j11;
            ro(this.bx);
        }
        b6.b bVar = this.mq;
        if (bVar != null) {
            bVar.fm(this.tzk, i6.a.a(this.f7082ef, this.pkk));
        }
        this.onz = true;
    }

    /* JADX INFO: Access modifiers changed from: private */
    public boolean si() {
        return this.wu.lvj() == 100.0f;
    }

    private void tzk() {
        this.ajl.lb(wbw());
        this.ajl.fm(this.lse);
        this.zan = System.currentTimeMillis();
        this.wsy.lb(8);
        this.wsy.lb(0);
        fm(new Runnable() { // from class: com.bytedance.sdk.openadsdk.core.fhx.yz.fm.2
            @Override // java.lang.Runnable
            public void run() {
                if (((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) fm.this).ajl == null) {
                    return;
                }
                fm.this.zan = System.currentTimeMillis();
                ((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) fm.this).wsy.yz(0);
                ((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) fm.this).ajl.fm(true, ((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) fm.this).f7082ef, ((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) fm.this).irt);
            }
        });
    }

    /* JADX INFO: Access modifiers changed from: private */
    public void zan() {
        ro(this.bx);
        this.lse.jnr = this.ajl.sds();
        ol();
        this.wey.set(false);
        this.si.set(false);
        fm(this.bx);
    }

    public void bx() {
        ajl ajlVar = this.gzf;
        if (ajlVar != null) {
            ajlVar.fm(13);
        }
    }

    public void gc() {
        yz yzVarFm;
        if (this.lz || !this.wey.get()) {
            return;
        }
        gzf();
        com.bytedance.sdk.openadsdk.core.model.yz yzVarKl = this.wu.kl();
        if (yzVarKl == null || (yzVarFm = yzVarKl.fm()) == null) {
            return;
        }
        yzVarFm.lb(ajl());
    }

    public void hxv() {
        this.mon.fm((b) null, 0, 0);
    }

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

    public void mon() {
        ajl ajlVar = this.gzf;
        if (ajlVar != null) {
            ajlVar.fm(2);
        }
    }

    public d xgn() {
        com.bytedance.sdk.openadsdk.core.fhx.ro.jnr jnrVar = this.wsy;
        if (jnrVar != null) {
            return jnrVar.dsz();
        }
        return null;
    }

    @Override // com.bytedance.sdk.openadsdk.core.fhx.fm.fm, b6.f
    public void yz() {
        lb lbVar = this.ajl;
        if (lbVar == null) {
            return;
        }
        lbVar.duv();
        this.ajl = null;
        com.bytedance.sdk.openadsdk.core.fhx.ro.jnr jnrVar = this.wsy;
        if (jnrVar != null) {
            jnrVar.ef();
        }
        this.f7085lb.removeCallbacks(this.f7115ne);
        this.f7085lb.removeCallbacksAndMessages(null);
        ajl ajlVar = this.gzf;
        if (ajlVar != null) {
            ajlVar.yz();
        }
        com.bytedance.sdk.openadsdk.yz.jnr.fm.fm.fm(this.wu, this.ol.get(), this.zan);
    }

    @Override // com.bytedance.sdk.openadsdk.core.fhx.fm.fm, b6.f
    public void lb() {
        yz yzVarFm;
        com.bytedance.sdk.openadsdk.core.fhx.ro.jnr jnrVar = this.wsy;
        if (jnrVar != null) {
            jnrVar.fm();
            this.wsy.fhx();
            this.wsy.gof();
        }
        lb lbVar = this.ajl;
        if (lbVar != null) {
            if (!lbVar.wsy()) {
                this.ajl.fm(false, this.f7082ef, this.irt);
            } else if (this.dsz) {
                if (vt.wey()) {
                    this.ajl.ro(3);
                    lb lbVar2 = this.ajl;
                    lbVar2.fm(false, lbVar2.gof(), this.irt);
                } else {
                    wey();
                }
            } else {
                ro(this.hxv);
            }
        }
        if (this.lz || !this.wey.get()) {
            return;
        }
        gzf();
        com.bytedance.sdk.openadsdk.core.model.yz yzVarKl = this.wu.kl();
        if (yzVarKl == null || (yzVarFm = yzVarKl.fm()) == null) {
            return;
        }
        yzVarFm.lb(ajl());
    }

    /* JADX INFO: Access modifiers changed from: private */
    public void ro(float f10, float f11) {
        try {
            Objects.toString(this.wu.cpu());
            if (ib()) {
                return;
            }
            int[] iArrRo = zan.ro(gof.fm());
            boolean z10 = false;
            boolean z11 = this.wu.nnq() == 1;
            float f12 = iArrRo[0];
            float f13 = iArrRo[1];
            if (z11) {
                if (f10 > f11) {
                    fm(f12, f13, f10, f11, true);
                    return;
                }
            } else if (f10 < f11) {
                fm(f12, f13, f10, f11, false);
                return;
            }
            float f14 = f10 / f11;
            float f15 = f12 / f13;
            if (z11) {
                if (f15 < 0.5625f && f14 == 0.5625f) {
                    f10 = (9.0f * f13) / 16.0f;
                    z10 = true;
                    f11 = f13;
                }
            } else if (f15 > 1.7777778f && f14 == 1.7777778f) {
                f11 = (9.0f * f12) / 16.0f;
                z10 = true;
                f10 = f12;
            }
            if (z10) {
                f12 = f10;
                f13 = f11;
            }
            int i10 = (int) f12;
            int i11 = (int) f13;
            RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(i10, i11);
            layoutParams.addRule(13);
            if (xgn() != null) {
                if (xgn() instanceof TextureView) {
                    ((TextureView) xgn()).setLayoutParams(layoutParams);
                } else if (xgn() instanceof SurfaceView) {
                    ((SurfaceView) xgn()).setLayoutParams(layoutParams);
                }
                ViewGroup.LayoutParams layoutParams2 = this.hi.getLayoutParams();
                if (layoutParams2 != null) {
                    layoutParams2.height = i11;
                    layoutParams2.width = i10;
                    this.hi.setLayoutParams(layoutParams2);
                }
            }
        } catch (Throwable th) {
            com.bytedance.sdk.component.utils.wey.fm(this.fm, "changeSize error", th);
        }
    }

    public void fm(boolean z10, float f10, float f11) {
        try {
            Objects.toString(this.wu.cpu());
            if (!ib() || z10) {
                RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams((int) f10, (int) f11);
                layoutParams.addRule(13);
                if (xgn() != null) {
                    if (xgn() instanceof TextureView) {
                        ((TextureView) xgn()).setLayoutParams(layoutParams);
                    } else if (xgn() instanceof SurfaceView) {
                        ((SurfaceView) xgn()).setLayoutParams(layoutParams);
                    }
                    ViewGroup.LayoutParams layoutParams2 = this.hi.getLayoutParams();
                    if (this.hi.getHeight() > 0) {
                        float fMin = Math.min(this.hi.getWidth() / f10, this.hi.getHeight() / f11);
                        if (layoutParams2 != null) {
                            layoutParams.width = (int) (f10 * fMin);
                            layoutParams.height = (int) (f11 * fMin);
                            if (xgn() instanceof TextureView) {
                                ((TextureView) xgn()).setLayoutParams(layoutParams);
                            } else if (xgn() instanceof SurfaceView) {
                                ((SurfaceView) xgn()).setLayoutParams(layoutParams);
                            }
                            if (this.lse.ajl == 4) {
                                layoutParams2.width = layoutParams.width;
                                layoutParams2.height = layoutParams.height;
                                this.hi.setLayoutParams(layoutParams2);
                            }
                        }
                    }
                }
            }
        } catch (Throwable th) {
            com.bytedance.sdk.component.utils.wey.fm(this.fm, "changeSize error", th);
        }
    }

    /* JADX INFO: Access modifiers changed from: private */
    public void lb(float f10, float f11) {
        try {
            if (xgn() != null && this.ajl != null) {
                boolean z10 = this.wu.nnq() == 1;
                int[] iArrRo = zan.ro(gof.fm());
                fm(iArrRo[0], iArrRo[1], f10, f11, z10);
            }
        } catch (Throwable unused) {
        }
    }

    /* JADX INFO: Access modifiers changed from: private */
    public void ro(final long j10, final long j11) {
        this.wu.yz(j10);
        this.f7082ef = j10;
        this.pkk = j11;
        final int iA = i6.a.a(j10, j11);
        this.f7085lb.post(new Runnable() { // from class: com.bytedance.sdk.openadsdk.core.fhx.yz.fm.4
            @Override // java.lang.Runnable
            public void run() {
                ((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) fm.this).wsy.fm(j10, j11);
                ((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) fm.this).wsy.fm(iA);
                try {
                    if (((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) fm.this).mq != null) {
                        ((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) fm.this).mq.fm(j10, j11);
                    }
                } catch (Throwable th) {
                    com.bytedance.sdk.component.utils.wey.fm(((com.bytedance.sdk.openadsdk.core.fhx.fm.fm) fm.this).fm, "onProgressUpdate error: ", th);
                }
            }
        });
    }

    @Override // com.bytedance.sdk.openadsdk.core.fhx.fm.fm, b6.f
    public boolean fm(@NonNull com.bykv.vk.openvk.fm.fm.fm.lb.lb lbVar) {
        int iMxq;
        super.fm(lbVar);
        if (this.ajl != null) {
            return false;
        }
        lbVar.irt();
        if (TextUtils.isEmpty(lbVar.irt())) {
            return false;
        }
        lbVar.ro(com.bytedance.sdk.openadsdk.hlt.jnr.fm("player_force_raw_url", 0) == 1);
        ro(lbVar);
        lbVar.yz(1);
        this.xgn = !lbVar.irt().startsWith("http");
        if (this.gzf != null) {
            if (this.lse.ajl == 1) {
                iMxq = this.wu.we();
            } else {
                iMxq = this.wu.mxq();
            }
            if (this.hi != null) {
                try {
                    int iTmm = this.wu.tmm();
                    if (iTmm == 7 || iTmm == 8) {
                        View viewFm = tzk.fm(this.hi, (Class<? extends View>) wu.class);
                        if (viewFm != null) {
                            View viewFindViewById = viewFm.findViewById(qhl.onz);
                            View viewFindViewById2 = viewFm.findViewById(qhl.kw);
                            View viewFindViewById3 = viewFm.findViewById(qhl.nss);
                            ajl ajlVar = this.gzf;
                            FriendlyObstructionPurpose friendlyObstructionPurpose = FriendlyObstructionPurpose.OTHER;
                            ajlVar.fm(viewFindViewById2, friendlyObstructionPurpose);
                            this.gzf.fm(viewFindViewById, friendlyObstructionPurpose);
                            this.gzf.fm(viewFindViewById3, friendlyObstructionPurpose);
                            if (this.f7114ib) {
                                View viewFm2 = tzk.fm(this.hi, (Class<? extends View>) com.bytedance.sdk.openadsdk.core.dsz.ro.ajl.fm.class);
                                if (viewFm2 instanceof com.bytedance.sdk.openadsdk.core.dsz.ro.ajl.fm) {
                                    this.gzf.fm(((com.bytedance.sdk.openadsdk.core.dsz.ro.ajl.fm) viewFm2).getMarkView(), friendlyObstructionPurpose);
                                }
                            }
                        }
                        Iterator<View> it = tzk.fm(this.hi, 1).iterator();
                        while (it.hasNext()) {
                            this.gzf.fm(it.next(), FriendlyObstructionPurpose.OTHER);
                        }
                    } else if (iTmm == 3) {
                        Iterator<View> it2 = tzk.fm(this.hi, 2).iterator();
                        while (it2.hasNext()) {
                            this.gzf.fm(it2.next(), FriendlyObstructionPurpose.OTHER);
                        }
                    }
                } catch (Throwable unused) {
                }
            }
            this.gzf.fm(iMxq > 0, iMxq / 1000.0f);
        }
        ol();
        if (lbVar.vt() > 0) {
            long jVt = lbVar.vt();
            this.f7082ef = jVt;
            this.vt = Math.max(this.vt, jVt);
        }
        if (this.f7082ef == this.pkk) {
            this.f7082ef = 0L;
        }
        com.bytedance.sdk.openadsdk.core.fhx.ro.jnr jnrVar = this.wsy;
        if (jnrVar != null) {
            jnrVar.fm();
            this.wsy.wsy();
            this.wsy.lb(lbVar.wu(), lbVar.ef());
            this.wsy.lb(this.hi);
        }
        lb lbVar2 = new lb();
        this.ajl = lbVar2;
        lbVar2.fm(this.mon);
        gof();
        this.tzk = 0L;
        tzk();
        return true;
    }

    @Override // com.bytedance.sdk.openadsdk.core.fhx.fm.fm
    public void fm(boolean z10, int i10) {
        yz();
    }

    /* JADX INFO: Access modifiers changed from: private */
    public void fm(float f10, float f11) {
        ViewGroup viewGroup;
        try {
            if (xgn() != null && this.ajl != null && (viewGroup = this.hi) != null) {
                float width = viewGroup.getWidth();
                float f12 = f10 / (width * 1.0f);
                float height = this.hi.getHeight();
                if (f12 <= f11 / (1.0f * height)) {
                    width = (height / f11) * f10;
                } else {
                    height = (width / f10) * f11;
                }
                RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams((int) width, (int) height);
                layoutParams.addRule(13);
                if (xgn() instanceof TextureView) {
                    ((TextureView) xgn()).setLayoutParams(layoutParams);
                } else if (xgn() instanceof SurfaceView) {
                    ((SurfaceView) xgn()).setLayoutParams(layoutParams);
                }
            }
        } catch (Throwable th) {
            com.bytedance.sdk.component.utils.wey.fm(this.fm, "changeVideoSizeSupportInteraction error", th);
        }
    }

    private void fm(float f10, float f11, float f12, float f13, boolean z10) {
        RelativeLayout.LayoutParams layoutParams;
        if (f12 <= 0.0f || f13 <= 0.0f) {
            try {
                f12 = this.wu.ex().f5922b;
                f13 = this.wu.ex().f5921a;
            } catch (Throwable unused) {
                return;
            }
        }
        if (f13 > 0.0f && f12 > 0.0f) {
            if (z10) {
                if (f12 < f13) {
                    return;
                }
                layoutParams = new RelativeLayout.LayoutParams((int) f10, (int) ((f13 * f10) / f12));
            } else if (f12 > f13) {
                return;
            } else {
                layoutParams = new RelativeLayout.LayoutParams((int) ((f12 * f11) / f13), (int) f11);
            }
            layoutParams.addRule(13);
            if (xgn() != null) {
                if (xgn() instanceof TextureView) {
                    ((TextureView) xgn()).setLayoutParams(layoutParams);
                } else if (xgn() instanceof SurfaceView) {
                    ((SurfaceView) xgn()).setLayoutParams(layoutParams);
                }
                ViewGroup.LayoutParams layoutParams2 = this.hi.getLayoutParams();
                if (!com.bytedance.sdk.component.adexpress.yz.ro.fm(gof.fm()) || this.hi.getHeight() <= 0 || layoutParams2 == null) {
                    return;
                }
                layoutParams2.width = layoutParams.width;
                layoutParams2.height = layoutParams.height;
                this.hi.setLayoutParams(layoutParams2);
            }
        }
    }

    @Override // com.bytedance.sdk.openadsdk.core.fhx.fm.fm, com.bytedance.sdk.openadsdk.core.fhx.ro.fm
    public void fm(g gVar, View view) {
        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()) {
            com.bytedance.sdk.openadsdk.core.fhx.ro.jnr jnrVar = this.wsy;
            if (jnrVar != null) {
                jnrVar.lb(this.hi);
            }
            jnr(this.f7082ef);
            com.bytedance.sdk.openadsdk.core.fhx.ro.jnr jnrVar2 = this.wsy;
            if (jnrVar2 != null) {
                jnrVar2.ro(false, false);
                return;
            }
            return;
        }
        lb();
        com.bytedance.sdk.openadsdk.core.fhx.ro.jnr jnrVar3 = this.wsy;
        if (jnrVar3 != null) {
            jnrVar3.ro(false, false);
        }
    }

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