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

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

/* JADX INFO: loaded from: classes.dex */
public class DynamicRootView extends FrameLayout implements com.bytedance.sdk.component.adexpress.dynamic.yz {
    private String bgColor;
    private Map<Integer, String> bgMaterialCenterCalcColor;
    private jnr dynamicBaseWidget;
    private int logoUnionHeight;
    private Context mContext;
    private com.bytedance.sdk.component.adexpress.dynamic.ajl.fm mDynamicClickListener;
    boolean mIsMute;
    private com.bytedance.sdk.component.adexpress.ro.ku mRenderListener;
    private com.bytedance.sdk.component.adexpress.ro.dsz mRenderRequest;
    private ViewGroup mTimeOut;
    private com.bytedance.sdk.component.adexpress.dynamic.ro muteListener;
    protected final com.bytedance.sdk.component.adexpress.ro.onz renderResult;
    private int scoreCountWithIcon;
    private List<com.bytedance.sdk.component.adexpress.dynamic.lb> timeOutListener;
    private int timedown;
    private com.bytedance.sdk.component.adexpress.dynamic.jnr videoListener;
    public View videoView;

    public DynamicRootView(Context context, boolean z10, com.bytedance.sdk.component.adexpress.ro.dsz dszVar, com.bytedance.sdk.component.adexpress.dynamic.ajl.fm fmVar) {
        super(context);
        this.mTimeOut = null;
        this.timedown = 0;
        this.timeOutListener = new ArrayList();
        this.logoUnionHeight = 0;
        this.scoreCountWithIcon = 0;
        this.mContext = context;
        com.bytedance.sdk.component.adexpress.ro.onz onzVar = new com.bytedance.sdk.component.adexpress.ro.onz();
        this.renderResult = onzVar;
        onzVar.fm(2);
        this.mDynamicClickListener = fmVar;
        fmVar.fm(this);
        this.mIsMute = z10;
        this.mRenderRequest = dszVar;
    }

    private void checkCanOpenLandingPage(com.bytedance.sdk.component.adexpress.dynamic.yz.wu wuVar) {
        com.bytedance.sdk.component.adexpress.dynamic.yz.ajl ajlVarJnr;
        com.bytedance.sdk.component.adexpress.dynamic.yz.jnr jnrVarVt = wuVar.vt();
        if (jnrVarVt == null || (ajlVarJnr = jnrVarVt.jnr()) == null) {
            return;
        }
        this.renderResult.ro(ajlVarJnr.rbn());
    }

    private boolean checkSizeValid() {
        jnr jnrVar = this.dynamicBaseWidget;
        return jnrVar.jnr > 0.0f && jnrVar.ajl > 0.0f;
    }

    private void setClipChildren(ViewGroup viewGroup, com.bytedance.sdk.component.adexpress.dynamic.yz.wu wuVar) {
        ViewGroup viewGroup2;
        if (viewGroup == null || (viewGroup2 = (ViewGroup) viewGroup.getParent()) == null || !wuVar.hlt()) {
            return;
        }
        viewGroup2.setClipChildren(false);
        viewGroup2.setClipToPadding(false);
        ViewGroup viewGroup3 = (ViewGroup) viewGroup2.getParent();
        if (viewGroup3 != null) {
            viewGroup3.setClipChildren(false);
            viewGroup3.setClipToPadding(false);
        }
    }

    public void beginHideFromVisible() {
        beginShowFromInvisible(this.dynamicBaseWidget, 4);
    }

    public void beginShowFromInvisible() {
        beginShowFromInvisible(this.dynamicBaseWidget, 0);
    }

    public void callBackRenderFail(int i10, String str) {
        this.renderResult.fm(false);
        this.renderResult.ro(i10);
        this.renderResult.fm(str);
        this.mRenderListener.fm(this.renderResult);
    }

    public String getBgColor() {
        return this.bgColor;
    }

    public Map<Integer, String> getBgMaterialCenterCalcColor() {
        return this.bgMaterialCenterCalcColor;
    }

    public com.bytedance.sdk.component.adexpress.dynamic.ajl.fm getDynamicClickListener() {
        return this.mDynamicClickListener;
    }

    public int getLogoUnionHeight() {
        return this.logoUnionHeight;
    }

    public com.bytedance.sdk.component.adexpress.ro.ku getRenderListener() {
        return this.mRenderListener;
    }

    public com.bytedance.sdk.component.adexpress.ro.dsz getRenderRequest() {
        return this.mRenderRequest;
    }

    public int getScoreCountWithIcon() {
        return this.scoreCountWithIcon;
    }

    public ViewGroup getTimeOut() {
        return this.mTimeOut;
    }

    public List<com.bytedance.sdk.component.adexpress.dynamic.lb> getTimeOutListener() {
        return this.timeOutListener;
    }

    public int getTimedown() {
        return this.timedown;
    }

    @Override // com.bytedance.sdk.component.adexpress.dynamic.yz
    public void onvideoComplate() {
        try {
            this.videoListener.fm();
        } catch (Exception unused) {
        }
    }

    public void render(com.bytedance.sdk.component.adexpress.dynamic.yz.wu wuVar, int i10) {
        this.dynamicBaseWidget = renderDynamicView(wuVar, this, i10);
        this.renderResult.fm(true);
        this.renderResult.fm(this.dynamicBaseWidget.jnr);
        this.renderResult.ro(this.dynamicBaseWidget.ajl);
        this.renderResult.fm(this.videoView);
        this.mRenderListener.fm(this.renderResult);
    }

    public jnr renderDynamicView(com.bytedance.sdk.component.adexpress.dynamic.yz.wu wuVar, ViewGroup viewGroup, int i10) {
        if (wuVar == null) {
            return null;
        }
        List<com.bytedance.sdk.component.adexpress.dynamic.yz.wu> listKu = wuVar.ku();
        jnr jnrVarFm = com.bytedance.sdk.component.adexpress.dynamic.fm.ro.fm(this.mContext, this, wuVar);
        if (jnrVarFm instanceof ol) {
            callBackRenderFail(i10 == 3 ? 128 : 118, "unknow widget");
            return null;
        }
        checkCanOpenLandingPage(wuVar);
        jnrVarFm.lb();
        if (viewGroup != null) {
            viewGroup.addView(jnrVarFm);
            setClipChildren(viewGroup, wuVar);
        }
        if (listKu == null || listKu.size() <= 0) {
            return null;
        }
        Iterator<com.bytedance.sdk.component.adexpress.dynamic.yz.wu> it = listKu.iterator();
        while (it.hasNext()) {
            renderDynamicView(it.next(), jnrVarFm, i10);
        }
        return jnrVarFm;
    }

    public void setBgColor(String str) {
        this.bgColor = str;
    }

    public void setBgMaterialCenterCalcColor(Map<Integer, String> map) {
        this.bgMaterialCenterCalcColor = map;
    }

    public void setLogoUnionHeight(int i10) {
        this.logoUnionHeight = i10;
    }

    public void setMuteListener(com.bytedance.sdk.component.adexpress.dynamic.ro roVar) {
        this.muteListener = roVar;
    }

    public void setRenderListener(com.bytedance.sdk.component.adexpress.ro.ku kuVar) {
        this.mRenderListener = kuVar;
        this.mDynamicClickListener.fm(kuVar);
    }

    public void setScoreCountWithIcon(int i10) {
        this.scoreCountWithIcon = i10;
    }

    @Override // com.bytedance.sdk.component.adexpress.dynamic.yz
    public void setSoundMute(boolean z10) {
        com.bytedance.sdk.component.adexpress.dynamic.ro roVar = this.muteListener;
        if (roVar != null) {
            roVar.setSoundMute(z10);
        }
    }

    @Override // com.bytedance.sdk.component.adexpress.dynamic.yz
    public void setTime(CharSequence charSequence, int i10, int i11, boolean z10) {
        for (int i12 = 0; i12 < this.timeOutListener.size(); i12++) {
            if (this.timeOutListener.get(i12) != null) {
                this.timeOutListener.get(i12).fm(charSequence, i10 == 1, i11, z10);
            }
        }
    }

    public void setTimeOut(ViewGroup viewGroup) {
        this.mTimeOut = viewGroup;
    }

    public void setTimeOutListener(com.bytedance.sdk.component.adexpress.dynamic.lb lbVar) {
        this.timeOutListener.add(lbVar);
    }

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

    public void setTimedown(int i10) {
        this.timedown = i10;
    }

    public void setVideoListener(com.bytedance.sdk.component.adexpress.dynamic.jnr jnrVar) {
        this.videoListener = jnrVar;
    }

    public void updateRenderInfoForVideo(double d10, double d11, double d12, double d13, float f10) {
        this.renderResult.lb(d10);
        this.renderResult.yz(d11);
        this.renderResult.jnr(d12);
        this.renderResult.ajl(d13);
        this.renderResult.fm(f10);
        this.renderResult.ro(f10);
        this.renderResult.lb(f10);
        this.renderResult.yz(f10);
    }

    public void beginShowFromInvisible(jnr jnrVar, int i10) {
        if (jnrVar == null) {
            return;
        }
        if (jnrVar.getBeginInvisibleAndShow()) {
            jnrVar.setVisibility(i10);
            View view = jnrVar.fhx;
            if (view != null) {
                view.setVisibility(i10);
            }
        }
        int childCount = jnrVar.getChildCount();
        if (childCount <= 0) {
            return;
        }
        for (int i11 = 0; i11 < childCount; i11++) {
            if (jnrVar.getChildAt(i11) instanceof jnr) {
                beginShowFromInvisible((jnr) jnrVar.getChildAt(i11), i10);
            }
        }
    }
}
