package androidx.constraintlayout.widget;

import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.util.Log;
import android.util.TypedValue;
import android.util.Xml;
import android.view.View;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.HashMap;
import org.xmlpull.v1.XmlPullParser;
import p061u.C1743h;

/* renamed from: androidx.constraintlayout.widget.b */
/* loaded from: classes.dex */
public class C0188b {

    /* renamed from: a */
    public boolean f830a;

    /* renamed from: b */
    public String f831b;

    /* renamed from: c */
    public EnumC0190b f832c;

    /* renamed from: d */
    public int f833d;

    /* renamed from: e */
    public float f834e;

    /* renamed from: f */
    public String f835f;

    /* renamed from: g */
    public boolean f836g;

    /* renamed from: h */
    public int f837h;

    /* renamed from: androidx.constraintlayout.widget.b$a */
    /* loaded from: classes.dex */
    public static /* synthetic */ class C0189a {

        /* renamed from: a */
        public static final /* synthetic */ int[] f838a;

        static {
            int[] iArr = new int[EnumC0190b.values().length];
            f838a = iArr;
            try {
                iArr[EnumC0190b.REFERENCE_TYPE.ordinal()] = 1;
            } catch (NoSuchFieldError unused) {
            }
            try {
                f838a[EnumC0190b.BOOLEAN_TYPE.ordinal()] = 2;
            } catch (NoSuchFieldError unused2) {
            }
            try {
                f838a[EnumC0190b.STRING_TYPE.ordinal()] = 3;
            } catch (NoSuchFieldError unused3) {
            }
            try {
                f838a[EnumC0190b.COLOR_TYPE.ordinal()] = 4;
            } catch (NoSuchFieldError unused4) {
            }
            try {
                f838a[EnumC0190b.COLOR_DRAWABLE_TYPE.ordinal()] = 5;
            } catch (NoSuchFieldError unused5) {
            }
            try {
                f838a[EnumC0190b.INT_TYPE.ordinal()] = 6;
            } catch (NoSuchFieldError unused6) {
            }
            try {
                f838a[EnumC0190b.FLOAT_TYPE.ordinal()] = 7;
            } catch (NoSuchFieldError unused7) {
            }
            try {
                f838a[EnumC0190b.DIMENSION_TYPE.ordinal()] = 8;
            } catch (NoSuchFieldError unused8) {
            }
        }
    }

    /* renamed from: androidx.constraintlayout.widget.b$b */
    /* loaded from: classes.dex */
    public enum EnumC0190b {
        INT_TYPE,
        FLOAT_TYPE,
        COLOR_TYPE,
        COLOR_DRAWABLE_TYPE,
        STRING_TYPE,
        BOOLEAN_TYPE,
        DIMENSION_TYPE,
        REFERENCE_TYPE
    }

    public C0188b(C0188b c0188b, Object obj) {
        this.f830a = false;
        this.f831b = c0188b.f831b;
        this.f832c = c0188b.f832c;
        m4556f(obj);
    }

    public C0188b(String str, EnumC0190b enumC0190b, Object obj, boolean z) {
        this.f831b = str;
        this.f832c = enumC0190b;
        this.f830a = z;
        m4556f(obj);
    }

    /* renamed from: a */
    public static HashMap<String, C0188b> m4561a(HashMap<String, C0188b> hashMap, View view) {
        HashMap<String, C0188b> hashMap2 = new HashMap<>();
        Class<?> cls = view.getClass();
        for (String str : hashMap.keySet()) {
            C0188b c0188b = hashMap.get(str);
            try {
                hashMap2.put(str, str.equals("BackgroundColor") ? new C0188b(c0188b, Integer.valueOf(((ColorDrawable) view.getBackground()).getColor())) : new C0188b(c0188b, cls.getMethod("getMap" + str, new Class[0]).invoke(view, new Object[0])));
            } catch (IllegalAccessException | NoSuchMethodException | InvocationTargetException e) {
                e.printStackTrace();
            }
        }
        return hashMap2;
    }

    /* renamed from: d */
    public static void m4558d(Context context, XmlPullParser xmlPullParser, HashMap<String, C0188b> hashMap) {
        EnumC0190b enumC0190b;
        int resourceId;
        Object string;
        float f;
        TypedArray obtainStyledAttributes = context.obtainStyledAttributes(Xml.asAttributeSet(xmlPullParser), C1743h.f4405y4);
        int indexCount = obtainStyledAttributes.getIndexCount();
        String str = null;
        Object obj = null;
        EnumC0190b enumC0190b2 = null;
        boolean z = false;
        for (int i = 0; i < indexCount; i++) {
            int index = obtainStyledAttributes.getIndex(i);
            if (index == C1743h.f4414z4) {
                str = obtainStyledAttributes.getString(index);
                if (str != null && str.length() > 0) {
                    str = Character.toUpperCase(str.charAt(0)) + str.substring(1);
                }
            } else if (index == C1743h.f4053J4) {
                str = obtainStyledAttributes.getString(index);
                z = true;
            } else if (index == C1743h.f3978A4) {
                obj = Boolean.valueOf(obtainStyledAttributes.getBoolean(index, false));
                enumC0190b2 = EnumC0190b.BOOLEAN_TYPE;
            } else {
                if (index == C1743h.f3996C4) {
                    enumC0190b = EnumC0190b.COLOR_TYPE;
                } else if (index == C1743h.f3987B4) {
                    enumC0190b = EnumC0190b.COLOR_DRAWABLE_TYPE;
                } else {
                    if (index == C1743h.f4029G4) {
                        enumC0190b = EnumC0190b.DIMENSION_TYPE;
                        f = TypedValue.applyDimension(1, obtainStyledAttributes.getDimension(index, 0.0f), context.getResources().getDisplayMetrics());
                    } else if (index == C1743h.f4005D4) {
                        enumC0190b = EnumC0190b.DIMENSION_TYPE;
                        f = obtainStyledAttributes.getDimension(index, 0.0f);
                    } else if (index == C1743h.f4013E4) {
                        enumC0190b = EnumC0190b.FLOAT_TYPE;
                        f = obtainStyledAttributes.getFloat(index, Float.NaN);
                    } else {
                        if (index == C1743h.f4021F4) {
                            enumC0190b = EnumC0190b.INT_TYPE;
                            resourceId = obtainStyledAttributes.getInteger(index, -1);
                        } else if (index == C1743h.f4045I4) {
                            enumC0190b = EnumC0190b.STRING_TYPE;
                            string = obtainStyledAttributes.getString(index);
                            Object obj2 = string;
                            enumC0190b2 = enumC0190b;
                            obj = obj2;
                        } else if (index == C1743h.f4037H4) {
                            enumC0190b = EnumC0190b.REFERENCE_TYPE;
                            resourceId = obtainStyledAttributes.getResourceId(index, -1);
                            if (resourceId == -1) {
                                resourceId = obtainStyledAttributes.getInt(index, -1);
                            }
                        }
                        string = Integer.valueOf(resourceId);
                        Object obj22 = string;
                        enumC0190b2 = enumC0190b;
                        obj = obj22;
                    }
                    string = Float.valueOf(f);
                    Object obj222 = string;
                    enumC0190b2 = enumC0190b;
                    obj = obj222;
                }
                resourceId = obtainStyledAttributes.getColor(index, 0);
                string = Integer.valueOf(resourceId);
                Object obj2222 = string;
                enumC0190b2 = enumC0190b;
                obj = obj2222;
            }
        }
        if (str != null && obj != null) {
            hashMap.put(str, new C0188b(str, enumC0190b2, obj, z));
        }
        obtainStyledAttributes.recycle();
    }

    /* renamed from: e */
    public static void m4557e(View view, HashMap<String, C0188b> hashMap) {
        StringBuilder sb;
        Class<?> cls = view.getClass();
        for (String str : hashMap.keySet()) {
            C0188b c0188b = hashMap.get(str);
            String str2 = c0188b.f830a ? str : "set" + str;
            try {
            } catch (IllegalAccessException e) {
                e = e;
                sb = new StringBuilder();
                sb.append(" Custom Attribute \"");
                sb.append(str);
                sb.append("\" not found on ");
                sb.append(cls.getName());
                Log.e("TransitionLayout", sb.toString());
                e.printStackTrace();
            } catch (NoSuchMethodException e2) {
                Log.e("TransitionLayout", e2.getMessage());
                Log.e("TransitionLayout", " Custom Attribute \"" + str + "\" not found on " + cls.getName());
                StringBuilder sb2 = new StringBuilder();
                sb2.append(cls.getName());
                sb2.append(" must have a method ");
                sb2.append(str2);
                Log.e("TransitionLayout", sb2.toString());
            } catch (InvocationTargetException e3) {
                e = e3;
                sb = new StringBuilder();
                sb.append(" Custom Attribute \"");
                sb.append(str);
                sb.append("\" not found on ");
                sb.append(cls.getName());
                Log.e("TransitionLayout", sb.toString());
                e.printStackTrace();
            }
            switch (C0189a.f838a[c0188b.f832c.ordinal()]) {
                case 1:
                    cls.getMethod(str2, Integer.TYPE).invoke(view, Integer.valueOf(c0188b.f833d));
                    continue;
                case 2:
                    cls.getMethod(str2, Boolean.TYPE).invoke(view, Boolean.valueOf(c0188b.f836g));
                    continue;
                case 3:
                    cls.getMethod(str2, CharSequence.class).invoke(view, c0188b.f835f);
                    continue;
                case 4:
                    cls.getMethod(str2, Integer.TYPE).invoke(view, Integer.valueOf(c0188b.f837h));
                    continue;
                case 5:
                    Method method = cls.getMethod(str2, Drawable.class);
                    ColorDrawable colorDrawable = new ColorDrawable();
                    colorDrawable.setColor(c0188b.f837h);
                    method.invoke(view, colorDrawable);
                    continue;
                case 6:
                    cls.getMethod(str2, Integer.TYPE).invoke(view, Integer.valueOf(c0188b.f833d));
                    continue;
                case 7:
                    cls.getMethod(str2, Float.TYPE).invoke(view, Float.valueOf(c0188b.f834e));
                    continue;
                case 8:
                    cls.getMethod(str2, Float.TYPE).invoke(view, Float.valueOf(c0188b.f834e));
                    continue;
                default:
                    continue;
            }
            Log.e("TransitionLayout", e2.getMessage());
            Log.e("TransitionLayout", " Custom Attribute \"" + str + "\" not found on " + cls.getName());
            StringBuilder sb22 = new StringBuilder();
            sb22.append(cls.getName());
            sb22.append(" must have a method ");
            sb22.append(str2);
            Log.e("TransitionLayout", sb22.toString());
        }
    }

    /* renamed from: b */
    public String m4560b() {
        return this.f831b;
    }

    /* renamed from: c */
    public EnumC0190b m4559c() {
        return this.f832c;
    }

    /* renamed from: f */
    public void m4556f(Object obj) {
        switch (C0189a.f838a[this.f832c.ordinal()]) {
            case 1:
            case 6:
                this.f833d = ((Integer) obj).intValue();
                return;
            case 2:
                this.f836g = ((Boolean) obj).booleanValue();
                return;
            case 3:
                this.f835f = (String) obj;
                return;
            case 4:
            case 5:
                this.f837h = ((Integer) obj).intValue();
                return;
            case 7:
            case 8:
                this.f834e = ((Float) obj).floatValue();
                return;
            default:
                return;
        }
    }
}