mirror of
https://github.com/Pinball3D/Rabbit-R1.git
synced 2024-12-27 09:32:27 -06:00
700 lines
28 KiB
Java
700 lines
28 KiB
Java
|
package com.google.android.material.navigation;
|
||
|
|
||
|
import android.R;
|
||
|
import android.content.Context;
|
||
|
import android.content.res.ColorStateList;
|
||
|
import android.graphics.drawable.Drawable;
|
||
|
import android.util.SparseArray;
|
||
|
import android.util.TypedValue;
|
||
|
import android.view.MenuItem;
|
||
|
import android.view.View;
|
||
|
import android.view.ViewGroup;
|
||
|
import android.view.accessibility.AccessibilityNodeInfo;
|
||
|
import androidx.appcompat.content.res.AppCompatResources;
|
||
|
import androidx.appcompat.view.menu.MenuBuilder;
|
||
|
import androidx.appcompat.view.menu.MenuItemImpl;
|
||
|
import androidx.appcompat.view.menu.MenuView;
|
||
|
import androidx.core.util.Pools;
|
||
|
import androidx.core.view.ViewCompat;
|
||
|
import androidx.core.view.accessibility.AccessibilityNodeInfoCompat;
|
||
|
import androidx.transition.AutoTransition;
|
||
|
import androidx.transition.TransitionManager;
|
||
|
import androidx.transition.TransitionSet;
|
||
|
import com.google.android.material.animation.AnimationUtils;
|
||
|
import com.google.android.material.badge.BadgeDrawable;
|
||
|
import com.google.android.material.internal.TextScale;
|
||
|
import com.google.android.material.motion.MotionUtils;
|
||
|
import com.google.android.material.shape.MaterialShapeDrawable;
|
||
|
import com.google.android.material.shape.ShapeAppearanceModel;
|
||
|
import java.util.HashSet;
|
||
|
|
||
|
/* loaded from: classes2.dex */
|
||
|
public abstract class NavigationBarMenuView extends ViewGroup implements MenuView {
|
||
|
private static final int[] CHECKED_STATE_SET = {R.attr.state_checked};
|
||
|
private static final int[] DISABLED_STATE_SET = {-16842910};
|
||
|
private static final int ITEM_POOL_SIZE = 5;
|
||
|
private static final int NO_PADDING = -1;
|
||
|
private final SparseArray<BadgeDrawable> badgeDrawables;
|
||
|
private NavigationBarItemView[] buttons;
|
||
|
private ColorStateList itemActiveIndicatorColor;
|
||
|
private boolean itemActiveIndicatorEnabled;
|
||
|
private int itemActiveIndicatorHeight;
|
||
|
private int itemActiveIndicatorLabelPadding;
|
||
|
private int itemActiveIndicatorMarginHorizontal;
|
||
|
private boolean itemActiveIndicatorResizeable;
|
||
|
private ShapeAppearanceModel itemActiveIndicatorShapeAppearance;
|
||
|
private int itemActiveIndicatorWidth;
|
||
|
private Drawable itemBackground;
|
||
|
private int itemBackgroundRes;
|
||
|
private int itemIconSize;
|
||
|
private ColorStateList itemIconTint;
|
||
|
private int itemPaddingBottom;
|
||
|
private int itemPaddingTop;
|
||
|
private final Pools.Pool<NavigationBarItemView> itemPool;
|
||
|
private ColorStateList itemRippleColor;
|
||
|
private int itemTextAppearanceActive;
|
||
|
private boolean itemTextAppearanceActiveBoldEnabled;
|
||
|
private int itemTextAppearanceInactive;
|
||
|
private final ColorStateList itemTextColorDefault;
|
||
|
private ColorStateList itemTextColorFromUser;
|
||
|
private int labelVisibilityMode;
|
||
|
private MenuBuilder menu;
|
||
|
private final View.OnClickListener onClickListener;
|
||
|
private final SparseArray<View.OnTouchListener> onTouchListeners;
|
||
|
private NavigationBarPresenter presenter;
|
||
|
private int selectedItemId;
|
||
|
private int selectedItemPosition;
|
||
|
private final TransitionSet set;
|
||
|
|
||
|
private boolean isValidId(int i) {
|
||
|
return i != -1;
|
||
|
}
|
||
|
|
||
|
protected abstract NavigationBarItemView createNavigationBarItemView(Context context);
|
||
|
|
||
|
public int getActiveIndicatorLabelPadding() {
|
||
|
return this.itemActiveIndicatorLabelPadding;
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
public SparseArray<BadgeDrawable> getBadgeDrawables() {
|
||
|
return this.badgeDrawables;
|
||
|
}
|
||
|
|
||
|
public ColorStateList getIconTintList() {
|
||
|
return this.itemIconTint;
|
||
|
}
|
||
|
|
||
|
public ColorStateList getItemActiveIndicatorColor() {
|
||
|
return this.itemActiveIndicatorColor;
|
||
|
}
|
||
|
|
||
|
public boolean getItemActiveIndicatorEnabled() {
|
||
|
return this.itemActiveIndicatorEnabled;
|
||
|
}
|
||
|
|
||
|
public int getItemActiveIndicatorHeight() {
|
||
|
return this.itemActiveIndicatorHeight;
|
||
|
}
|
||
|
|
||
|
public int getItemActiveIndicatorMarginHorizontal() {
|
||
|
return this.itemActiveIndicatorMarginHorizontal;
|
||
|
}
|
||
|
|
||
|
public ShapeAppearanceModel getItemActiveIndicatorShapeAppearance() {
|
||
|
return this.itemActiveIndicatorShapeAppearance;
|
||
|
}
|
||
|
|
||
|
public int getItemActiveIndicatorWidth() {
|
||
|
return this.itemActiveIndicatorWidth;
|
||
|
}
|
||
|
|
||
|
@Deprecated
|
||
|
public int getItemBackgroundRes() {
|
||
|
return this.itemBackgroundRes;
|
||
|
}
|
||
|
|
||
|
public int getItemIconSize() {
|
||
|
return this.itemIconSize;
|
||
|
}
|
||
|
|
||
|
public int getItemPaddingBottom() {
|
||
|
return this.itemPaddingBottom;
|
||
|
}
|
||
|
|
||
|
public int getItemPaddingTop() {
|
||
|
return this.itemPaddingTop;
|
||
|
}
|
||
|
|
||
|
public ColorStateList getItemRippleColor() {
|
||
|
return this.itemRippleColor;
|
||
|
}
|
||
|
|
||
|
public int getItemTextAppearanceActive() {
|
||
|
return this.itemTextAppearanceActive;
|
||
|
}
|
||
|
|
||
|
public int getItemTextAppearanceInactive() {
|
||
|
return this.itemTextAppearanceInactive;
|
||
|
}
|
||
|
|
||
|
public ColorStateList getItemTextColor() {
|
||
|
return this.itemTextColorFromUser;
|
||
|
}
|
||
|
|
||
|
public int getLabelVisibilityMode() {
|
||
|
return this.labelVisibilityMode;
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: protected */
|
||
|
public MenuBuilder getMenu() {
|
||
|
return this.menu;
|
||
|
}
|
||
|
|
||
|
public int getSelectedItemId() {
|
||
|
return this.selectedItemId;
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: protected */
|
||
|
public int getSelectedItemPosition() {
|
||
|
return this.selectedItemPosition;
|
||
|
}
|
||
|
|
||
|
@Override // androidx.appcompat.view.menu.MenuView
|
||
|
public int getWindowAnimations() {
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
@Override // androidx.appcompat.view.menu.MenuView
|
||
|
public void initialize(MenuBuilder menuBuilder) {
|
||
|
this.menu = menuBuilder;
|
||
|
}
|
||
|
|
||
|
protected boolean isItemActiveIndicatorResizeable() {
|
||
|
return this.itemActiveIndicatorResizeable;
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: protected */
|
||
|
public boolean isShifting(int i, int i2) {
|
||
|
if (i == -1) {
|
||
|
if (i2 > 3) {
|
||
|
return true;
|
||
|
}
|
||
|
} else if (i == 0) {
|
||
|
return true;
|
||
|
}
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
public void setLabelVisibilityMode(int i) {
|
||
|
this.labelVisibilityMode = i;
|
||
|
}
|
||
|
|
||
|
public void setPresenter(NavigationBarPresenter navigationBarPresenter) {
|
||
|
this.presenter = navigationBarPresenter;
|
||
|
}
|
||
|
|
||
|
public NavigationBarMenuView(Context context) {
|
||
|
super(context);
|
||
|
this.itemPool = new Pools.SynchronizedPool(5);
|
||
|
this.onTouchListeners = new SparseArray<>(5);
|
||
|
this.selectedItemId = 0;
|
||
|
this.selectedItemPosition = 0;
|
||
|
this.badgeDrawables = new SparseArray<>(5);
|
||
|
this.itemPaddingTop = -1;
|
||
|
this.itemPaddingBottom = -1;
|
||
|
this.itemActiveIndicatorLabelPadding = -1;
|
||
|
this.itemActiveIndicatorResizeable = false;
|
||
|
this.itemTextColorDefault = createDefaultColorStateList(R.attr.textColorSecondary);
|
||
|
if (isInEditMode()) {
|
||
|
this.set = null;
|
||
|
} else {
|
||
|
AutoTransition autoTransition = new AutoTransition();
|
||
|
this.set = autoTransition;
|
||
|
autoTransition.setOrdering(0);
|
||
|
autoTransition.setDuration(MotionUtils.resolveThemeDuration(getContext(), com.google.android.material.R.attr.motionDurationMedium4, getResources().getInteger(com.google.android.material.R.integer.material_motion_duration_long_1)));
|
||
|
autoTransition.setInterpolator(MotionUtils.resolveThemeInterpolator(getContext(), com.google.android.material.R.attr.motionEasingStandard, AnimationUtils.FAST_OUT_SLOW_IN_INTERPOLATOR));
|
||
|
autoTransition.addTransition(new TextScale());
|
||
|
}
|
||
|
this.onClickListener = new View.OnClickListener() { // from class: com.google.android.material.navigation.NavigationBarMenuView.1
|
||
|
@Override // android.view.View.OnClickListener
|
||
|
public void onClick(View view) {
|
||
|
MenuItemImpl itemData = ((NavigationBarItemView) view).getItemData();
|
||
|
if (NavigationBarMenuView.this.menu.performItemAction(itemData, NavigationBarMenuView.this.presenter, 0)) {
|
||
|
return;
|
||
|
}
|
||
|
itemData.setChecked(true);
|
||
|
}
|
||
|
};
|
||
|
ViewCompat.setImportantForAccessibility(this, 1);
|
||
|
}
|
||
|
|
||
|
@Override // android.view.View
|
||
|
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo accessibilityNodeInfo) {
|
||
|
super.onInitializeAccessibilityNodeInfo(accessibilityNodeInfo);
|
||
|
AccessibilityNodeInfoCompat.wrap(accessibilityNodeInfo).setCollectionInfo(AccessibilityNodeInfoCompat.CollectionInfoCompat.obtain(1, this.menu.getVisibleItems().size(), false, 1));
|
||
|
}
|
||
|
|
||
|
public void setIconTintList(ColorStateList colorStateList) {
|
||
|
this.itemIconTint = colorStateList;
|
||
|
NavigationBarItemView[] navigationBarItemViewArr = this.buttons;
|
||
|
if (navigationBarItemViewArr != null) {
|
||
|
for (NavigationBarItemView navigationBarItemView : navigationBarItemViewArr) {
|
||
|
navigationBarItemView.setIconTintList(colorStateList);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public void setItemIconSize(int i) {
|
||
|
this.itemIconSize = i;
|
||
|
NavigationBarItemView[] navigationBarItemViewArr = this.buttons;
|
||
|
if (navigationBarItemViewArr != null) {
|
||
|
for (NavigationBarItemView navigationBarItemView : navigationBarItemViewArr) {
|
||
|
navigationBarItemView.setIconSize(i);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public void setItemTextColor(ColorStateList colorStateList) {
|
||
|
this.itemTextColorFromUser = colorStateList;
|
||
|
NavigationBarItemView[] navigationBarItemViewArr = this.buttons;
|
||
|
if (navigationBarItemViewArr != null) {
|
||
|
for (NavigationBarItemView navigationBarItemView : navigationBarItemViewArr) {
|
||
|
navigationBarItemView.setTextColor(colorStateList);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public void setItemTextAppearanceInactive(int i) {
|
||
|
this.itemTextAppearanceInactive = i;
|
||
|
NavigationBarItemView[] navigationBarItemViewArr = this.buttons;
|
||
|
if (navigationBarItemViewArr != null) {
|
||
|
for (NavigationBarItemView navigationBarItemView : navigationBarItemViewArr) {
|
||
|
navigationBarItemView.setTextAppearanceInactive(i);
|
||
|
ColorStateList colorStateList = this.itemTextColorFromUser;
|
||
|
if (colorStateList != null) {
|
||
|
navigationBarItemView.setTextColor(colorStateList);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public void setItemTextAppearanceActive(int i) {
|
||
|
this.itemTextAppearanceActive = i;
|
||
|
NavigationBarItemView[] navigationBarItemViewArr = this.buttons;
|
||
|
if (navigationBarItemViewArr != null) {
|
||
|
for (NavigationBarItemView navigationBarItemView : navigationBarItemViewArr) {
|
||
|
navigationBarItemView.setTextAppearanceActive(i);
|
||
|
ColorStateList colorStateList = this.itemTextColorFromUser;
|
||
|
if (colorStateList != null) {
|
||
|
navigationBarItemView.setTextColor(colorStateList);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public void setItemTextAppearanceActiveBoldEnabled(boolean z) {
|
||
|
this.itemTextAppearanceActiveBoldEnabled = z;
|
||
|
NavigationBarItemView[] navigationBarItemViewArr = this.buttons;
|
||
|
if (navigationBarItemViewArr != null) {
|
||
|
for (NavigationBarItemView navigationBarItemView : navigationBarItemViewArr) {
|
||
|
navigationBarItemView.setTextAppearanceActiveBoldEnabled(z);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public void setItemBackgroundRes(int i) {
|
||
|
this.itemBackgroundRes = i;
|
||
|
NavigationBarItemView[] navigationBarItemViewArr = this.buttons;
|
||
|
if (navigationBarItemViewArr != null) {
|
||
|
for (NavigationBarItemView navigationBarItemView : navigationBarItemViewArr) {
|
||
|
navigationBarItemView.setItemBackground(i);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public void setItemPaddingTop(int i) {
|
||
|
this.itemPaddingTop = i;
|
||
|
NavigationBarItemView[] navigationBarItemViewArr = this.buttons;
|
||
|
if (navigationBarItemViewArr != null) {
|
||
|
for (NavigationBarItemView navigationBarItemView : navigationBarItemViewArr) {
|
||
|
navigationBarItemView.setItemPaddingTop(i);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public void setItemPaddingBottom(int i) {
|
||
|
this.itemPaddingBottom = i;
|
||
|
NavigationBarItemView[] navigationBarItemViewArr = this.buttons;
|
||
|
if (navigationBarItemViewArr != null) {
|
||
|
for (NavigationBarItemView navigationBarItemView : navigationBarItemViewArr) {
|
||
|
navigationBarItemView.setItemPaddingBottom(i);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public void setActiveIndicatorLabelPadding(int i) {
|
||
|
this.itemActiveIndicatorLabelPadding = i;
|
||
|
NavigationBarItemView[] navigationBarItemViewArr = this.buttons;
|
||
|
if (navigationBarItemViewArr != null) {
|
||
|
for (NavigationBarItemView navigationBarItemView : navigationBarItemViewArr) {
|
||
|
navigationBarItemView.setActiveIndicatorLabelPadding(i);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public void setItemActiveIndicatorEnabled(boolean z) {
|
||
|
this.itemActiveIndicatorEnabled = z;
|
||
|
NavigationBarItemView[] navigationBarItemViewArr = this.buttons;
|
||
|
if (navigationBarItemViewArr != null) {
|
||
|
for (NavigationBarItemView navigationBarItemView : navigationBarItemViewArr) {
|
||
|
navigationBarItemView.setActiveIndicatorEnabled(z);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public void setItemActiveIndicatorWidth(int i) {
|
||
|
this.itemActiveIndicatorWidth = i;
|
||
|
NavigationBarItemView[] navigationBarItemViewArr = this.buttons;
|
||
|
if (navigationBarItemViewArr != null) {
|
||
|
for (NavigationBarItemView navigationBarItemView : navigationBarItemViewArr) {
|
||
|
navigationBarItemView.setActiveIndicatorWidth(i);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public void setItemActiveIndicatorHeight(int i) {
|
||
|
this.itemActiveIndicatorHeight = i;
|
||
|
NavigationBarItemView[] navigationBarItemViewArr = this.buttons;
|
||
|
if (navigationBarItemViewArr != null) {
|
||
|
for (NavigationBarItemView navigationBarItemView : navigationBarItemViewArr) {
|
||
|
navigationBarItemView.setActiveIndicatorHeight(i);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public void setItemActiveIndicatorMarginHorizontal(int i) {
|
||
|
this.itemActiveIndicatorMarginHorizontal = i;
|
||
|
NavigationBarItemView[] navigationBarItemViewArr = this.buttons;
|
||
|
if (navigationBarItemViewArr != null) {
|
||
|
for (NavigationBarItemView navigationBarItemView : navigationBarItemViewArr) {
|
||
|
navigationBarItemView.setActiveIndicatorMarginHorizontal(i);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public void setItemActiveIndicatorShapeAppearance(ShapeAppearanceModel shapeAppearanceModel) {
|
||
|
this.itemActiveIndicatorShapeAppearance = shapeAppearanceModel;
|
||
|
NavigationBarItemView[] navigationBarItemViewArr = this.buttons;
|
||
|
if (navigationBarItemViewArr != null) {
|
||
|
for (NavigationBarItemView navigationBarItemView : navigationBarItemViewArr) {
|
||
|
navigationBarItemView.setActiveIndicatorDrawable(createItemActiveIndicatorDrawable());
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: protected */
|
||
|
public void setItemActiveIndicatorResizeable(boolean z) {
|
||
|
this.itemActiveIndicatorResizeable = z;
|
||
|
NavigationBarItemView[] navigationBarItemViewArr = this.buttons;
|
||
|
if (navigationBarItemViewArr != null) {
|
||
|
for (NavigationBarItemView navigationBarItemView : navigationBarItemViewArr) {
|
||
|
navigationBarItemView.setActiveIndicatorResizeable(z);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public void setItemActiveIndicatorColor(ColorStateList colorStateList) {
|
||
|
this.itemActiveIndicatorColor = colorStateList;
|
||
|
NavigationBarItemView[] navigationBarItemViewArr = this.buttons;
|
||
|
if (navigationBarItemViewArr != null) {
|
||
|
for (NavigationBarItemView navigationBarItemView : navigationBarItemViewArr) {
|
||
|
navigationBarItemView.setActiveIndicatorDrawable(createItemActiveIndicatorDrawable());
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private Drawable createItemActiveIndicatorDrawable() {
|
||
|
if (this.itemActiveIndicatorShapeAppearance == null || this.itemActiveIndicatorColor == null) {
|
||
|
return null;
|
||
|
}
|
||
|
MaterialShapeDrawable materialShapeDrawable = new MaterialShapeDrawable(this.itemActiveIndicatorShapeAppearance);
|
||
|
materialShapeDrawable.setFillColor(this.itemActiveIndicatorColor);
|
||
|
return materialShapeDrawable;
|
||
|
}
|
||
|
|
||
|
public void setItemBackground(Drawable drawable) {
|
||
|
this.itemBackground = drawable;
|
||
|
NavigationBarItemView[] navigationBarItemViewArr = this.buttons;
|
||
|
if (navigationBarItemViewArr != null) {
|
||
|
for (NavigationBarItemView navigationBarItemView : navigationBarItemViewArr) {
|
||
|
navigationBarItemView.setItemBackground(drawable);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public void setItemRippleColor(ColorStateList colorStateList) {
|
||
|
this.itemRippleColor = colorStateList;
|
||
|
NavigationBarItemView[] navigationBarItemViewArr = this.buttons;
|
||
|
if (navigationBarItemViewArr != null) {
|
||
|
for (NavigationBarItemView navigationBarItemView : navigationBarItemViewArr) {
|
||
|
navigationBarItemView.setItemRippleColor(colorStateList);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public Drawable getItemBackground() {
|
||
|
NavigationBarItemView[] navigationBarItemViewArr = this.buttons;
|
||
|
return (navigationBarItemViewArr == null || navigationBarItemViewArr.length <= 0) ? this.itemBackground : navigationBarItemViewArr[0].getBackground();
|
||
|
}
|
||
|
|
||
|
public void setItemOnTouchListener(int i, View.OnTouchListener onTouchListener) {
|
||
|
if (onTouchListener == null) {
|
||
|
this.onTouchListeners.remove(i);
|
||
|
} else {
|
||
|
this.onTouchListeners.put(i, onTouchListener);
|
||
|
}
|
||
|
NavigationBarItemView[] navigationBarItemViewArr = this.buttons;
|
||
|
if (navigationBarItemViewArr != null) {
|
||
|
for (NavigationBarItemView navigationBarItemView : navigationBarItemViewArr) {
|
||
|
if (navigationBarItemView.getItemData().getItemId() == i) {
|
||
|
navigationBarItemView.setOnTouchListener(onTouchListener);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public ColorStateList createDefaultColorStateList(int i) {
|
||
|
TypedValue typedValue = new TypedValue();
|
||
|
if (!getContext().getTheme().resolveAttribute(i, typedValue, true)) {
|
||
|
return null;
|
||
|
}
|
||
|
ColorStateList colorStateList = AppCompatResources.getColorStateList(getContext(), typedValue.resourceId);
|
||
|
if (!getContext().getTheme().resolveAttribute(androidx.appcompat.R.attr.colorPrimary, typedValue, true)) {
|
||
|
return null;
|
||
|
}
|
||
|
int i2 = typedValue.data;
|
||
|
int defaultColor = colorStateList.getDefaultColor();
|
||
|
int[] iArr = DISABLED_STATE_SET;
|
||
|
return new ColorStateList(new int[][]{iArr, CHECKED_STATE_SET, EMPTY_STATE_SET}, new int[]{colorStateList.getColorForState(iArr, defaultColor), i2, defaultColor});
|
||
|
}
|
||
|
|
||
|
public void buildMenuView() {
|
||
|
removeAllViews();
|
||
|
NavigationBarItemView[] navigationBarItemViewArr = this.buttons;
|
||
|
if (navigationBarItemViewArr != null) {
|
||
|
for (NavigationBarItemView navigationBarItemView : navigationBarItemViewArr) {
|
||
|
if (navigationBarItemView != null) {
|
||
|
this.itemPool.release(navigationBarItemView);
|
||
|
navigationBarItemView.clear();
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
if (this.menu.size() == 0) {
|
||
|
this.selectedItemId = 0;
|
||
|
this.selectedItemPosition = 0;
|
||
|
this.buttons = null;
|
||
|
return;
|
||
|
}
|
||
|
removeUnusedBadges();
|
||
|
this.buttons = new NavigationBarItemView[this.menu.size()];
|
||
|
boolean isShifting = isShifting(this.labelVisibilityMode, this.menu.getVisibleItems().size());
|
||
|
for (int i = 0; i < this.menu.size(); i++) {
|
||
|
this.presenter.setUpdateSuspended(true);
|
||
|
this.menu.getItem(i).setCheckable(true);
|
||
|
this.presenter.setUpdateSuspended(false);
|
||
|
NavigationBarItemView newItem = getNewItem();
|
||
|
this.buttons[i] = newItem;
|
||
|
newItem.setIconTintList(this.itemIconTint);
|
||
|
newItem.setIconSize(this.itemIconSize);
|
||
|
newItem.setTextColor(this.itemTextColorDefault);
|
||
|
newItem.setTextAppearanceInactive(this.itemTextAppearanceInactive);
|
||
|
newItem.setTextAppearanceActive(this.itemTextAppearanceActive);
|
||
|
newItem.setTextAppearanceActiveBoldEnabled(this.itemTextAppearanceActiveBoldEnabled);
|
||
|
newItem.setTextColor(this.itemTextColorFromUser);
|
||
|
int i2 = this.itemPaddingTop;
|
||
|
if (i2 != -1) {
|
||
|
newItem.setItemPaddingTop(i2);
|
||
|
}
|
||
|
int i3 = this.itemPaddingBottom;
|
||
|
if (i3 != -1) {
|
||
|
newItem.setItemPaddingBottom(i3);
|
||
|
}
|
||
|
int i4 = this.itemActiveIndicatorLabelPadding;
|
||
|
if (i4 != -1) {
|
||
|
newItem.setActiveIndicatorLabelPadding(i4);
|
||
|
}
|
||
|
newItem.setActiveIndicatorWidth(this.itemActiveIndicatorWidth);
|
||
|
newItem.setActiveIndicatorHeight(this.itemActiveIndicatorHeight);
|
||
|
newItem.setActiveIndicatorMarginHorizontal(this.itemActiveIndicatorMarginHorizontal);
|
||
|
newItem.setActiveIndicatorDrawable(createItemActiveIndicatorDrawable());
|
||
|
newItem.setActiveIndicatorResizeable(this.itemActiveIndicatorResizeable);
|
||
|
newItem.setActiveIndicatorEnabled(this.itemActiveIndicatorEnabled);
|
||
|
Drawable drawable = this.itemBackground;
|
||
|
if (drawable != null) {
|
||
|
newItem.setItemBackground(drawable);
|
||
|
} else {
|
||
|
newItem.setItemBackground(this.itemBackgroundRes);
|
||
|
}
|
||
|
newItem.setItemRippleColor(this.itemRippleColor);
|
||
|
newItem.setShifting(isShifting);
|
||
|
newItem.setLabelVisibilityMode(this.labelVisibilityMode);
|
||
|
MenuItemImpl menuItemImpl = (MenuItemImpl) this.menu.getItem(i);
|
||
|
newItem.initialize(menuItemImpl, 0);
|
||
|
newItem.setItemPosition(i);
|
||
|
int itemId = menuItemImpl.getItemId();
|
||
|
newItem.setOnTouchListener(this.onTouchListeners.get(itemId));
|
||
|
newItem.setOnClickListener(this.onClickListener);
|
||
|
int i5 = this.selectedItemId;
|
||
|
if (i5 != 0 && itemId == i5) {
|
||
|
this.selectedItemPosition = i;
|
||
|
}
|
||
|
setBadgeIfNeeded(newItem);
|
||
|
addView(newItem);
|
||
|
}
|
||
|
int min = Math.min(this.menu.size() - 1, this.selectedItemPosition);
|
||
|
this.selectedItemPosition = min;
|
||
|
this.menu.getItem(min).setChecked(true);
|
||
|
}
|
||
|
|
||
|
public void updateMenuView() {
|
||
|
TransitionSet transitionSet;
|
||
|
MenuBuilder menuBuilder = this.menu;
|
||
|
if (menuBuilder == null || this.buttons == null) {
|
||
|
return;
|
||
|
}
|
||
|
int size = menuBuilder.size();
|
||
|
if (size != this.buttons.length) {
|
||
|
buildMenuView();
|
||
|
return;
|
||
|
}
|
||
|
int i = this.selectedItemId;
|
||
|
for (int i2 = 0; i2 < size; i2++) {
|
||
|
MenuItem item = this.menu.getItem(i2);
|
||
|
if (item.isChecked()) {
|
||
|
this.selectedItemId = item.getItemId();
|
||
|
this.selectedItemPosition = i2;
|
||
|
}
|
||
|
}
|
||
|
if (i != this.selectedItemId && (transitionSet = this.set) != null) {
|
||
|
TransitionManager.beginDelayedTransition(this, transitionSet);
|
||
|
}
|
||
|
boolean isShifting = isShifting(this.labelVisibilityMode, this.menu.getVisibleItems().size());
|
||
|
for (int i3 = 0; i3 < size; i3++) {
|
||
|
this.presenter.setUpdateSuspended(true);
|
||
|
this.buttons[i3].setLabelVisibilityMode(this.labelVisibilityMode);
|
||
|
this.buttons[i3].setShifting(isShifting);
|
||
|
this.buttons[i3].initialize((MenuItemImpl) this.menu.getItem(i3), 0);
|
||
|
this.presenter.setUpdateSuspended(false);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private NavigationBarItemView getNewItem() {
|
||
|
NavigationBarItemView acquire = this.itemPool.acquire();
|
||
|
return acquire == null ? createNavigationBarItemView(getContext()) : acquire;
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
public void tryRestoreSelectedItemId(int i) {
|
||
|
int size = this.menu.size();
|
||
|
for (int i2 = 0; i2 < size; i2++) {
|
||
|
MenuItem item = this.menu.getItem(i2);
|
||
|
if (i == item.getItemId()) {
|
||
|
this.selectedItemId = i;
|
||
|
this.selectedItemPosition = i2;
|
||
|
item.setChecked(true);
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
public void restoreBadgeDrawables(SparseArray<BadgeDrawable> sparseArray) {
|
||
|
for (int i = 0; i < sparseArray.size(); i++) {
|
||
|
int keyAt = sparseArray.keyAt(i);
|
||
|
if (this.badgeDrawables.indexOfKey(keyAt) < 0) {
|
||
|
this.badgeDrawables.append(keyAt, sparseArray.get(keyAt));
|
||
|
}
|
||
|
}
|
||
|
NavigationBarItemView[] navigationBarItemViewArr = this.buttons;
|
||
|
if (navigationBarItemViewArr != null) {
|
||
|
for (NavigationBarItemView navigationBarItemView : navigationBarItemViewArr) {
|
||
|
BadgeDrawable badgeDrawable = this.badgeDrawables.get(navigationBarItemView.getId());
|
||
|
if (badgeDrawable != null) {
|
||
|
navigationBarItemView.setBadge(badgeDrawable);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public BadgeDrawable getBadge(int i) {
|
||
|
return this.badgeDrawables.get(i);
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
public BadgeDrawable getOrCreateBadge(int i) {
|
||
|
validateMenuItemId(i);
|
||
|
BadgeDrawable badgeDrawable = this.badgeDrawables.get(i);
|
||
|
if (badgeDrawable == null) {
|
||
|
badgeDrawable = BadgeDrawable.create(getContext());
|
||
|
this.badgeDrawables.put(i, badgeDrawable);
|
||
|
}
|
||
|
NavigationBarItemView findItemView = findItemView(i);
|
||
|
if (findItemView != null) {
|
||
|
findItemView.setBadge(badgeDrawable);
|
||
|
}
|
||
|
return badgeDrawable;
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
public void removeBadge(int i) {
|
||
|
validateMenuItemId(i);
|
||
|
NavigationBarItemView findItemView = findItemView(i);
|
||
|
if (findItemView != null) {
|
||
|
findItemView.removeBadge();
|
||
|
}
|
||
|
this.badgeDrawables.put(i, null);
|
||
|
}
|
||
|
|
||
|
private void setBadgeIfNeeded(NavigationBarItemView navigationBarItemView) {
|
||
|
BadgeDrawable badgeDrawable;
|
||
|
int id = navigationBarItemView.getId();
|
||
|
if (isValidId(id) && (badgeDrawable = this.badgeDrawables.get(id)) != null) {
|
||
|
navigationBarItemView.setBadge(badgeDrawable);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private void removeUnusedBadges() {
|
||
|
HashSet hashSet = new HashSet();
|
||
|
for (int i = 0; i < this.menu.size(); i++) {
|
||
|
hashSet.add(Integer.valueOf(this.menu.getItem(i).getItemId()));
|
||
|
}
|
||
|
for (int i2 = 0; i2 < this.badgeDrawables.size(); i2++) {
|
||
|
int keyAt = this.badgeDrawables.keyAt(i2);
|
||
|
if (!hashSet.contains(Integer.valueOf(keyAt))) {
|
||
|
this.badgeDrawables.delete(keyAt);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public NavigationBarItemView findItemView(int i) {
|
||
|
validateMenuItemId(i);
|
||
|
NavigationBarItemView[] navigationBarItemViewArr = this.buttons;
|
||
|
if (navigationBarItemViewArr == null) {
|
||
|
return null;
|
||
|
}
|
||
|
for (NavigationBarItemView navigationBarItemView : navigationBarItemViewArr) {
|
||
|
if (navigationBarItemView.getId() == i) {
|
||
|
return navigationBarItemView;
|
||
|
}
|
||
|
}
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
private void validateMenuItemId(int i) {
|
||
|
if (!isValidId(i)) {
|
||
|
throw new IllegalArgumentException(i + " is not a valid view id");
|
||
|
}
|
||
|
}
|
||
|
}
|