package com.google.android.material.appbar;

import X.1gt;
import X.C4782Qsl;
import X.C4783Qsm;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.view.View;
import androidx.core.g.t;
import com.bytedance.covode.number.Covode;
import java.util.List;

public class AppBarLayout$ScrollingViewBehavior extends C4783Qsm {
    static {
        Covode.recordClassIndex(43869);
    }

    public AppBarLayout$ScrollingViewBehavior() {
    }

    public /* bridge */ /* synthetic */ int getLeftAndRightOffset() {
        return super.getLeftAndRightOffset();
    }

    public /* bridge */ /* synthetic */ int getTopAndBottomOffset() {
        return super.getTopAndBottomOffset();
    }

    public /* bridge */ /* synthetic */ boolean setLeftAndRightOffset(int i) {
        return super.setLeftAndRightOffset(i);
    }

    public /* bridge */ /* synthetic */ boolean setTopAndBottomOffset(int i) {
        return super.setTopAndBottomOffset(i);
    }

    public final int LIZIZ(View view) {
        if (view instanceof C4782Qsl) {
            return ((C4782Qsl) view).getTotalScrollRange();
        }
        return super.LIZIZ(view);
    }

    /* access modifiers changed from: private */
    /* renamed from: LIZIZ */
    public C4782Qsl LIZ(List<View> list) {
        int size = list.size();
        for (int i = 0; i < size; i++) {
            View view = list.get(i);
            if (view instanceof C4782Qsl) {
                return (C4782Qsl) view;
            }
        }
        return null;
    }

    public final float LIZ(View view) {
        int i;
        int i2;
        if (view instanceof C4782Qsl) {
            C4782Qsl qsl = (C4782Qsl) view;
            int totalScrollRange = qsl.getTotalScrollRange();
            int downNestedPreScrollRange = qsl.getDownNestedPreScrollRange();
            HeaderBehavior headerBehavior = qsl.getLayoutParams().LIZ;
            if (headerBehavior instanceof AppBarLayout$BaseBehavior) {
                i = headerBehavior.getTopBottomOffsetForScrollingSibling();
            } else {
                i = 0;
            }
            if ((downNestedPreScrollRange == 0 || totalScrollRange + i > downNestedPreScrollRange) && (i2 = totalScrollRange - downNestedPreScrollRange) != 0) {
                return (((float) i) / ((float) i2)) + 1.0f;
            }
        }
        return 0.0f;
    }

    public AppBarLayout$ScrollingViewBehavior(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
        TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, new int[]{2130969078});
        this.LIZLLL = obtainStyledAttributes.getDimensionPixelSize(0, 0);
        obtainStyledAttributes.recycle();
    }

    public boolean layoutDependsOn(1gt r2, View view, View view2) {
        return view2 instanceof C4782Qsl;
    }

    public /* bridge */ /* synthetic */ boolean onLayoutChild(1gt r2, View view, int i) {
        return super.onLayoutChild(r2, view, i);
    }

    public boolean onDependentViewChanged(1gt r4, View view, View view2) {
        boolean z;
        AppBarLayout$BaseBehavior appBarLayout$BaseBehavior = view2.getLayoutParams().LIZ;
        if (appBarLayout$BaseBehavior instanceof AppBarLayout$BaseBehavior) {
            t.LIZIZ(view, (((view2.getBottom() - view.getTop()) + appBarLayout$BaseBehavior.offsetDelta) + this.LIZJ) - LIZJ(view2));
        }
        if (view2 instanceof C4782Qsl) {
            C4782Qsl qsl = (C4782Qsl) view2;
            if (qsl.LJFF) {
                if (view.getScrollY() > 0) {
                    z = true;
                } else {
                    z = false;
                }
                qsl.LIZ(z);
            }
        }
        return false;
    }

    public boolean onRequestChildRectangleOnScreen(1gt r6, View view, Rect rect, boolean z) {
        C4782Qsl LIZIZ = LIZ((List<View>) r6.LIZIZ(view));
        if (LIZIZ != null) {
            rect.offset(view.getLeft(), view.getTop());
            Rect rect2 = this.LIZ;
            rect2.set(0, 0, r6.getWidth(), r6.getHeight());
            if (!rect2.contains(rect)) {
                LIZIZ.LIZ(false, !z, true);
                return true;
            }
        }
        return false;
    }

    public /* bridge */ /* synthetic */ boolean onMeasureChild(1gt r2, View view, int i, int i2, int i3, int i4) {
        return super.onMeasureChild(r2, view, i, i2, i3, i4);
    }
}
