package androidx.constraintlayout.widget;

import android.content.Context;
import android.content.res.TypedArray;
import android.content.res.XmlResourceParser;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.util.TypedValue;
import android.util.Xml;
import android.view.View;
import java.lang.reflect.Method;
import java.util.HashMap;

/* JADX INFO: loaded from: classes.dex */
public final class a {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public boolean f1300a = false;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public String f1301b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public ConstraintAttribute$AttributeType f1302c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public int f1303d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public float f1304e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public String f1305f;

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public boolean f1306g;

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public int f1307h;

    public a(a aVar, Object obj) {
        this.f1301b = aVar.f1301b;
        this.f1302c = aVar.f1302c;
        f(obj);
    }

    public static void d(Context context, XmlResourceParser xmlResourceParser, HashMap map) {
        ConstraintAttribute$AttributeType constraintAttribute$AttributeType;
        Object objValueOf;
        TypedArray typedArrayObtainStyledAttributes = context.obtainStyledAttributes(Xml.asAttributeSet(xmlResourceParser), s.CustomAttribute);
        int indexCount = typedArrayObtainStyledAttributes.getIndexCount();
        String string = null;
        Object objValueOf2 = null;
        ConstraintAttribute$AttributeType constraintAttribute$AttributeType2 = null;
        boolean z10 = false;
        for (int i10 = 0; i10 < indexCount; i10++) {
            int index = typedArrayObtainStyledAttributes.getIndex(i10);
            if (index == s.CustomAttribute_attributeName) {
                string = typedArrayObtainStyledAttributes.getString(index);
                if (string != null && string.length() > 0) {
                    string = Character.toUpperCase(string.charAt(0)) + string.substring(1);
                }
            } else if (index == s.CustomAttribute_methodName) {
                string = typedArrayObtainStyledAttributes.getString(index);
                z10 = true;
            } else if (index == s.CustomAttribute_customBoolean) {
                objValueOf2 = Boolean.valueOf(typedArrayObtainStyledAttributes.getBoolean(index, false));
                constraintAttribute$AttributeType2 = ConstraintAttribute$AttributeType.f1263f;
            } else {
                if (index == s.CustomAttribute_customColorValue) {
                    constraintAttribute$AttributeType = ConstraintAttribute$AttributeType.f1260c;
                    objValueOf = Integer.valueOf(typedArrayObtainStyledAttributes.getColor(index, 0));
                } else if (index == s.CustomAttribute_customColorDrawableValue) {
                    constraintAttribute$AttributeType = ConstraintAttribute$AttributeType.f1261d;
                    objValueOf = Integer.valueOf(typedArrayObtainStyledAttributes.getColor(index, 0));
                } else {
                    int i11 = s.CustomAttribute_customPixelDimension;
                    ConstraintAttribute$AttributeType constraintAttribute$AttributeType3 = ConstraintAttribute$AttributeType.f1264g;
                    if (index == i11) {
                        objValueOf2 = Float.valueOf(TypedValue.applyDimension(1, typedArrayObtainStyledAttributes.getDimension(index, 0.0f), context.getResources().getDisplayMetrics()));
                    } else if (index == s.CustomAttribute_customDimension) {
                        objValueOf2 = Float.valueOf(typedArrayObtainStyledAttributes.getDimension(index, 0.0f));
                    } else if (index == s.CustomAttribute_customFloatValue) {
                        constraintAttribute$AttributeType = ConstraintAttribute$AttributeType.f1259b;
                        objValueOf = Float.valueOf(typedArrayObtainStyledAttributes.getFloat(index, Float.NaN));
                    } else if (index == s.CustomAttribute_customIntegerValue) {
                        constraintAttribute$AttributeType = ConstraintAttribute$AttributeType.f1258a;
                        objValueOf = Integer.valueOf(typedArrayObtainStyledAttributes.getInteger(index, -1));
                    } else if (index == s.CustomAttribute_customStringValue) {
                        constraintAttribute$AttributeType = ConstraintAttribute$AttributeType.f1262e;
                        objValueOf = typedArrayObtainStyledAttributes.getString(index);
                    } else if (index == s.CustomAttribute_customReference) {
                        constraintAttribute$AttributeType = ConstraintAttribute$AttributeType.f1265h;
                        int resourceId = typedArrayObtainStyledAttributes.getResourceId(index, -1);
                        if (resourceId == -1) {
                            resourceId = typedArrayObtainStyledAttributes.getInt(index, -1);
                        }
                        objValueOf = Integer.valueOf(resourceId);
                    }
                    constraintAttribute$AttributeType2 = constraintAttribute$AttributeType3;
                }
                Object obj = objValueOf;
                constraintAttribute$AttributeType2 = constraintAttribute$AttributeType;
                objValueOf2 = obj;
            }
        }
        if (string != null && objValueOf2 != null) {
            a aVar = new a();
            aVar.f1301b = string;
            aVar.f1302c = constraintAttribute$AttributeType2;
            aVar.f1300a = z10;
            aVar.f(objValueOf2);
            map.put(string, aVar);
        }
        typedArrayObtainStyledAttributes.recycle();
    }

    public static void e(View view, HashMap map) {
        Class<?> cls = view.getClass();
        for (String strI : map.keySet()) {
            a aVar = (a) map.get(strI);
            if (!aVar.f1300a) {
                strI = defpackage.e.i("set", strI);
            }
            switch (aVar.f1302c.ordinal()) {
                case 0:
                    cls.getMethod(strI, Integer.TYPE).invoke(view, Integer.valueOf(aVar.f1303d));
                    continue;
                case 1:
                    cls.getMethod(strI, Float.TYPE).invoke(view, Float.valueOf(aVar.f1304e));
                    continue;
                case 2:
                    cls.getMethod(strI, Integer.TYPE).invoke(view, Integer.valueOf(aVar.f1307h));
                    continue;
                case 3:
                    Method method = cls.getMethod(strI, Drawable.class);
                    ColorDrawable colorDrawable = new ColorDrawable();
                    colorDrawable.setColor(aVar.f1307h);
                    method.invoke(view, colorDrawable);
                    continue;
                case 4:
                    cls.getMethod(strI, CharSequence.class).invoke(view, aVar.f1305f);
                    continue;
                case 5:
                    cls.getMethod(strI, Boolean.TYPE).invoke(view, Boolean.valueOf(aVar.f1306g));
                    continue;
                case 6:
                    cls.getMethod(strI, Float.TYPE).invoke(view, Float.valueOf(aVar.f1304e));
                    continue;
                case 7:
                    cls.getMethod(strI, Integer.TYPE).invoke(view, Integer.valueOf(aVar.f1303d));
                    continue;
                default:
                    continue;
            }
        }
    }

    public final float a() {
        switch (this.f1302c.ordinal()) {
            case 0:
                return this.f1303d;
            case 1:
            case 6:
                return this.f1304e;
            case 2:
            case 3:
                throw new RuntimeException("Color does not have a single color to interpolate");
            case 4:
                throw new RuntimeException("Cannot interpolate String");
            case 5:
                return this.f1306g ? 1.0f : 0.0f;
            default:
                return Float.NaN;
        }
    }

    public final void b(float[] fArr) {
        switch (this.f1302c.ordinal()) {
            case 0:
                fArr[0] = this.f1303d;
                return;
            case 1:
                fArr[0] = this.f1304e;
                return;
            case 2:
            case 3:
                int i10 = (this.f1307h >> 24) & 255;
                float fPow = (float) Math.pow(((r0 >> 16) & 255) / 255.0f, 2.2d);
                float fPow2 = (float) Math.pow(((r0 >> 8) & 255) / 255.0f, 2.2d);
                float fPow3 = (float) Math.pow((r0 & 255) / 255.0f, 2.2d);
                fArr[0] = fPow;
                fArr[1] = fPow2;
                fArr[2] = fPow3;
                fArr[3] = i10 / 255.0f;
                return;
            case 4:
                throw new RuntimeException("Color does not have a single color to interpolate");
            case 5:
                fArr[0] = this.f1306g ? 1.0f : 0.0f;
                return;
            case 6:
                fArr[0] = this.f1304e;
                return;
            default:
                return;
        }
    }

    public final int c() {
        int iOrdinal = this.f1302c.ordinal();
        return (iOrdinal == 2 || iOrdinal == 3) ? 4 : 1;
    }

    public final void f(Object obj) {
        switch (this.f1302c.ordinal()) {
            case 0:
            case 7:
                this.f1303d = ((Integer) obj).intValue();
                break;
            case 1:
                this.f1304e = ((Float) obj).floatValue();
                break;
            case 2:
            case 3:
                this.f1307h = ((Integer) obj).intValue();
                break;
            case 4:
                this.f1305f = (String) obj;
                break;
            case 5:
                this.f1306g = ((Boolean) obj).booleanValue();
                break;
            case 6:
                this.f1304e = ((Float) obj).floatValue();
                break;
        }
    }
}
