package androidx.appcompat.app;

import android.R;
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.InflateException;
import android.view.View;
import androidx.appcompat.widget.m;
import androidx.appcompat.widget.p;
import androidx.appcompat.widget.q0;
import androidx.appcompat.widget.s;
import androidx.appcompat.widget.t;
import androidx.appcompat.widget.u;
import androidx.appcompat.widget.w;
import androidx.appcompat.widget.y;
import com.seewo.sdk.model.SDKKeyboardCode;
import g.e.j.o;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Map;
import okhttp3.HttpUrl;

/* JADX INFO: loaded from: classes.dex */
public class AppCompatViewInflater {
    private static final Class<?>[] b = {Context.class, AttributeSet.class};
    private static final int[] c = {R.attr.onClick};
    private static final String[] d = {"android.widget.", "android.view.", "android.webkit."};
    private static final Map<String, Constructor<? extends View>> e = new g.c.a();
    private final Object[] a = new Object[2];

    private static class a implements View.OnClickListener {
        private final View b;
        private final String d;
        private Method e;
        private Context f;

        public a(View view, String str) {
            this.b = view;
            this.d = str;
        }

        private void a(Context context, String str) {
            String str2;
            Method method;
            while (context != null) {
                try {
                    if (!context.isRestricted() && (method = context.getClass().getMethod(this.d, View.class)) != null) {
                        this.e = method;
                        this.f = context;
                        return;
                    }
                } catch (NoSuchMethodException unused) {
                }
                context = context instanceof ContextWrapper ? ((ContextWrapper) context).getBaseContext() : null;
            }
            int id = this.b.getId();
            if (id == -1) {
                str2 = HttpUrl.FRAGMENT_ENCODE_SET;
            } else {
                str2 = " with id '" + this.b.getContext().getResources().getResourceEntryName(id) + "'";
            }
            throw new IllegalStateException("Could not find method " + this.d + "(View) in a parent or ancestor Context for android:onClick attribute defined on view " + this.b.getClass() + str2);
        }

        @Override // android.view.View.OnClickListener
        public void onClick(View view) {
            if (this.e == null) {
                a(this.b.getContext(), this.d);
            }
            try {
                this.e.invoke(this.f, 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);
            }
        }
    }

    private void a(View view, AttributeSet attributeSet) {
        Context context = view.getContext();
        if (context instanceof ContextWrapper) {
            if (Build.VERSION.SDK_INT < 15 || o.j(view)) {
                TypedArray typedArrayObtainStyledAttributes = context.obtainStyledAttributes(attributeSet, c);
                String string = typedArrayObtainStyledAttributes.getString(0);
                if (string != null) {
                    view.setOnClickListener(new a(view, string));
                }
                typedArrayObtainStyledAttributes.recycle();
            }
        }
    }

    private View q(Context context, String str, String str2) throws InflateException, ClassNotFoundException {
        String str3;
        Constructor<? extends View> constructor = e.get(str);
        if (constructor == null) {
            try {
                ClassLoader classLoader = context.getClassLoader();
                if (str2 != null) {
                    str3 = str2 + str;
                } else {
                    str3 = str;
                }
                constructor = classLoader.loadClass(str3).asSubclass(View.class).getConstructor(b);
                e.put(str, constructor);
            } catch (Exception unused) {
                return null;
            }
        }
        constructor.setAccessible(true);
        return constructor.newInstance(this.a);
    }

    private View r(Context context, String str, AttributeSet attributeSet) {
        if (str.equals("view")) {
            str = attributeSet.getAttributeValue(null, "class");
        }
        try {
            this.a[0] = context;
            this.a[1] = attributeSet;
            if (-1 != str.indexOf(46)) {
                return q(context, str, null);
            }
            for (int i2 = 0; i2 < d.length; i2++) {
                View viewQ = q(context, str, d[i2]);
                if (viewQ != null) {
                    return viewQ;
                }
            }
            return null;
        } catch (Exception unused) {
            return null;
        } finally {
            Object[] objArr = this.a;
            objArr[0] = null;
            objArr[1] = null;
        }
    }

    private static Context s(Context context, AttributeSet attributeSet, boolean z, boolean z2) {
        TypedArray typedArrayObtainStyledAttributes = context.obtainStyledAttributes(attributeSet, g.a.j.View, 0, 0);
        int resourceId = z ? typedArrayObtainStyledAttributes.getResourceId(g.a.j.View_android_theme, 0) : 0;
        if (z2 && resourceId == 0 && (resourceId = typedArrayObtainStyledAttributes.getResourceId(g.a.j.View_theme, 0)) != 0) {
            Log.i("AppCompatViewInflater", "app:theme is now deprecated. Please move to using android:theme instead.");
        }
        typedArrayObtainStyledAttributes.recycle();
        return resourceId != 0 ? ((context instanceof g.a.m.d) && ((g.a.m.d) context).b() == resourceId) ? context : new g.a.m.d(context, resourceId) : context;
    }

    private void t(View view, String str) {
        if (view != null) {
            return;
        }
        throw new IllegalStateException(AppCompatViewInflater.class.getName() + " asked to inflate view for <" + str + ">, but returned null");
    }

    protected androidx.appcompat.widget.d b(Context context, AttributeSet attributeSet) {
        return new androidx.appcompat.widget.d(context, attributeSet);
    }

    protected androidx.appcompat.widget.f c(Context context, AttributeSet attributeSet) {
        return new androidx.appcompat.widget.f(context, attributeSet);
    }

    protected androidx.appcompat.widget.g d(Context context, AttributeSet attributeSet) {
        return new androidx.appcompat.widget.g(context, attributeSet);
    }

    protected androidx.appcompat.widget.h e(Context context, AttributeSet attributeSet) {
        return new androidx.appcompat.widget.h(context, attributeSet);
    }

    protected androidx.appcompat.widget.k f(Context context, AttributeSet attributeSet) {
        return new androidx.appcompat.widget.k(context, attributeSet);
    }

    protected m g(Context context, AttributeSet attributeSet) {
        return new m(context, attributeSet);
    }

    protected androidx.appcompat.widget.o h(Context context, AttributeSet attributeSet) {
        return new androidx.appcompat.widget.o(context, attributeSet);
    }

    protected p i(Context context, AttributeSet attributeSet) {
        return new p(context, attributeSet);
    }

    protected s j(Context context, AttributeSet attributeSet) {
        return new s(context, attributeSet);
    }

    protected t k(Context context, AttributeSet attributeSet) {
        return new t(context, attributeSet);
    }

    protected u l(Context context, AttributeSet attributeSet) {
        return new u(context, attributeSet);
    }

    protected w m(Context context, AttributeSet attributeSet) {
        return new w(context, attributeSet);
    }

    protected y n(Context context, AttributeSet attributeSet) {
        return new y(context, attributeSet);
    }

    protected View o(Context context, String str, AttributeSet attributeSet) {
        return null;
    }

    /* JADX WARN: Failed to restore switch over string. Please report as a decompilation issue */
    final View p(View view, String str, Context context, AttributeSet attributeSet, boolean z, boolean z2, boolean z3, boolean z4) {
        View viewN;
        Context context2 = (!z || view == null) ? context : view.getContext();
        if (z2 || z3) {
            context2 = s(context2, attributeSet, z2, z3);
        }
        if (z4) {
            context2 = q0.b(context2);
        }
        byte b2 = -1;
        switch (str.hashCode()) {
            case -1946472170:
                if (str.equals("RatingBar")) {
                    b2 = SDKKeyboardCode.FUNCTION_KEY_BOARD_H;
                }
                break;
            case -1455429095:
                if (str.equals("CheckedTextView")) {
                    b2 = 8;
                }
                break;
            case -1346021293:
                if (str.equals("MultiAutoCompleteTextView")) {
                    b2 = 10;
                }
                break;
            case -938935918:
                if (str.equals("TextView")) {
                    b2 = 0;
                }
                break;
            case -937446323:
                if (str.equals("ImageButton")) {
                    b2 = 5;
                }
                break;
            case -658531749:
                if (str.equals("SeekBar")) {
                    b2 = SDKKeyboardCode.FUNCTION_KEY_BOARD_I;
                }
                break;
            case -339785223:
                if (str.equals("Spinner")) {
                    b2 = 4;
                }
                break;
            case 776382189:
                if (str.equals("RadioButton")) {
                    b2 = 7;
                }
                break;
            case 1125864064:
                if (str.equals("ImageView")) {
                    b2 = 1;
                }
                break;
            case 1413872058:
                if (str.equals("AutoCompleteTextView")) {
                    b2 = 9;
                }
                break;
            case 1601505219:
                if (str.equals("CheckBox")) {
                    b2 = 6;
                }
                break;
            case 1666676343:
                if (str.equals("EditText")) {
                    b2 = 3;
                }
                break;
            case 2001146706:
                if (str.equals("Button")) {
                    b2 = 2;
                }
                break;
        }
        switch (b2) {
            case 0:
                viewN = n(context2, attributeSet);
                t(viewN, str);
                break;
            case 1:
                viewN = h(context2, attributeSet);
                t(viewN, str);
                break;
            case 2:
                viewN = c(context2, attributeSet);
                t(viewN, str);
                break;
            case 3:
                viewN = f(context2, attributeSet);
                t(viewN, str);
                break;
            case 4:
                viewN = m(context2, attributeSet);
                t(viewN, str);
                break;
            case 5:
                viewN = g(context2, attributeSet);
                t(viewN, str);
                break;
            case 6:
                viewN = d(context2, attributeSet);
                t(viewN, str);
                break;
            case 7:
                viewN = j(context2, attributeSet);
                t(viewN, str);
                break;
            case 8:
                viewN = e(context2, attributeSet);
                t(viewN, str);
                break;
            case 9:
                viewN = b(context2, attributeSet);
                t(viewN, str);
                break;
            case 10:
                viewN = i(context2, attributeSet);
                t(viewN, str);
                break;
            case 11:
                viewN = k(context2, attributeSet);
                t(viewN, str);
                break;
            case 12:
                viewN = l(context2, attributeSet);
                t(viewN, str);
                break;
            default:
                viewN = o(context2, str, attributeSet);
                break;
        }
        if (viewN == null && context != context2) {
            viewN = r(context2, str, attributeSet);
        }
        if (viewN != null) {
            a(viewN, attributeSet);
        }
        return viewN;
    }
}
