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

import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.content.Context;
import android.graphics.SurfaceTexture;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Message;
import android.text.TextUtils;
import android.view.SurfaceHolder;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import b6.a;
import b6.f;
import b6.g;
import com.bytedance.sdk.component.utils.maa;
import com.bytedance.sdk.component.utils.mq;
import com.bytedance.sdk.openadsdk.api.nativeAd.PAGNativeAd;
import com.bytedance.sdk.openadsdk.core.fhx.ro.ajl;
import com.bytedance.sdk.openadsdk.core.gof;
import com.bytedance.sdk.openadsdk.core.lb.fm;
import com.bytedance.sdk.openadsdk.core.lb.ro;
import com.bytedance.sdk.openadsdk.core.model.lse;
import com.bytedance.sdk.openadsdk.core.widget.gqi;
import com.bytedance.sdk.openadsdk.core.widget.wey;
import com.bytedance.sdk.openadsdk.utils.ku;
import com.bytedance.sdk.openadsdk.utils.qhl;
import com.bytedance.sdk.openadsdk.utils.zan;
import java.lang.ref.WeakReference;
import org.jetbrains.annotations.Nullable;
import w5.b;
import w5.d;

/* JADX INFO: loaded from: classes2.dex */
public class jnr implements b, g, mq.fm, fm.InterfaceC0078fm, gqi.fm, wey.ro {
    com.bytedance.sdk.openadsdk.core.lb.fm ai;
    View ajl;
    TextView dsz;
    View duv;

    /* JADX INFO: renamed from: ef, reason: collision with root package name */
    View f7097ef;
    int fhx;
    protected final int fm;
    boolean gof;
    boolean gqi;
    f gzf;

    /* JADX INFO: renamed from: ha, reason: collision with root package name */
    private ajl.fm f7098ha;
    fm hi;
    wey hlt;
    private final String hxv;
    int irt;
    ImageView jnr;
    ImageView ku;

    /* JADX INFO: renamed from: lb, reason: collision with root package name */
    ViewGroup f7099lb;
    Context lse;
    lse maa;
    com.bytedance.sdk.openadsdk.sds.fm.fm.lb mq;
    boolean nt;
    com.bytedance.sdk.openadsdk.core.lb.fm ol;
    int onz;
    private long pkk;
    int qhl;
    protected final int ro;
    int sds;
    View vt;
    boolean wbw;
    int wey;
    View wsy;
    ImageView wu;
    d yz;

    public jnr(Context context, ViewGroup viewGroup, boolean z10, int i10, lse lseVar, f fVar, boolean z11) {
        this.fm = 228;
        this.ro = 160;
        this.gof = true;
        this.nt = true;
        this.wbw = true;
        this.hxv = Build.MODEL;
        if (this instanceof yz) {
            return;
        }
        this.lse = gof.fm().getApplicationContext();
        yz(z11);
        this.f7099lb = viewGroup;
        this.gof = z10;
        this.sds = i10;
        this.gzf = fVar;
        this.maa = lseVar;
        yz(8);
        fm(context, this.f7099lb);
        yz();
        duv();
    }

    private boolean hi() {
        return lse.jnr(this.maa) && (!com.bytedance.sdk.openadsdk.core.dsz.jnr.fm(this.maa.te()) ? this.maa.zzn() == null : this.maa.po() == null) && this.maa.qb() == 1;
    }

    public void ajl() {
    }

    public d dsz() {
        return this.yz;
    }

    /* JADX WARN: Removed duplicated region for block: B:19:0x003b  */
    /* JADX WARN: Removed duplicated region for block: B:22:0x005a  */
    /* JADX WARN: Removed duplicated region for block: B:23:0x0060  */
    /* JADX WARN: Removed duplicated region for block: B:31:0x0092  */
    /* JADX WARN: Removed duplicated region for block: B:36:? A[RETURN, SYNTHETIC] */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public void duv() {
        String str;
        int i10;
        String str2;
        int i11;
        com.bytedance.sdk.openadsdk.sds.fm.fm.lb lbVar;
        com.bytedance.sdk.openadsdk.core.lb.fm fmVar;
        String str3 = this.nt ? "embeded_ad" : "embeded_ad_landingpage";
        if (this.maa.ii()) {
            str2 = "rewarded_video";
            i11 = 7;
        } else if (this.maa.vc()) {
            str2 = "fullscreen_interstitial_ad";
            i11 = 5;
        } else {
            if (!this.maa.se()) {
                str = str3;
                i10 = 1;
                if (this.maa.oy() == 4) {
                    this.mq = com.bytedance.sdk.openadsdk.sds.fm.fm.yz.fm(this.lse, str);
                }
                com.bytedance.sdk.openadsdk.core.lb.fm fmVar2 = new com.bytedance.sdk.openadsdk.core.lb.fm(this.lse, this.maa, str, i10);
                this.ai = fmVar2;
                fmVar2.fm(this);
                this.ai.ro(true);
                if (this.nt) {
                    this.ai.fm(false);
                    this.ai.lb(true);
                } else {
                    this.ai.fm(true);
                }
                this.ai.fm(this.gzf);
                this.ai.jnr(true);
                this.ai.fm(new ro.fm() { // from class: com.bytedance.sdk.openadsdk.core.fhx.ro.jnr.1
                    @Override // com.bytedance.sdk.openadsdk.core.lb.ro.fm
                    public void fm(View view, int i12) {
                        if (jnr.this.f7098ha != null) {
                            jnr.this.f7098ha.fm(view, i12);
                        }
                    }
                });
                lbVar = this.mq;
                if (lbVar != null && (fmVar = this.ai) != null) {
                    fmVar.fm(lbVar);
                }
                if (hi()) {
                    return;
                }
                com.bytedance.sdk.openadsdk.core.lb.fm fmVar3 = new com.bytedance.sdk.openadsdk.core.lb.fm(this.lse, this.maa, str, i10) { // from class: com.bytedance.sdk.openadsdk.core.fhx.ro.jnr.2
                    @Override // com.bytedance.sdk.openadsdk.core.lb.fm
                    public boolean lb() {
                        View view = jnr.this.vt;
                        if (view != null && view.getVisibility() == 0) {
                            return true;
                        }
                        View view2 = jnr.this.duv;
                        return view2 != null && view2.getVisibility() == 0;
                    }

                    @Override // com.bytedance.sdk.openadsdk.core.lb.fm
                    public boolean ro() {
                        wey weyVar = jnr.this.hlt;
                        boolean zFm = weyVar != null ? weyVar.fm() : false;
                        jnr.this.jnr.getVisibility();
                        return zFm || jnr.this.jnr.getVisibility() == 0;
                    }
                };
                this.ol = fmVar3;
                fmVar3.fm(new ro.fm() { // from class: com.bytedance.sdk.openadsdk.core.fhx.ro.jnr.3
                    @Override // com.bytedance.sdk.openadsdk.core.lb.ro.fm
                    public void fm(View view, int i12) {
                        if (jnr.this.f7098ha != null) {
                            jnr.this.f7098ha.fm(view, i12);
                        }
                    }
                });
                this.ol.ro(true);
                this.ol.fm(this.nt);
                this.ol.fm(this.gzf);
                this.ol.jnr(true);
                com.bytedance.sdk.openadsdk.sds.fm.fm.lb lbVar2 = this.mq;
                if (lbVar2 != null) {
                    this.ol.fm(lbVar2);
                }
                this.ol.fm(this);
                return;
            }
            str2 = "banner_ad";
            i11 = 2;
        }
        str = str2;
        i10 = i11;
        if (this.maa.oy() == 4) {
        }
        com.bytedance.sdk.openadsdk.core.lb.fm fmVar22 = new com.bytedance.sdk.openadsdk.core.lb.fm(this.lse, this.maa, str, i10);
        this.ai = fmVar22;
        fmVar22.fm(this);
        this.ai.ro(true);
        if (this.nt) {
        }
        this.ai.fm(this.gzf);
        this.ai.jnr(true);
        this.ai.fm(new ro.fm() { // from class: com.bytedance.sdk.openadsdk.core.fhx.ro.jnr.1
            @Override // com.bytedance.sdk.openadsdk.core.lb.ro.fm
            public void fm(View view, int i12) {
                if (jnr.this.f7098ha != null) {
                    jnr.this.f7098ha.fm(view, i12);
                }
            }
        });
        lbVar = this.mq;
        if (lbVar != null) {
            fmVar.fm(lbVar);
        }
        if (hi()) {
        }
    }

    public void ef() {
        yz(8);
        if (hlt()) {
            this.yz.setVisibility(8);
        }
        ImageView imageView = this.wu;
        if (imageView != null) {
            imageView.setImageDrawable(null);
        }
        yz(8);
        zan.fm(this.vt, 8);
        zan.fm((View) this.ku, 8);
        zan.fm(this.duv, 8);
        wey weyVar = this.hlt;
        if (weyVar != null) {
            weyVar.fm(true);
        }
    }

    public void fhx() {
        wey weyVar = this.hlt;
        if (weyVar != null) {
            weyVar.fm(false);
        }
    }

    public void fm(int i10) {
    }

    @Override // com.bytedance.sdk.openadsdk.core.lb.fm.InterfaceC0078fm
    public long getVideoProgress() {
        if (this.pkk <= 0) {
            lse lseVar = this.maa;
            if (lseVar != null && lseVar.ex() != null) {
                this.pkk = (long) (this.maa.ex().f5924d * 1000.0d);
            }
            f fVar = this.gzf;
            if (fVar != null) {
                this.pkk = fVar.ef();
            }
        }
        return this.pkk;
    }

    @TargetApi(14)
    public void gof() {
        zan.fm((View) this.f7099lb, 0);
        d dVar = this.yz;
        if (dVar != null) {
            zan.fm(dVar.getView(), 0);
        }
    }

    public void gqi() {
        try {
            zan.fm(this.vt, 8);
            zan.fm((View) this.ku, 8);
            zan.fm(this.duv, 8);
            zan.fm((View) this.dsz, 8);
        } catch (Exception unused) {
        }
    }

    public boolean hlt() {
        return (this.sds & 4) != 4 || this.gof;
    }

    public boolean irt() {
        return this.hi != null;
    }

    public void jnr() {
    }

    @Override // com.bytedance.sdk.openadsdk.core.widget.wey.ro
    public void ku() {
        fm(true, false);
    }

    @Override // b6.g
    public View lb() {
        return this.f7099lb;
    }

    @Override // com.bytedance.sdk.openadsdk.core.widget.gqi.fm
    public boolean lse() {
        wey weyVar = this.hlt;
        return weyVar != null && weyVar.fm();
    }

    public boolean maa() {
        return this.gqi;
    }

    public void onz() {
        if (this.hi == null || this.hlt != null) {
            return;
        }
        System.currentTimeMillis();
        wey weyVar = new wey();
        this.hlt = weyVar;
        weyVar.fm(this.lse, this.f7099lb);
        this.hlt.fm(this.hi, this);
        System.currentTimeMillis();
    }

    public void qhl() {
        zan.ajl(this.ajl);
        zan.ajl(this.wsy);
        if (this.jnr.getVisibility() == 0) {
            zan.fm((View) this.jnr, 8);
        }
    }

    public void ro(@Nullable ViewGroup viewGroup) {
    }

    public boolean sds() {
        return this.gof;
    }

    @Override // com.bytedance.sdk.openadsdk.core.widget.wey.ro
    public boolean vt() {
        return false;
    }

    public void wey() {
        ImageView imageView = this.ku;
        if (imageView != null) {
            imageView.setImageBitmap(null);
        }
    }

    public void wsy() {
        lse lseVar;
        zan.ajl(this.ajl);
        zan.ajl(this.wsy);
        if (this.wu != null && (lseVar = this.maa) != null && lseVar.ex() != null && this.maa.ex().f5926f != null) {
            zan.ajl(this.wu);
            com.bytedance.sdk.openadsdk.wey.ro.ro().fm(this.maa.ex().f5926f, this.maa.ex().f5922b, this.maa.ex().f5921a, this.wu, this.maa);
        }
        if (this.jnr.getVisibility() == 0) {
            zan.fm((View) this.jnr, 8);
        }
    }

    public void wu() {
        zan.jnr(this.ajl);
    }

    public void yz() {
        this.yz.a(this);
        this.jnr.setOnClickListener(new View.OnClickListener() { // from class: com.bytedance.sdk.openadsdk.core.fhx.ro.jnr.4
            @Override // android.view.View.OnClickListener
            public void onClick(View view) {
                if (jnr.this.irt()) {
                    TextView textView = jnr.this.dsz;
                    if (textView == null || textView.getVisibility() != 0) {
                        jnr jnrVar = jnr.this;
                        jnrVar.hi.fm(jnrVar, view);
                    }
                }
            }
        });
    }

    private void ajl(int i10) {
        zan.fm(this.duv, i10);
    }

    private int jnr(int i10) {
        if (this.irt <= 0 || this.qhl <= 0) {
            return 0;
        }
        int iRo = zan.ro(this.lse, 228.0f);
        int iRo2 = zan.ro(this.lse, 160.0f);
        int i11 = (int) (this.qhl * ((i10 * 1.0f) / this.irt));
        return i11 > iRo ? iRo : i11 < iRo2 ? iRo2 : i11;
    }

    public void fm(long j10) {
    }

    public void lb(int i10, int i11) {
        this.irt = i10;
        this.qhl = i11;
    }

    public void ro(boolean z10) {
    }

    public void fm(long j10, long j11) {
    }

    public void lb(boolean z10) {
    }

    public boolean ro(int i10) {
        return false;
    }

    public void yz(boolean z10) {
        this.nt = z10;
        if (z10) {
            com.bytedance.sdk.openadsdk.core.lb.fm fmVar = this.ai;
            if (fmVar != null) {
                fmVar.fm(true);
            }
            com.bytedance.sdk.openadsdk.core.lb.fm fmVar2 = this.ol;
            if (fmVar2 != null) {
                fmVar2.fm(true);
                return;
            }
            return;
        }
        com.bytedance.sdk.openadsdk.core.lb.fm fmVar3 = this.ai;
        if (fmVar3 != null) {
            fmVar3.fm(false);
        }
        com.bytedance.sdk.openadsdk.core.lb.fm fmVar4 = this.ol;
        if (fmVar4 != null) {
            fmVar4.fm(false);
        }
    }

    @Override // com.bytedance.sdk.component.utils.mq.fm
    public void fm(Message message) {
    }

    public void lb(int i10) {
        zan.fm((View) this.f7099lb, 0);
        d dVar = this.yz;
        if (dVar != null) {
            dVar.setVisibility(i10);
        }
    }

    public void ro(boolean z10, boolean z11) {
        ImageView imageView = this.jnr;
        if (imageView != null) {
            if (z10) {
                imageView.setImageDrawable(ku.fm(this.lse, "tt_play_movebar_textpage"));
            } else {
                imageView.setImageDrawable(ku.fm(this.lse, "tt_stop_movebar_textpage"));
            }
        }
    }

    @Override // com.bytedance.sdk.openadsdk.core.widget.gqi.fm
    public void fm(View view, boolean z10) {
    }

    public void fm(@Nullable ViewGroup viewGroup) {
    }

    public void lb(@Nullable ViewGroup viewGroup) {
        if (viewGroup == null) {
            return;
        }
        if (this.f7099lb.getParent() == null) {
            viewGroup.addView(this.f7099lb);
        }
        yz(0);
    }

    public void ro(int i10, int i11) {
        ViewGroup.LayoutParams layoutParams = this.f7099lb.getLayoutParams();
        if (layoutParams == null) {
            return;
        }
        if (i10 == -1 || i10 == -2 || i10 > 0) {
            layoutParams.width = i10;
        }
        if (i11 == -1 || i11 == -2 || i11 > 0) {
            layoutParams.height = i11;
        }
        this.f7099lb.setLayoutParams(layoutParams);
    }

    public void fm(ajl.fm fmVar) {
        this.f7098ha = fmVar;
    }

    public void yz(int i10) {
        this.wey = i10;
        zan.fm((View) this.f7099lb, i10);
    }

    public void fm(String str) {
    }

    @Override // b6.g
    public void fm(boolean z10) {
        this.wbw = z10;
    }

    public jnr(Context context, ViewGroup viewGroup, boolean z10, int i10, lse lseVar, f fVar) {
        this(context, viewGroup, z10, i10, lseVar, fVar, true);
    }

    @Override // b6.g
    public void ro() {
        zan.jnr(this.ajl);
        zan.jnr(this.wsy);
        ImageView imageView = this.wu;
        if (imageView != null) {
            zan.jnr(imageView);
        }
    }

    @Override // b6.g
    @SuppressLint({"ClickableViewAccessibility"})
    public /* bridge */ /* synthetic */ void fm(Object obj, WeakReference weakReference, boolean z10) {
        fm((lse) obj, (WeakReference<Context>) weakReference, z10);
    }

    public void fm(PAGNativeAd pAGNativeAd) {
        com.bytedance.sdk.openadsdk.core.lb.fm fmVar = this.ai;
        if (fmVar != null) {
            fmVar.fm(pAGNativeAd);
        }
        com.bytedance.sdk.openadsdk.core.lb.fm fmVar2 = this.ol;
        if (fmVar2 != null) {
            fmVar2.fm(pAGNativeAd);
        }
    }

    @Override // w5.b
    public void ro(SurfaceHolder surfaceHolder) {
        if (surfaceHolder != this.yz.getHolder()) {
            return;
        }
        this.gqi = false;
        if (irt()) {
            this.hi.ro(this, surfaceHolder);
        }
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Type inference failed for: r1v3, types: [android.view.ViewGroup, android.widget.RelativeLayout] */
    /* JADX WARN: Type inference failed for: r4v25 */
    /* JADX WARN: Type inference failed for: r4v26 */
    /* JADX WARN: Type inference failed for: r4v5, types: [android.view.View, w5.d] */
    public void fm(Context context, View view) {
        ?? lbVar;
        System.currentTimeMillis();
        lse lseVar = this.maa;
        if ((lseVar == null || ((!lseVar.lty() && !this.maa.se()) || com.bytedance.sdk.openadsdk.core.settings.ku.ro().zzn())) && view != null) {
            view.setKeepScreenOn(true);
        }
        f fVar = this.gzf;
        if (fVar != null && fVar.fhx()) {
            lbVar = new com.bykv.vk.openvk.fm.fm.fm.ajl.yz(this.lse);
        } else {
            lbVar = new com.bykv.vk.openvk.fm.fm.fm.ajl.lb(this.lse);
        }
        if (view instanceof RelativeLayout) {
            RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(-2, -2);
            layoutParams.addRule(13);
            ((RelativeLayout) view).addView(lbVar, 0, layoutParams);
        }
        zan.fm((View) lbVar, 8);
        this.yz = lbVar;
        this.jnr = (ImageView) view.findViewById(qhl.eys);
        this.ajl = view.findViewById(qhl.zzm);
        this.wsy = view.findViewById(qhl.nn);
        this.wu = (ImageView) view.findViewById(qhl.qlg);
        this.f7097ef = view.findViewById(qhl.xp);
        System.currentTimeMillis();
    }

    @Override // w5.b
    public void ro(SurfaceTexture surfaceTexture) {
        f fVar = this.gzf;
        if (fVar != null) {
            fVar.fm(surfaceTexture);
        }
    }

    public void fm(View view, Context context) {
        View view2;
        if (view == null || context == null || (view2 = this.f7097ef) == null || view2.getParent() == null || this.vt != null) {
            return;
        }
        this.vt = this.f7097ef;
        this.ku = (ImageView) view.findViewById(qhl.vj);
        this.duv = view.findViewById(qhl.hou);
        this.dsz = (TextView) view.findViewById(qhl.si);
    }

    public boolean fm(int i10, com.bykv.vk.openvk.fm.fm.fm.lb.b bVar, boolean z10) {
        wey weyVar = this.hlt;
        return weyVar == null || weyVar.fm(i10, bVar, z10);
    }

    public void fm(a aVar) {
        if (aVar instanceof fm) {
            this.hi = (fm) aVar;
            onz();
        }
    }

    public void fm(int i10, int i11) {
        if (i10 == -1) {
            i10 = zan.lb(this.lse);
        }
        if (i10 <= 0) {
            return;
        }
        this.onz = i10;
        if (sds() || vt() || (this.sds & 8) == 8) {
            this.fhx = i11;
        } else {
            this.fhx = jnr(i10);
        }
        ro(this.onz, this.fhx);
    }

    @Override // b6.g
    public void fm() {
        fm(false, this.gof);
        gqi();
    }

    /* JADX WARN: Removed duplicated region for block: B:33:0x009d  */
    @SuppressLint({"ClickableViewAccessibility"})
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public void fm(lse lseVar, WeakReference<Context> weakReference, boolean z10) {
        lse lseVar2;
        if (lseVar == null) {
            return;
        }
        fm(false, this.gof);
        fm(this.f7099lb, gof.fm());
        View view = this.vt;
        if (view != null) {
            zan.fm(view, 0);
        }
        ImageView imageView = this.ku;
        if (imageView != null) {
            zan.fm((View) imageView, 0);
        }
        zan.fm(this.duv, 0);
        if (this.ku != null && (lseVar2 = this.maa) != null && lseVar2.ex() != null && this.maa.ex().f5926f != null) {
            com.bytedance.sdk.openadsdk.wey.ro.ro().fm(this.maa.ex().f5926f, this.maa.ex().f5922b, this.maa.ex().f5921a, this.ku, lseVar);
        }
        zan.fm((View) this.dsz, 0);
        String strEys = lseVar.eys();
        if (TextUtils.isEmpty(strEys)) {
            int iOy = lseVar.oy();
            if (iOy == 2 || iOy == 3) {
                strEys = maa.fm(this.lse, "tt_video_mobile_go_detail");
            } else if (iOy == 4) {
                strEys = maa.fm(this.lse, "tt_video_download_apk");
            } else if (iOy == 5) {
                strEys = maa.fm(this.lse, "tt_video_dial_phone");
            } else if (iOy != 8) {
                strEys = maa.fm(this.lse, "tt_video_mobile_go_detail");
            }
        }
        TextView textView = this.dsz;
        if (textView != null) {
            textView.setText(strEys);
            this.dsz.setOnClickListener(this.ai);
            this.dsz.setOnTouchListener(this.ai);
        }
        if (this.wbw) {
            return;
        }
        ajl(4);
    }

    @Override // w5.b
    public void fm(SurfaceHolder surfaceHolder) {
        if (surfaceHolder != this.yz.getHolder()) {
            return;
        }
        this.gqi = true;
        if (irt()) {
            this.hi.fm(this, surfaceHolder);
        }
    }

    @Override // w5.b
    public void fm(SurfaceHolder surfaceHolder, int i10, int i11, int i12) {
        if (surfaceHolder != this.yz.getHolder()) {
            return;
        }
        irt();
    }

    @Override // w5.b
    public void fm(SurfaceTexture surfaceTexture, int i10, int i11) {
        this.gqi = true;
        if (irt()) {
            this.hi.fm(this, surfaceTexture);
        }
    }

    @Override // w5.b
    public boolean fm(SurfaceTexture surfaceTexture) {
        this.gqi = false;
        if (!irt()) {
            return true;
        }
        this.hi.ro(this, surfaceTexture);
        return true;
    }

    public void fm(boolean z10, boolean z11, boolean z12) {
        zan.fm((View) this.jnr, (!z10 || this.ajl.getVisibility() == 0) ? 8 : 0);
    }

    public void fm(boolean z10, boolean z11) {
        zan.fm((View) this.jnr, 8);
    }

    @Override // b6.g
    public void fm(Drawable drawable) {
        ViewGroup viewGroup = this.f7099lb;
        if (viewGroup != null) {
            viewGroup.setBackgroundDrawable(drawable);
        }
    }
}
