Rabbit-R1/android (non root)/java/sources/com/google/android/material/internal/NavigationMenuPresenter.java
2024-05-21 17:08:36 -04:00

830 lines
33 KiB
Java

package com.google.android.material.internal;
import android.content.Context;
import android.content.res.ColorStateList;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.RippleDrawable;
import android.os.Bundle;
import android.os.Parcelable;
import android.util.SparseArray;
import android.view.LayoutInflater;
import android.view.SubMenu;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.appcompat.view.menu.MenuBuilder;
import androidx.appcompat.view.menu.MenuItemImpl;
import androidx.appcompat.view.menu.MenuPresenter;
import androidx.appcompat.view.menu.MenuView;
import androidx.appcompat.view.menu.SubMenuBuilder;
import androidx.core.view.AccessibilityDelegateCompat;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
import androidx.core.view.accessibility.AccessibilityNodeInfoCompat;
import androidx.core.widget.TextViewCompat;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.RecyclerViewAccessibilityDelegate;
import com.google.android.material.R;
import java.util.ArrayList;
/* loaded from: classes2.dex */
public class NavigationMenuPresenter implements MenuPresenter {
public static final int NO_TEXT_APPEARANCE_SET = 0;
private static final String STATE_ADAPTER = "android:menu:adapter";
private static final String STATE_HEADER = "android:menu:header";
private static final String STATE_HIERARCHY = "android:menu:list";
NavigationMenuAdapter adapter;
private MenuPresenter.Callback callback;
int dividerInsetEnd;
int dividerInsetStart;
boolean hasCustomItemIconSize;
LinearLayout headerLayout;
ColorStateList iconTintList;
private int id;
Drawable itemBackground;
RippleDrawable itemForeground;
int itemHorizontalPadding;
int itemIconPadding;
int itemIconSize;
private int itemMaxLines;
int itemVerticalPadding;
LayoutInflater layoutInflater;
MenuBuilder menu;
private NavigationMenuView menuView;
int paddingSeparator;
private int paddingTopDefault;
ColorStateList subheaderColor;
int subheaderInsetEnd;
int subheaderInsetStart;
ColorStateList textColor;
int subheaderTextAppearance = 0;
int textAppearance = 0;
boolean textAppearanceActiveBoldEnabled = true;
boolean isBehindStatusBar = true;
private int overScrollMode = -1;
final View.OnClickListener onClickListener = new View.OnClickListener() { // from class: com.google.android.material.internal.NavigationMenuPresenter.1
@Override // android.view.View.OnClickListener
public void onClick(View view) {
boolean z = true;
NavigationMenuPresenter.this.setUpdateSuspended(true);
MenuItemImpl itemData = ((NavigationMenuItemView) view).getItemData();
boolean performItemAction = NavigationMenuPresenter.this.menu.performItemAction(itemData, NavigationMenuPresenter.this, 0);
if (itemData != null && itemData.isCheckable() && performItemAction) {
NavigationMenuPresenter.this.adapter.setCheckedItem(itemData);
} else {
z = false;
}
NavigationMenuPresenter.this.setUpdateSuspended(false);
if (z) {
NavigationMenuPresenter.this.updateMenuView(false);
}
}
};
/* JADX INFO: Access modifiers changed from: private */
/* loaded from: classes2.dex */
public interface NavigationMenuItem {
}
@Override // androidx.appcompat.view.menu.MenuPresenter
public boolean collapseItemActionView(MenuBuilder menuBuilder, MenuItemImpl menuItemImpl) {
return false;
}
@Override // androidx.appcompat.view.menu.MenuPresenter
public boolean expandItemActionView(MenuBuilder menuBuilder, MenuItemImpl menuItemImpl) {
return false;
}
@Override // androidx.appcompat.view.menu.MenuPresenter
public boolean flagActionItems() {
return false;
}
public int getDividerInsetEnd() {
return this.dividerInsetEnd;
}
public int getDividerInsetStart() {
return this.dividerInsetStart;
}
@Override // androidx.appcompat.view.menu.MenuPresenter
public int getId() {
return this.id;
}
public Drawable getItemBackground() {
return this.itemBackground;
}
public int getItemHorizontalPadding() {
return this.itemHorizontalPadding;
}
public int getItemIconPadding() {
return this.itemIconPadding;
}
public int getItemMaxLines() {
return this.itemMaxLines;
}
public ColorStateList getItemTextColor() {
return this.textColor;
}
public ColorStateList getItemTintList() {
return this.iconTintList;
}
public int getItemVerticalPadding() {
return this.itemVerticalPadding;
}
public int getSubheaderInsetEnd() {
return this.subheaderInsetEnd;
}
public int getSubheaderInsetStart() {
return this.subheaderInsetStart;
}
public boolean isBehindStatusBar() {
return this.isBehindStatusBar;
}
@Override // androidx.appcompat.view.menu.MenuPresenter
public boolean onSubMenuSelected(SubMenuBuilder subMenuBuilder) {
return false;
}
@Override // androidx.appcompat.view.menu.MenuPresenter
public void setCallback(MenuPresenter.Callback callback) {
this.callback = callback;
}
public void setId(int i) {
this.id = i;
}
@Override // androidx.appcompat.view.menu.MenuPresenter
public void initForMenu(Context context, MenuBuilder menuBuilder) {
this.layoutInflater = LayoutInflater.from(context);
this.menu = menuBuilder;
this.paddingSeparator = context.getResources().getDimensionPixelOffset(R.dimen.design_navigation_separator_vertical_padding);
}
@Override // androidx.appcompat.view.menu.MenuPresenter
public MenuView getMenuView(ViewGroup viewGroup) {
if (this.menuView == null) {
NavigationMenuView navigationMenuView = (NavigationMenuView) this.layoutInflater.inflate(R.layout.design_navigation_menu, viewGroup, false);
this.menuView = navigationMenuView;
navigationMenuView.setAccessibilityDelegateCompat(new NavigationMenuViewAccessibilityDelegate(this.menuView));
if (this.adapter == null) {
this.adapter = new NavigationMenuAdapter();
}
int i = this.overScrollMode;
if (i != -1) {
this.menuView.setOverScrollMode(i);
}
LinearLayout linearLayout = (LinearLayout) this.layoutInflater.inflate(R.layout.design_navigation_item_header, (ViewGroup) this.menuView, false);
this.headerLayout = linearLayout;
ViewCompat.setImportantForAccessibility(linearLayout, 2);
this.menuView.setAdapter(this.adapter);
}
return this.menuView;
}
@Override // androidx.appcompat.view.menu.MenuPresenter
public void updateMenuView(boolean z) {
NavigationMenuAdapter navigationMenuAdapter = this.adapter;
if (navigationMenuAdapter != null) {
navigationMenuAdapter.update();
}
}
@Override // androidx.appcompat.view.menu.MenuPresenter
public void onCloseMenu(MenuBuilder menuBuilder, boolean z) {
MenuPresenter.Callback callback = this.callback;
if (callback != null) {
callback.onCloseMenu(menuBuilder, z);
}
}
@Override // androidx.appcompat.view.menu.MenuPresenter
public Parcelable onSaveInstanceState() {
Bundle bundle = new Bundle();
if (this.menuView != null) {
SparseArray<? extends Parcelable> sparseArray = new SparseArray<>();
this.menuView.saveHierarchyState(sparseArray);
bundle.putSparseParcelableArray("android:menu:list", sparseArray);
}
NavigationMenuAdapter navigationMenuAdapter = this.adapter;
if (navigationMenuAdapter != null) {
bundle.putBundle(STATE_ADAPTER, navigationMenuAdapter.createInstanceState());
}
if (this.headerLayout != null) {
SparseArray<? extends Parcelable> sparseArray2 = new SparseArray<>();
this.headerLayout.saveHierarchyState(sparseArray2);
bundle.putSparseParcelableArray(STATE_HEADER, sparseArray2);
}
return bundle;
}
@Override // androidx.appcompat.view.menu.MenuPresenter
public void onRestoreInstanceState(Parcelable parcelable) {
if (parcelable instanceof Bundle) {
Bundle bundle = (Bundle) parcelable;
SparseArray sparseParcelableArray = bundle.getSparseParcelableArray("android:menu:list");
if (sparseParcelableArray != null) {
this.menuView.restoreHierarchyState(sparseParcelableArray);
}
Bundle bundle2 = bundle.getBundle(STATE_ADAPTER);
if (bundle2 != null) {
this.adapter.restoreInstanceState(bundle2);
}
SparseArray sparseParcelableArray2 = bundle.getSparseParcelableArray(STATE_HEADER);
if (sparseParcelableArray2 != null) {
this.headerLayout.restoreHierarchyState(sparseParcelableArray2);
}
}
}
public void setCheckedItem(MenuItemImpl menuItemImpl) {
this.adapter.setCheckedItem(menuItemImpl);
}
public MenuItemImpl getCheckedItem() {
return this.adapter.getCheckedItem();
}
public View inflateHeaderView(int i) {
View inflate = this.layoutInflater.inflate(i, (ViewGroup) this.headerLayout, false);
addHeaderView(inflate);
return inflate;
}
public void addHeaderView(View view) {
this.headerLayout.addView(view);
NavigationMenuView navigationMenuView = this.menuView;
navigationMenuView.setPadding(0, 0, 0, navigationMenuView.getPaddingBottom());
}
public void removeHeaderView(View view) {
this.headerLayout.removeView(view);
if (hasHeader()) {
return;
}
NavigationMenuView navigationMenuView = this.menuView;
navigationMenuView.setPadding(0, this.paddingTopDefault, 0, navigationMenuView.getPaddingBottom());
}
public int getHeaderCount() {
return this.headerLayout.getChildCount();
}
private boolean hasHeader() {
return getHeaderCount() > 0;
}
public View getHeaderView(int i) {
return this.headerLayout.getChildAt(i);
}
public void setSubheaderColor(ColorStateList colorStateList) {
this.subheaderColor = colorStateList;
updateMenuView(false);
}
public void setSubheaderTextAppearance(int i) {
this.subheaderTextAppearance = i;
updateMenuView(false);
}
public void setItemIconTintList(ColorStateList colorStateList) {
this.iconTintList = colorStateList;
updateMenuView(false);
}
public void setItemTextColor(ColorStateList colorStateList) {
this.textColor = colorStateList;
updateMenuView(false);
}
public void setItemTextAppearance(int i) {
this.textAppearance = i;
updateMenuView(false);
}
public void setItemTextAppearanceActiveBoldEnabled(boolean z) {
this.textAppearanceActiveBoldEnabled = z;
updateMenuView(false);
}
public void setItemBackground(Drawable drawable) {
this.itemBackground = drawable;
updateMenuView(false);
}
public void setItemForeground(RippleDrawable rippleDrawable) {
this.itemForeground = rippleDrawable;
updateMenuView(false);
}
public void setItemHorizontalPadding(int i) {
this.itemHorizontalPadding = i;
updateMenuView(false);
}
public void setItemVerticalPadding(int i) {
this.itemVerticalPadding = i;
updateMenuView(false);
}
public void setDividerInsetStart(int i) {
this.dividerInsetStart = i;
updateMenuView(false);
}
public void setDividerInsetEnd(int i) {
this.dividerInsetEnd = i;
updateMenuView(false);
}
public void setSubheaderInsetStart(int i) {
this.subheaderInsetStart = i;
updateMenuView(false);
}
public void setSubheaderInsetEnd(int i) {
this.subheaderInsetEnd = i;
updateMenuView(false);
}
public void setItemIconPadding(int i) {
this.itemIconPadding = i;
updateMenuView(false);
}
public void setItemMaxLines(int i) {
this.itemMaxLines = i;
updateMenuView(false);
}
public void setItemIconSize(int i) {
if (this.itemIconSize != i) {
this.itemIconSize = i;
this.hasCustomItemIconSize = true;
updateMenuView(false);
}
}
public void setUpdateSuspended(boolean z) {
NavigationMenuAdapter navigationMenuAdapter = this.adapter;
if (navigationMenuAdapter != null) {
navigationMenuAdapter.setUpdateSuspended(z);
}
}
public void setBehindStatusBar(boolean z) {
if (this.isBehindStatusBar != z) {
this.isBehindStatusBar = z;
updateTopPadding();
}
}
private void updateTopPadding() {
int i = (hasHeader() || !this.isBehindStatusBar) ? 0 : this.paddingTopDefault;
NavigationMenuView navigationMenuView = this.menuView;
navigationMenuView.setPadding(0, i, 0, navigationMenuView.getPaddingBottom());
}
public void dispatchApplyWindowInsets(WindowInsetsCompat windowInsetsCompat) {
int systemWindowInsetTop = windowInsetsCompat.getSystemWindowInsetTop();
if (this.paddingTopDefault != systemWindowInsetTop) {
this.paddingTopDefault = systemWindowInsetTop;
updateTopPadding();
}
NavigationMenuView navigationMenuView = this.menuView;
navigationMenuView.setPadding(0, navigationMenuView.getPaddingTop(), 0, windowInsetsCompat.getSystemWindowInsetBottom());
ViewCompat.dispatchApplyWindowInsets(this.headerLayout, windowInsetsCompat);
}
public void setOverScrollMode(int i) {
this.overScrollMode = i;
NavigationMenuView navigationMenuView = this.menuView;
if (navigationMenuView != null) {
navigationMenuView.setOverScrollMode(i);
}
}
/* loaded from: classes2.dex */
private static abstract class ViewHolder extends RecyclerView.ViewHolder {
public ViewHolder(View view) {
super(view);
}
}
/* JADX INFO: Access modifiers changed from: private */
/* loaded from: classes2.dex */
public static class NormalViewHolder extends ViewHolder {
public NormalViewHolder(LayoutInflater layoutInflater, ViewGroup viewGroup, View.OnClickListener onClickListener) {
super(layoutInflater.inflate(R.layout.design_navigation_item, viewGroup, false));
this.itemView.setOnClickListener(onClickListener);
}
}
/* JADX INFO: Access modifiers changed from: private */
/* loaded from: classes2.dex */
public static class SubheaderViewHolder extends ViewHolder {
public SubheaderViewHolder(LayoutInflater layoutInflater, ViewGroup viewGroup) {
super(layoutInflater.inflate(R.layout.design_navigation_item_subheader, viewGroup, false));
}
}
/* JADX INFO: Access modifiers changed from: private */
/* loaded from: classes2.dex */
public static class SeparatorViewHolder extends ViewHolder {
public SeparatorViewHolder(LayoutInflater layoutInflater, ViewGroup viewGroup) {
super(layoutInflater.inflate(R.layout.design_navigation_item_separator, viewGroup, false));
}
}
/* JADX INFO: Access modifiers changed from: private */
/* loaded from: classes2.dex */
public static class HeaderViewHolder extends ViewHolder {
public HeaderViewHolder(View view) {
super(view);
}
}
/* JADX INFO: Access modifiers changed from: private */
/* loaded from: classes2.dex */
public class NavigationMenuAdapter extends RecyclerView.Adapter<ViewHolder> {
private static final String STATE_ACTION_VIEWS = "android:menu:action_views";
private static final String STATE_CHECKED_ITEM = "android:menu:checked";
private static final int VIEW_TYPE_HEADER = 3;
private static final int VIEW_TYPE_NORMAL = 0;
private static final int VIEW_TYPE_SEPARATOR = 2;
private static final int VIEW_TYPE_SUBHEADER = 1;
private MenuItemImpl checkedItem;
private final ArrayList<NavigationMenuItem> items = new ArrayList<>();
private boolean updateSuspended;
public MenuItemImpl getCheckedItem() {
return this.checkedItem;
}
@Override // androidx.recyclerview.widget.RecyclerView.Adapter
public long getItemId(int i) {
return i;
}
public void setUpdateSuspended(boolean z) {
this.updateSuspended = z;
}
NavigationMenuAdapter() {
prepareMenuItems();
}
@Override // androidx.recyclerview.widget.RecyclerView.Adapter
public int getItemCount() {
return this.items.size();
}
@Override // androidx.recyclerview.widget.RecyclerView.Adapter
public int getItemViewType(int i) {
NavigationMenuItem navigationMenuItem = this.items.get(i);
if (navigationMenuItem instanceof NavigationMenuSeparatorItem) {
return 2;
}
if (navigationMenuItem instanceof NavigationMenuHeaderItem) {
return 3;
}
if (navigationMenuItem instanceof NavigationMenuTextItem) {
return ((NavigationMenuTextItem) navigationMenuItem).getMenuItem().hasSubMenu() ? 1 : 0;
}
throw new RuntimeException("Unknown item type.");
}
@Override // androidx.recyclerview.widget.RecyclerView.Adapter
public ViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
if (i == 0) {
return new NormalViewHolder(NavigationMenuPresenter.this.layoutInflater, viewGroup, NavigationMenuPresenter.this.onClickListener);
}
if (i == 1) {
return new SubheaderViewHolder(NavigationMenuPresenter.this.layoutInflater, viewGroup);
}
if (i == 2) {
return new SeparatorViewHolder(NavigationMenuPresenter.this.layoutInflater, viewGroup);
}
if (i != 3) {
return null;
}
return new HeaderViewHolder(NavigationMenuPresenter.this.headerLayout);
}
@Override // androidx.recyclerview.widget.RecyclerView.Adapter
public void onBindViewHolder(ViewHolder viewHolder, int i) {
int itemViewType = getItemViewType(i);
if (itemViewType != 0) {
if (itemViewType != 1) {
if (itemViewType != 2) {
return;
}
NavigationMenuSeparatorItem navigationMenuSeparatorItem = (NavigationMenuSeparatorItem) this.items.get(i);
viewHolder.itemView.setPadding(NavigationMenuPresenter.this.dividerInsetStart, navigationMenuSeparatorItem.getPaddingTop(), NavigationMenuPresenter.this.dividerInsetEnd, navigationMenuSeparatorItem.getPaddingBottom());
return;
}
TextView textView = (TextView) viewHolder.itemView;
textView.setText(((NavigationMenuTextItem) this.items.get(i)).getMenuItem().getTitle());
TextViewCompat.setTextAppearance(textView, NavigationMenuPresenter.this.subheaderTextAppearance);
textView.setPadding(NavigationMenuPresenter.this.subheaderInsetStart, textView.getPaddingTop(), NavigationMenuPresenter.this.subheaderInsetEnd, textView.getPaddingBottom());
if (NavigationMenuPresenter.this.subheaderColor != null) {
textView.setTextColor(NavigationMenuPresenter.this.subheaderColor);
}
setAccessibilityDelegate(textView, i, true);
return;
}
NavigationMenuItemView navigationMenuItemView = (NavigationMenuItemView) viewHolder.itemView;
navigationMenuItemView.setIconTintList(NavigationMenuPresenter.this.iconTintList);
navigationMenuItemView.setTextAppearance(NavigationMenuPresenter.this.textAppearance);
if (NavigationMenuPresenter.this.textColor != null) {
navigationMenuItemView.setTextColor(NavigationMenuPresenter.this.textColor);
}
ViewCompat.setBackground(navigationMenuItemView, NavigationMenuPresenter.this.itemBackground != null ? NavigationMenuPresenter.this.itemBackground.getConstantState().newDrawable() : null);
if (NavigationMenuPresenter.this.itemForeground != null) {
navigationMenuItemView.setForeground(NavigationMenuPresenter.this.itemForeground.getConstantState().newDrawable());
}
NavigationMenuTextItem navigationMenuTextItem = (NavigationMenuTextItem) this.items.get(i);
navigationMenuItemView.setNeedsEmptyIcon(navigationMenuTextItem.needsEmptyIcon);
navigationMenuItemView.setPadding(NavigationMenuPresenter.this.itemHorizontalPadding, NavigationMenuPresenter.this.itemVerticalPadding, NavigationMenuPresenter.this.itemHorizontalPadding, NavigationMenuPresenter.this.itemVerticalPadding);
navigationMenuItemView.setIconPadding(NavigationMenuPresenter.this.itemIconPadding);
if (NavigationMenuPresenter.this.hasCustomItemIconSize) {
navigationMenuItemView.setIconSize(NavigationMenuPresenter.this.itemIconSize);
}
navigationMenuItemView.setMaxLines(NavigationMenuPresenter.this.itemMaxLines);
navigationMenuItemView.initialize(navigationMenuTextItem.getMenuItem(), NavigationMenuPresenter.this.textAppearanceActiveBoldEnabled);
setAccessibilityDelegate(navigationMenuItemView, i, false);
}
private void setAccessibilityDelegate(View view, final int i, final boolean z) {
ViewCompat.setAccessibilityDelegate(view, new AccessibilityDelegateCompat() { // from class: com.google.android.material.internal.NavigationMenuPresenter.NavigationMenuAdapter.1
@Override // androidx.core.view.AccessibilityDelegateCompat
public void onInitializeAccessibilityNodeInfo(View view2, AccessibilityNodeInfoCompat accessibilityNodeInfoCompat) {
super.onInitializeAccessibilityNodeInfo(view2, accessibilityNodeInfoCompat);
accessibilityNodeInfoCompat.setCollectionItemInfo(AccessibilityNodeInfoCompat.CollectionItemInfoCompat.obtain(NavigationMenuAdapter.this.adjustItemPositionForA11yDelegate(i), 1, 1, 1, z, view2.isSelected()));
}
});
}
/* JADX INFO: Access modifiers changed from: private */
public int adjustItemPositionForA11yDelegate(int i) {
int i2 = i;
for (int i3 = 0; i3 < i; i3++) {
if (NavigationMenuPresenter.this.adapter.getItemViewType(i3) == 2 || NavigationMenuPresenter.this.adapter.getItemViewType(i3) == 3) {
i2--;
}
}
return i2;
}
@Override // androidx.recyclerview.widget.RecyclerView.Adapter
public void onViewRecycled(ViewHolder viewHolder) {
if (viewHolder instanceof NormalViewHolder) {
((NavigationMenuItemView) viewHolder.itemView).recycle();
}
}
public void update() {
prepareMenuItems();
notifyDataSetChanged();
}
private void prepareMenuItems() {
if (this.updateSuspended) {
return;
}
boolean z = true;
this.updateSuspended = true;
this.items.clear();
this.items.add(new NavigationMenuHeaderItem());
int size = NavigationMenuPresenter.this.menu.getVisibleItems().size();
int i = -1;
int i2 = 0;
boolean z2 = false;
int i3 = 0;
while (i2 < size) {
MenuItemImpl menuItemImpl = NavigationMenuPresenter.this.menu.getVisibleItems().get(i2);
if (menuItemImpl.isChecked()) {
setCheckedItem(menuItemImpl);
}
if (menuItemImpl.isCheckable()) {
menuItemImpl.setExclusiveCheckable(false);
}
if (menuItemImpl.hasSubMenu()) {
SubMenu subMenu = menuItemImpl.getSubMenu();
if (subMenu.hasVisibleItems()) {
if (i2 != 0) {
this.items.add(new NavigationMenuSeparatorItem(NavigationMenuPresenter.this.paddingSeparator, 0));
}
this.items.add(new NavigationMenuTextItem(menuItemImpl));
int size2 = this.items.size();
int size3 = subMenu.size();
int i4 = 0;
boolean z3 = false;
while (i4 < size3) {
MenuItemImpl menuItemImpl2 = (MenuItemImpl) subMenu.getItem(i4);
if (menuItemImpl2.isVisible()) {
if (!z3 && menuItemImpl2.getIcon() != null) {
z3 = z;
}
if (menuItemImpl2.isCheckable()) {
menuItemImpl2.setExclusiveCheckable(false);
}
if (menuItemImpl.isChecked()) {
setCheckedItem(menuItemImpl);
}
this.items.add(new NavigationMenuTextItem(menuItemImpl2));
}
i4++;
z = true;
}
if (z3) {
appendTransparentIconIfMissing(size2, this.items.size());
}
}
} else {
int groupId = menuItemImpl.getGroupId();
if (groupId != i) {
i3 = this.items.size();
z2 = menuItemImpl.getIcon() != null;
if (i2 != 0) {
i3++;
this.items.add(new NavigationMenuSeparatorItem(NavigationMenuPresenter.this.paddingSeparator, NavigationMenuPresenter.this.paddingSeparator));
}
} else if (!z2 && menuItemImpl.getIcon() != null) {
appendTransparentIconIfMissing(i3, this.items.size());
z2 = true;
}
NavigationMenuTextItem navigationMenuTextItem = new NavigationMenuTextItem(menuItemImpl);
navigationMenuTextItem.needsEmptyIcon = z2;
this.items.add(navigationMenuTextItem);
i = groupId;
}
i2++;
z = true;
}
this.updateSuspended = false;
}
private void appendTransparentIconIfMissing(int i, int i2) {
while (i < i2) {
((NavigationMenuTextItem) this.items.get(i)).needsEmptyIcon = true;
i++;
}
}
public void setCheckedItem(MenuItemImpl menuItemImpl) {
if (this.checkedItem == menuItemImpl || !menuItemImpl.isCheckable()) {
return;
}
MenuItemImpl menuItemImpl2 = this.checkedItem;
if (menuItemImpl2 != null) {
menuItemImpl2.setChecked(false);
}
this.checkedItem = menuItemImpl;
menuItemImpl.setChecked(true);
}
public Bundle createInstanceState() {
Bundle bundle = new Bundle();
MenuItemImpl menuItemImpl = this.checkedItem;
if (menuItemImpl != null) {
bundle.putInt(STATE_CHECKED_ITEM, menuItemImpl.getItemId());
}
SparseArray<? extends Parcelable> sparseArray = new SparseArray<>();
int size = this.items.size();
for (int i = 0; i < size; i++) {
NavigationMenuItem navigationMenuItem = this.items.get(i);
if (navigationMenuItem instanceof NavigationMenuTextItem) {
MenuItemImpl menuItem = ((NavigationMenuTextItem) navigationMenuItem).getMenuItem();
View actionView = menuItem != null ? menuItem.getActionView() : null;
if (actionView != null) {
ParcelableSparseArray parcelableSparseArray = new ParcelableSparseArray();
actionView.saveHierarchyState(parcelableSparseArray);
sparseArray.put(menuItem.getItemId(), parcelableSparseArray);
}
}
}
bundle.putSparseParcelableArray(STATE_ACTION_VIEWS, sparseArray);
return bundle;
}
public void restoreInstanceState(Bundle bundle) {
MenuItemImpl menuItem;
View actionView;
ParcelableSparseArray parcelableSparseArray;
MenuItemImpl menuItem2;
int i = bundle.getInt(STATE_CHECKED_ITEM, 0);
if (i != 0) {
this.updateSuspended = true;
int size = this.items.size();
int i2 = 0;
while (true) {
if (i2 >= size) {
break;
}
NavigationMenuItem navigationMenuItem = this.items.get(i2);
if ((navigationMenuItem instanceof NavigationMenuTextItem) && (menuItem2 = ((NavigationMenuTextItem) navigationMenuItem).getMenuItem()) != null && menuItem2.getItemId() == i) {
setCheckedItem(menuItem2);
break;
}
i2++;
}
this.updateSuspended = false;
prepareMenuItems();
}
SparseArray sparseParcelableArray = bundle.getSparseParcelableArray(STATE_ACTION_VIEWS);
if (sparseParcelableArray != null) {
int size2 = this.items.size();
for (int i3 = 0; i3 < size2; i3++) {
NavigationMenuItem navigationMenuItem2 = this.items.get(i3);
if ((navigationMenuItem2 instanceof NavigationMenuTextItem) && (menuItem = ((NavigationMenuTextItem) navigationMenuItem2).getMenuItem()) != null && (actionView = menuItem.getActionView()) != null && (parcelableSparseArray = (ParcelableSparseArray) sparseParcelableArray.get(menuItem.getItemId())) != null) {
actionView.restoreHierarchyState(parcelableSparseArray);
}
}
}
}
int getRowCount() {
int i = 0;
for (int i2 = 0; i2 < NavigationMenuPresenter.this.adapter.getItemCount(); i2++) {
int itemViewType = NavigationMenuPresenter.this.adapter.getItemViewType(i2);
if (itemViewType == 0 || itemViewType == 1) {
i++;
}
}
return i;
}
}
/* JADX INFO: Access modifiers changed from: private */
/* loaded from: classes2.dex */
public static class NavigationMenuTextItem implements NavigationMenuItem {
private final MenuItemImpl menuItem;
boolean needsEmptyIcon;
public MenuItemImpl getMenuItem() {
return this.menuItem;
}
NavigationMenuTextItem(MenuItemImpl menuItemImpl) {
this.menuItem = menuItemImpl;
}
}
/* JADX INFO: Access modifiers changed from: private */
/* loaded from: classes2.dex */
public static class NavigationMenuSeparatorItem implements NavigationMenuItem {
private final int paddingBottom;
private final int paddingTop;
public int getPaddingBottom() {
return this.paddingBottom;
}
public int getPaddingTop() {
return this.paddingTop;
}
public NavigationMenuSeparatorItem(int i, int i2) {
this.paddingTop = i;
this.paddingBottom = i2;
}
}
/* JADX INFO: Access modifiers changed from: private */
/* loaded from: classes2.dex */
public static class NavigationMenuHeaderItem implements NavigationMenuItem {
NavigationMenuHeaderItem() {
}
}
/* JADX INFO: Access modifiers changed from: private */
/* loaded from: classes2.dex */
public class NavigationMenuViewAccessibilityDelegate extends RecyclerViewAccessibilityDelegate {
NavigationMenuViewAccessibilityDelegate(RecyclerView recyclerView) {
super(recyclerView);
}
@Override // androidx.recyclerview.widget.RecyclerViewAccessibilityDelegate, androidx.core.view.AccessibilityDelegateCompat
public void onInitializeAccessibilityNodeInfo(View view, AccessibilityNodeInfoCompat accessibilityNodeInfoCompat) {
super.onInitializeAccessibilityNodeInfo(view, accessibilityNodeInfoCompat);
accessibilityNodeInfoCompat.setCollectionInfo(AccessibilityNodeInfoCompat.CollectionInfoCompat.obtain(NavigationMenuPresenter.this.adapter.getRowCount(), 1, false));
}
}
}