package ῲ.ῲ.ඓ;

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.graphics.PorterDuff;
import android.os.Build;
import android.util.AttributeSet;
import android.util.Log;
import android.util.Xml;
import android.view.InflateException;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.SubMenu;
import android.view.View;
import androidx.appcompat.R$styleable;
import androidx.recyclerview.widget.RecyclerView;
import java.io.IOException;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import ඓ.K.K.K.C1293;
import ῲ.ᨨ.ᨨ.AbstractC1743;
import ῲ.ᨨ.㸾.K.AbstractMenuC1864;
import ῲ.ᨨ.㸾.K.AbstractMenuItemC1863;
import ῲ.ῲ.ඓ.㳳.C1922;
import ῲ.ῲ.ඓ.㳳.MenuItemC1904;
import ῲ.ῲ.㴹.C2019;
import ῲ.ῲ.㴹.C2021;

/* renamed from: ῲ.ῲ.ඓ.ⁱ  reason: contains not printable characters */
/* compiled from: SupportMenuInflater */
public class C1892 extends MenuInflater {

    /* renamed from: ඓ  reason: contains not printable characters */
    public static final Class<?>[] f6394 = {Context.class};

    /* renamed from: 㴹  reason: contains not printable characters */
    public static final Class<?>[] f6395 = f6394;

    /* renamed from: ʬ  reason: contains not printable characters */
    public Context f6396;

    /* renamed from: ῲ  reason: contains not printable characters */
    public final Object[] f6397 = this.f6398;

    /* renamed from: K  reason: contains not printable characters */
    public final Object[] f6398;

    /* renamed from: 㸾  reason: contains not printable characters */
    public Object f6399;

    /* renamed from: ῲ.ῲ.ඓ.ⁱ$K  reason: contains not printable characters */
    /* compiled from: SupportMenuInflater */
    public static class MenuItem$OnMenuItemClickListenerC1894 implements MenuItem.OnMenuItemClickListener {

        /* renamed from: ʬ  reason: contains not printable characters */
        public static final Class<?>[] f6432 = {MenuItem.class};

        /* renamed from: ῲ  reason: contains not printable characters */
        public Method f6433;

        /* renamed from: K  reason: contains not printable characters */
        public Object f6434;

        public MenuItem$OnMenuItemClickListenerC1894(Object obj, String str) {
            this.f6434 = obj;
            Class<?> cls = obj.getClass();
            try {
                this.f6433 = cls.getMethod(str, f6432);
            } catch (Exception e) {
                InflateException inflateException = new InflateException("Couldn't resolve menu item onClick handler " + str + " in class " + cls.getName());
                inflateException.initCause(e);
                throw inflateException;
            }
        }

        public boolean onMenuItemClick(MenuItem menuItem) {
            try {
                if (this.f6433.getReturnType() == Boolean.TYPE) {
                    return ((Boolean) this.f6433.invoke(this.f6434, menuItem)).booleanValue();
                }
                this.f6433.invoke(this.f6434, menuItem);
                return true;
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }
    }

    public C1892(Context context) {
        super(context);
        this.f6396 = context;
        this.f6398 = new Object[]{context};
    }

    public void inflate(int i, Menu menu) {
        if (!(menu instanceof AbstractMenuC1864)) {
            super.inflate(i, menu);
            return;
        }
        XmlResourceParser xmlResourceParser = null;
        try {
            xmlResourceParser = this.f6396.getResources().getLayout(i);
            m4914(xmlResourceParser, Xml.asAttributeSet(xmlResourceParser), menu);
            xmlResourceParser.close();
        } catch (XmlPullParserException e) {
            throw new InflateException("Error inflating menu XML", e);
        } catch (IOException e2) {
            throw new InflateException("Error inflating menu XML", e2);
        } catch (Throwable th) {
            if (xmlResourceParser != null) {
                xmlResourceParser.close();
            }
            throw th;
        }
    }

    /* renamed from: K  reason: contains not printable characters */
    public final void m4914(XmlPullParser xmlPullParser, AttributeSet attributeSet, Menu menu) throws XmlPullParserException, IOException {
        char c;
        char c2;
        C1893 r2 = new C1893(menu);
        int eventType = xmlPullParser.getEventType();
        while (true) {
            if (eventType == 2) {
                String name = xmlPullParser.getName();
                if (name.equals("menu")) {
                    eventType = xmlPullParser.next();
                } else {
                    throw new RuntimeException(C1293.m3412("Expecting menu, got ", name));
                }
            } else {
                eventType = xmlPullParser.next();
                if (eventType == 1) {
                    break;
                }
            }
        }
        boolean z = false;
        boolean z2 = false;
        String str = null;
        while (!z) {
            if (eventType != 1) {
                if (eventType != 2) {
                    if (eventType == 3) {
                        String name2 = xmlPullParser.getName();
                        if (z2 && name2.equals(str)) {
                            str = null;
                            z2 = false;
                            eventType = xmlPullParser.next();
                        } else if (name2.equals("group")) {
                            r2.f6413 = 0;
                            r2.f6400 = 0;
                            r2.f6427 = 0;
                            r2.f6405 = 0;
                            r2.f6425 = true;
                            r2.f6414 = true;
                        } else if (name2.equals("item")) {
                            if (!r2.f6428) {
                                AbstractC1743 r3 = r2.f6418;
                                if (r3 == null || !((MenuItemC1904.C1908) r3).f6458.hasSubMenu()) {
                                    r2.f6428 = true;
                                    r2.m4917(r2.f6415.add(r2.f6413, r2.f6412, r2.f6423, r2.f6410));
                                } else {
                                    r2.m4915();
                                }
                            }
                        } else if (name2.equals("menu")) {
                            z = true;
                            eventType = xmlPullParser.next();
                        }
                    }
                } else if (!z2) {
                    String name3 = xmlPullParser.getName();
                    if (name3.equals("group")) {
                        TypedArray obtainStyledAttributes = C1892.this.f6396.obtainStyledAttributes(attributeSet, R$styleable.MenuGroup);
                        r2.f6413 = obtainStyledAttributes.getResourceId(R$styleable.MenuGroup_android_id, 0);
                        r2.f6400 = obtainStyledAttributes.getInt(R$styleable.MenuGroup_android_menuCategory, 0);
                        r2.f6427 = obtainStyledAttributes.getInt(R$styleable.MenuGroup_android_orderInCategory, 0);
                        r2.f6405 = obtainStyledAttributes.getInt(R$styleable.MenuGroup_android_checkableBehavior, 0);
                        r2.f6425 = obtainStyledAttributes.getBoolean(R$styleable.MenuGroup_android_visible, true);
                        r2.f6414 = obtainStyledAttributes.getBoolean(R$styleable.MenuGroup_android_enabled, true);
                        obtainStyledAttributes.recycle();
                    } else if (name3.equals("item")) {
                        C2019 r32 = C2019.m5222(C1892.this.f6396, attributeSet, R$styleable.MenuItem);
                        r2.f6412 = r32.m5230(R$styleable.MenuItem_android_id, 0);
                        r2.f6423 = (r32.m5238(R$styleable.MenuItem_android_menuCategory, r2.f6400) & -65536) | (r32.m5238(R$styleable.MenuItem_android_orderInCategory, r2.f6427) & 65535);
                        r2.f6410 = r32.m5227(R$styleable.MenuItem_android_title);
                        r2.f6419 = r32.m5227(R$styleable.MenuItem_android_titleCondensed);
                        r2.f6430 = r32.m5230(R$styleable.MenuItem_android_icon, 0);
                        String r12 = r32.m5239(R$styleable.MenuItem_android_alphabeticShortcut);
                        if (r12 == null) {
                            c = 0;
                        } else {
                            c = r12.charAt(0);
                        }
                        r2.f6401 = c;
                        r2.f6420 = r32.m5238(R$styleable.MenuItem_alphabeticModifiers, RecyclerView.AbstractC0269.FLAG_APPEARED_IN_PRE_LAYOUT);
                        String r122 = r32.m5239(R$styleable.MenuItem_android_numericShortcut);
                        if (r122 == null) {
                            c2 = 0;
                        } else {
                            c2 = r122.charAt(0);
                        }
                        r2.f6403 = c2;
                        r2.f6409 = r32.m5238(R$styleable.MenuItem_numericModifiers, RecyclerView.AbstractC0269.FLAG_APPEARED_IN_PRE_LAYOUT);
                        if (r32.m5237(R$styleable.MenuItem_android_checkable)) {
                            r2.f6421 = r32.m5235(R$styleable.MenuItem_android_checkable, false) ? 1 : 0;
                        } else {
                            r2.f6421 = r2.f6405;
                        }
                        r2.f6404 = r32.m5235(R$styleable.MenuItem_android_checked, false);
                        r2.f6429 = r32.m5235(R$styleable.MenuItem_android_visible, r2.f6425);
                        r2.f6402 = r32.m5235(R$styleable.MenuItem_android_enabled, r2.f6414);
                        r2.f6426 = r32.m5238(R$styleable.MenuItem_showAsAction, -1);
                        r2.f6417 = r32.m5239(R$styleable.MenuItem_android_onClick);
                        r2.f6408 = r32.m5230(R$styleable.MenuItem_actionLayout, 0);
                        r2.f6424 = r32.m5239(R$styleable.MenuItem_actionViewClass);
                        r2.f6407 = r32.m5239(R$styleable.MenuItem_actionProviderClass);
                        boolean z3 = r2.f6407 != null;
                        if (z3 && r2.f6408 == 0 && r2.f6424 == null) {
                            r2.f6418 = (AbstractC1743) r2.m4916(r2.f6407, f6395, C1892.this.f6397);
                        } else {
                            if (z3) {
                                Log.w("SupportMenuInflater", "Ignoring attribute 'actionProviderClass'. Action view already specified.");
                            }
                            r2.f6418 = null;
                        }
                        r2.f6422 = r32.m5227(R$styleable.MenuItem_contentDescription);
                        r2.f6431 = r32.m5227(R$styleable.MenuItem_tooltipText);
                        if (r32.m5237(R$styleable.MenuItem_iconTintMode)) {
                            r2.f6406 = C2021.m5242(r32.m5238(R$styleable.MenuItem_iconTintMode, -1), r2.f6406);
                        } else {
                            r2.f6406 = null;
                        }
                        if (r32.m5237(R$styleable.MenuItem_iconTint)) {
                            r2.f6411 = r32.m5233(R$styleable.MenuItem_iconTint);
                        } else {
                            r2.f6411 = null;
                        }
                        r32.f6846.recycle();
                        r2.f6428 = false;
                    } else {
                        if (name3.equals("menu")) {
                            m4914(xmlPullParser, attributeSet, r2.m4915());
                        } else {
                            z2 = true;
                            str = name3;
                        }
                        eventType = xmlPullParser.next();
                    }
                }
                eventType = xmlPullParser.next();
            } else {
                throw new RuntimeException("Unexpected end of document");
            }
        }
    }

    /* renamed from: ῲ.ῲ.ඓ.ⁱ$ῲ  reason: contains not printable characters */
    /* compiled from: SupportMenuInflater */
    public class C1893 {

        /* renamed from: ʬ  reason: contains not printable characters */
        public int f6400;

        /* renamed from: Ԕ  reason: contains not printable characters */
        public char f6401;

        /* renamed from: Ԛ  reason: contains not printable characters */
        public boolean f6402;

        /* renamed from: ؿ  reason: contains not printable characters */
        public char f6403;

        /* renamed from: ݜ  reason: contains not printable characters */
        public boolean f6404;

        /* renamed from: ඓ  reason: contains not printable characters */
        public int f6405;

        /* renamed from: ᆯ  reason: contains not printable characters */
        public PorterDuff.Mode f6406 = null;

        /* renamed from: ᑓ  reason: contains not printable characters */
        public String f6407;

        /* renamed from: ᓆ  reason: contains not printable characters */
        public int f6408;

        /* renamed from: ᓣ  reason: contains not printable characters */
        public int f6409;

        /* renamed from: ᕣ  reason: contains not printable characters */
        public CharSequence f6410;

        /* renamed from: ᝁ  reason: contains not printable characters */
        public ColorStateList f6411 = null;

        /* renamed from: ᨨ  reason: contains not printable characters */
        public int f6412;

        /* renamed from: ῲ  reason: contains not printable characters */
        public int f6413;

        /* renamed from: ⁱ  reason: contains not printable characters */
        public boolean f6414;

        /* renamed from: K  reason: contains not printable characters */
        public Menu f6415;

        /* renamed from: ゎ  reason: contains not printable characters */
        public String f6417;

        /* renamed from: ト  reason: contains not printable characters */
        public AbstractC1743 f6418;

        /* renamed from: 㑃  reason: contains not printable characters */
        public CharSequence f6419;

        /* renamed from: 㗗  reason: contains not printable characters */
        public int f6420;

        /* renamed from: 㗽  reason: contains not printable characters */
        public int f6421;

        /* renamed from: 㮔  reason: contains not printable characters */
        public CharSequence f6422;

        /* renamed from: 㳳  reason: contains not printable characters */
        public int f6423;

        /* renamed from: 㴪  reason: contains not printable characters */
        public String f6424;

        /* renamed from: 㴹  reason: contains not printable characters */
        public boolean f6425;

        /* renamed from: 㶋  reason: contains not printable characters */
        public int f6426;

        /* renamed from: 㸾  reason: contains not printable characters */
        public int f6427;

        /* renamed from: 㿎  reason: contains not printable characters */
        public boolean f6428;

        /* renamed from: 䀟  reason: contains not printable characters */
        public boolean f6429;

        /* renamed from: 䁗  reason: contains not printable characters */
        public int f6430;

        /* renamed from: 䃖  reason: contains not printable characters */
        public CharSequence f6431;

        public C1893(Menu menu) {
            this.f6415 = menu;
            this.f6413 = 0;
            this.f6400 = 0;
            this.f6427 = 0;
            this.f6405 = 0;
            this.f6425 = true;
            this.f6414 = true;
        }

        /* renamed from: K  reason: contains not printable characters */
        public final void m4917(MenuItem menuItem) {
            boolean z = false;
            menuItem.setChecked(this.f6404).setVisible(this.f6429).setEnabled(this.f6402).setCheckable(this.f6421 >= 1).setTitleCondensed(this.f6419).setIcon(this.f6430);
            int i = this.f6426;
            if (i >= 0) {
                menuItem.setShowAsAction(i);
            }
            if (this.f6417 != null) {
                if (!C1892.this.f6396.isRestricted()) {
                    C1892 r1 = C1892.this;
                    if (r1.f6399 == null) {
                        r1.f6399 = r1.m4913(r1.f6396);
                    }
                    menuItem.setOnMenuItemClickListener(new MenuItem$OnMenuItemClickListenerC1894(r1.f6399, this.f6417));
                } else {
                    throw new IllegalStateException("The android:onClick attribute cannot be used within a restricted context");
                }
            }
            if (this.f6421 >= 2) {
                if (menuItem instanceof C1922) {
                    ((C1922) menuItem).m4967(true);
                } else if (menuItem instanceof MenuItemC1904) {
                    MenuItemC1904 r0 = (MenuItemC1904) menuItem;
                    try {
                        if (r0.f6452 == null) {
                            r0.f6452 = r0.f6453.getClass().getDeclaredMethod("setExclusiveCheckable", Boolean.TYPE);
                        }
                        r0.f6452.invoke(r0.f6453, true);
                    } catch (Exception e) {
                        Log.w("MenuItemWrapper", "Error while calling setExclusiveCheckable", e);
                    }
                }
            }
            String str = this.f6424;
            if (str != null) {
                menuItem.setActionView((View) m4916(str, C1892.f6394, C1892.this.f6398));
                z = true;
            }
            int i2 = this.f6408;
            if (i2 > 0) {
                if (!z) {
                    menuItem.setActionView(i2);
                } else {
                    Log.w("SupportMenuInflater", "Ignoring attribute 'itemActionViewLayout'. Action view already specified.");
                }
            }
            AbstractC1743 r02 = this.f6418;
            if (r02 != null) {
                if (menuItem instanceof AbstractMenuItemC1863) {
                    ((AbstractMenuItemC1863) menuItem).m4825(r02);
                } else {
                    Log.w("MenuItemCompat", "setActionProvider: item does not implement SupportMenuItem; ignoring");
                }
            }
            CharSequence charSequence = this.f6422;
            boolean z2 = menuItem instanceof AbstractMenuItemC1863;
            if (z2) {
                ((AbstractMenuItemC1863) menuItem).setContentDescription(charSequence);
            } else if (Build.VERSION.SDK_INT >= 26) {
                menuItem.setContentDescription(charSequence);
            }
            CharSequence charSequence2 = this.f6431;
            if (z2) {
                ((AbstractMenuItemC1863) menuItem).setTooltipText(charSequence2);
            } else if (Build.VERSION.SDK_INT >= 26) {
                menuItem.setTooltipText(charSequence2);
            }
            char c = this.f6401;
            int i3 = this.f6420;
            if (z2) {
                ((AbstractMenuItemC1863) menuItem).setAlphabeticShortcut(c, i3);
            } else if (Build.VERSION.SDK_INT >= 26) {
                menuItem.setAlphabeticShortcut(c, i3);
            }
            char c2 = this.f6403;
            int i4 = this.f6409;
            if (z2) {
                ((AbstractMenuItemC1863) menuItem).setNumericShortcut(c2, i4);
            } else if (Build.VERSION.SDK_INT >= 26) {
                menuItem.setNumericShortcut(c2, i4);
            }
            PorterDuff.Mode mode = this.f6406;
            if (mode != null) {
                if (z2) {
                    ((AbstractMenuItemC1863) menuItem).setIconTintMode(mode);
                } else if (Build.VERSION.SDK_INT >= 26) {
                    menuItem.setIconTintMode(mode);
                }
            }
            ColorStateList colorStateList = this.f6411;
            if (colorStateList == null) {
                return;
            }
            if (z2) {
                ((AbstractMenuItemC1863) menuItem).setIconTintList(colorStateList);
            } else if (Build.VERSION.SDK_INT >= 26) {
                menuItem.setIconTintList(colorStateList);
            }
        }

        /* renamed from: K  reason: contains not printable characters */
        public SubMenu m4915() {
            this.f6428 = true;
            SubMenu addSubMenu = this.f6415.addSubMenu(this.f6413, this.f6412, this.f6423, this.f6410);
            m4917(addSubMenu.getItem());
            return addSubMenu;
        }

        /* renamed from: K  reason: contains not printable characters */
        public final <T> T m4916(String str, Class<?>[] clsArr, Object[] objArr) {
            try {
                Constructor<?> constructor = Class.forName(str, false, C1892.this.f6396.getClassLoader()).getConstructor(clsArr);
                constructor.setAccessible(true);
                return (T) constructor.newInstance(objArr);
            } catch (Exception e) {
                Log.w("SupportMenuInflater", "Cannot instantiate class: " + str, e);
                return null;
            }
        }
    }

    /* renamed from: K  reason: contains not printable characters */
    public final Object m4913(Object obj) {
        return (!(obj instanceof Activity) && (obj instanceof ContextWrapper)) ? m4913(((ContextWrapper) obj).getBaseContext()) : obj;
    }
}
