package com.bytedance.adsdk.ugeno.ef.ajl;

import android.content.Context;
import android.graphics.Typeface;
import android.os.Build;
import android.text.TextUtils;
import com.bytedance.adsdk.ugeno.ro.lb;
import com.bytedance.adsdk.ugeno.wsy.wu;

/* JADX INFO: loaded from: classes.dex */
public class ro extends lb<fm> {
    private float bp;
    protected int cyr;
    private int ex;

    /* JADX INFO: renamed from: ff, reason: collision with root package name */
    private int f6329ff;
    protected String fm;
    private float hou;

    /* JADX INFO: renamed from: kc, reason: collision with root package name */
    private TextUtils.TruncateAt f6330kc;
    private int ky;

    /* JADX INFO: renamed from: le, reason: collision with root package name */
    private boolean f6331le;
    private int lsa;

    @Deprecated
    private TextUtils.TruncateAt oy;
    private float po;

    @Deprecated
    private float pyj;

    @Deprecated
    private float rbn;
    private float ucr;
    private float ug;
    private float vj;
    private int vod;
    private int wjb;
    private float xp;
    private float zzm;

    public ro(Context context) {
        super(context);
        this.cyr = -16777216;
        this.ucr = 12.0f;
        this.po = -1.0f;
        this.lsa = Integer.MAX_VALUE;
        this.wjb = 8388611;
        this.f6330kc = TextUtils.TruncateAt.END;
        this.ug = -1.0f;
        this.bp = 400.0f;
    }

    private TextUtils.TruncateAt dsz(String str) {
        str.getClass();
        switch (str) {
            case "center":
                this.oy = TextUtils.TruncateAt.MIDDLE;
                break;
            case "end":
                this.oy = TextUtils.TruncateAt.END;
                break;
            case "start":
                this.oy = TextUtils.TruncateAt.START;
                break;
            default:
                this.oy = null;
                break;
        }
        return this.oy;
    }

    private void ef() {
        float f10 = this.ug;
        if (f10 <= 3.0f) {
            ((fm) this.jnr).setLineSpacing(0.0f, f10);
            return;
        }
        if (Build.VERSION.SDK_INT >= 28) {
            int iRound = Math.round(wu.fm(this.ro, (f10 - (this.ucr * 1.2f)) / 2.0f));
            int paddingTop = ((fm) this.jnr).getPaddingTop() + iRound;
            int paddingBottom = ((fm) this.jnr).getPaddingBottom() + iRound;
            T t10 = this.jnr;
            ((fm) t10).setPadding(((fm) t10).getPaddingLeft(), paddingTop, ((fm) this.jnr).getPaddingRight(), paddingBottom);
            ((fm) this.jnr).setLineHeight(Math.round(wu.fm(this.ro, this.ug)));
        }
    }

    private TextUtils.TruncateAt fhx(String str) {
        if (TextUtils.equals(str, "none")) {
            return null;
        }
        return TextUtils.TruncateAt.END;
    }

    private int gof(String str) {
        str.getClass();
        switch (str) {
            case "underline":
                return 8;
            case "strikethrough":
                return 16;
            case "none":
            default:
                return Integer.MAX_VALUE;
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:18:0x0035  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    private int irt(String str) {
        byte b10;
        int iHashCode = str.hashCode();
        if (iHashCode != -1178781136) {
            if (iHashCode != -1039745817) {
                b10 = (iHashCode == 3029637 && str.equals("bold")) ? (byte) 0 : (byte) -1;
            } else if (str.equals("normal")) {
                b10 = 2;
            }
        } else if (str.equals("italic")) {
            b10 = 1;
        }
        if (b10 != 0) {
            return b10 != 1 ? 0 : 2;
        }
        return 1;
    }

    /* JADX WARN: Failed to restore switch over string. Please report as a decompilation issue */
    private int qhl(String str) {
        str.getClass();
        byte b10 = -1;
        switch (str.hashCode()) {
            case -1364013995:
                if (str.equals("center")) {
                    b10 = 0;
                }
                break;
            case -348726240:
                if (str.equals("center_vertical")) {
                    b10 = 1;
                }
                break;
            case 3317767:
                if (str.equals("left")) {
                    b10 = 2;
                }
                break;
            case 108511772:
                if (str.equals("right")) {
                    b10 = 3;
                }
                break;
            case 1063616078:
                if (str.equals("center_horizontal")) {
                    b10 = 4;
                }
                break;
        }
        switch (b10) {
            case 0:
                return 17;
            case 1:
                return 16;
            case 2:
            default:
                return 3;
            case 3:
                return 5;
            case 4:
                return 1;
        }
    }

    private void yz() {
        ((fm) this.jnr).setLineSpacing(0.0f, this.ug);
    }

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

    public void onz(String str) {
        this.fm = str;
        if (TextUtils.isEmpty(str)) {
            return;
        }
        if (TextUtils.equals("null", str)) {
            this.fm = "";
        }
        ((fm) this.jnr).setText(this.fm);
    }

    @Override // com.bytedance.adsdk.ugeno.ro.lb
    public void ro() {
        super.ro();
        if (TextUtils.equals("null", this.fm)) {
            this.fm = "";
        }
        onz(this.fm);
        ((fm) this.jnr).setTextSize(1, this.ucr);
        ((fm) this.jnr).setTextColor(this.cyr);
        ((fm) this.jnr).setLines(this.ex);
        ((fm) this.jnr).setMaxLines(this.lsa);
        ((fm) this.jnr).setGravity(this.wjb);
        ((fm) this.jnr).setIncludeFontPadding(false);
        ((fm) this.jnr).setMinTextSize(wu.fm(this.ro, this.po));
        fm(this.ky);
        if (wbw()) {
            fm(this.f6330kc);
        } else {
            fm(this.oy);
        }
        if (this.ug > 0.0f) {
            if (wbw()) {
                ef();
            } else {
                yz();
            }
        }
        int i10 = Build.VERSION.SDK_INT;
        ((fm) this.jnr).setBreakStrategy(0);
        if (!wbw()) {
            ((fm) this.jnr).setShadowLayer(this.vj, this.rbn, this.pyj, this.f6329ff);
        } else if (this.f6331le) {
            if (this.vj <= 0.0f) {
                this.vj = 1.0E-5f;
            }
            ((fm) this.jnr).setShadowLayer(this.vj, this.xp, this.hou, this.f6329ff);
        }
        int i11 = this.vod;
        if (i11 == 1) {
            ((fm) this.jnr).setTypeface(Typeface.DEFAULT, i11);
        } else if (i10 >= 28) {
            ((fm) this.jnr).setTypeface(Typeface.create(Typeface.DEFAULT, (int) this.bp, i11 == 2));
        } else if (this.bp >= 500.0f) {
            ((fm) this.jnr).setTypeface(Typeface.DEFAULT, 1);
        }
        if (wu.fm(this.ro, this.ucr) > 0.0f) {
            ((fm) this.jnr).setLetterSpacing(this.zzm / wu.fm(this.ro, this.ucr));
        }
    }

    public void fm(int i10) {
        this.ky = i10;
        if (i10 == Integer.MAX_VALUE) {
            return;
        }
        ((fm) this.jnr).setPaintFlags(i10);
    }

    public void fm(TextUtils.TruncateAt truncateAt) {
        if (truncateAt == null) {
            return;
        }
        ((fm) this.jnr).setEllipsize(truncateAt);
    }

    @Override // com.bytedance.adsdk.ugeno.ro.lb
    public void fm(String str, String str2) {
        if (TextUtils.isEmpty(str)) {
        }
        super.fm(str, str2);
        str.getClass();
        switch (str) {
            case "shadowRadius":
            case "shadowBlur":
                this.vj = com.bytedance.adsdk.ugeno.wsy.lb.fm(str2, 0.0f);
                break;
            case "shadowColor":
                this.f6329ff = com.bytedance.adsdk.ugeno.wsy.fm.fm(str2);
                this.f6331le = true;
                break;
            case "shadowOffsetX":
                this.xp = wu.fm(this.ro, com.bytedance.adsdk.ugeno.wsy.lb.fm(str2, 0.0f));
                break;
            case "shadowOffsetY":
                this.hou = wu.fm(this.ro, com.bytedance.adsdk.ugeno.wsy.lb.fm(str2, 0.0f));
                break;
            case "textAlign":
                this.wjb = qhl(str2);
                break;
            case "textColor":
                this.cyr = com.bytedance.adsdk.ugeno.wsy.fm.fm(str2);
                break;
            case "textStyle":
                this.vod = irt(str2);
                break;
            case "textSize":
                this.ucr = com.bytedance.adsdk.ugeno.wsy.lb.fm(str2, 0.0f);
                break;
            case "textDecoration":
                this.ky = gof(str2);
                break;
            case "shadowDx":
                this.rbn = com.bytedance.adsdk.ugeno.wsy.lb.fm(str2, 0.0f);
                break;
            case "shadowDy":
                this.pyj = com.bytedance.adsdk.ugeno.wsy.lb.fm(str2, 0.0f);
                break;
            case "fontWeight":
                float fFm = com.bytedance.adsdk.ugeno.wsy.lb.fm(str2, -1.0f);
                this.bp = fFm;
                if (fFm < 1.0f || fFm > 1000.0f) {
                    this.bp = 400.0f;
                    break;
                }
                break;
            case "lineHeight":
                this.ug = com.bytedance.adsdk.ugeno.wsy.lb.fm(str2, 1.0f);
                break;
            case "text":
                this.fm = str2;
                break;
            case "lines":
                this.ex = com.bytedance.adsdk.ugeno.wsy.lb.fm(str2, 0);
                break;
            case "ellipsis":
                this.f6330kc = fhx(str2);
                break;
            case "minTextSize":
                this.po = com.bytedance.adsdk.ugeno.wsy.lb.fm(str2, -1.0f);
                break;
            case "maxLines":
                int iFm = com.bytedance.adsdk.ugeno.wsy.lb.fm(str2, Integer.MAX_VALUE);
                this.lsa = iFm > 0 ? iFm : Integer.MAX_VALUE;
                break;
            case "ellipsize":
                this.oy = dsz(str2);
                break;
            case "letterSpacing":
                this.zzm = wu.fm(this.ro, com.bytedance.adsdk.ugeno.wsy.lb.fm(str2, 0.0f));
                break;
        }
    }
}
