ADD week 5
This commit is contained in:
		| @@ -0,0 +1,573 @@ | ||||
| package androidx.appcompat.view; | ||||
|  | ||||
| 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.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; | ||||
| import androidx.appcompat.view.menu.MenuItemImpl; | ||||
| import androidx.appcompat.view.menu.MenuItemWrapperICS; | ||||
| import androidx.appcompat.widget.DrawableUtils; | ||||
| import androidx.appcompat.widget.TintTypedArray; | ||||
| import androidx.core.internal.view.SupportMenu; | ||||
| import androidx.core.view.ActionProvider; | ||||
| import androidx.core.view.MenuItemCompat; | ||||
| import java.io.IOException; | ||||
| import java.lang.reflect.Constructor; | ||||
| import java.lang.reflect.Method; | ||||
| import org.xmlpull.v1.XmlPullParserException; | ||||
|  | ||||
| /* loaded from: classes.dex */ | ||||
| public class SupportMenuInflater extends MenuInflater { | ||||
|     static final Class<?>[] ACTION_PROVIDER_CONSTRUCTOR_SIGNATURE; | ||||
|     static final Class<?>[] ACTION_VIEW_CONSTRUCTOR_SIGNATURE; | ||||
|     static final String LOG_TAG = "SupportMenuInflater"; | ||||
|     static final int NO_ID = 0; | ||||
|     private static final String XML_GROUP = "group"; | ||||
|     private static final String XML_ITEM = "item"; | ||||
|     private static final String XML_MENU = "menu"; | ||||
|     final Object[] mActionProviderConstructorArguments; | ||||
|     final Object[] mActionViewConstructorArguments; | ||||
|     Context mContext; | ||||
|     private Object mRealOwner; | ||||
|  | ||||
|     static { | ||||
|         Class<?>[] clsArr = {Context.class}; | ||||
|         ACTION_VIEW_CONSTRUCTOR_SIGNATURE = clsArr; | ||||
|         ACTION_PROVIDER_CONSTRUCTOR_SIGNATURE = clsArr; | ||||
|     } | ||||
|  | ||||
|     public SupportMenuInflater(Context context) { | ||||
|         super(context); | ||||
|         this.mContext = context; | ||||
|         Object[] objArr = {context}; | ||||
|         this.mActionViewConstructorArguments = objArr; | ||||
|         this.mActionProviderConstructorArguments = objArr; | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.MenuInflater | ||||
|     public void inflate(int i, Menu menu) { | ||||
|         if (!(menu instanceof SupportMenu)) { | ||||
|             super.inflate(i, menu); | ||||
|             return; | ||||
|         } | ||||
|         XmlResourceParser xmlResourceParser = null; | ||||
|         try { | ||||
|             try { | ||||
|                 try { | ||||
|                     xmlResourceParser = this.mContext.getResources().getLayout(i); | ||||
|                     parseMenu(xmlResourceParser, Xml.asAttributeSet(xmlResourceParser), menu); | ||||
|                 } catch (XmlPullParserException e) { | ||||
|                     throw new InflateException("Error inflating menu XML", e); | ||||
|                 } | ||||
|             } catch (IOException e2) { | ||||
|                 throw new InflateException("Error inflating menu XML", e2); | ||||
|             } | ||||
|         } finally { | ||||
|             if (xmlResourceParser != null) { | ||||
|                 xmlResourceParser.close(); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     /* JADX WARN: Code restructure failed: missing block: B:11:0x0045, code lost: | ||||
|      | ||||
|         if (r15 == 2) goto L41; | ||||
|      */ | ||||
|     /* JADX WARN: Code restructure failed: missing block: B:13:0x0048, code lost: | ||||
|      | ||||
|         if (r15 == 3) goto L20; | ||||
|      */ | ||||
|     /* JADX WARN: Code restructure failed: missing block: B:14:0x004c, code lost: | ||||
|      | ||||
|         r15 = r13.getName(); | ||||
|      */ | ||||
|     /* JADX WARN: Code restructure failed: missing block: B:15:0x0050, code lost: | ||||
|      | ||||
|         if (r7 == false) goto L25; | ||||
|      */ | ||||
|     /* JADX WARN: Code restructure failed: missing block: B:17:0x0056, code lost: | ||||
|      | ||||
|         if (r15.equals(r8) == false) goto L25; | ||||
|      */ | ||||
|     /* JADX WARN: Code restructure failed: missing block: B:18:0x0058, code lost: | ||||
|      | ||||
|         r8 = null; | ||||
|         r7 = false; | ||||
|      */ | ||||
|     /* JADX WARN: Code restructure failed: missing block: B:20:0x00b8, code lost: | ||||
|      | ||||
|         r15 = r13.next(); | ||||
|      */ | ||||
|     /* JADX WARN: Code restructure failed: missing block: B:22:0x005f, code lost: | ||||
|      | ||||
|         if (r15.equals(androidx.appcompat.view.SupportMenuInflater.XML_GROUP) == false) goto L28; | ||||
|      */ | ||||
|     /* JADX WARN: Code restructure failed: missing block: B:23:0x0061, code lost: | ||||
|      | ||||
|         r0.resetGroup(); | ||||
|      */ | ||||
|     /* JADX WARN: Code restructure failed: missing block: B:26:0x0069, code lost: | ||||
|      | ||||
|         if (r15.equals(androidx.appcompat.view.SupportMenuInflater.XML_ITEM) == false) goto L38; | ||||
|      */ | ||||
|     /* JADX WARN: Code restructure failed: missing block: B:28:0x006f, code lost: | ||||
|      | ||||
|         if (r0.hasAddedItem() != false) goto L65; | ||||
|      */ | ||||
|     /* JADX WARN: Code restructure failed: missing block: B:30:0x0073, code lost: | ||||
|      | ||||
|         if (r0.itemActionProvider == null) goto L37; | ||||
|      */ | ||||
|     /* JADX WARN: Code restructure failed: missing block: B:32:0x007b, code lost: | ||||
|      | ||||
|         if (r0.itemActionProvider.hasSubMenu() == false) goto L37; | ||||
|      */ | ||||
|     /* JADX WARN: Code restructure failed: missing block: B:33:0x007d, code lost: | ||||
|      | ||||
|         r0.addSubMenuItem(); | ||||
|      */ | ||||
|     /* JADX WARN: Code restructure failed: missing block: B:35:0x0081, code lost: | ||||
|      | ||||
|         r0.addItem(); | ||||
|      */ | ||||
|     /* JADX WARN: Code restructure failed: missing block: B:39:0x0089, code lost: | ||||
|      | ||||
|         if (r15.equals(androidx.appcompat.view.SupportMenuInflater.XML_MENU) == false) goto L68; | ||||
|      */ | ||||
|     /* JADX WARN: Code restructure failed: missing block: B:40:0x008b, code lost: | ||||
|      | ||||
|         r6 = true; | ||||
|      */ | ||||
|     /* JADX WARN: Code restructure failed: missing block: B:44:0x008d, code lost: | ||||
|      | ||||
|         if (r7 == false) goto L43; | ||||
|      */ | ||||
|     /* JADX WARN: Code restructure failed: missing block: B:45:0x0090, code lost: | ||||
|      | ||||
|         r15 = r13.getName(); | ||||
|      */ | ||||
|     /* JADX WARN: Code restructure failed: missing block: B:46:0x0098, code lost: | ||||
|      | ||||
|         if (r15.equals(androidx.appcompat.view.SupportMenuInflater.XML_GROUP) == false) goto L46; | ||||
|      */ | ||||
|     /* JADX WARN: Code restructure failed: missing block: B:47:0x009a, code lost: | ||||
|      | ||||
|         r0.readGroup(r14); | ||||
|      */ | ||||
|     /* JADX WARN: Code restructure failed: missing block: B:50:0x00a2, code lost: | ||||
|      | ||||
|         if (r15.equals(androidx.appcompat.view.SupportMenuInflater.XML_ITEM) == false) goto L49; | ||||
|      */ | ||||
|     /* JADX WARN: Code restructure failed: missing block: B:51:0x00a4, code lost: | ||||
|      | ||||
|         r0.readItem(r14); | ||||
|      */ | ||||
|     /* JADX WARN: Code restructure failed: missing block: B:54:0x00ac, code lost: | ||||
|      | ||||
|         if (r15.equals(androidx.appcompat.view.SupportMenuInflater.XML_MENU) == false) goto L52; | ||||
|      */ | ||||
|     /* JADX WARN: Code restructure failed: missing block: B:55:0x00ae, code lost: | ||||
|      | ||||
|         parseMenu(r13, r14, r0.addSubMenuItem()); | ||||
|      */ | ||||
|     /* JADX WARN: Code restructure failed: missing block: B:57:0x00b6, code lost: | ||||
|      | ||||
|         r8 = r15; | ||||
|         r7 = true; | ||||
|      */ | ||||
|     /* JADX WARN: Code restructure failed: missing block: B:62:0x00c4, code lost: | ||||
|      | ||||
|         throw new java.lang.RuntimeException("Unexpected end of document"); | ||||
|      */ | ||||
|     /* JADX WARN: Code restructure failed: missing block: B:65:0x00c5, code lost: | ||||
|      | ||||
|         return; | ||||
|      */ | ||||
|     /* JADX WARN: Code restructure failed: missing block: B:7:0x0038, code lost: | ||||
|      | ||||
|         r8 = null; | ||||
|         r6 = false; | ||||
|         r7 = false; | ||||
|      */ | ||||
|     /* JADX WARN: Code restructure failed: missing block: B:8:0x003d, code lost: | ||||
|      | ||||
|         if (r6 != false) goto L60; | ||||
|      */ | ||||
|     /* JADX WARN: Code restructure failed: missing block: B:9:0x003f, code lost: | ||||
|      | ||||
|         if (r15 == 1) goto L61; | ||||
|      */ | ||||
|     /* | ||||
|         Code decompiled incorrectly, please refer to instructions dump. | ||||
|         To view partially-correct add '--show-bad-code' argument | ||||
|     */ | ||||
|     private void parseMenu(org.xmlpull.v1.XmlPullParser r13, android.util.AttributeSet r14, android.view.Menu r15) throws org.xmlpull.v1.XmlPullParserException, java.io.IOException { | ||||
|         /* | ||||
|             r12 = this; | ||||
|             androidx.appcompat.view.SupportMenuInflater$MenuState r0 = new androidx.appcompat.view.SupportMenuInflater$MenuState | ||||
|             r0.<init>(r15) | ||||
|             int r15 = r13.getEventType() | ||||
|         L9: | ||||
|             r1 = 2 | ||||
|             java.lang.String r2 = "menu" | ||||
|             r3 = 1 | ||||
|             if (r15 != r1) goto L32 | ||||
|             java.lang.String r15 = r13.getName() | ||||
|             boolean r4 = r15.equals(r2) | ||||
|             if (r4 == 0) goto L1e | ||||
|             int r15 = r13.next() | ||||
|             goto L38 | ||||
|         L1e: | ||||
|             java.lang.RuntimeException r13 = new java.lang.RuntimeException | ||||
|             java.lang.StringBuilder r14 = new java.lang.StringBuilder | ||||
|             java.lang.String r0 = "Expecting menu, got " | ||||
|             r14.<init>(r0) | ||||
|             r14.append(r15) | ||||
|             java.lang.String r14 = r14.toString() | ||||
|             r13.<init>(r14) | ||||
|             throw r13 | ||||
|         L32: | ||||
|             int r15 = r13.next() | ||||
|             if (r15 != r3) goto L9 | ||||
|         L38: | ||||
|             r4 = 0 | ||||
|             r5 = 0 | ||||
|             r8 = r5 | ||||
|             r6 = 0 | ||||
|             r7 = 0 | ||||
|         L3d: | ||||
|             if (r6 != 0) goto Lc5 | ||||
|             if (r15 == r3) goto Lbd | ||||
|             java.lang.String r9 = "item" | ||||
|             java.lang.String r10 = "group" | ||||
|             if (r15 == r1) goto L8d | ||||
|             r11 = 3 | ||||
|             if (r15 == r11) goto L4c | ||||
|             goto Lb8 | ||||
|         L4c: | ||||
|             java.lang.String r15 = r13.getName() | ||||
|             if (r7 == 0) goto L5b | ||||
|             boolean r11 = r15.equals(r8) | ||||
|             if (r11 == 0) goto L5b | ||||
|             r8 = r5 | ||||
|             r7 = 0 | ||||
|             goto Lb8 | ||||
|         L5b: | ||||
|             boolean r10 = r15.equals(r10) | ||||
|             if (r10 == 0) goto L65 | ||||
|             r0.resetGroup() | ||||
|             goto Lb8 | ||||
|         L65: | ||||
|             boolean r9 = r15.equals(r9) | ||||
|             if (r9 == 0) goto L85 | ||||
|             boolean r15 = r0.hasAddedItem() | ||||
|             if (r15 != 0) goto Lb8 | ||||
|             androidx.core.view.ActionProvider r15 = r0.itemActionProvider | ||||
|             if (r15 == 0) goto L81 | ||||
|             androidx.core.view.ActionProvider r15 = r0.itemActionProvider | ||||
|             boolean r15 = r15.hasSubMenu() | ||||
|             if (r15 == 0) goto L81 | ||||
|             r0.addSubMenuItem() | ||||
|             goto Lb8 | ||||
|         L81: | ||||
|             r0.addItem() | ||||
|             goto Lb8 | ||||
|         L85: | ||||
|             boolean r15 = r15.equals(r2) | ||||
|             if (r15 == 0) goto Lb8 | ||||
|             r6 = 1 | ||||
|             goto Lb8 | ||||
|         L8d: | ||||
|             if (r7 == 0) goto L90 | ||||
|             goto Lb8 | ||||
|         L90: | ||||
|             java.lang.String r15 = r13.getName() | ||||
|             boolean r10 = r15.equals(r10) | ||||
|             if (r10 == 0) goto L9e | ||||
|             r0.readGroup(r14) | ||||
|             goto Lb8 | ||||
|         L9e: | ||||
|             boolean r9 = r15.equals(r9) | ||||
|             if (r9 == 0) goto La8 | ||||
|             r0.readItem(r14) | ||||
|             goto Lb8 | ||||
|         La8: | ||||
|             boolean r9 = r15.equals(r2) | ||||
|             if (r9 == 0) goto Lb6 | ||||
|             android.view.SubMenu r15 = r0.addSubMenuItem() | ||||
|             r12.parseMenu(r13, r14, r15) | ||||
|             goto Lb8 | ||||
|         Lb6: | ||||
|             r8 = r15 | ||||
|             r7 = 1 | ||||
|         Lb8: | ||||
|             int r15 = r13.next() | ||||
|             goto L3d | ||||
|         Lbd: | ||||
|             java.lang.RuntimeException r13 = new java.lang.RuntimeException | ||||
|             java.lang.String r14 = "Unexpected end of document" | ||||
|             r13.<init>(r14) | ||||
|             throw r13 | ||||
|         Lc5: | ||||
|             return | ||||
|         */ | ||||
|         throw new UnsupportedOperationException("Method not decompiled: androidx.appcompat.view.SupportMenuInflater.parseMenu(org.xmlpull.v1.XmlPullParser, android.util.AttributeSet, android.view.Menu):void"); | ||||
|     } | ||||
|  | ||||
|     Object getRealOwner() { | ||||
|         if (this.mRealOwner == null) { | ||||
|             this.mRealOwner = findRealOwner(this.mContext); | ||||
|         } | ||||
|         return this.mRealOwner; | ||||
|     } | ||||
|  | ||||
|     private Object findRealOwner(Object obj) { | ||||
|         return (!(obj instanceof Activity) && (obj instanceof ContextWrapper)) ? findRealOwner(((ContextWrapper) obj).getBaseContext()) : obj; | ||||
|     } | ||||
|  | ||||
|     private static class InflatedOnMenuItemClickListener implements MenuItem.OnMenuItemClickListener { | ||||
|         private static final Class<?>[] PARAM_TYPES = {MenuItem.class}; | ||||
|         private Method mMethod; | ||||
|         private Object mRealOwner; | ||||
|  | ||||
|         public InflatedOnMenuItemClickListener(Object obj, String str) { | ||||
|             this.mRealOwner = obj; | ||||
|             Class<?> cls = obj.getClass(); | ||||
|             try { | ||||
|                 this.mMethod = cls.getMethod(str, PARAM_TYPES); | ||||
|             } catch (Exception e) { | ||||
|                 InflateException inflateException = new InflateException("Couldn't resolve menu item onClick handler " + str + " in class " + cls.getName()); | ||||
|                 inflateException.initCause(e); | ||||
|                 throw inflateException; | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         @Override // android.view.MenuItem.OnMenuItemClickListener | ||||
|         public boolean onMenuItemClick(MenuItem menuItem) { | ||||
|             try { | ||||
|                 if (this.mMethod.getReturnType() == Boolean.TYPE) { | ||||
|                     return ((Boolean) this.mMethod.invoke(this.mRealOwner, menuItem)).booleanValue(); | ||||
|                 } | ||||
|                 this.mMethod.invoke(this.mRealOwner, menuItem); | ||||
|                 return true; | ||||
|             } catch (Exception e) { | ||||
|                 throw new RuntimeException(e); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     private class MenuState { | ||||
|         private static final int defaultGroupId = 0; | ||||
|         private static final int defaultItemCategory = 0; | ||||
|         private static final int defaultItemCheckable = 0; | ||||
|         private static final boolean defaultItemChecked = false; | ||||
|         private static final boolean defaultItemEnabled = true; | ||||
|         private static final int defaultItemId = 0; | ||||
|         private static final int defaultItemOrder = 0; | ||||
|         private static final boolean defaultItemVisible = true; | ||||
|         private int groupCategory; | ||||
|         private int groupCheckable; | ||||
|         private boolean groupEnabled; | ||||
|         private int groupId; | ||||
|         private int groupOrder; | ||||
|         private boolean groupVisible; | ||||
|         ActionProvider itemActionProvider; | ||||
|         private String itemActionProviderClassName; | ||||
|         private String itemActionViewClassName; | ||||
|         private int itemActionViewLayout; | ||||
|         private boolean itemAdded; | ||||
|         private int itemAlphabeticModifiers; | ||||
|         private char itemAlphabeticShortcut; | ||||
|         private int itemCategoryOrder; | ||||
|         private int itemCheckable; | ||||
|         private boolean itemChecked; | ||||
|         private CharSequence itemContentDescription; | ||||
|         private boolean itemEnabled; | ||||
|         private int itemIconResId; | ||||
|         private ColorStateList itemIconTintList = null; | ||||
|         private PorterDuff.Mode itemIconTintMode = null; | ||||
|         private int itemId; | ||||
|         private String itemListenerMethodName; | ||||
|         private int itemNumericModifiers; | ||||
|         private char itemNumericShortcut; | ||||
|         private int itemShowAsAction; | ||||
|         private CharSequence itemTitle; | ||||
|         private CharSequence itemTitleCondensed; | ||||
|         private CharSequence itemTooltipText; | ||||
|         private boolean itemVisible; | ||||
|         private Menu menu; | ||||
|  | ||||
|         public boolean hasAddedItem() { | ||||
|             return this.itemAdded; | ||||
|         } | ||||
|  | ||||
|         public void resetGroup() { | ||||
|             this.groupId = 0; | ||||
|             this.groupCategory = 0; | ||||
|             this.groupOrder = 0; | ||||
|             this.groupCheckable = 0; | ||||
|             this.groupVisible = true; | ||||
|             this.groupEnabled = true; | ||||
|         } | ||||
|  | ||||
|         public MenuState(Menu menu) { | ||||
|             this.menu = menu; | ||||
|             resetGroup(); | ||||
|         } | ||||
|  | ||||
|         public void readGroup(AttributeSet attributeSet) { | ||||
|             TypedArray obtainStyledAttributes = SupportMenuInflater.this.mContext.obtainStyledAttributes(attributeSet, R.styleable.MenuGroup); | ||||
|             this.groupId = obtainStyledAttributes.getResourceId(R.styleable.MenuGroup_android_id, 0); | ||||
|             this.groupCategory = obtainStyledAttributes.getInt(R.styleable.MenuGroup_android_menuCategory, 0); | ||||
|             this.groupOrder = obtainStyledAttributes.getInt(R.styleable.MenuGroup_android_orderInCategory, 0); | ||||
|             this.groupCheckable = obtainStyledAttributes.getInt(R.styleable.MenuGroup_android_checkableBehavior, 0); | ||||
|             this.groupVisible = obtainStyledAttributes.getBoolean(R.styleable.MenuGroup_android_visible, true); | ||||
|             this.groupEnabled = obtainStyledAttributes.getBoolean(R.styleable.MenuGroup_android_enabled, true); | ||||
|             obtainStyledAttributes.recycle(); | ||||
|         } | ||||
|  | ||||
|         public void readItem(AttributeSet attributeSet) { | ||||
|             TintTypedArray obtainStyledAttributes = TintTypedArray.obtainStyledAttributes(SupportMenuInflater.this.mContext, attributeSet, R.styleable.MenuItem); | ||||
|             this.itemId = obtainStyledAttributes.getResourceId(R.styleable.MenuItem_android_id, 0); | ||||
|             this.itemCategoryOrder = (obtainStyledAttributes.getInt(R.styleable.MenuItem_android_menuCategory, this.groupCategory) & SupportMenu.CATEGORY_MASK) | (obtainStyledAttributes.getInt(R.styleable.MenuItem_android_orderInCategory, this.groupOrder) & SupportMenu.USER_MASK); | ||||
|             this.itemTitle = obtainStyledAttributes.getText(R.styleable.MenuItem_android_title); | ||||
|             this.itemTitleCondensed = obtainStyledAttributes.getText(R.styleable.MenuItem_android_titleCondensed); | ||||
|             this.itemIconResId = obtainStyledAttributes.getResourceId(R.styleable.MenuItem_android_icon, 0); | ||||
|             this.itemAlphabeticShortcut = getShortcut(obtainStyledAttributes.getString(R.styleable.MenuItem_android_alphabeticShortcut)); | ||||
|             this.itemAlphabeticModifiers = obtainStyledAttributes.getInt(R.styleable.MenuItem_alphabeticModifiers, 4096); | ||||
|             this.itemNumericShortcut = getShortcut(obtainStyledAttributes.getString(R.styleable.MenuItem_android_numericShortcut)); | ||||
|             this.itemNumericModifiers = obtainStyledAttributes.getInt(R.styleable.MenuItem_numericModifiers, 4096); | ||||
|             if (obtainStyledAttributes.hasValue(R.styleable.MenuItem_android_checkable)) { | ||||
|                 this.itemCheckable = obtainStyledAttributes.getBoolean(R.styleable.MenuItem_android_checkable, false) ? 1 : 0; | ||||
|             } else { | ||||
|                 this.itemCheckable = this.groupCheckable; | ||||
|             } | ||||
|             this.itemChecked = obtainStyledAttributes.getBoolean(R.styleable.MenuItem_android_checked, false); | ||||
|             this.itemVisible = obtainStyledAttributes.getBoolean(R.styleable.MenuItem_android_visible, this.groupVisible); | ||||
|             this.itemEnabled = obtainStyledAttributes.getBoolean(R.styleable.MenuItem_android_enabled, this.groupEnabled); | ||||
|             this.itemShowAsAction = obtainStyledAttributes.getInt(R.styleable.MenuItem_showAsAction, -1); | ||||
|             this.itemListenerMethodName = obtainStyledAttributes.getString(R.styleable.MenuItem_android_onClick); | ||||
|             this.itemActionViewLayout = obtainStyledAttributes.getResourceId(R.styleable.MenuItem_actionLayout, 0); | ||||
|             this.itemActionViewClassName = obtainStyledAttributes.getString(R.styleable.MenuItem_actionViewClass); | ||||
|             String string = obtainStyledAttributes.getString(R.styleable.MenuItem_actionProviderClass); | ||||
|             this.itemActionProviderClassName = string; | ||||
|             boolean z = string != null; | ||||
|             if (z && this.itemActionViewLayout == 0 && this.itemActionViewClassName == null) { | ||||
|                 this.itemActionProvider = (ActionProvider) newInstance(string, SupportMenuInflater.ACTION_PROVIDER_CONSTRUCTOR_SIGNATURE, SupportMenuInflater.this.mActionProviderConstructorArguments); | ||||
|             } else { | ||||
|                 if (z) { | ||||
|                     Log.w(SupportMenuInflater.LOG_TAG, "Ignoring attribute 'actionProviderClass'. Action view already specified."); | ||||
|                 } | ||||
|                 this.itemActionProvider = null; | ||||
|             } | ||||
|             this.itemContentDescription = obtainStyledAttributes.getText(R.styleable.MenuItem_contentDescription); | ||||
|             this.itemTooltipText = obtainStyledAttributes.getText(R.styleable.MenuItem_tooltipText); | ||||
|             if (obtainStyledAttributes.hasValue(R.styleable.MenuItem_iconTintMode)) { | ||||
|                 this.itemIconTintMode = DrawableUtils.parseTintMode(obtainStyledAttributes.getInt(R.styleable.MenuItem_iconTintMode, -1), this.itemIconTintMode); | ||||
|             } else { | ||||
|                 this.itemIconTintMode = null; | ||||
|             } | ||||
|             if (obtainStyledAttributes.hasValue(R.styleable.MenuItem_iconTint)) { | ||||
|                 this.itemIconTintList = obtainStyledAttributes.getColorStateList(R.styleable.MenuItem_iconTint); | ||||
|             } else { | ||||
|                 this.itemIconTintList = null; | ||||
|             } | ||||
|             obtainStyledAttributes.recycle(); | ||||
|             this.itemAdded = false; | ||||
|         } | ||||
|  | ||||
|         private char getShortcut(String str) { | ||||
|             if (str == null) { | ||||
|                 return (char) 0; | ||||
|             } | ||||
|             return str.charAt(0); | ||||
|         } | ||||
|  | ||||
|         private void setItem(MenuItem menuItem) { | ||||
|             boolean z = false; | ||||
|             menuItem.setChecked(this.itemChecked).setVisible(this.itemVisible).setEnabled(this.itemEnabled).setCheckable(this.itemCheckable >= 1).setTitleCondensed(this.itemTitleCondensed).setIcon(this.itemIconResId); | ||||
|             int i = this.itemShowAsAction; | ||||
|             if (i >= 0) { | ||||
|                 menuItem.setShowAsAction(i); | ||||
|             } | ||||
|             if (this.itemListenerMethodName != null) { | ||||
|                 if (SupportMenuInflater.this.mContext.isRestricted()) { | ||||
|                     throw new IllegalStateException("The android:onClick attribute cannot be used within a restricted context"); | ||||
|                 } | ||||
|                 menuItem.setOnMenuItemClickListener(new InflatedOnMenuItemClickListener(SupportMenuInflater.this.getRealOwner(), this.itemListenerMethodName)); | ||||
|             } | ||||
|             if (this.itemCheckable >= 2) { | ||||
|                 if (menuItem instanceof MenuItemImpl) { | ||||
|                     ((MenuItemImpl) menuItem).setExclusiveCheckable(true); | ||||
|                 } else if (menuItem instanceof MenuItemWrapperICS) { | ||||
|                     ((MenuItemWrapperICS) menuItem).setExclusiveCheckable(true); | ||||
|                 } | ||||
|             } | ||||
|             String str = this.itemActionViewClassName; | ||||
|             if (str != null) { | ||||
|                 menuItem.setActionView((View) newInstance(str, SupportMenuInflater.ACTION_VIEW_CONSTRUCTOR_SIGNATURE, SupportMenuInflater.this.mActionViewConstructorArguments)); | ||||
|                 z = true; | ||||
|             } | ||||
|             int i2 = this.itemActionViewLayout; | ||||
|             if (i2 > 0) { | ||||
|                 if (!z) { | ||||
|                     menuItem.setActionView(i2); | ||||
|                 } else { | ||||
|                     Log.w(SupportMenuInflater.LOG_TAG, "Ignoring attribute 'itemActionViewLayout'. Action view already specified."); | ||||
|                 } | ||||
|             } | ||||
|             ActionProvider actionProvider = this.itemActionProvider; | ||||
|             if (actionProvider != null) { | ||||
|                 MenuItemCompat.setActionProvider(menuItem, actionProvider); | ||||
|             } | ||||
|             MenuItemCompat.setContentDescription(menuItem, this.itemContentDescription); | ||||
|             MenuItemCompat.setTooltipText(menuItem, this.itemTooltipText); | ||||
|             MenuItemCompat.setAlphabeticShortcut(menuItem, this.itemAlphabeticShortcut, this.itemAlphabeticModifiers); | ||||
|             MenuItemCompat.setNumericShortcut(menuItem, this.itemNumericShortcut, this.itemNumericModifiers); | ||||
|             PorterDuff.Mode mode = this.itemIconTintMode; | ||||
|             if (mode != null) { | ||||
|                 MenuItemCompat.setIconTintMode(menuItem, mode); | ||||
|             } | ||||
|             ColorStateList colorStateList = this.itemIconTintList; | ||||
|             if (colorStateList != null) { | ||||
|                 MenuItemCompat.setIconTintList(menuItem, colorStateList); | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         public void addItem() { | ||||
|             this.itemAdded = true; | ||||
|             setItem(this.menu.add(this.groupId, this.itemId, this.itemCategoryOrder, this.itemTitle)); | ||||
|         } | ||||
|  | ||||
|         public SubMenu addSubMenuItem() { | ||||
|             this.itemAdded = true; | ||||
|             SubMenu addSubMenu = this.menu.addSubMenu(this.groupId, this.itemId, this.itemCategoryOrder, this.itemTitle); | ||||
|             setItem(addSubMenu.getItem()); | ||||
|             return addSubMenu; | ||||
|         } | ||||
|  | ||||
|         private <T> T newInstance(String str, Class<?>[] clsArr, Object[] objArr) { | ||||
|             try { | ||||
|                 Constructor<?> constructor = Class.forName(str, false, SupportMenuInflater.this.mContext.getClassLoader()).getConstructor(clsArr); | ||||
|                 constructor.setAccessible(true); | ||||
|                 return (T) constructor.newInstance(objArr); | ||||
|             } catch (Exception e) { | ||||
|                 Log.w(SupportMenuInflater.LOG_TAG, "Cannot instantiate class: " + str, e); | ||||
|                 return null; | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user