package androidx.core.widget;

import android.R;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.os.Parcelable;
import android.util.AttributeSet;
import android.util.TypedValue;
import android.view.FocusFinder;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.VelocityTracker;
import android.view.View;
import android.view.ViewConfiguration;
import android.view.ViewGroup;
import android.view.ViewParent;
import android.view.animation.AnimationUtils;
import android.widget.EdgeEffect;
import android.widget.FrameLayout;
import android.widget.OverScroller;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import androidx.core.view.e0;
import androidx.core.view.g0;
import androidx.core.view.i0;
import androidx.core.view.k0;
import androidx.core.view.o;
import androidx.core.view.q0;
import androidx.core.view.s1;
import e.y;
import java.util.ArrayList;
import m0.a;
import u0.h;
import u0.k;
import u0.l;
import u0.m;
import u0.n;

/* JADX INFO: loaded from: classes.dex */
public class NestedScrollView extends FrameLayout implements i0, e0, q0 {

    /* JADX INFO: renamed from: i0, reason: collision with root package name */
    public static final float f1879i0 = (float) (Math.log(0.78d) / Math.log(0.9d));

    /* JADX INFO: renamed from: j0, reason: collision with root package name */
    public static final k f1880j0 = new k(0);

    /* JADX INFO: renamed from: k0, reason: collision with root package name */
    public static final int[] f1881k0 = {R.attr.fillViewport};
    public boolean Q;
    public final int R;
    public final int S;
    public final int T;
    public int U;
    public final int[] V;
    public final int[] W;

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final float f1882a;

    /* JADX INFO: renamed from: a0, reason: collision with root package name */
    public int f1883a0;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public long f1884b;

    /* JADX INFO: renamed from: b0, reason: collision with root package name */
    public int f1885b0;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final Rect f1886c;

    /* JADX INFO: renamed from: c0, reason: collision with root package name */
    public n f1887c0;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public final OverScroller f1888d;

    /* JADX INFO: renamed from: d0, reason: collision with root package name */
    public final k0 f1889d0;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public final EdgeEffect f1890e;

    /* JADX INFO: renamed from: e0, reason: collision with root package name */
    public final g0 f1891e0;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public final EdgeEffect f1892f;

    /* JADX INFO: renamed from: f0, reason: collision with root package name */
    public float f1893f0;

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public int f1894g;

    /* JADX INFO: renamed from: g0, reason: collision with root package name */
    public m f1895g0;

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public boolean f1896h;

    /* JADX INFO: renamed from: h0, reason: collision with root package name */
    public final o f1897h0;

    /* JADX INFO: renamed from: i, reason: collision with root package name */
    public boolean f1898i;

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    public View f1899j;

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    public boolean f1900k;

    /* JADX INFO: renamed from: l, reason: collision with root package name */
    public VelocityTracker f1901l;

    /* JADX INFO: renamed from: m, reason: collision with root package name */
    public boolean f1902m;

    public NestedScrollView(@NonNull Context context) {
        this(context, null);
    }

    public static boolean f(View view, View view2) {
        if (view == view2) {
            return true;
        }
        Object parent = view.getParent();
        return (parent instanceof ViewGroup) && f((View) parent, view2);
    }

    private void onNestedScrollInternal(int i10, int i11, @Nullable int[] iArr) {
        int scrollY = getScrollY();
        scrollBy(0, i10);
        int scrollY2 = getScrollY() - scrollY;
        if (iArr != null) {
            iArr[1] = iArr[1] + scrollY2;
        }
        this.f1891e0.dispatchNestedScroll(0, scrollY2, 0, i10 - scrollY2, null, i11, iArr);
    }

    public final boolean a(int i10) {
        View viewFindFocus = findFocus();
        if (viewFindFocus == this) {
            viewFindFocus = null;
        }
        View viewFindNextFocus = FocusFinder.getInstance().findNextFocus(this, viewFindFocus, i10);
        int maxScrollAmount = getMaxScrollAmount();
        if (viewFindNextFocus == null || !g(viewFindNextFocus, maxScrollAmount, getHeight())) {
            if (i10 == 33 && getScrollY() < maxScrollAmount) {
                maxScrollAmount = getScrollY();
            } else if (i10 == 130 && getChildCount() > 0) {
                View childAt = getChildAt(0);
                maxScrollAmount = Math.min((childAt.getBottom() + ((FrameLayout.LayoutParams) childAt.getLayoutParams()).bottomMargin) - ((getHeight() + getScrollY()) - getPaddingBottom()), maxScrollAmount);
            }
            if (maxScrollAmount == 0) {
                return false;
            }
            if (i10 != 130) {
                maxScrollAmount = -maxScrollAmount;
            }
            l(maxScrollAmount, 0, 1, true);
        } else {
            Rect rect = this.f1886c;
            viewFindNextFocus.getDrawingRect(rect);
            offsetDescendantRectToMyCoords(viewFindNextFocus, rect);
            l(b(rect), 0, 1, true);
            viewFindNextFocus.requestFocus(i10);
        }
        if (viewFindFocus != null && viewFindFocus.isFocused() && (!g(viewFindFocus, 0, getHeight()))) {
            int descendantFocusability = getDescendantFocusability();
            setDescendantFocusability(131072);
            requestFocus();
            setDescendantFocusability(descendantFocusability);
        }
        return true;
    }

    @Override // android.view.ViewGroup
    public final void addView(View view) {
        if (getChildCount() > 0) {
            throw new IllegalStateException("ScrollView can host only one direct child");
        }
        super.addView(view);
    }

    public final int b(Rect rect) {
        if (getChildCount() == 0) {
            return 0;
        }
        int height = getHeight();
        int scrollY = getScrollY();
        int i10 = scrollY + height;
        int verticalFadingEdgeLength = getVerticalFadingEdgeLength();
        if (rect.top > 0) {
            scrollY += verticalFadingEdgeLength;
        }
        View childAt = getChildAt(0);
        FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) childAt.getLayoutParams();
        int i11 = rect.bottom < (childAt.getHeight() + layoutParams.topMargin) + layoutParams.bottomMargin ? i10 - verticalFadingEdgeLength : i10;
        int i12 = rect.bottom;
        if (i12 > i11 && rect.top > scrollY) {
            return Math.min(rect.height() > height ? rect.top - scrollY : rect.bottom - i11, (childAt.getBottom() + layoutParams.bottomMargin) - i10);
        }
        if (rect.top >= scrollY || i12 >= i11) {
            return 0;
        }
        return Math.max(rect.height() > height ? 0 - (i11 - rect.bottom) : 0 - (scrollY - rect.top), -getScrollY());
    }

    public final boolean c(KeyEvent keyEvent) {
        this.f1886c.setEmpty();
        if (getChildCount() > 0) {
            View childAt = getChildAt(0);
            FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) childAt.getLayoutParams();
            if (childAt.getHeight() + layoutParams.topMargin + layoutParams.bottomMargin > (getHeight() - getPaddingTop()) - getPaddingBottom()) {
                if (keyEvent.getAction() != 0) {
                    return false;
                }
                int keyCode = keyEvent.getKeyCode();
                if (keyCode == 19) {
                    return keyEvent.isAltPressed() ? e(33) : a(33);
                }
                if (keyCode == 20) {
                    return keyEvent.isAltPressed() ? e(130) : a(130);
                }
                if (keyCode == 62) {
                    j(keyEvent.isShiftPressed() ? 33 : 130);
                    return false;
                }
                if (keyCode == 92) {
                    return e(33);
                }
                if (keyCode == 93) {
                    return e(130);
                }
                if (keyCode == 122) {
                    j(33);
                    return false;
                }
                if (keyCode != 123) {
                    return false;
                }
                j(130);
                return false;
            }
        }
        if (!isFocused() || keyEvent.getKeyCode() == 4) {
            return false;
        }
        View viewFindFocus = findFocus();
        if (viewFindFocus == this) {
            viewFindFocus = null;
        }
        View viewFindNextFocus = FocusFinder.getInstance().findNextFocus(this, viewFindFocus, 130);
        return (viewFindNextFocus == null || viewFindNextFocus == this || !viewFindNextFocus.requestFocus(130)) ? false : true;
    }

    @Override // android.view.View
    public final int computeHorizontalScrollExtent() {
        return super.computeHorizontalScrollExtent();
    }

    @Override // android.view.View
    public final int computeHorizontalScrollOffset() {
        return super.computeHorizontalScrollOffset();
    }

    @Override // android.view.View
    public final int computeHorizontalScrollRange() {
        return super.computeHorizontalScrollRange();
    }

    /* JADX WARN: Removed duplicated region for block: B:21:0x0083  */
    /* JADX WARN: Removed duplicated region for block: B:23:0x0092  */
    /* JADX WARN: Removed duplicated region for block: B:25:0x00b6  */
    /* JADX WARN: Removed duplicated region for block: B:39:0x00f3  */
    /* JADX WARN: Removed duplicated region for block: B:40:0x00f7  */
    @Override // android.view.View
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void computeScroll() {
        int iRound;
        int i10;
        if (this.f1888d.isFinished()) {
            return;
        }
        this.f1888d.computeScrollOffset();
        int currY = this.f1888d.getCurrY();
        int i11 = currY - this.f1885b0;
        int height = getHeight();
        EdgeEffect edgeEffect = this.f1892f;
        EdgeEffect edgeEffect2 = this.f1890e;
        if (i11 <= 0 || h.a(edgeEffect2) == 0.0f) {
            if (i11 < 0 && h.a(edgeEffect) != 0.0f) {
                float f10 = height;
                iRound = Math.round(h.b(edgeEffect, (i11 * 4.0f) / f10, 0.5f) * (f10 / 4.0f));
                if (iRound != i11) {
                    edgeEffect.finish();
                }
            }
            this.f1885b0 = currY;
            int[] iArr = this.W;
            iArr[1] = 0;
            dispatchNestedPreScroll(0, i11, iArr, null, 1);
            i10 = i11 - iArr[1];
            int scrollRange = getScrollRange();
            if (a.d()) {
                l.a(Math.abs(this.f1888d.getCurrVelocity()), this);
            }
            if (i10 != 0) {
                int scrollY = getScrollY();
                i(i10, getScrollX(), scrollY, scrollRange);
                int scrollY2 = getScrollY() - scrollY;
                int i12 = i10 - scrollY2;
                iArr[1] = 0;
                dispatchNestedScroll(0, scrollY2, 0, i12, this.V, 1, iArr);
                i10 = i12 - iArr[1];
            }
            if (i10 != 0) {
                int overScrollMode = getOverScrollMode();
                if (overScrollMode == 0 || (overScrollMode == 1 && scrollRange > 0)) {
                    if (i10 < 0) {
                        if (edgeEffect2.isFinished()) {
                            edgeEffect2.onAbsorb((int) this.f1888d.getCurrVelocity());
                        }
                    } else if (edgeEffect.isFinished()) {
                        edgeEffect.onAbsorb((int) this.f1888d.getCurrVelocity());
                    }
                }
                this.f1888d.abortAnimation();
                r(1);
            }
            if (this.f1888d.isFinished()) {
                postInvalidateOnAnimation();
                return;
            } else {
                r(1);
                return;
            }
        }
        iRound = Math.round(h.b(edgeEffect2, ((-i11) * 4.0f) / height, 0.5f) * ((-height) / 4.0f));
        if (iRound != i11) {
            edgeEffect2.finish();
        }
        i11 -= iRound;
        this.f1885b0 = currY;
        int[] iArr2 = this.W;
        iArr2[1] = 0;
        dispatchNestedPreScroll(0, i11, iArr2, null, 1);
        i10 = i11 - iArr2[1];
        int scrollRange2 = getScrollRange();
        if (a.d()) {
        }
        if (i10 != 0) {
        }
        if (i10 != 0) {
        }
        if (this.f1888d.isFinished()) {
        }
    }

    @Override // android.view.View
    public final int computeVerticalScrollExtent() {
        return super.computeVerticalScrollExtent();
    }

    @Override // android.view.View
    public final int computeVerticalScrollOffset() {
        return Math.max(0, super.computeVerticalScrollOffset());
    }

    @Override // android.view.View
    public final int computeVerticalScrollRange() {
        int childCount = getChildCount();
        int height = (getHeight() - getPaddingBottom()) - getPaddingTop();
        if (childCount == 0) {
            return height;
        }
        View childAt = getChildAt(0);
        int bottom = childAt.getBottom() + ((FrameLayout.LayoutParams) childAt.getLayoutParams()).bottomMargin;
        int scrollY = getScrollY();
        int iMax = Math.max(0, bottom - height);
        return scrollY < 0 ? bottom - scrollY : scrollY > iMax ? bottom + (scrollY - iMax) : bottom;
    }

    public final void d(int i10) {
        if (getChildCount() > 0) {
            this.f1888d.fling(getScrollX(), getScrollY(), 0, i10, 0, 0, Integer.MIN_VALUE, Integer.MAX_VALUE, 0, 0);
            p(2, 1);
            this.f1885b0 = getScrollY();
            postInvalidateOnAnimation();
            if (a.d()) {
                l.a(Math.abs(this.f1888d.getCurrVelocity()), this);
            }
        }
    }

    @Override // android.view.ViewGroup, android.view.View
    public final boolean dispatchKeyEvent(KeyEvent keyEvent) {
        return super.dispatchKeyEvent(keyEvent) || c(keyEvent);
    }

    @Override // android.view.View
    public final boolean dispatchNestedFling(float f10, float f11, boolean z10) {
        return this.f1891e0.a(f10, f11, z10);
    }

    @Override // android.view.View
    public final boolean dispatchNestedPreFling(float f10, float f11) {
        return this.f1891e0.b(f10, f11);
    }

    @Override // androidx.core.view.e0, androidx.core.view.d0
    public boolean dispatchNestedPreScroll(int i10, int i11, @Nullable int[] iArr, @Nullable int[] iArr2, int i12) {
        return this.f1891e0.dispatchNestedPreScroll(i10, i11, iArr, iArr2, i12);
    }

    @Override // androidx.core.view.e0
    public void dispatchNestedScroll(int i10, int i11, int i12, int i13, @Nullable int[] iArr, int i14, @NonNull int[] iArr2) {
        this.f1891e0.dispatchNestedScroll(i10, i11, i12, i13, iArr, i14, iArr2);
    }

    @Override // android.view.View
    public final void draw(Canvas canvas) {
        int paddingLeft;
        super.draw(canvas);
        int scrollY = getScrollY();
        EdgeEffect edgeEffect = this.f1890e;
        int paddingLeft2 = 0;
        if (!edgeEffect.isFinished()) {
            int iSave = canvas.save();
            int width = getWidth();
            int height = getHeight();
            int iMin = Math.min(0, scrollY);
            if (getClipToPadding()) {
                width -= getPaddingRight() + getPaddingLeft();
                paddingLeft = getPaddingLeft();
            } else {
                paddingLeft = 0;
            }
            if (getClipToPadding()) {
                height -= getPaddingBottom() + getPaddingTop();
                iMin += getPaddingTop();
            }
            canvas.translate(paddingLeft, iMin);
            edgeEffect.setSize(width, height);
            if (edgeEffect.draw(canvas)) {
                postInvalidateOnAnimation();
            }
            canvas.restoreToCount(iSave);
        }
        EdgeEffect edgeEffect2 = this.f1892f;
        if (edgeEffect2.isFinished()) {
            return;
        }
        int iSave2 = canvas.save();
        int width2 = getWidth();
        int height2 = getHeight();
        int iMax = Math.max(getScrollRange(), scrollY) + height2;
        if (getClipToPadding()) {
            width2 -= getPaddingRight() + getPaddingLeft();
            paddingLeft2 = getPaddingLeft();
        }
        if (getClipToPadding()) {
            height2 -= getPaddingBottom() + getPaddingTop();
            iMax -= getPaddingBottom();
        }
        canvas.translate(paddingLeft2 - width2, iMax);
        canvas.rotate(180.0f, width2, 0.0f);
        edgeEffect2.setSize(width2, height2);
        if (edgeEffect2.draw(canvas)) {
            postInvalidateOnAnimation();
        }
        canvas.restoreToCount(iSave2);
    }

    public final boolean e(int i10) {
        int childCount;
        boolean z10 = i10 == 130;
        int height = getHeight();
        Rect rect = this.f1886c;
        rect.top = 0;
        rect.bottom = height;
        if (z10 && (childCount = getChildCount()) > 0) {
            View childAt = getChildAt(childCount - 1);
            rect.bottom = getPaddingBottom() + childAt.getBottom() + ((FrameLayout.LayoutParams) childAt.getLayoutParams()).bottomMargin;
            rect.top = rect.bottom - height;
        }
        return k(i10, rect.top, rect.bottom);
    }

    public final boolean g(View view, int i10, int i11) {
        Rect rect = this.f1886c;
        view.getDrawingRect(rect);
        offsetDescendantRectToMyCoords(view, rect);
        return rect.bottom + i10 >= getScrollY() && rect.top - i10 <= getScrollY() + i11;
    }

    @Override // android.view.View
    public float getBottomFadingEdgeStrength() {
        if (getChildCount() == 0) {
            return 0.0f;
        }
        View childAt = getChildAt(0);
        FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) childAt.getLayoutParams();
        int verticalFadingEdgeLength = getVerticalFadingEdgeLength();
        int bottom = ((childAt.getBottom() + layoutParams.bottomMargin) - getScrollY()) - (getHeight() - getPaddingBottom());
        if (bottom < verticalFadingEdgeLength) {
            return bottom / verticalFadingEdgeLength;
        }
        return 1.0f;
    }

    public int getMaxScrollAmount() {
        return (int) (getHeight() * 0.5f);
    }

    @Override // android.view.ViewGroup
    public int getNestedScrollAxes() {
        k0 k0Var = this.f1889d0;
        return k0Var.f1774b | k0Var.f1773a;
    }

    public int getScrollRange() {
        if (getChildCount() <= 0) {
            return 0;
        }
        View childAt = getChildAt(0);
        FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) childAt.getLayoutParams();
        return Math.max(0, ((childAt.getHeight() + layoutParams.topMargin) + layoutParams.bottomMargin) - ((getHeight() - getPaddingTop()) - getPaddingBottom()));
    }

    @Override // android.view.View
    public float getTopFadingEdgeStrength() {
        if (getChildCount() == 0) {
            return 0.0f;
        }
        int verticalFadingEdgeLength = getVerticalFadingEdgeLength();
        int scrollY = getScrollY();
        if (scrollY < verticalFadingEdgeLength) {
            return scrollY / verticalFadingEdgeLength;
        }
        return 1.0f;
    }

    @VisibleForTesting
    public float getVerticalScrollFactorCompat() {
        if (this.f1893f0 == 0.0f) {
            TypedValue typedValue = new TypedValue();
            Context context = getContext();
            if (!context.getTheme().resolveAttribute(R.attr.listPreferredItemHeight, typedValue, true)) {
                throw new IllegalStateException("Expected theme to define listPreferredItemHeight.");
            }
            this.f1893f0 = typedValue.getDimension(context.getResources().getDisplayMetrics());
        }
        return this.f1893f0;
    }

    public final void h(MotionEvent motionEvent) {
        int actionIndex = motionEvent.getActionIndex();
        if (motionEvent.getPointerId(actionIndex) == this.U) {
            int i10 = actionIndex == 0 ? 1 : 0;
            this.f1894g = (int) motionEvent.getY(i10);
            this.U = motionEvent.getPointerId(i10);
            VelocityTracker velocityTracker = this.f1901l;
            if (velocityTracker != null) {
                velocityTracker.clear();
            }
        }
    }

    @Override // android.view.View
    public final boolean hasNestedScrollingParent() {
        return this.f1891e0.d(0);
    }

    public final boolean i(int i10, int i11, int i12, int i13) {
        boolean z10;
        boolean z11;
        getOverScrollMode();
        computeHorizontalScrollRange();
        computeHorizontalScrollExtent();
        computeVerticalScrollRange();
        computeVerticalScrollExtent();
        int i14 = i12 + i10;
        if (i11 <= 0 && i11 >= 0) {
            z10 = false;
        } else {
            i11 = 0;
            z10 = true;
        }
        if (i14 > i13) {
            z11 = true;
        } else if (i14 < 0) {
            i13 = 0;
            z11 = true;
        } else {
            i13 = i14;
            z11 = false;
        }
        if (z11 && !this.f1891e0.d(1)) {
            this.f1888d.springBack(i11, i13, 0, 0, 0, getScrollRange());
        }
        onOverScrolled(i11, i13, z10, z11);
        return z10 || z11;
    }

    @Override // android.view.View
    public final boolean isNestedScrollingEnabled() {
        return this.f1891e0.f1752d;
    }

    public final void j(int i10) {
        boolean z10 = i10 == 130;
        int height = getHeight();
        Rect rect = this.f1886c;
        if (z10) {
            rect.top = getScrollY() + height;
            int childCount = getChildCount();
            if (childCount > 0) {
                View childAt = getChildAt(childCount - 1);
                int paddingBottom = getPaddingBottom() + childAt.getBottom() + ((FrameLayout.LayoutParams) childAt.getLayoutParams()).bottomMargin;
                if (rect.top + height > paddingBottom) {
                    rect.top = paddingBottom - height;
                }
            }
        } else {
            int scrollY = getScrollY() - height;
            rect.top = scrollY;
            if (scrollY < 0) {
                rect.top = 0;
            }
        }
        int i11 = rect.top;
        int i12 = height + i11;
        rect.bottom = i12;
        k(i10, i11, i12);
    }

    /* JADX WARN: Removed duplicated region for block: B:32:0x0068  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final boolean k(int i10, int i11, int i12) {
        boolean z10;
        int height = getHeight();
        int scrollY = getScrollY();
        int i13 = height + scrollY;
        boolean z11 = i10 == 33;
        ArrayList<View> focusables = getFocusables(2);
        int size = focusables.size();
        View view = null;
        boolean z12 = false;
        for (int i14 = 0; i14 < size; i14++) {
            View view2 = focusables.get(i14);
            int top = view2.getTop();
            int bottom = view2.getBottom();
            if (i11 < bottom && top < i12) {
                boolean z13 = i11 < top && bottom < i12;
                if (view == null) {
                    view = view2;
                    z12 = z13;
                } else {
                    boolean z14 = (z11 && top < view.getTop()) || (!z11 && bottom > view.getBottom());
                    if (z12) {
                        if (z13 && z14) {
                            view = view2;
                        }
                    } else if (z13) {
                        view = view2;
                        z12 = true;
                    } else if (z14) {
                    }
                }
            }
        }
        if (view == null) {
            view = this;
        }
        if (i11 < scrollY || i12 > i13) {
            l(z11 ? i11 - scrollY : i12 - i13, 0, 1, true);
            z10 = true;
        } else {
            z10 = false;
        }
        if (view != findFocus()) {
            view.requestFocus(i10);
        }
        return z10;
    }

    public final int l(int i10, int i11, int i12, boolean z10) {
        int i13;
        int i14;
        VelocityTracker velocityTracker;
        if (i12 == 1) {
            p(2, i12);
        }
        boolean zDispatchNestedPreScroll = dispatchNestedPreScroll(0, i10, this.W, this.V, i12);
        int[] iArr = this.W;
        int[] iArr2 = this.V;
        if (zDispatchNestedPreScroll) {
            i13 = i10 - iArr[1];
            i14 = iArr2[1];
        } else {
            i13 = i10;
            i14 = 0;
        }
        int scrollY = getScrollY();
        int scrollRange = getScrollRange();
        int overScrollMode = getOverScrollMode();
        boolean z11 = (overScrollMode == 0 || (overScrollMode == 1 && getScrollRange() > 0)) && !z10;
        boolean z12 = i(i13, 0, scrollY, scrollRange) && !this.f1891e0.d(i12);
        int scrollY2 = getScrollY() - scrollY;
        iArr[1] = 0;
        dispatchNestedScroll(0, scrollY2, 0, i13 - scrollY2, this.V, i12, iArr);
        int i15 = i14 + iArr2[1];
        int i16 = i13 - iArr[1];
        int i17 = scrollY + i16;
        EdgeEffect edgeEffect = this.f1892f;
        EdgeEffect edgeEffect2 = this.f1890e;
        if (i17 < 0) {
            if (z11) {
                h.b(edgeEffect2, (-i16) / getHeight(), i11 / getWidth());
                if (!edgeEffect.isFinished()) {
                    edgeEffect.onRelease();
                }
            }
        } else if (i17 > scrollRange && z11) {
            h.b(edgeEffect, i16 / getHeight(), 1.0f - (i11 / getWidth()));
            if (!edgeEffect2.isFinished()) {
                edgeEffect2.onRelease();
            }
        }
        if (!edgeEffect2.isFinished() || !edgeEffect.isFinished()) {
            postInvalidateOnAnimation();
        } else if (z12 && i12 == 0 && (velocityTracker = this.f1901l) != null) {
            velocityTracker.clear();
        }
        if (i12 == 1) {
            r(i12);
            edgeEffect2.onRelease();
            edgeEffect.onRelease();
        }
        return i15;
    }

    public final boolean m(EdgeEffect edgeEffect, int i10) {
        if (i10 > 0) {
            return true;
        }
        float fA = h.a(edgeEffect) * getHeight();
        float fAbs = Math.abs(-i10) * 0.35f;
        float f10 = this.f1882a * 0.015f;
        double dLog = Math.log(fAbs / f10);
        double d10 = f1879i0;
        return ((float) (Math.exp((d10 / (d10 - 1.0d)) * dLog) * ((double) f10))) < fA;
    }

    @Override // android.view.ViewGroup
    public final void measureChild(View view, int i10, int i11) {
        ViewGroup.LayoutParams layoutParams = view.getLayoutParams();
        view.measure(ViewGroup.getChildMeasureSpec(i10, getPaddingRight() + getPaddingLeft(), layoutParams.width), View.MeasureSpec.makeMeasureSpec(0, 0));
    }

    @Override // android.view.ViewGroup
    public final void measureChildWithMargins(View view, int i10, int i11, int i12, int i13) {
        ViewGroup.MarginLayoutParams marginLayoutParams = (ViewGroup.MarginLayoutParams) view.getLayoutParams();
        view.measure(ViewGroup.getChildMeasureSpec(i10, getPaddingRight() + getPaddingLeft() + marginLayoutParams.leftMargin + marginLayoutParams.rightMargin + i11, marginLayoutParams.width), View.MeasureSpec.makeMeasureSpec(marginLayoutParams.topMargin + marginLayoutParams.bottomMargin, 0));
    }

    public final void n(int i10, int i11, boolean z10) {
        if (getChildCount() == 0) {
            return;
        }
        if (AnimationUtils.currentAnimationTimeMillis() - this.f1884b > 250) {
            View childAt = getChildAt(0);
            FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) childAt.getLayoutParams();
            int height = childAt.getHeight() + layoutParams.topMargin + layoutParams.bottomMargin;
            int height2 = (getHeight() - getPaddingTop()) - getPaddingBottom();
            int scrollY = getScrollY();
            this.f1888d.startScroll(getScrollX(), scrollY, 0, Math.max(0, Math.min(i11 + scrollY, Math.max(0, height - height2))) - scrollY, 250);
            if (z10) {
                p(2, 1);
            } else {
                r(1);
            }
            this.f1885b0 = getScrollY();
            postInvalidateOnAnimation();
        } else {
            if (!this.f1888d.isFinished()) {
                this.f1888d.abortAnimation();
                r(1);
            }
            scrollBy(i10, i11);
        }
        this.f1884b = AnimationUtils.currentAnimationTimeMillis();
    }

    public final void o(int i10) {
        n(0 - getScrollX(), i10 - getScrollY(), false);
    }

    @Override // android.view.ViewGroup, android.view.View
    public final void onAttachedToWindow() {
        super.onAttachedToWindow();
        this.f1898i = false;
    }

    @Override // android.view.View
    public final boolean onGenericMotionEvent(MotionEvent motionEvent) {
        int i10;
        int width;
        float axisValue;
        if (motionEvent.getAction() == 8 && !this.f1900k) {
            if ((motionEvent.getSource() & 2) == 2) {
                i10 = 9;
                axisValue = motionEvent.getAxisValue(9);
                width = (int) motionEvent.getX();
            } else if ((motionEvent.getSource() & 4194304) == 4194304) {
                i10 = 26;
                float axisValue2 = motionEvent.getAxisValue(26);
                width = getWidth() / 2;
                axisValue = axisValue2;
            } else {
                i10 = 0;
                width = 0;
                axisValue = 0.0f;
            }
            if (axisValue != 0.0f) {
                l(-((int) (getVerticalScrollFactorCompat() * axisValue)), width, 1, (motionEvent.getSource() & 8194) == 8194);
                if (i10 != 0) {
                    this.f1897h0.a(motionEvent, i10);
                }
                return true;
            }
        }
        return false;
    }

    /* JADX WARN: Removed duplicated region for block: B:34:0x006b  */
    /* JADX WARN: Removed duplicated region for block: B:62:0x00ff  */
    @Override // android.view.ViewGroup
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final boolean onInterceptTouchEvent(MotionEvent motionEvent) {
        int iFindPointerIndex;
        int action = motionEvent.getAction();
        boolean z10 = true;
        if (action == 2 && this.f1900k) {
            return true;
        }
        int i10 = action & 255;
        if (i10 == 0) {
            int y10 = (int) motionEvent.getY();
            int x10 = (int) motionEvent.getX();
            if (getChildCount() > 0) {
                int scrollY = getScrollY();
                View childAt = getChildAt(0);
                if (y10 < childAt.getTop() - scrollY || y10 >= childAt.getBottom() - scrollY || x10 < childAt.getLeft() || x10 >= childAt.getRight()) {
                    if (!q(motionEvent) && this.f1888d.isFinished()) {
                        z10 = false;
                    }
                    this.f1900k = z10;
                    VelocityTracker velocityTracker = this.f1901l;
                    if (velocityTracker != null) {
                        velocityTracker.recycle();
                        this.f1901l = null;
                    }
                } else {
                    this.f1894g = y10;
                    this.U = motionEvent.getPointerId(0);
                    VelocityTracker velocityTracker2 = this.f1901l;
                    if (velocityTracker2 == null) {
                        this.f1901l = VelocityTracker.obtain();
                    } else {
                        velocityTracker2.clear();
                    }
                    this.f1901l.addMovement(motionEvent);
                    this.f1888d.computeScrollOffset();
                    if (!q(motionEvent) && this.f1888d.isFinished()) {
                        z10 = false;
                    }
                    this.f1900k = z10;
                    p(2, 0);
                }
            }
        } else if (i10 == 1) {
            this.f1900k = false;
            this.U = -1;
            VelocityTracker velocityTracker3 = this.f1901l;
            if (velocityTracker3 != null) {
                velocityTracker3.recycle();
                this.f1901l = null;
            }
            if (this.f1888d.springBack(getScrollX(), getScrollY(), 0, 0, 0, getScrollRange())) {
                postInvalidateOnAnimation();
            }
            r(0);
        } else if (i10 == 2) {
            int i11 = this.U;
            if (i11 != -1 && (iFindPointerIndex = motionEvent.findPointerIndex(i11)) != -1) {
                int y11 = (int) motionEvent.getY(iFindPointerIndex);
                if (Math.abs(y11 - this.f1894g) > this.R && (2 & getNestedScrollAxes()) == 0) {
                    this.f1900k = true;
                    this.f1894g = y11;
                    if (this.f1901l == null) {
                        this.f1901l = VelocityTracker.obtain();
                    }
                    this.f1901l.addMovement(motionEvent);
                    this.f1883a0 = 0;
                    ViewParent parent = getParent();
                    if (parent != null) {
                        parent.requestDisallowInterceptTouchEvent(true);
                    }
                }
            }
        } else if (i10 != 3) {
            if (i10 == 6) {
                h(motionEvent);
            }
        }
        return this.f1900k;
    }

    @Override // android.widget.FrameLayout, android.view.ViewGroup, android.view.View
    public final void onLayout(boolean z10, int i10, int i11, int i12, int i13) {
        int measuredHeight;
        super.onLayout(z10, i10, i11, i12, i13);
        int i14 = 0;
        this.f1896h = false;
        View view = this.f1899j;
        if (view != null && f(view, this)) {
            View view2 = this.f1899j;
            Rect rect = this.f1886c;
            view2.getDrawingRect(rect);
            offsetDescendantRectToMyCoords(view2, rect);
            int iB = b(rect);
            if (iB != 0) {
                scrollBy(0, iB);
            }
        }
        this.f1899j = null;
        if (!this.f1898i) {
            if (this.f1887c0 != null) {
                scrollTo(getScrollX(), this.f1887c0.f33192a);
                this.f1887c0 = null;
            }
            if (getChildCount() > 0) {
                View childAt = getChildAt(0);
                FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) childAt.getLayoutParams();
                measuredHeight = childAt.getMeasuredHeight() + layoutParams.topMargin + layoutParams.bottomMargin;
            } else {
                measuredHeight = 0;
            }
            int paddingTop = ((i13 - i11) - getPaddingTop()) - getPaddingBottom();
            int scrollY = getScrollY();
            if (paddingTop < measuredHeight && scrollY >= 0) {
                i14 = paddingTop + scrollY > measuredHeight ? measuredHeight - paddingTop : scrollY;
            }
            if (i14 != scrollY) {
                scrollTo(getScrollX(), i14);
            }
        }
        scrollTo(getScrollX(), getScrollY());
        this.f1898i = true;
    }

    @Override // android.widget.FrameLayout, android.view.View
    public final void onMeasure(int i10, int i11) {
        super.onMeasure(i10, i11);
        if (this.f1902m && View.MeasureSpec.getMode(i11) != 0 && getChildCount() > 0) {
            View childAt = getChildAt(0);
            FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) childAt.getLayoutParams();
            int measuredHeight = childAt.getMeasuredHeight();
            int measuredHeight2 = (((getMeasuredHeight() - getPaddingTop()) - getPaddingBottom()) - layoutParams.topMargin) - layoutParams.bottomMargin;
            if (measuredHeight < measuredHeight2) {
                childAt.measure(ViewGroup.getChildMeasureSpec(i10, getPaddingRight() + getPaddingLeft() + layoutParams.leftMargin + layoutParams.rightMargin, layoutParams.width), View.MeasureSpec.makeMeasureSpec(measuredHeight2, 1073741824));
            }
        }
    }

    @Override // android.view.ViewGroup, android.view.ViewParent
    public final boolean onNestedFling(View view, float f10, float f11, boolean z10) {
        if (z10) {
            return false;
        }
        dispatchNestedFling(0.0f, f11, true);
        d((int) f11);
        return true;
    }

    @Override // android.view.ViewGroup, android.view.ViewParent
    public final boolean onNestedPreFling(View view, float f10, float f11) {
        return dispatchNestedPreFling(f10, f11);
    }

    @Override // android.view.ViewGroup, android.view.ViewParent
    public final void onNestedPreScroll(View view, int i10, int i11, int[] iArr) {
        dispatchNestedPreScroll(i10, i11, iArr, null, 0);
    }

    @Override // androidx.core.view.i0
    public final void onNestedScroll(View view, int i10, int i11, int i12, int i13, int i14, int[] iArr) {
        onNestedScrollInternal(i13, i14, iArr);
    }

    @Override // androidx.core.view.h0
    public final void onNestedScrollAccepted(View view, View view2, int i10, int i11) {
        this.f1889d0.a(i10, i11);
        p(2, i11);
    }

    @Override // android.view.View
    public final void onOverScrolled(int i10, int i11, boolean z10, boolean z11) {
        super.scrollTo(i10, i11);
    }

    @Override // android.view.ViewGroup
    public final boolean onRequestFocusInDescendants(int i10, Rect rect) {
        if (i10 == 2) {
            i10 = 130;
        } else if (i10 == 1) {
            i10 = 33;
        }
        View viewFindNextFocus = rect == null ? FocusFinder.getInstance().findNextFocus(this, null, i10) : FocusFinder.getInstance().findNextFocusFromRect(this, rect, i10);
        if (viewFindNextFocus == null || (true ^ g(viewFindNextFocus, 0, getHeight()))) {
            return false;
        }
        return viewFindNextFocus.requestFocus(i10, rect);
    }

    @Override // android.view.View
    public final void onRestoreInstanceState(Parcelable parcelable) {
        if (!(parcelable instanceof n)) {
            super.onRestoreInstanceState(parcelable);
            return;
        }
        n nVar = (n) parcelable;
        super.onRestoreInstanceState(nVar.getSuperState());
        this.f1887c0 = nVar;
        requestLayout();
    }

    @Override // android.view.View
    public final Parcelable onSaveInstanceState() {
        n nVar = new n(super.onSaveInstanceState());
        nVar.f33192a = getScrollY();
        return nVar;
    }

    @Override // android.view.View
    public final void onScrollChanged(int i10, int i11, int i12, int i13) {
        super.onScrollChanged(i10, i11, i12, i13);
        m mVar = this.f1895g0;
        if (mVar != null) {
            mVar.b(this, i11, i13);
        }
    }

    @Override // android.view.View
    public final void onSizeChanged(int i10, int i11, int i12, int i13) {
        super.onSizeChanged(i10, i11, i12, i13);
        View viewFindFocus = findFocus();
        if (viewFindFocus == null || this == viewFindFocus || !g(viewFindFocus, 0, i13)) {
            return;
        }
        Rect rect = this.f1886c;
        viewFindFocus.getDrawingRect(rect);
        offsetDescendantRectToMyCoords(viewFindFocus, rect);
        int iB = b(rect);
        if (iB != 0) {
            if (this.Q) {
                n(0, iB, false);
            } else {
                scrollBy(0, iB);
            }
        }
    }

    @Override // androidx.core.view.h0
    public final boolean onStartNestedScroll(View view, View view2, int i10, int i11) {
        return (i10 & 2) != 0;
    }

    @Override // androidx.core.view.h0
    public final void onStopNestedScroll(View view, int i10) {
        k0 k0Var = this.f1889d0;
        if (i10 == 1) {
            k0Var.f1774b = 0;
        } else {
            k0Var.f1773a = 0;
        }
        r(i10);
    }

    @Override // android.view.View
    public final boolean onTouchEvent(MotionEvent motionEvent) {
        ViewParent parent;
        if (this.f1901l == null) {
            this.f1901l = VelocityTracker.obtain();
        }
        int actionMasked = motionEvent.getActionMasked();
        if (actionMasked == 0) {
            this.f1883a0 = 0;
        }
        MotionEvent motionEventObtain = MotionEvent.obtain(motionEvent);
        float f10 = 0.0f;
        motionEventObtain.offsetLocation(0.0f, this.f1883a0);
        if (actionMasked != 0) {
            EdgeEffect edgeEffect = this.f1892f;
            EdgeEffect edgeEffect2 = this.f1890e;
            if (actionMasked == 1) {
                VelocityTracker velocityTracker = this.f1901l;
                velocityTracker.computeCurrentVelocity(1000, this.T);
                int yVelocity = (int) velocityTracker.getYVelocity(this.U);
                if (Math.abs(yVelocity) >= this.S) {
                    if (h.a(edgeEffect2) != 0.0f) {
                        if (m(edgeEffect2, yVelocity)) {
                            edgeEffect2.onAbsorb(yVelocity);
                        } else {
                            d(-yVelocity);
                        }
                    } else if (h.a(edgeEffect) != 0.0f) {
                        int i10 = -yVelocity;
                        if (m(edgeEffect, i10)) {
                            edgeEffect.onAbsorb(i10);
                        } else {
                            d(i10);
                        }
                    } else {
                        int i11 = -yVelocity;
                        float f11 = i11;
                        if (!dispatchNestedPreFling(0.0f, f11)) {
                            dispatchNestedFling(0.0f, f11, true);
                            d(i11);
                        }
                    }
                } else if (this.f1888d.springBack(getScrollX(), getScrollY(), 0, 0, 0, getScrollRange())) {
                    postInvalidateOnAnimation();
                }
                this.U = -1;
                this.f1900k = false;
                VelocityTracker velocityTracker2 = this.f1901l;
                if (velocityTracker2 != null) {
                    velocityTracker2.recycle();
                    this.f1901l = null;
                }
                r(0);
                this.f1890e.onRelease();
                this.f1892f.onRelease();
            } else if (actionMasked == 2) {
                int iFindPointerIndex = motionEvent.findPointerIndex(this.U);
                if (iFindPointerIndex != -1) {
                    int y10 = (int) motionEvent.getY(iFindPointerIndex);
                    int i12 = this.f1894g - y10;
                    float x10 = motionEvent.getX(iFindPointerIndex) / getWidth();
                    float height = i12 / getHeight();
                    if (h.a(edgeEffect2) != 0.0f) {
                        float f12 = -h.b(edgeEffect2, -height, x10);
                        if (h.a(edgeEffect2) == 0.0f) {
                            edgeEffect2.onRelease();
                        }
                        f10 = f12;
                    } else if (h.a(edgeEffect) != 0.0f) {
                        float fB = h.b(edgeEffect, height, 1.0f - x10);
                        if (h.a(edgeEffect) == 0.0f) {
                            edgeEffect.onRelease();
                        }
                        f10 = fB;
                    }
                    int iRound = Math.round(f10 * getHeight());
                    if (iRound != 0) {
                        invalidate();
                    }
                    int i13 = i12 - iRound;
                    if (!this.f1900k && Math.abs(i13) > this.R) {
                        ViewParent parent2 = getParent();
                        if (parent2 != null) {
                            parent2.requestDisallowInterceptTouchEvent(true);
                        }
                        this.f1900k = true;
                        i13 = i13 > 0 ? i13 - this.R : i13 + this.R;
                    }
                    if (this.f1900k) {
                        int iL = l(i13, (int) motionEvent.getX(iFindPointerIndex), 0, false);
                        this.f1894g = y10 - iL;
                        this.f1883a0 += iL;
                    }
                }
            } else if (actionMasked == 3) {
                if (this.f1900k && getChildCount() > 0 && this.f1888d.springBack(getScrollX(), getScrollY(), 0, 0, 0, getScrollRange())) {
                    postInvalidateOnAnimation();
                }
                this.U = -1;
                this.f1900k = false;
                VelocityTracker velocityTracker3 = this.f1901l;
                if (velocityTracker3 != null) {
                    velocityTracker3.recycle();
                    this.f1901l = null;
                }
                r(0);
                this.f1890e.onRelease();
                this.f1892f.onRelease();
            } else if (actionMasked == 5) {
                int actionIndex = motionEvent.getActionIndex();
                this.f1894g = (int) motionEvent.getY(actionIndex);
                this.U = motionEvent.getPointerId(actionIndex);
            } else if (actionMasked == 6) {
                h(motionEvent);
                this.f1894g = (int) motionEvent.getY(motionEvent.findPointerIndex(this.U));
            }
        } else {
            if (getChildCount() == 0) {
                return false;
            }
            if (this.f1900k && (parent = getParent()) != null) {
                parent.requestDisallowInterceptTouchEvent(true);
            }
            if (!this.f1888d.isFinished()) {
                this.f1888d.abortAnimation();
                r(1);
            }
            int y11 = (int) motionEvent.getY();
            int pointerId = motionEvent.getPointerId(0);
            this.f1894g = y11;
            this.U = pointerId;
            p(2, 0);
        }
        VelocityTracker velocityTracker4 = this.f1901l;
        if (velocityTracker4 != null) {
            velocityTracker4.addMovement(motionEventObtain);
        }
        motionEventObtain.recycle();
        return true;
    }

    public final boolean p(int i10, int i11) {
        return this.f1891e0.f(2, i11);
    }

    public final boolean q(MotionEvent motionEvent) {
        boolean z10;
        EdgeEffect edgeEffect = this.f1890e;
        if (h.a(edgeEffect) != 0.0f) {
            h.b(edgeEffect, 0.0f, motionEvent.getX() / getWidth());
            z10 = true;
        } else {
            z10 = false;
        }
        EdgeEffect edgeEffect2 = this.f1892f;
        if (h.a(edgeEffect2) == 0.0f) {
            return z10;
        }
        h.b(edgeEffect2, 0.0f, 1.0f - (motionEvent.getX() / getWidth()));
        return true;
    }

    public final void r(int i10) {
        this.f1891e0.g(i10);
    }

    @Override // android.view.ViewGroup, android.view.ViewParent
    public final void requestChildFocus(View view, View view2) {
        if (this.f1896h) {
            this.f1899j = view2;
        } else {
            Rect rect = this.f1886c;
            view2.getDrawingRect(rect);
            offsetDescendantRectToMyCoords(view2, rect);
            int iB = b(rect);
            if (iB != 0) {
                scrollBy(0, iB);
            }
        }
        super.requestChildFocus(view, view2);
    }

    @Override // android.view.ViewGroup, android.view.ViewParent
    public final boolean requestChildRectangleOnScreen(View view, Rect rect, boolean z10) {
        rect.offset(view.getLeft() - view.getScrollX(), view.getTop() - view.getScrollY());
        int iB = b(rect);
        boolean z11 = iB != 0;
        if (z11) {
            if (z10) {
                scrollBy(0, iB);
            } else {
                n(0, iB, false);
            }
        }
        return z11;
    }

    @Override // android.view.ViewGroup, android.view.ViewParent
    public final void requestDisallowInterceptTouchEvent(boolean z10) {
        VelocityTracker velocityTracker;
        if (z10 && (velocityTracker = this.f1901l) != null) {
            velocityTracker.recycle();
            this.f1901l = null;
        }
        super.requestDisallowInterceptTouchEvent(z10);
    }

    @Override // android.view.View, android.view.ViewParent
    public final void requestLayout() {
        this.f1896h = true;
        super.requestLayout();
    }

    @Override // android.view.View
    public final void scrollTo(int i10, int i11) {
        if (getChildCount() > 0) {
            View childAt = getChildAt(0);
            FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) childAt.getLayoutParams();
            int width = (getWidth() - getPaddingLeft()) - getPaddingRight();
            int width2 = childAt.getWidth() + layoutParams.leftMargin + layoutParams.rightMargin;
            int height = (getHeight() - getPaddingTop()) - getPaddingBottom();
            int height2 = childAt.getHeight() + layoutParams.topMargin + layoutParams.bottomMargin;
            if (width >= width2 || i10 < 0) {
                i10 = 0;
            } else if (width + i10 > width2) {
                i10 = width2 - width;
            }
            if (height >= height2 || i11 < 0) {
                i11 = 0;
            } else if (height + i11 > height2) {
                i11 = height2 - height;
            }
            if (i10 == getScrollX() && i11 == getScrollY()) {
                return;
            }
            super.scrollTo(i10, i11);
        }
    }

    public void setFillViewport(boolean z10) {
        if (z10 != this.f1902m) {
            this.f1902m = z10;
            requestLayout();
        }
    }

    @Override // android.view.View
    public void setNestedScrollingEnabled(boolean z10) {
        this.f1891e0.e(z10);
    }

    public void setOnScrollChangeListener(@Nullable m mVar) {
        this.f1895g0 = mVar;
    }

    public void setSmoothScrollingEnabled(boolean z10) {
        this.Q = z10;
    }

    @Override // android.widget.FrameLayout, android.view.ViewGroup
    public final boolean shouldDelayChildPressedState() {
        return true;
    }

    @Override // android.view.View
    public final boolean startNestedScroll(int i10) {
        return this.f1891e0.f(i10, 0);
    }

    @Override // android.view.View
    public final void stopNestedScroll() {
        r(0);
    }

    public NestedScrollView(@NonNull Context context, @Nullable AttributeSet attributeSet) {
        this(context, attributeSet, e0.a.nestedScrollViewStyle);
    }

    @Override // android.view.View, androidx.core.view.e0, androidx.core.view.d0, androidx.core.view.f0
    public boolean dispatchNestedPreScroll(int i10, int i11, @Nullable int[] iArr, @Nullable int[] iArr2) {
        return dispatchNestedPreScroll(i10, i11, iArr, iArr2, 0);
    }

    @Override // androidx.core.view.e0, androidx.core.view.d0
    public boolean dispatchNestedScroll(int i10, int i11, int i12, int i13, @Nullable int[] iArr, int i14) {
        return this.f1891e0.dispatchNestedScroll(i10, i11, i12, i13, iArr, i14);
    }

    @Override // androidx.core.view.h0
    public final void onNestedPreScroll(View view, int i10, int i11, int[] iArr, int i12) {
        dispatchNestedPreScroll(i10, i11, iArr, null, i12);
    }

    @Override // androidx.core.view.h0
    public final void onNestedScroll(View view, int i10, int i11, int i12, int i13, int i14) {
        onNestedScrollInternal(i13, i14, null);
    }

    @Override // android.view.ViewGroup, android.view.ViewParent
    public final boolean onStartNestedScroll(View view, View view2, int i10) {
        return onStartNestedScroll(view, view2, i10, 0);
    }

    public NestedScrollView(@NonNull Context context, @Nullable AttributeSet attributeSet, int i10) {
        super(context, attributeSet, i10);
        this.f1886c = new Rect();
        this.f1896h = true;
        this.f1898i = false;
        this.f1899j = null;
        this.f1900k = false;
        this.Q = true;
        this.U = -1;
        this.V = new int[2];
        this.W = new int[2];
        this.f1897h0 = new o(getContext(), new y(this));
        this.f1890e = h.create(context, attributeSet);
        this.f1892f = h.create(context, attributeSet);
        this.f1882a = context.getResources().getDisplayMetrics().density * 160.0f * 386.0878f * 0.84f;
        this.f1888d = new OverScroller(getContext());
        setFocusable(true);
        setDescendantFocusability(262144);
        setWillNotDraw(false);
        ViewConfiguration viewConfiguration = ViewConfiguration.get(getContext());
        this.R = viewConfiguration.getScaledTouchSlop();
        this.S = viewConfiguration.getScaledMinimumFlingVelocity();
        this.T = viewConfiguration.getScaledMaximumFlingVelocity();
        TypedArray typedArrayObtainStyledAttributes = context.obtainStyledAttributes(attributeSet, f1881k0, i10, 0);
        setFillViewport(typedArrayObtainStyledAttributes.getBoolean(0, false));
        typedArrayObtainStyledAttributes.recycle();
        this.f1889d0 = new k0();
        this.f1891e0 = new g0(this);
        setNestedScrollingEnabled(true);
        s1.setAccessibilityDelegate(this, f1880j0);
    }

    @Override // android.view.View, androidx.core.view.e0, androidx.core.view.d0, androidx.core.view.f0
    public boolean dispatchNestedScroll(int i10, int i11, int i12, int i13, @Nullable int[] iArr) {
        return this.f1891e0.dispatchNestedScroll(i10, i11, i12, i13, iArr);
    }

    @Override // android.view.ViewGroup, android.view.ViewParent
    public final void onNestedScroll(View view, int i10, int i11, int i12, int i13) {
        onNestedScrollInternal(i13, 0, null);
    }

    @Override // android.view.ViewGroup, android.view.ViewParent
    public final void onNestedScrollAccepted(View view, View view2, int i10) {
        onNestedScrollAccepted(view, view2, i10, 0);
    }

    @Override // android.view.ViewGroup
    public final void addView(View view, int i10) {
        if (getChildCount() <= 0) {
            super.addView(view, i10);
            return;
        }
        throw new IllegalStateException("ScrollView can host only one direct child");
    }

    @Override // android.view.ViewGroup, android.view.ViewParent
    public final void onStopNestedScroll(View view) {
        onStopNestedScroll(view, 0);
    }

    @Override // android.view.ViewGroup, android.view.ViewManager
    public final void addView(View view, ViewGroup.LayoutParams layoutParams) {
        if (getChildCount() <= 0) {
            super.addView(view, layoutParams);
            return;
        }
        throw new IllegalStateException("ScrollView can host only one direct child");
    }

    @Override // android.view.ViewGroup
    public final void addView(View view, int i10, ViewGroup.LayoutParams layoutParams) {
        if (getChildCount() <= 0) {
            super.addView(view, i10, layoutParams);
            return;
        }
        throw new IllegalStateException("ScrollView can host only one direct child");
    }
}
