package com.google.android.material.bottomnavigation;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.FrameLayout;
import androidx.appcompat.widget.v0;
import androidx.core.view.h1;
import androidx.core.view.s0;
import com.google.android.material.internal.o;
import com.google.android.material.internal.q;
import com.google.android.material.navigation.e;
import vi.d;
import vi.k;
import vi.l;

/* loaded from: classes3.dex */
public class BottomNavigationView extends e {

    /* JADX INFO: Access modifiers changed from: package-private */
    /* loaded from: classes3.dex */
    public class a implements q.d {
        a() {
        }

        @Override // com.google.android.material.internal.q.d
        public h1 a(View view, h1 h1Var, q.e eVar) {
            eVar.f13394d += h1Var.i();
            boolean z10 = s0.z(view) == 1;
            int j10 = h1Var.j();
            int k10 = h1Var.k();
            eVar.f13391a += z10 ? k10 : j10;
            int i10 = eVar.f13393c;
            if (!z10) {
                j10 = k10;
            }
            eVar.f13393c = i10 + j10;
            eVar.a(view);
            return h1Var;
        }
    }

    /* loaded from: classes3.dex */
    public interface b extends e.b {
    }

    /* loaded from: classes3.dex */
    public interface c extends e.c {
    }

    public BottomNavigationView(Context context, AttributeSet attributeSet) {
        this(context, attributeSet, vi.b.f39723e);
    }

    private void f(Context context) {
        View view = new View(context);
        view.setBackgroundColor(androidx.core.content.a.getColor(context, vi.c.f39745a));
        view.setLayoutParams(new FrameLayout.LayoutParams(-1, getResources().getDimensionPixelSize(d.f39768g)));
        addView(view);
    }

    private void g() {
        q.a(this, new a());
    }

    private int h(int i10) {
        int suggestedMinimumHeight = getSuggestedMinimumHeight();
        if (View.MeasureSpec.getMode(i10) == 1073741824 || suggestedMinimumHeight <= 0) {
            return i10;
        }
        return View.MeasureSpec.makeMeasureSpec(Math.min(View.MeasureSpec.getSize(i10), suggestedMinimumHeight + getPaddingTop() + getPaddingBottom()), 1073741824);
    }

    private boolean i() {
        return false;
    }

    @Override // com.google.android.material.navigation.e
    protected com.google.android.material.navigation.c d(Context context) {
        return new com.google.android.material.bottomnavigation.b(context);
    }

    @Override // com.google.android.material.navigation.e
    public int getMaxItemCount() {
        return 5;
    }

    @Override // android.widget.FrameLayout, android.view.View
    protected void onMeasure(int i10, int i11) {
        super.onMeasure(i10, h(i11));
    }

    public void setItemHorizontalTranslationEnabled(boolean z10) {
        com.google.android.material.bottomnavigation.b bVar = (com.google.android.material.bottomnavigation.b) getMenuView();
        if (bVar.n() != z10) {
            bVar.setItemHorizontalTranslationEnabled(z10);
            getPresenter().d(false);
        }
    }

    @Deprecated
    public void setOnNavigationItemReselectedListener(b bVar) {
        setOnItemReselectedListener(bVar);
    }

    @Deprecated
    public void setOnNavigationItemSelectedListener(c cVar) {
        setOnItemSelectedListener(cVar);
    }

    public BottomNavigationView(Context context, AttributeSet attributeSet, int i10) {
        this(context, attributeSet, i10, k.f39894i);
    }

    public BottomNavigationView(Context context, AttributeSet attributeSet, int i10, int i11) {
        super(context, attributeSet, i10, i11);
        Context context2 = getContext();
        v0 i12 = o.i(context2, attributeSet, l.S, i10, i11, new int[0]);
        setItemHorizontalTranslationEnabled(i12.a(l.U, true));
        int i13 = l.T;
        if (i12.s(i13)) {
            setMinimumHeight(i12.f(i13, 0));
        }
        i12.w();
        if (i()) {
            f(context2);
        }
        g();
    }
}
