package com.bytedance.adsdk.ugeno.yoga.ro;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.widget.ImageView;
import com.bytedance.adsdk.ugeno.fm;
import com.bytedance.adsdk.ugeno.ro.fm;
import com.bytedance.adsdk.ugeno.wsy.wu;
import com.bytedance.adsdk.ugeno.yoga.ajl;
import com.bytedance.adsdk.ugeno.yoga.dsz;
import com.bytedance.adsdk.ugeno.yoga.jnr;
import com.bytedance.adsdk.ugeno.yoga.onz;
import com.bytedance.adsdk.ugeno.yoga.ro.lb;
import com.bytedance.adsdk.ugeno.yoga.vt;
import com.bytedance.adsdk.ugeno.yoga.yz;
import defpackage.e;

/* JADX INFO: loaded from: classes.dex */
public class fm extends com.bytedance.adsdk.ugeno.ro.fm<lb> {
    private jnr cyr;
    private vt ex;
    private com.bytedance.adsdk.ugeno.yoga.fm lsa;
    private ajl po;
    private onz ucr;
    private com.bytedance.adsdk.ugeno.yoga.fm vod;

    /* JADX INFO: renamed from: com.bytedance.adsdk.ugeno.yoga.ro.fm$fm, reason: collision with other inner class name */
    public static class C0023fm extends fm.C0019fm {
        public int ai;
        private boolean bx;

        /* JADX INFO: renamed from: gc, reason: collision with root package name */
        public int f6411gc;
        public float gzf;

        /* JADX INFO: renamed from: ha, reason: collision with root package name */
        public int f6412ha;
        public int hxv;
        private boolean lz;
        private boolean mon;
        public float mq;
        public int nt;
        public float ol;
        public int pkk;

        /* JADX INFO: renamed from: qf, reason: collision with root package name */
        private boolean f6413qf;
        private boolean tzk;
        public int wbw;
        public float xgn;
        private boolean zan;

        public C0023fm(com.bytedance.adsdk.ugeno.ro.fm fmVar) {
            super(fmVar);
            this.nt = 1;
            this.mq = 0.0f;
            this.gzf = 1.0f;
            this.ai = com.bytedance.adsdk.ugeno.yoga.fm.AUTO.fm();
            this.ol = -1.0f;
            this.wbw = dsz.RELATIVE.fm();
        }

        private void yz() {
            com.bytedance.adsdk.ugeno.ro.fm fmVar = this.hi;
            if (fmVar instanceof fm) {
                if (((fm) fmVar).mpp() == jnr.ROW && this.hi.gc() == -2 && this.fm == -1.0f && !this.hi.qf()) {
                    this.fm = -2.0f;
                    this.gzf = 1.0f;
                    this.mq = 1.0f;
                    this.mon = true;
                    this.ol = -1.0f;
                }
                if (((fm) this.hi).mpp() == jnr.COLUMN && this.hi.xgn() == -2 && this.ro == -1.0f && !this.hi.qf()) {
                    this.ro = -2.0f;
                    this.gzf = 1.0f;
                    this.mq = 1.0f;
                    this.mon = true;
                    this.ol = -1.0f;
                }
            }
        }

        public boolean lb() {
            float f10 = this.fm;
            if (f10 == -1.0f && this.ro == -1.0f) {
                return false;
            }
            return f10 == -2.0f || this.ro == -2.0f;
        }

        @Override // com.bytedance.adsdk.ugeno.ro.fm.C0019fm
        /* JADX INFO: renamed from: ro, reason: merged with bridge method [inline-methods] */
        public lb.fm fm() {
            yz();
            lb.fm fmVar = new lb.fm((int) this.fm, (int) this.ro);
            fmVar.duv((int) (this.wey ? this.ajl : this.jnr));
            fmVar.onz((int) (this.sds ? this.wsy : this.jnr));
            fmVar.ku((int) (this.maa ? this.wu : this.jnr));
            fmVar.dsz((int) (this.lse ? this.f6371ef : this.jnr));
            fmVar.fm(this.nt);
            fmVar.jnr(this.ai);
            fmVar.ro(this.mq);
            fmVar.lb(this.gzf);
            fmVar.irt(this.f6372lb);
            fmVar.qhl(this.yz);
            if (this.mon) {
                fmVar.yz(this.ol);
            }
            fmVar.ajl(this.wbw);
            if (this.bx) {
                fmVar.wsy(this.f6412ha);
            }
            if (this.zan) {
                fmVar.ef(this.pkk);
            }
            if (this.tzk) {
                fmVar.wu(this.hxv);
            }
            if (this.lz) {
                fmVar.vt(this.f6411gc);
            }
            if (this.f6413qf && lb()) {
                float f10 = this.xgn;
                if (f10 > 0.0f) {
                    fmVar.fhx(f10);
                    fmVar.lb(0.0f);
                    fmVar.ro(0.0f);
                }
            }
            return fmVar;
        }

        @Override // com.bytedance.adsdk.ugeno.ro.fm.C0019fm
        public String toString() {
            StringBuilder sb = new StringBuilder("LayoutParams{mOrder=");
            sb.append(this.nt);
            sb.append(", mFlexGrow=");
            sb.append(this.mq);
            sb.append(", mFlexShrink=");
            sb.append(this.gzf);
            sb.append(", mAlignSelf=");
            sb.append(this.ai);
            sb.append(", mFlexBasis=");
            sb.append(this.ol);
            sb.append(", mPosition=");
            sb.append(this.wbw);
            sb.append(", mTop=");
            sb.append(this.f6412ha);
            sb.append(", mBottom=");
            sb.append(this.pkk);
            sb.append(", mLeft=");
            sb.append(this.hxv);
            sb.append(", mRight=");
            return e.l(sb, this.f6411gc, '}');
        }

        @Override // com.bytedance.adsdk.ugeno.ro.fm.C0019fm
        public void fm(Context context, String str, String str2) {
            if (TextUtils.isEmpty(str)) {
            }
            super.fm(context, str, str2);
            str.getClass();
            switch (str) {
                case "flexBasis":
                    this.mon = true;
                    float fFm = com.bytedance.adsdk.ugeno.wsy.lb.fm(str2, -1.0f);
                    this.ol = fFm;
                    this.ol = wu.fm(context, fFm);
                    break;
                case "bottom":
                    this.zan = true;
                    this.pkk = (int) wu.fm(context, com.bytedance.adsdk.ugeno.wsy.lb.fm(str2, 0));
                    break;
                case "top":
                    this.bx = true;
                    this.f6412ha = (int) wu.fm(context, com.bytedance.adsdk.ugeno.wsy.lb.fm(str2, 0));
                    break;
                case "left":
                    this.tzk = true;
                    this.hxv = (int) wu.fm(context, com.bytedance.adsdk.ugeno.wsy.lb.fm(str2, 0));
                    break;
                case "order":
                    this.nt = com.bytedance.adsdk.ugeno.wsy.lb.fm(str2, 1);
                    break;
                case "ratio":
                    this.f6413qf = true;
                    this.xgn = com.bytedance.adsdk.ugeno.wsy.lb.fm(str2, 0.0f);
                    break;
                case "right":
                    this.lz = true;
                    this.f6411gc = (int) wu.fm(context, com.bytedance.adsdk.ugeno.wsy.lb.fm(str2, 0));
                    break;
                case "position":
                    this.wbw = dsz.fm(str2).fm();
                    break;
                case "flexShrink":
                    this.gzf = com.bytedance.adsdk.ugeno.wsy.lb.fm(str2, 1.0f);
                    break;
                case "flexGrow":
                    this.mq = com.bytedance.adsdk.ugeno.wsy.lb.fm(str2, 0.0f);
                    break;
                case "alignSelf":
                    this.ai = com.bytedance.adsdk.ugeno.yoga.fm.fm(str2).fm();
                    break;
            }
        }
    }

    public fm(Context context) {
        super(context);
        this.cyr = jnr.ROW;
        this.ucr = onz.NO_WRAP;
        this.po = ajl.FLEX_START;
        com.bytedance.adsdk.ugeno.yoga.fm fmVar = com.bytedance.adsdk.ugeno.yoga.fm.STRETCH;
        this.vod = fmVar;
        this.lsa = fmVar;
    }

    @Override // com.bytedance.adsdk.ugeno.ro.lb
    public void gzf() {
        ImageView.ScaleType scaleType;
        if (this.tzk) {
            com.bytedance.adsdk.ugeno.jnr.fm().ro().fm(this.f6374ef, this.mon, new fm.InterfaceC0016fm() { // from class: com.bytedance.adsdk.ugeno.yoga.ro.fm.1
                @Override // com.bytedance.adsdk.ugeno.fm.InterfaceC0016fm
                public void fm(Bitmap bitmap) {
                    if (bitmap == null) {
                        if (((com.bytedance.adsdk.ugeno.ro.lb) fm.this).grs != null) {
                            com.bytedance.adsdk.ugeno.core.ajl unused = ((com.bytedance.adsdk.ugeno.ro.lb) fm.this).grs;
                            String unused2 = ((com.bytedance.adsdk.ugeno.ro.lb) fm.this).mon;
                            return;
                        }
                        return;
                    }
                    if (((com.bytedance.adsdk.ugeno.ro.lb) fm.this).grs != null) {
                        com.bytedance.adsdk.ugeno.core.ajl unused3 = ((com.bytedance.adsdk.ugeno.ro.lb) fm.this).grs;
                        String unused4 = ((com.bytedance.adsdk.ugeno.ro.lb) fm.this).mon;
                    }
                    final Bitmap bitmapFm = wu.fm(((com.bytedance.adsdk.ugeno.ro.lb) fm.this).ro, bitmap, (int) ((com.bytedance.adsdk.ugeno.ro.lb) fm.this).zan);
                    if (bitmapFm != null) {
                        wu.fm(new Runnable() { // from class: com.bytedance.adsdk.ugeno.yoga.ro.fm.1.1
                            @Override // java.lang.Runnable
                            public void run() {
                                fm.this.fm(new BitmapDrawable(bitmapFm));
                            }
                        });
                    }
                }
            });
            return;
        }
        com.bytedance.adsdk.ugeno.ef.yz.fm fmVar = new com.bytedance.adsdk.ugeno.ef.yz.fm(this.ro);
        com.bytedance.adsdk.ugeno.jnr.fm().ro().fm(this.f6374ef, this.mon, fmVar, this.jnr.getWidth(), this.jnr.getHeight(), new fm.InterfaceC0016fm() { // from class: com.bytedance.adsdk.ugeno.yoga.ro.fm.2
            @Override // com.bytedance.adsdk.ugeno.fm.InterfaceC0016fm
            public void fm(Bitmap bitmap) {
                if (bitmap == null) {
                    if (((com.bytedance.adsdk.ugeno.ro.lb) fm.this).grs != null) {
                        com.bytedance.adsdk.ugeno.core.ajl unused = ((com.bytedance.adsdk.ugeno.ro.lb) fm.this).grs;
                        String unused2 = ((com.bytedance.adsdk.ugeno.ro.lb) fm.this).mon;
                        return;
                    }
                    return;
                }
                if (((com.bytedance.adsdk.ugeno.ro.lb) fm.this).grs != null) {
                    com.bytedance.adsdk.ugeno.core.ajl unused3 = ((com.bytedance.adsdk.ugeno.ro.lb) fm.this).grs;
                    String unused4 = ((com.bytedance.adsdk.ugeno.ro.lb) fm.this).mon;
                }
            }
        });
        if (!this.lz || (scaleType = this.bx) == ImageView.ScaleType.FIT_XY) {
            fmVar.setScaleType(ImageView.ScaleType.FIT_XY);
        } else {
            fmVar.setScaleType(scaleType);
        }
        fmVar.setCornerRadius(this.f6385qf);
        lb.fm fmVar2 = new lb.fm(-1, -1);
        fmVar2.ajl(dsz.ABSOLUTE.fm());
        fmVar2.wsy(0.0f);
        fmVar2.wu(0.0f);
        T t10 = this.jnr;
        if (t10 instanceof lb) {
            ((lb) t10).addView(fmVar, 0, fmVar2);
            fm(fmVar);
        }
    }

    public jnr mpp() {
        return this.cyr;
    }

    @Override // com.bytedance.adsdk.ugeno.ro.lb
    /* JADX INFO: renamed from: lb, reason: merged with bridge method [inline-methods] */
    public lb fm() {
        lb lbVar = new lb(this.ro);
        lbVar.fm(this);
        this.ex = lbVar.getYogaNode();
        return lbVar;
    }

    @Override // com.bytedance.adsdk.ugeno.ro.lb
    public void onz() {
        if (this.wbw) {
            this.ex.ro(yz.ALL, this.nt);
        }
        if (this.f6377ha) {
            this.ex.ro(yz.LEFT, this.mq);
        }
        if (this.pkk) {
            this.ex.ro(yz.RIGHT, this.gzf);
        }
        if (this.hxv) {
            this.ex.ro(yz.TOP, this.ai);
        }
        if (this.f6376gc) {
            this.ex.ro(yz.BOTTOM, this.ol);
        }
    }

    @Override // com.bytedance.adsdk.ugeno.ro.fm, com.bytedance.adsdk.ugeno.ro.lb
    public void ro() {
        super.ro();
        this.ex.fm(this.cyr);
        this.ex.fm(this.ucr);
        this.ex.fm(this.po);
        this.ex.fm(this.vod);
        this.ex.lb(this.lsa);
        this.ex.fm(true);
    }

    @Override // com.bytedance.adsdk.ugeno.ro.fm
    /* JADX INFO: renamed from: yz, reason: merged with bridge method [inline-methods] */
    public C0023fm vt() {
        return new C0023fm(this);
    }

    @Override // com.bytedance.adsdk.ugeno.ro.lb
    public void fm(Drawable drawable) {
        ImageView.ScaleType scaleType;
        com.bytedance.adsdk.ugeno.ef.yz.fm fmVar = new com.bytedance.adsdk.ugeno.ef.yz.fm(this.ro);
        fmVar.setImageDrawable(drawable);
        if (this.lz && (scaleType = this.bx) != ImageView.ScaleType.FIT_XY) {
            fmVar.setScaleType(scaleType);
        } else {
            fmVar.setScaleType(ImageView.ScaleType.FIT_XY);
        }
        fmVar.setCornerRadius(this.f6385qf);
        lb.fm fmVar2 = new lb.fm(-1, -1);
        fmVar2.ajl(dsz.ABSOLUTE.fm());
        fmVar2.wsy(0.0f);
        fmVar2.wu(0.0f);
        T t10 = this.jnr;
        if (t10 instanceof lb) {
            ((lb) t10).addView(fmVar, 0, fmVar2);
            fm(fmVar);
        }
    }

    private void fm(final com.bytedance.adsdk.ugeno.ef.yz.fm fmVar) {
        this.jnr.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { // from class: com.bytedance.adsdk.ugeno.yoga.ro.fm.3
            @Override // android.view.ViewTreeObserver.OnGlobalLayoutListener
            public void onGlobalLayout() {
                vt vtVarFm;
                if (((com.bytedance.adsdk.ugeno.ro.lb) fm.this).jnr == null || (vtVarFm = ((lb) ((com.bytedance.adsdk.ugeno.ro.lb) fm.this).jnr).fm(fmVar)) == null) {
                    return;
                }
                int width = ((com.bytedance.adsdk.ugeno.ro.lb) fm.this).jnr.getWidth();
                vtVarFm.yz(width);
                int height = ((com.bytedance.adsdk.ugeno.ro.lb) fm.this).jnr.getHeight();
                vtVarFm.ajl(height);
                fmVar.setCornerRadius(((com.bytedance.adsdk.ugeno.ro.lb) fm.this).f6385qf);
                ((com.bytedance.adsdk.ugeno.ro.lb) fm.this).jnr.requestLayout();
                if (width > 0 || height > 0) {
                    ((com.bytedance.adsdk.ugeno.ro.lb) fm.this).jnr.getViewTreeObserver().removeOnGlobalLayoutListener(this);
                }
            }
        });
    }

    @Override // com.bytedance.adsdk.ugeno.ro.fm
    public void fm(com.bytedance.adsdk.ugeno.ro.lb lbVar) {
        super.fm(lbVar);
    }

    @Override // com.bytedance.adsdk.ugeno.ro.fm
    public void fm(com.bytedance.adsdk.ugeno.ro.lb lbVar, ViewGroup.LayoutParams layoutParams) {
        if (lbVar == null) {
            return;
        }
        ((com.bytedance.adsdk.ugeno.ro.fm) this).fm.add(lbVar);
        View viewKu = lbVar.ku();
        if (viewKu != null) {
            ((lb) this.jnr).addView(viewKu, layoutParams);
        }
    }

    @Override // com.bytedance.adsdk.ugeno.ro.lb
    public void fm(String str, String str2) {
        super.fm(str, str2);
        str.getClass();
        switch (str) {
            case "alignItems":
                this.vod = com.bytedance.adsdk.ugeno.yoga.fm.fm(str2);
                break;
            case "flexDirection":
                this.cyr = jnr.fm(str2);
                break;
            case "alignContent":
                this.lsa = com.bytedance.adsdk.ugeno.yoga.fm.fm(str2);
                break;
            case "flexWrap":
                this.ucr = onz.fm(str2);
                break;
            case "justifyContent":
                this.po = ajl.fm(str2);
                break;
        }
    }
}
