package com.google.android.material.bottomappbar;

import android.graphics.Rect;
import android.graphics.RectF;
import android.view.View;
import android.view.ViewGroup;
import com.google.android.material.bottomappbar.BottomAppBar;
import com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import d0.d;
import x8.e;

/* JADX INFO: loaded from: classes2.dex */
public final class a implements View.OnLayoutChangeListener {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final /* synthetic */ BottomAppBar.Behavior f22257a;

    public a(BottomAppBar.Behavior behavior) {
        this.f22257a = behavior;
    }

    @Override // android.view.View.OnLayoutChangeListener
    public final void onLayoutChange(View view, int i10, int i11, int i12, int i13, int i14, int i15, int i16, int i17) {
        BottomAppBar.Behavior behavior = this.f22257a;
        BottomAppBar bottomAppBar = (BottomAppBar) behavior.S.get();
        if (bottomAppBar == null || !((view instanceof FloatingActionButton) || (view instanceof ExtendedFloatingActionButton))) {
            view.removeOnLayoutChangeListener(this);
            return;
        }
        int height = view.getHeight();
        if (view instanceof FloatingActionButton) {
            FloatingActionButton floatingActionButton = (FloatingActionButton) view;
            Rect rect = behavior.R;
            floatingActionButton.f(rect);
            int iHeight = rect.height();
            bottomAppBar.N(iHeight);
            bottomAppBar.setFabCornerSize(floatingActionButton.getShapeAppearanceModel().f23155e.a(new RectF(rect)));
            height = iHeight;
        }
        d dVar = (d) view.getLayoutParams();
        if (behavior.T == 0) {
            if (bottomAppBar.D0 == 1) {
                ((ViewGroup.MarginLayoutParams) dVar).bottomMargin = bottomAppBar.getBottomInset() + (bottomAppBar.getResources().getDimensionPixelOffset(e.mtrl_bottomappbar_fab_bottom_margin) - ((view.getMeasuredHeight() - height) / 2));
            }
            ((ViewGroup.MarginLayoutParams) dVar).leftMargin = bottomAppBar.getLeftInset();
            ((ViewGroup.MarginLayoutParams) dVar).rightMargin = bottomAppBar.getRightInset();
            int layoutDirection = view.getLayoutDirection();
            int i18 = bottomAppBar.E0;
            if (layoutDirection == 1) {
                ((ViewGroup.MarginLayoutParams) dVar).leftMargin += i18;
            } else {
                ((ViewGroup.MarginLayoutParams) dVar).rightMargin += i18;
            }
        }
        int i19 = BottomAppBar.V0;
        bottomAppBar.M();
    }
}
