package com.bytedance.sdk.component.adexpress.dynamic.dynamicview;

import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.GradientDrawable;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.TextView;
import androidx.media3.exoplayer.rtsp.SessionDescription;
import com.google.android.gms.measurement.internal.u1;

/* JADX INFO: loaded from: classes.dex */
public class ha extends ajl implements com.bytedance.sdk.component.adexpress.dynamic.jnr {
    TextView fm;
    FrameLayout ro;
    boolean wey;

    public ha(Context context, DynamicRootView dynamicRootView, com.bytedance.sdk.component.adexpress.dynamic.yz.wu wuVar) {
        super(context, dynamicRootView, wuVar);
        this.wey = false;
        View view = new View(context);
        this.fhx = view;
        view.setTag(Integer.valueOf(getClickArea()));
        this.fm = new TextView(context);
        this.ro = new FrameLayout(context);
        FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams((int) com.bytedance.sdk.component.adexpress.yz.wsy.fm(context, 40.0f), (int) com.bytedance.sdk.component.adexpress.yz.wsy.fm(context, 15.0f));
        layoutParams.gravity = 8388693;
        layoutParams.rightMargin = 20;
        layoutParams.bottomMargin = 20;
        this.fm.setLayoutParams(layoutParams);
        GradientDrawable gradientDrawable = new GradientDrawable();
        gradientDrawable.setShape(0);
        gradientDrawable.setCornerRadius(25.0f);
        gradientDrawable.setColor(Color.parseColor("#57000000"));
        this.fm.setBackground(gradientDrawable);
        this.fm.setTextSize(10.0f);
        this.fm.setGravity(17);
        this.fm.setTextColor(-1);
        this.fm.setVisibility(8);
        if (com.bytedance.sdk.component.adexpress.yz.ro()) {
            addView(this.ro, new FrameLayout.LayoutParams(-1, -1));
        }
        addView(this.fm);
        addView(this.fhx, getWidgetLayoutParams());
        if (!com.bytedance.sdk.component.adexpress.yz.ro()) {
            addView(this.ro, getWidgetLayoutParams());
        }
        dynamicRootView.videoView = this.ro;
        dynamicRootView.setVideoListener(this);
    }

    private void lb(View view) {
        if (view == this.fm || view == ((ajl) this).gqi) {
            return;
        }
        try {
            if (((Integer) view.getTag(com.bytedance.sdk.component.adexpress.dynamic.fm.ajl)).intValue() == 1) {
                return;
            }
        } catch (Throwable unused) {
        }
        int i10 = 0;
        view.setVisibility(0);
        if (!(view instanceof ViewGroup)) {
            return;
        }
        while (true) {
            ViewGroup viewGroup = (ViewGroup) view;
            if (i10 >= viewGroup.getChildCount()) {
                return;
            }
            lb(viewGroup.getChildAt(i10));
            i10++;
        }
    }

    @Override // com.bytedance.sdk.component.adexpress.dynamic.dynamicview.ajl, com.bytedance.sdk.component.adexpress.dynamic.dynamicview.pkk
    public boolean ef() {
        super.ef();
        double dJnr = 0.0d;
        double dYz = 0.0d;
        for (com.bytedance.sdk.component.adexpress.dynamic.yz.wu wuVarDuv = this.dsz; wuVarDuv != null; wuVarDuv = wuVarDuv.duv()) {
            double dAjl = dYz + ((double) wuVarDuv.ajl());
            double dWsy = dJnr + ((double) wuVarDuv.wsy());
            dYz = dAjl - ((double) wuVarDuv.yz());
            dJnr = dWsy - ((double) wuVarDuv.jnr());
        }
        try {
            float f10 = (float) dYz;
            int iFm = (int) com.bytedance.sdk.component.adexpress.yz.wsy.fm(getContext(), f10);
            int iFm2 = (int) com.bytedance.sdk.component.adexpress.yz.wsy.fm(getContext(), f10 + this.jnr);
            if (com.bytedance.sdk.component.adexpress.yz.ro.fm(getContext())) {
                int dynamicWidth = ((gof) this.onz.getChildAt(0)).getDynamicWidth();
                int i10 = dynamicWidth - iFm2;
                iFm2 = dynamicWidth - iFm;
                iFm = i10;
            }
            if ("open_ad".equals(this.onz.getRenderRequest().yz())) {
                this.onz.videoView = this.ro;
            } else {
                float f11 = (float) dJnr;
                ((gof) this.onz.getChildAt(0)).fm.fm(iFm, (int) com.bytedance.sdk.component.adexpress.yz.wsy.fm(getContext(), f11), iFm2, (int) com.bytedance.sdk.component.adexpress.yz.wsy.fm(getContext(), f11 + this.ajl));
            }
        } catch (Exception unused) {
        }
        this.onz.updateRenderInfoForVideo(dYz, dJnr, this.jnr, this.ajl, this.duv.fhx());
        return true;
    }

    @Override // com.bytedance.sdk.component.adexpress.dynamic.jnr
    public void fm() {
        this.fm.setVisibility(8);
    }

    @Override // com.bytedance.sdk.component.adexpress.dynamic.dynamicview.jnr
    public boolean jnr() {
        return true;
    }

    @Override // com.bytedance.sdk.component.adexpress.dynamic.jnr
    public void setTimeUpdate(int i10) {
        if (!this.dsz.vt().jnr().ug() || i10 <= 0 || this.wey) {
            this.wey = true;
            for (int i11 = 0; i11 < getChildCount(); i11++) {
                lb(getChildAt(i11));
            }
            this.fm.setVisibility(8);
            return;
        }
        String strJ = u1.j(i10 >= 60 ? SessionDescription.SUPPORTED_SDP_VERSION + (i10 / 60) : "00", ":");
        int i12 = i10 % 60;
        this.fm.setText(i12 > 9 ? strJ + i12 : strJ + SessionDescription.SUPPORTED_SDP_VERSION + i12);
        this.fm.setVisibility(0);
    }
}
