package p010d;

import android.content.Context;
import android.content.ContextWrapper;
import android.content.res.TypedArray;
import android.os.Build;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import p007c.C0494j;
import p022h.C0746d;
import p023h0.C0829h1;
import p028j.C1074c;
import p028j.C1091d3;
import p028j.C1092e;
import p028j.C1097f;
import p028j.C1100f2;
import p028j.C1102g;
import p028j.C1123k;
import p028j.C1145m0;
import p028j.C1159n0;
import p028j.C1163o;
import p028j.C1165o1;
import p028j.C1183q;
import p028j.C1184q0;
import p028j.C1188r;
import p028j.C1194s0;
import p037m.C1457g;

/* renamed from: d.z */
/* loaded from: classes.dex */
public class C0596z {

    /* renamed from: b */
    public static final Class<?>[] f2121b = {Context.class, AttributeSet.class};

    /* renamed from: c */
    public static final int[] f2122c = {16843375};

    /* renamed from: d */
    public static final int[] f2123d = {16844160};

    /* renamed from: e */
    public static final int[] f2124e = {16844156};

    /* renamed from: f */
    public static final int[] f2125f = {16844148};

    /* renamed from: g */
    public static final String[] f2126g = {"android.widget.", "android.view.", "android.webkit."};

    /* renamed from: h */
    public static final C1457g<String, Constructor<? extends View>> f2127h = new C1457g<>();

    /* renamed from: a */
    public final Object[] f2128a = new Object[2];

    /* renamed from: d.z$a */
    /* loaded from: classes.dex */
    public static class View$OnClickListenerC0597a implements View.OnClickListener {

        /* renamed from: d */
        public final View f2129d;

        /* renamed from: e */
        public final String f2130e;

        /* renamed from: f */
        public Method f2131f;

        /* renamed from: g */
        public Context f2132g;

        public View$OnClickListenerC0597a(View view, String str) {
            this.f2129d = view;
            this.f2130e = str;
        }

        /* renamed from: a */
        public final void m3292a(Context context) {
            int id;
            String str;
            Method method;
            while (context != null) {
                try {
                    if (!context.isRestricted() && (method = context.getClass().getMethod(this.f2130e, View.class)) != null) {
                        this.f2131f = method;
                        this.f2132g = context;
                        return;
                    }
                } catch (NoSuchMethodException unused) {
                }
                context = context instanceof ContextWrapper ? ((ContextWrapper) context).getBaseContext() : null;
            }
            if (this.f2129d.getId() == -1) {
                str = "";
            } else {
                str = " with id '" + this.f2129d.getContext().getResources().getResourceEntryName(id) + "'";
            }
            throw new IllegalStateException("Could not find method " + this.f2130e + "(View) in a parent or ancestor Context for android:onClick attribute defined on view " + this.f2129d.getClass() + str);
        }

        @Override // android.view.View.OnClickListener
        public void onClick(View view) {
            if (this.f2131f == null) {
                m3292a(this.f2129d.getContext());
            }
            try {
                this.f2131f.invoke(this.f2132g, view);
            } catch (IllegalAccessException e) {
                throw new IllegalStateException("Could not execute non-public method for android:onClick", e);
            } catch (InvocationTargetException e2) {
                throw new IllegalStateException("Could not execute method for android:onClick", e2);
            }
        }
    }

    /* renamed from: u */
    public static Context m3294u(Context context, AttributeSet attributeSet, boolean z, boolean z2) {
        TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, C0494j.f1910v3, 0, 0);
        int resourceId = z ? obtainStyledAttributes.getResourceId(C0494j.f1915w3, 0) : 0;
        if (z2 && resourceId == 0 && (resourceId = obtainStyledAttributes.getResourceId(C0494j.f1920x3, 0)) != 0) {
            Log.i("AppCompatViewInflater", "app:theme is now deprecated. Please move to using android:theme instead.");
        }
        obtainStyledAttributes.recycle();
        return resourceId != 0 ? ((context instanceof C0746d) && ((C0746d) context).m3014c() == resourceId) ? context : new C0746d(context, resourceId) : context;
    }

    /* renamed from: a */
    public final void m3314a(Context context, View view, AttributeSet attributeSet) {
        int i = Build.VERSION.SDK_INT;
        if (i < 19 || i > 28) {
            return;
        }
        TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, f2123d);
        if (obtainStyledAttributes.hasValue(0)) {
            C0829h1.m2847P(view, obtainStyledAttributes.getBoolean(0, false));
        }
        obtainStyledAttributes.recycle();
        TypedArray obtainStyledAttributes2 = context.obtainStyledAttributes(attributeSet, f2124e);
        if (obtainStyledAttributes2.hasValue(0)) {
            C0829h1.m2846Q(view, obtainStyledAttributes2.getString(0));
        }
        obtainStyledAttributes2.recycle();
        TypedArray obtainStyledAttributes3 = context.obtainStyledAttributes(attributeSet, f2125f);
        if (obtainStyledAttributes3.hasValue(0)) {
            C0829h1.m2839X(view, obtainStyledAttributes3.getBoolean(0, false));
        }
        obtainStyledAttributes3.recycle();
    }

    /* renamed from: b */
    public final void m3313b(View view, AttributeSet attributeSet) {
        Context context = view.getContext();
        if ((context instanceof ContextWrapper) && C0829h1.m2809y(view)) {
            TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, f2122c);
            String string = obtainStyledAttributes.getString(0);
            if (string != null) {
                view.setOnClickListener(new View$OnClickListenerC0597a(view, string));
            }
            obtainStyledAttributes.recycle();
        }
    }

    /* renamed from: c */
    public C1074c m3312c(Context context, AttributeSet attributeSet) {
        return new C1074c(context, attributeSet);
    }

    /* renamed from: d */
    public C1092e m3311d(Context context, AttributeSet attributeSet) {
        return new C1092e(context, attributeSet);
    }

    /* renamed from: e */
    public C1097f m3310e(Context context, AttributeSet attributeSet) {
        return new C1097f(context, attributeSet);
    }

    /* renamed from: f */
    public C1102g m3309f(Context context, AttributeSet attributeSet) {
        return new C1102g(context, attributeSet);
    }

    /* renamed from: g */
    public C1123k m3308g(Context context, AttributeSet attributeSet) {
        return new C1123k(context, attributeSet);
    }

    /* renamed from: h */
    public C1163o m3307h(Context context, AttributeSet attributeSet) {
        return new C1163o(context, attributeSet);
    }

    /* renamed from: i */
    public C1183q m3306i(Context context, AttributeSet attributeSet) {
        return new C1183q(context, attributeSet);
    }

    /* renamed from: j */
    public C1188r m3305j(Context context, AttributeSet attributeSet) {
        return new C1188r(context, attributeSet);
    }

    /* renamed from: k */
    public C1145m0 m3304k(Context context, AttributeSet attributeSet) {
        return new C1145m0(context, attributeSet);
    }

    /* renamed from: l */
    public C1159n0 m3303l(Context context, AttributeSet attributeSet) {
        return new C1159n0(context, attributeSet);
    }

    /* renamed from: m */
    public C1184q0 m3302m(Context context, AttributeSet attributeSet) {
        return new C1184q0(context, attributeSet);
    }

    /* renamed from: n */
    public C1194s0 m3301n(Context context, AttributeSet attributeSet) {
        return new C1194s0(context, attributeSet);
    }

    /* renamed from: o */
    public C1165o1 m3300o(Context context, AttributeSet attributeSet) {
        return new C1165o1(context, attributeSet);
    }

    /* renamed from: p */
    public C1100f2 m3299p(Context context, AttributeSet attributeSet) {
        return new C1100f2(context, attributeSet);
    }

    /* renamed from: q */
    public View m3298q(Context context, String str, AttributeSet attributeSet) {
        return null;
    }

    /* renamed from: r */
    public final View m3297r(View view, String str, Context context, AttributeSet attributeSet, boolean z, boolean z2, boolean z3, boolean z4) {
        View m3303l;
        Context context2 = (!z || view == null) ? context : view.getContext();
        if (z2 || z3) {
            context2 = m3294u(context2, attributeSet, z2, z3);
        }
        if (z4) {
            context2 = C1091d3.m2198b(context2);
        }
        str.hashCode();
        char c = '\uffff';
        switch (str.hashCode()) {
            case -1946472170:
                if (str.equals("RatingBar")) {
                    c = 0;
                    break;
                }
                break;
            case -1455429095:
                if (str.equals("CheckedTextView")) {
                    c = 1;
                    break;
                }
                break;
            case -1346021293:
                if (str.equals("MultiAutoCompleteTextView")) {
                    c = 2;
                    break;
                }
                break;
            case -938935918:
                if (str.equals("TextView")) {
                    c = 3;
                    break;
                }
                break;
            case -937446323:
                if (str.equals("ImageButton")) {
                    c = 4;
                    break;
                }
                break;
            case -658531749:
                if (str.equals("SeekBar")) {
                    c = 5;
                    break;
                }
                break;
            case -339785223:
                if (str.equals("Spinner")) {
                    c = 6;
                    break;
                }
                break;
            case 776382189:
                if (str.equals("RadioButton")) {
                    c = 7;
                    break;
                }
                break;
            case 799298502:
                if (str.equals("ToggleButton")) {
                    c = '\b';
                    break;
                }
                break;
            case 1125864064:
                if (str.equals("ImageView")) {
                    c = '\t';
                    break;
                }
                break;
            case 1413872058:
                if (str.equals("AutoCompleteTextView")) {
                    c = '\n';
                    break;
                }
                break;
            case 1601505219:
                if (str.equals("CheckBox")) {
                    c = 11;
                    break;
                }
                break;
            case 1666676343:
                if (str.equals("EditText")) {
                    c = '\f';
                    break;
                }
                break;
            case 2001146706:
                if (str.equals("Button")) {
                    c = '\r';
                    break;
                }
                break;
        }
        switch (c) {
            case 0:
                m3303l = m3303l(context2, attributeSet);
                m3293v(m3303l, str);
                break;
            case 1:
                m3303l = m3309f(context2, attributeSet);
                m3293v(m3303l, str);
                break;
            case 2:
                m3303l = m3305j(context2, attributeSet);
                m3293v(m3303l, str);
                break;
            case 3:
                m3303l = m3300o(context2, attributeSet);
                m3293v(m3303l, str);
                break;
            case 4:
                m3303l = m3307h(context2, attributeSet);
                m3293v(m3303l, str);
                break;
            case 5:
                m3303l = m3302m(context2, attributeSet);
                m3293v(m3303l, str);
                break;
            case 6:
                m3303l = m3301n(context2, attributeSet);
                m3293v(m3303l, str);
                break;
            case 7:
                m3303l = m3304k(context2, attributeSet);
                m3293v(m3303l, str);
                break;
            case '\b':
                m3303l = m3299p(context2, attributeSet);
                m3293v(m3303l, str);
                break;
            case '\t':
                m3303l = m3306i(context2, attributeSet);
                m3293v(m3303l, str);
                break;
            case '\n':
                m3303l = m3312c(context2, attributeSet);
                m3293v(m3303l, str);
                break;
            case 11:
                m3303l = m3310e(context2, attributeSet);
                m3293v(m3303l, str);
                break;
            case '\f':
                m3303l = m3308g(context2, attributeSet);
                m3293v(m3303l, str);
                break;
            case '\r':
                m3303l = m3311d(context2, attributeSet);
                m3293v(m3303l, str);
                break;
            default:
                m3303l = m3298q(context2, str, attributeSet);
                break;
        }
        if (m3303l == null && context != context2) {
            m3303l = m3295t(context2, str, attributeSet);
        }
        if (m3303l != null) {
            m3313b(m3303l, attributeSet);
            m3314a(context2, m3303l, attributeSet);
        }
        return m3303l;
    }

    /* renamed from: s */
    public final View m3296s(Context context, String str, String str2) {
        String str3;
        C1457g<String, Constructor<? extends View>> c1457g = f2127h;
        Constructor<? extends View> constructor = c1457g.get(str);
        if (constructor == null) {
            if (str2 != null) {
                try {
                    str3 = str2 + str;
                } catch (Exception unused) {
                    return null;
                }
            } else {
                str3 = str;
            }
            constructor = Class.forName(str3, false, context.getClassLoader()).asSubclass(View.class).getConstructor(f2121b);
            c1457g.put(str, constructor);
        }
        constructor.setAccessible(true);
        return constructor.newInstance(this.f2128a);
    }

    /* renamed from: t */
    public final View m3295t(Context context, String str, AttributeSet attributeSet) {
        if (str.equals("view")) {
            str = attributeSet.getAttributeValue(null, "class");
        }
        try {
            Object[] objArr = this.f2128a;
            objArr[0] = context;
            objArr[1] = attributeSet;
            if (-1 != str.indexOf(46)) {
                return m3296s(context, str, null);
            }
            int i = 0;
            while (true) {
                String[] strArr = f2126g;
                if (i >= strArr.length) {
                    return null;
                }
                View m3296s = m3296s(context, str, strArr[i]);
                if (m3296s != null) {
                    return m3296s;
                }
                i++;
            }
        } catch (Exception unused) {
            return null;
        } finally {
            Object[] objArr2 = this.f2128a;
            objArr2[0] = null;
            objArr2[1] = null;
        }
    }

    /* renamed from: v */
    public final void m3293v(View view, String str) {
        if (view != null) {
            return;
        }
        throw new IllegalStateException(getClass().getName() + " asked to inflate view for <" + str + ">, but returned null");
    }
}