package com.a.b.b;

import X.3GT;
import X.AnonymousClass0HG;
import X.M12;
import android.content.Context;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.widget.Toast;
import com.a.b.a.a;
import com.bytedance.covode.number.Covode;
import kotlin.h.b.n;
import kotlin.o.y;
import kotlin.o.z;

public final class a {
    static {
        Covode.recordClassIndex(1925);
    }

    public static void LIZ(Toast toast) {
        if (Build.VERSION.SDK_INT == 25) {
            3GT.LIZ(toast);
        }
        toast.show();
    }

    public static final String LIZ(String str) {
        M12.LIZ(str);
        int LIZ = z.LIZ(str, ":");
        if (LIZ == -1) {
            return str;
        }
        String substring = str.substring(LIZ + 1);
        n.LIZ(substring, "");
        return substring;
    }

    public static final boolean LIZ(com.a.b.a.a aVar) {
        M12.LIZ(aVar);
        if (aVar instanceof a.c) {
            String str = aVar.LIZ;
            n.LIZ(str, "");
            return Boolean.parseBoolean(str);
        }
        throw new IllegalArgumentException("getBoolean:Drawable unsupported ParamsType type: " + aVar.LIZ);
    }

    public static final int LIZIZ(Context context, com.a.b.a.a aVar) {
        M12.LIZ(context, aVar);
        if (aVar instanceof a.b) {
            a.b bVar = (a.b) aVar;
            if (n.LIZ(bVar.LIZIZ, "drawable") || n.LIZ(bVar.LIZIZ, "color")) {
                String str = aVar.LIZ;
                n.LIZ(str, "");
                return Integer.parseInt(str);
            }
        }
        throw new IllegalArgumentException("getDrawableId:Int unsupported ParamsType type: " + aVar.LIZ);
    }

    public static final Drawable LIZJ(Context context, com.a.b.a.a aVar) {
        M12.LIZ(context, aVar);
        if (aVar instanceof a.b) {
            a.b bVar = (a.b) aVar;
            if (n.LIZ(bVar.LIZIZ, "drawable") || n.LIZ(bVar.LIZIZ, "color")) {
                Resources resources = context.getResources();
                String str = aVar.LIZ;
                n.LIZ(str, "");
                Drawable drawable = resources.getDrawable(Integer.parseInt(str));
                n.LIZ(drawable, "");
                return drawable;
            }
        }
        throw new IllegalArgumentException("getDrawable:Drawable unsupported ParamsType type: " + aVar.LIZ);
    }

    /* JADX WARNING: Code restructure failed: missing block: B:19:0x0052, code lost:
        if (r2.equals("dip") != false) goto L_0x0054;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:23:0x0074, code lost:
        if (r2.equals("dp") != false) goto L_0x0054;
     */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    public static final float LIZ(android.content.Context r5, com.a.b.a.a r6) {
        /*
            X.M12.LIZ(r5, r6)
            boolean r0 = r6 instanceof com.a.b.a.a.b
            java.lang.String r3 = ""
            if (r0 == 0) goto L_0x002c
            r0 = r6
            com.a.b.a.a$b r0 = (com.a.b.a.a.b) r0
            java.lang.String r1 = r0.LIZIZ
            java.lang.String r0 = "dimen"
            boolean r0 = kotlin.h.b.n.LIZ(r1, r0)
            if (r0 == 0) goto L_0x002c
            android.content.res.Resources r1 = r5.getResources()
            java.lang.String r0 = r6.LIZ
            java.lang.Integer r0 = java.lang.Integer.valueOf(r0)
            kotlin.h.b.n.LIZ(r0, r3)
            int r0 = r0.intValue()
            float r0 = r1.getDimension(r0)
            return r0
        L_0x002c:
            boolean r0 = r6 instanceof com.a.b.a.a.d
            if (r0 == 0) goto L_0x00d1
            r4 = r6
            com.a.b.a.a$d r4 = (com.a.b.a.a.d) r4
            java.lang.String r2 = r4.LIZIZ
            if (r2 == 0) goto L_0x00bb
            int r1 = r2.hashCode()
            r0 = 3212(0xc8c, float:4.501E-42)
            if (r1 == r0) goto L_0x006e
            r0 = 3592(0xe08, float:5.033E-42)
            if (r1 == r0) goto L_0x0099
            r0 = 3677(0xe5d, float:5.153E-42)
            if (r1 == r0) goto L_0x0077
            r0 = 99467(0x1848b, float:1.39383E-40)
            if (r1 != r0) goto L_0x00bb
            java.lang.String r0 = "dip"
            boolean r0 = r2.equals(r0)
            if (r0 == 0) goto L_0x00bb
        L_0x0054:
            java.lang.String r0 = r6.LIZ
            kotlin.h.b.n.LIZ(r0, r3)
            float r2 = java.lang.Float.parseFloat(r0)
            r1 = 1
            android.content.res.Resources r0 = r5.getResources()
            kotlin.h.b.n.LIZ(r0, r3)
            android.util.DisplayMetrics r0 = r0.getDisplayMetrics()
            float r0 = android.util.TypedValue.applyDimension(r1, r2, r0)
            return r0
        L_0x006e:
            java.lang.String r0 = "dp"
            boolean r0 = r2.equals(r0)
            if (r0 == 0) goto L_0x00bb
            goto L_0x0054
        L_0x0077:
            java.lang.String r0 = "sp"
            boolean r0 = r2.equals(r0)
            if (r0 == 0) goto L_0x00bb
            java.lang.String r0 = r6.LIZ
            kotlin.h.b.n.LIZ(r0, r3)
            float r2 = java.lang.Float.parseFloat(r0)
            r1 = 2
            android.content.res.Resources r0 = r5.getResources()
            kotlin.h.b.n.LIZ(r0, r3)
            android.util.DisplayMetrics r0 = r0.getDisplayMetrics()
            float r0 = android.util.TypedValue.applyDimension(r1, r2, r0)
            return r0
        L_0x0099:
            java.lang.String r0 = "px"
            boolean r0 = r2.equals(r0)
            if (r0 == 0) goto L_0x00bb
            java.lang.String r0 = r6.LIZ
            kotlin.h.b.n.LIZ(r0, r3)
            float r2 = java.lang.Float.parseFloat(r0)
            r1 = 0
            android.content.res.Resources r0 = r5.getResources()
            kotlin.h.b.n.LIZ(r0, r3)
            android.util.DisplayMetrics r0 = r0.getDisplayMetrics()
            float r0 = android.util.TypedValue.applyDimension(r1, r2, r0)
            return r0
        L_0x00bb:
            java.lang.IllegalArgumentException r2 = new java.lang.IllegalArgumentException
            java.lang.StringBuilder r1 = new java.lang.StringBuilder
            java.lang.String r0 = "getDimen:Float unsupported dimen type: "
            r1.<init>(r0)
            java.lang.String r0 = r4.LIZIZ
            r1.append(r0)
            java.lang.String r0 = r1.toString()
            r2.<init>(r0)
            throw r2
        L_0x00d1:
            java.lang.IllegalArgumentException r2 = new java.lang.IllegalArgumentException
            java.lang.StringBuilder r1 = new java.lang.StringBuilder
            java.lang.String r0 = "unsupported ParamsType type: "
            r1.<init>(r0)
            java.lang.String r0 = r6.LIZ
            r1.append(r0)
            java.lang.String r0 = r1.toString()
            r2.<init>(r0)
            throw r2
        */
        throw new UnsupportedOperationException("Method not decompiled: com.a.b.b.a.LIZ(android.content.Context, com.a.b.a.a):float");
    }

    public static final int LIZLLL(Context context, com.a.b.a.a aVar) {
        M12.LIZ(context, aVar);
        if (aVar instanceof a.c) {
            String str = aVar.LIZ;
            n.LIZ(str, "");
            if (y.LIZIZ(str, "#", false)) {
                if (aVar.LIZ.length() >= 7) {
                    return Color.parseColor(aVar.LIZ);
                }
                throw new IllegalArgumentException("color format must be like #FF0000 current is " + aVar.LIZ);
            }
        }
        if (aVar instanceof a.b) {
            a.b bVar = (a.b) aVar;
            if (bVar.LIZIZ.equals("color")) {
                Resources resources = context.getResources();
                String str2 = aVar.LIZ;
                n.LIZ(str2, "");
                return resources.getColor(Integer.parseInt(str2));
            }
            String str3 = bVar.LIZIZ;
            n.LIZ(str3, "");
            if (y.LIZIZ(str3, "attr", false)) {
                String str4 = aVar.LIZ;
                n.LIZ(str4, "");
                TypedArray obtainStyledAttributes = context.getTheme().obtainStyledAttributes(new int[]{Integer.parseInt(str4)});
                int color = obtainStyledAttributes.getColor(0, 0);
                obtainStyledAttributes.recycle();
                return color;
            }
        }
        throw new IllegalArgumentException("getColor:Drawable unsupported ParamsType type: " + aVar.LIZ);
    }

    public static final boolean LIZ(Context context, String str, String str2) {
        M12.LIZ(str, str2);
        String str3 = str + " unsupported attr: " + str2;
        if (AnonymousClass0HG.LIZ) {
            LIZ(Toast.makeText(context, str3, 1));
        }
        throw new IllegalArgumentException(str3);
    }
}
