package defpackage;

import android.app.Activity;
import android.content.Context;
import android.content.ContextWrapper;
import android.content.res.ColorStateList;
import android.content.res.TypedArray;
import android.content.res.XmlResourceParser;
import android.util.AttributeSet;
import android.util.Xml;
import android.view.InflateException;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.SubMenu;
import java.io.IOException;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;

/* JADX INFO: renamed from: ʾᵜᵙ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes3.dex */
public final class C0291 extends MenuInflater {

    /* JADX INFO: renamed from: ᵨᵣ, reason: contains not printable characters */
    public static final Class[] f1940;

    /* JADX INFO: renamed from: ᵻˈᵦʼ, reason: contains not printable characters */
    public static final Class[] f1941;

    /* JADX INFO: renamed from: ʽˈˋ, reason: contains not printable characters */
    public final Object[] f1942;

    /* JADX INFO: renamed from: ːˏᵟᵯ, reason: contains not printable characters */
    public final Context f1943;

    /* JADX INFO: renamed from: ᵲᵶᵳˈ, reason: contains not printable characters */
    public final Object[] f1944;

    /* JADX INFO: renamed from: ᵷᵺʾᵖ, reason: contains not printable characters */
    public Object f1945;

    static {
        Class[] clsArr = {Context.class};
        f1940 = clsArr;
        f1941 = clsArr;
    }

    public C0291(Context context) {
        super(context);
        this.f1943 = context;
        Object[] objArr = {context};
        this.f1944 = objArr;
        this.f1942 = objArr;
    }

    /* JADX INFO: renamed from: ᵲᵶᵳˈ, reason: contains not printable characters */
    public static Object m1535(Object obj) {
        return (!(obj instanceof Activity) && (obj instanceof ContextWrapper)) ? m1535(((ContextWrapper) obj).getBaseContext()) : obj;
    }

    @Override // android.view.MenuInflater
    public final void inflate(int i, Menu menu) {
        if (!(menu instanceof MenuC3271)) {
            super.inflate(i, menu);
            return;
        }
        XmlResourceParser layout = null;
        boolean z = false;
        try {
            try {
                layout = this.f1943.getResources().getLayout(i);
                AttributeSet attributeSetAsAttributeSet = Xml.asAttributeSet(layout);
                if (menu instanceof MenuC3271) {
                    MenuC3271 menuC3271 = (MenuC3271) menu;
                    if (!menuC3271.f12524) {
                        menuC3271.m7501();
                        z = true;
                    }
                }
                m1536(layout, attributeSetAsAttributeSet, menu);
                if (z) {
                    ((MenuC3271) menu).m7498();
                }
                layout.close();
            } catch (IOException e) {
                throw new InflateException("Error inflating menu XML", e);
            } catch (XmlPullParserException e2) {
                throw new InflateException("Error inflating menu XML", e2);
            }
        } catch (Throwable th) {
            if (z) {
                ((MenuC3271) menu).m7498();
            }
            if (layout != null) {
                layout.close();
            }
            throw th;
        }
    }

    /* JADX INFO: renamed from: ʽˈˋ, reason: contains not printable characters */
    public final void m1536(XmlPullParser xmlPullParser, AttributeSet attributeSet, Menu menu) throws XmlPullParserException, IOException {
        int i;
        XmlPullParser xmlPullParser2;
        ColorStateList colorStateList;
        int resourceId;
        C2216 c2216 = new C2216(this, menu);
        int eventType = xmlPullParser.getEventType();
        while (true) {
            i = 2;
            if (eventType == 2) {
                String name = xmlPullParser.getName();
                if (!name.equals("menu")) {
                    C4935.m10237("Expecting menu, got ".concat(name));
                    return;
                }
                eventType = xmlPullParser.next();
            } else {
                eventType = xmlPullParser.next();
                if (eventType == 1) {
                    break;
                }
            }
        }
        boolean z = false;
        boolean z2 = false;
        String str = null;
        while (!z) {
            if (eventType == 1) {
                C4935.m10237("Unexpected end of document");
                return;
            }
            Menu menu2 = c2216.f8806;
            if (eventType != i) {
                if (eventType != 3) {
                    xmlPullParser2 = xmlPullParser;
                    z = z;
                } else {
                    String name2 = xmlPullParser.getName();
                    if (z2 && name2.equals(str)) {
                        xmlPullParser2 = xmlPullParser;
                        z2 = false;
                        str = null;
                    } else {
                        if (name2.equals("group")) {
                            c2216.f8783 = 0;
                            c2216.f8793 = 0;
                            c2216.f8810 = 0;
                            c2216.f8799 = 0;
                            c2216.f8813 = true;
                            c2216.f8807 = true;
                        } else if (name2.equals("item")) {
                            if (!c2216.f8788) {
                                ActionProviderVisibilityListenerC3445 actionProviderVisibilityListenerC3445 = c2216.f8803;
                                if (actionProviderVisibilityListenerC3445 == null || !actionProviderVisibilityListenerC3445.f13288.hasSubMenu()) {
                                    c2216.f8788 = true;
                                    c2216.m5805(menu2.add(c2216.f8783, c2216.f8812, c2216.f8805, c2216.f8809));
                                } else {
                                    c2216.f8788 = true;
                                    c2216.m5805(menu2.addSubMenu(c2216.f8783, c2216.f8812, c2216.f8805, c2216.f8809).getItem());
                                }
                            }
                        } else if (name2.equals("menu")) {
                            xmlPullParser2 = xmlPullParser;
                            z = true;
                        }
                        xmlPullParser2 = xmlPullParser;
                        z = z;
                    }
                }
                eventType = xmlPullParser2.next();
                i = 2;
                z = z;
                z2 = z2;
            } else {
                if (!z2) {
                    String name3 = xmlPullParser.getName();
                    boolean zEquals = name3.equals("group");
                    Context context = this.f1943;
                    if (zEquals) {
                        TypedArray typedArrayObtainStyledAttributes = context.obtainStyledAttributes(attributeSet, AbstractC0430.f2389);
                        c2216.f8783 = typedArrayObtainStyledAttributes.getResourceId(1, 0);
                        c2216.f8793 = typedArrayObtainStyledAttributes.getInt(3, 0);
                        c2216.f8810 = typedArrayObtainStyledAttributes.getInt(4, 0);
                        c2216.f8799 = typedArrayObtainStyledAttributes.getInt(5, 0);
                        c2216.f8813 = typedArrayObtainStyledAttributes.getBoolean(2, true);
                        c2216.f8807 = typedArrayObtainStyledAttributes.getBoolean(0, true);
                        typedArrayObtainStyledAttributes.recycle();
                    } else {
                        if (name3.equals("item")) {
                            TypedArray typedArrayObtainStyledAttributes2 = context.obtainStyledAttributes(attributeSet, AbstractC0430.f2395);
                            c2216.f8812 = typedArrayObtainStyledAttributes2.getResourceId(2, 0);
                            c2216.f8805 = (typedArrayObtainStyledAttributes2.getInt(5, c2216.f8793) & (-65536)) | (typedArrayObtainStyledAttributes2.getInt(6, c2216.f8810) & 65535);
                            c2216.f8809 = typedArrayObtainStyledAttributes2.getText(7);
                            c2216.f8802 = typedArrayObtainStyledAttributes2.getText(8);
                            c2216.f8797 = typedArrayObtainStyledAttributes2.getResourceId(0, 0);
                            String string = typedArrayObtainStyledAttributes2.getString(9);
                            c2216.f8789 = string == null ? (char) 0 : string.charAt(0);
                            c2216.f8801 = typedArrayObtainStyledAttributes2.getInt(16, 4096);
                            String string2 = typedArrayObtainStyledAttributes2.getString(10);
                            c2216.f8798 = string2 == null ? (char) 0 : string2.charAt(0);
                            c2216.f8804 = typedArrayObtainStyledAttributes2.getInt(20, 4096);
                            if (typedArrayObtainStyledAttributes2.hasValue(11)) {
                                c2216.f8786 = typedArrayObtainStyledAttributes2.getBoolean(11, false) ? 1 : 0;
                            } else {
                                c2216.f8786 = c2216.f8799;
                            }
                            c2216.f8785 = typedArrayObtainStyledAttributes2.getBoolean(3, false);
                            c2216.f8792 = typedArrayObtainStyledAttributes2.getBoolean(4, c2216.f8813);
                            c2216.f8787 = typedArrayObtainStyledAttributes2.getBoolean(1, c2216.f8807);
                            c2216.f8790 = typedArrayObtainStyledAttributes2.getInt(21, -1);
                            c2216.f8800 = typedArrayObtainStyledAttributes2.getString(12);
                            c2216.f8796 = typedArrayObtainStyledAttributes2.getResourceId(13, 0);
                            c2216.f8795 = typedArrayObtainStyledAttributes2.getString(15);
                            String string3 = typedArrayObtainStyledAttributes2.getString(14);
                            if (string3 != null && c2216.f8796 == 0 && c2216.f8795 == null) {
                                c2216.f8803 = (ActionProviderVisibilityListenerC3445) c2216.m5806(string3, f1941, this.f1942);
                            } else {
                                c2216.f8803 = null;
                            }
                            c2216.f8808 = typedArrayObtainStyledAttributes2.getText(17);
                            c2216.f8784 = typedArrayObtainStyledAttributes2.getText(22);
                            if (typedArrayObtainStyledAttributes2.hasValue(19)) {
                                c2216.f8811 = AbstractC0912.m3159(typedArrayObtainStyledAttributes2.getInt(19, -1), c2216.f8811);
                            } else {
                                c2216.f8811 = null;
                            }
                            if (typedArrayObtainStyledAttributes2.hasValue(18)) {
                                if (!typedArrayObtainStyledAttributes2.hasValue(18) || (resourceId = typedArrayObtainStyledAttributes2.getResourceId(18, 0)) == 0 || (colorStateList = AbstractC1630.m4515(context, resourceId)) == null) {
                                    colorStateList = typedArrayObtainStyledAttributes2.getColorStateList(18);
                                }
                                c2216.f8791 = colorStateList;
                            } else {
                                c2216.f8791 = null;
                            }
                            typedArrayObtainStyledAttributes2.recycle();
                            c2216.f8788 = false;
                            xmlPullParser2 = xmlPullParser;
                        } else if (name3.equals("menu")) {
                            c2216.f8788 = true;
                            SubMenu subMenuAddSubMenu = menu2.addSubMenu(c2216.f8783, c2216.f8812, c2216.f8805, c2216.f8809);
                            c2216.m5805(subMenuAddSubMenu.getItem());
                            xmlPullParser2 = xmlPullParser;
                            m1536(xmlPullParser2, attributeSet, subMenuAddSubMenu);
                        } else {
                            xmlPullParser2 = xmlPullParser;
                            str = name3;
                            z2 = true;
                        }
                        eventType = xmlPullParser2.next();
                        i = 2;
                        z = z;
                        z2 = z2;
                    }
                }
                xmlPullParser2 = xmlPullParser;
                z = z;
            }
            eventType = xmlPullParser2.next();
            i = 2;
            z = z;
            z2 = z2;
        }
    }
}
