package com.google.android.material.bottomnavigation; import android.content.Context; import android.content.res.Resources; import android.view.View; import android.widget.FrameLayout; import androidx.core.view.ViewCompat; import com.google.android.material.navigation.NavigationBarItemView; import com.google.android.material.navigation.NavigationBarMenuView; import java.util.ArrayList; import java.util.List; import o.C17052tZT; import o.NoP; import org.bouncycastle.asn1.cmp.PKIFailureInfo; /* loaded from: classes2.dex */ public class BottomNavigationMenuView extends NavigationBarMenuView { boolean a; private final int g; private final int i; private final int l; private final List n; /* renamed from: o, reason: collision with root package name */ private final int f6467o; public BottomNavigationMenuView(Context context) { super(context); this.n = new ArrayList(); FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(-2, -2); layoutParams.gravity = 17; setLayoutParams(layoutParams); Resources resources = getResources(); this.l = resources.getDimensionPixelSize(C17052tZT.HBt.design_bottom_navigation_item_max_width); this.f6467o = resources.getDimensionPixelSize(C17052tZT.HBt.design_bottom_navigation_item_min_width); this.i = resources.getDimensionPixelSize(C17052tZT.HBt.design_bottom_navigation_active_item_max_width); this.g = resources.getDimensionPixelSize(C17052tZT.HBt.design_bottom_navigation_active_item_min_width); } @Override // android.view.ViewGroup, android.view.View protected void onLayout(boolean z, int i, int i2, int i3, int i4) { int childCount = getChildCount(); int i5 = i4 - i2; int i6 = 0; for (int i7 = 0; i7 < childCount; i7++) { View childAt = getChildAt(i7); if (childAt.getVisibility() != 8) { if (ViewCompat.m(this) == 1) { int i8 = (i3 - i) - i6; childAt.layout(i8 - childAt.getMeasuredWidth(), 0, i8, i5); } else { childAt.layout(i6, 0, childAt.getMeasuredWidth() + i6, i5); } i6 += childAt.getMeasuredWidth(); } } } @Override // com.google.android.material.navigation.NavigationBarMenuView public final NavigationBarItemView a(Context context) { return new BottomNavigationItemView(context); } @Override // android.view.View protected void onMeasure(int i, int i2) { int i3; int i4; NoP noP = this.c; int size = View.MeasureSpec.getSize(i); int size2 = noP.d().size(); int childCount = getChildCount(); this.n.clear(); int size3 = View.MeasureSpec.getSize(i2); int makeMeasureSpec = View.MeasureSpec.makeMeasureSpec(size3, 1073741824); int i5 = this.d; if ((i5 != -1 ? i5 == 0 : size2 > 3) && this.a) { View childAt = getChildAt(this.h); int i6 = this.g; if (childAt.getVisibility() != 8) { childAt.measure(View.MeasureSpec.makeMeasureSpec(this.i, PKIFailureInfo.systemUnavail), makeMeasureSpec); i6 = Math.max(i6, childAt.getMeasuredWidth()); } int i7 = size2 - (childAt.getVisibility() != 8 ? 1 : 0); int min = Math.min(size - (this.f6467o * i7), Math.min(i6, this.i)); int i8 = size - min; int min2 = Math.min(i8 / (i7 != 0 ? i7 : 1), this.l); int i9 = i8 - (i7 * min2); int i10 = 0; while (i10 < childCount) { if (getChildAt(i10).getVisibility() != 8) { i4 = i10 == this.h ? min : min2; if (i9 > 0) { i4++; i9--; } } else { i4 = 0; } this.n.add(Integer.valueOf(i4)); i10++; } } else { int min3 = Math.min(size / (size2 != 0 ? size2 : 1), this.i); int i11 = size - (size2 * min3); for (int i12 = 0; i12 < childCount; i12++) { if (getChildAt(i12).getVisibility() == 8) { i3 = 0; } else if (i11 > 0) { i3 = min3 + 1; i11--; } else { i3 = min3; } this.n.add(Integer.valueOf(i3)); } } int i13 = 0; for (int i14 = 0; i14 < childCount; i14++) { View childAt2 = getChildAt(i14); if (childAt2.getVisibility() != 8) { childAt2.measure(View.MeasureSpec.makeMeasureSpec(this.n.get(i14).intValue(), 1073741824), makeMeasureSpec); childAt2.getLayoutParams().width = childAt2.getMeasuredWidth(); i13 += childAt2.getMeasuredWidth(); } } setMeasuredDimension(i13, size3); } public void setItemHorizontalTranslationEnabled(boolean z) { this.a = z; } }