package androidx.core.widget;

import A7.a;
import M.B;
import M.C0177g;
import M.C0180j;
import M.InterfaceC0182l;
import M.J;
import M.r;
import P.c;
import P.e;
import P.f;
import P.g;
import P.h;
import P.i;
import android.R;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.os.Build;
import android.os.Parcelable;
import android.util.AttributeSet;
import android.util.Log;
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 java.lang.reflect.Field;
import java.util.ArrayList;
import s7.d;

/* JADX INFO: loaded from: classes.dex */
public class NestedScrollView extends FrameLayout implements InterfaceC0182l {

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

    /* JADX INFO: renamed from: T, reason: collision with root package name */
    public static final e f7959T = new e(0);

    /* JADX INFO: renamed from: U, reason: collision with root package name */
    public static final int[] f7960U = {R.attr.fillViewport};

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

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

    /* JADX INFO: renamed from: C, reason: collision with root package name */
    public VelocityTracker f7963C;
    public boolean D;

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

    /* JADX INFO: renamed from: F, reason: collision with root package name */
    public final int f7965F;

    /* JADX INFO: renamed from: G, reason: collision with root package name */
    public final int f7966G;
    public final int H;

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

    /* JADX INFO: renamed from: J, reason: collision with root package name */
    public final int[] f7968J;

    /* JADX INFO: renamed from: K, reason: collision with root package name */
    public final int[] f7969K;

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

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

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

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

    /* JADX INFO: renamed from: P, reason: collision with root package name */
    public final C0180j f7974P;

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

    /* JADX INFO: renamed from: R, reason: collision with root package name */
    public final C0177g f7976R;

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

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

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

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

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

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

    /* JADX INFO: renamed from: w, reason: collision with root package name */
    public r f7983w;

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

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

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

    public NestedScrollView(Context context, AttributeSet attributeSet) {
        super(context, attributeSet, com.martsnew.tv.R.attr.nestedScrollViewStyle);
        this.f7979s = new Rect();
        this.f7985y = true;
        this.f7986z = false;
        this.f7961A = null;
        this.f7962B = false;
        this.f7964E = true;
        this.f7967I = -1;
        this.f7968J = new int[2];
        this.f7969K = new int[2];
        this.f7976R = new C0177g(getContext(), new g(0, this));
        int i = Build.VERSION.SDK_INT;
        this.f7981u = i >= 31 ? c.a(context, attributeSet) : new EdgeEffect(context);
        this.f7982v = i >= 31 ? c.a(context, attributeSet) : new EdgeEffect(context);
        this.f7977q = context.getResources().getDisplayMetrics().density * 160.0f * 386.0878f * 0.84f;
        this.f7980t = new OverScroller(getContext());
        setFocusable(true);
        setDescendantFocusability(262144);
        setWillNotDraw(false);
        ViewConfiguration viewConfiguration = ViewConfiguration.get(getContext());
        this.f7965F = viewConfiguration.getScaledTouchSlop();
        this.f7966G = viewConfiguration.getScaledMinimumFlingVelocity();
        this.H = viewConfiguration.getScaledMaximumFlingVelocity();
        TypedArray typedArrayObtainStyledAttributes = context.obtainStyledAttributes(attributeSet, f7960U, com.martsnew.tv.R.attr.nestedScrollViewStyle, 0);
        setFillViewport(typedArrayObtainStyledAttributes.getBoolean(0, false));
        typedArrayObtainStyledAttributes.recycle();
        this.f7973O = new a();
        this.f7974P = new C0180j(this);
        setNestedScrollingEnabled(true);
        J.j(this, f7959T);
    }

    private r getScrollFeedbackProvider() {
        if (this.f7983w == null) {
            this.f7983w = new r(this);
        }
        return this.f7983w;
    }

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

    @Override // M.InterfaceC0181k
    public final void a(View view, View view2, int i, int i5) {
        a aVar = this.f7973O;
        if (i5 == 1) {
            aVar.f461b = i;
        } else {
            aVar.f460a = i;
        }
        this.f7974P.g(2, i5);
    }

    @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);
    }

    @Override // M.InterfaceC0181k
    public final void b(View view, int i) {
        a aVar = this.f7973O;
        if (i == 1) {
            aVar.f461b = 0;
        } else {
            aVar.f460a = 0;
        }
        v(i);
    }

    @Override // M.InterfaceC0181k
    public final void c(View view, int i, int i5, int[] iArr, int i8) {
        this.f7974P.c(i, i5, i8, iArr, null);
    }

    @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:22:0x0087  */
    /* JADX WARN: Removed duplicated region for block: B:24:0x0096  */
    /* JADX WARN: Removed duplicated region for block: B:26:0x00bb  */
    /* JADX WARN: Removed duplicated region for block: B:40:0x00f8  */
    /* JADX WARN: Removed duplicated region for block: B:42:0x00fc  */
    @Override // android.view.View
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void computeScroll() {
        int iRound;
        int i;
        if (this.f7980t.isFinished()) {
            return;
        }
        this.f7980t.computeScrollOffset();
        int currY = this.f7980t.getCurrY();
        int i5 = currY - this.f7971M;
        int height = getHeight();
        EdgeEffect edgeEffect = this.f7982v;
        EdgeEffect edgeEffect2 = this.f7981u;
        if (i5 <= 0 || W2.g.t(edgeEffect2) == 0.0f) {
            if (i5 < 0 && W2.g.t(edgeEffect) != 0.0f) {
                float f3 = height;
                iRound = Math.round(W2.g.C(edgeEffect, (i5 * 4.0f) / f3, 0.5f) * (f3 / 4.0f));
                if (iRound != i5) {
                    edgeEffect.finish();
                }
            }
            int i8 = i5;
            this.f7971M = currY;
            int[] iArr = this.f7969K;
            iArr[1] = 0;
            this.f7974P.c(0, i8, 1, iArr, null);
            i = i8 - iArr[1];
            int scrollRange = getScrollRange();
            if (Build.VERSION.SDK_INT >= 35) {
                f.a(this, Math.abs(this.f7980t.getCurrVelocity()));
            }
            if (i != 0) {
                int scrollY = getScrollY();
                o(i, getScrollX(), scrollY, scrollRange);
                int scrollY2 = getScrollY() - scrollY;
                int i9 = i - scrollY2;
                iArr[1] = 0;
                this.f7974P.d(0, scrollY2, 0, i9, this.f7968J, 1, iArr);
                i = i9 - iArr[1];
            }
            if (i != 0) {
                int overScrollMode = getOverScrollMode();
                if (overScrollMode == 0 || (overScrollMode == 1 && scrollRange > 0)) {
                    if (i < 0) {
                        if (edgeEffect2.isFinished()) {
                            edgeEffect2.onAbsorb((int) this.f7980t.getCurrVelocity());
                        }
                    } else if (edgeEffect.isFinished()) {
                        edgeEffect.onAbsorb((int) this.f7980t.getCurrVelocity());
                    }
                }
                this.f7980t.abortAnimation();
                v(1);
            }
            if (this.f7980t.isFinished()) {
                postInvalidateOnAnimation();
                return;
            } else {
                v(1);
                return;
            }
        }
        iRound = Math.round(W2.g.C(edgeEffect2, ((-i5) * 4.0f) / height, 0.5f) * ((-height) / 4.0f));
        if (iRound != i5) {
            edgeEffect2.finish();
        }
        i5 -= iRound;
        int i82 = i5;
        this.f7971M = currY;
        int[] iArr2 = this.f7969K;
        iArr2[1] = 0;
        this.f7974P.c(0, i82, 1, iArr2, null);
        i = i82 - iArr2[1];
        int scrollRange2 = getScrollRange();
        if (Build.VERSION.SDK_INT >= 35) {
        }
        if (i != 0) {
        }
        if (i != 0) {
        }
        if (this.f7980t.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 ? (scrollY - iMax) + bottom : bottom;
    }

    @Override // M.InterfaceC0182l
    public final void d(View view, int i, int i5, int i8, int i9, int i10, int[] iArr) {
        m(i9, i10, iArr);
    }

    /* JADX WARN: Removed duplicated region for block: B:26:0x0065  */
    /* JADX WARN: Removed duplicated region for block: B:42:0x00a1  */
    /* JADX WARN: Removed duplicated region for block: B:57:0x00cb A[RETURN] */
    @Override // android.view.ViewGroup, android.view.View
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final boolean dispatchKeyEvent(KeyEvent keyEvent) {
        boolean zJ;
        if (!super.dispatchKeyEvent(keyEvent)) {
            this.f7979s.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) {
                        zJ = false;
                        if (!zJ) {
                            return false;
                        }
                    } else {
                        int keyCode = keyEvent.getKeyCode();
                        if (keyCode == 19) {
                            zJ = keyEvent.isAltPressed() ? j(33) : g(33);
                        } else if (keyCode != 20) {
                            if (keyCode == 62) {
                                p(keyEvent.isShiftPressed() ? 33 : 130);
                            } else if (keyCode == 92) {
                                zJ = j(33);
                            } else if (keyCode == 93) {
                                zJ = j(130);
                            } else if (keyCode == 122) {
                                p(33);
                            } else if (keyCode == 123) {
                                p(130);
                            }
                            zJ = false;
                        } else {
                            zJ = keyEvent.isAltPressed() ? j(130) : g(130);
                        }
                        if (!zJ) {
                        }
                    }
                } else if (isFocused() && keyEvent.getKeyCode() != 4) {
                    View viewFindFocus = findFocus();
                    if (viewFindFocus == this) {
                        viewFindFocus = null;
                    }
                    View viewFindNextFocus = FocusFinder.getInstance().findNextFocus(this, viewFindFocus, 130);
                    if (viewFindNextFocus != null && viewFindNextFocus != this && viewFindNextFocus.requestFocus(130)) {
                        zJ = true;
                    }
                    if (!zJ) {
                    }
                }
            }
        }
        return true;
    }

    @Override // android.view.View
    public final boolean dispatchNestedFling(float f3, float f7, boolean z8) {
        return this.f7974P.a(f3, f7, z8);
    }

    @Override // android.view.View
    public final boolean dispatchNestedPreFling(float f3, float f7) {
        return this.f7974P.b(f3, f7);
    }

    @Override // android.view.View
    public final boolean dispatchNestedPreScroll(int i, int i5, int[] iArr, int[] iArr2) {
        return this.f7974P.c(i, i5, 0, iArr, iArr2);
    }

    @Override // android.view.View
    public final boolean dispatchNestedScroll(int i, int i5, int i8, int i9, int[] iArr) {
        return this.f7974P.d(i, i5, i8, i9, iArr, 0, null);
    }

    @Override // android.view.View
    public final void draw(Canvas canvas) {
        int paddingLeft;
        super.draw(canvas);
        int scrollY = getScrollY();
        EdgeEffect edgeEffect = this.f7981u;
        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.f7982v;
        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);
    }

    @Override // M.InterfaceC0181k
    public final void e(View view, int i, int i5, int i8, int i9, int i10) {
        m(i9, i10, null);
    }

    @Override // M.InterfaceC0181k
    public final boolean f(View view, View view2, int i, int i5) {
        return (i & 2) != 0;
    }

    public final boolean g(int i) {
        View viewFindFocus = findFocus();
        if (viewFindFocus == this) {
            viewFindFocus = null;
        }
        View view = viewFindFocus;
        View viewFindNextFocus = FocusFinder.getInstance().findNextFocus(this, view, i);
        int maxScrollAmount = getMaxScrollAmount();
        if (viewFindNextFocus == null || !l(viewFindNextFocus, maxScrollAmount, getHeight())) {
            if (i == 33 && getScrollY() < maxScrollAmount) {
                maxScrollAmount = getScrollY();
            } else if (i == 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 (i != 130) {
                maxScrollAmount = -maxScrollAmount;
            }
            r(maxScrollAmount, -1, null, 0, 1, true);
        } else {
            Rect rect = this.f7979s;
            viewFindNextFocus.getDrawingRect(rect);
            offsetDescendantRectToMyCoords(viewFindNextFocus, rect);
            r(h(rect), -1, null, 0, 1, true);
            viewFindNextFocus.requestFocus(i);
        }
        if (view != null && view.isFocused() && !l(view, 0, getHeight())) {
            int descendantFocusability = getDescendantFocusability();
            setDescendantFocusability(131072);
            requestFocus();
            setDescendantFocusability(descendantFocusability);
        }
        return true;
    }

    @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() {
        a aVar = this.f7973O;
        return aVar.f461b | aVar.f460a;
    }

    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;
    }

    public float getVerticalScrollFactorCompat() {
        if (this.f7975Q == 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.f7975Q = typedValue.getDimension(context.getResources().getDisplayMetrics());
        }
        return this.f7975Q;
    }

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

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

    public final void i(int i) {
        if (getChildCount() > 0) {
            this.f7980t.fling(getScrollX(), getScrollY(), 0, i, 0, 0, Integer.MIN_VALUE, Integer.MAX_VALUE, 0, 0);
            this.f7974P.g(2, 1);
            this.f7971M = getScrollY();
            postInvalidateOnAnimation();
            if (Build.VERSION.SDK_INT >= 35) {
                f.a(this, Math.abs(this.f7980t.getCurrVelocity()));
            }
        }
    }

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

    public final boolean j(int i) {
        int childCount;
        boolean z8 = i == 130;
        int height = getHeight();
        Rect rect = this.f7979s;
        rect.top = 0;
        rect.bottom = height;
        if (z8 && (childCount = getChildCount()) > 0) {
            View childAt = getChildAt(childCount - 1);
            int paddingBottom = getPaddingBottom() + childAt.getBottom() + ((FrameLayout.LayoutParams) childAt.getLayoutParams()).bottomMargin;
            rect.bottom = paddingBottom;
            rect.top = paddingBottom - height;
        }
        return q(i, rect.top, rect.bottom);
    }

    public final boolean l(View view, int i, int i5) {
        Rect rect = this.f7979s;
        view.getDrawingRect(rect);
        offsetDescendantRectToMyCoords(view, rect);
        return rect.bottom + i >= getScrollY() && rect.top - i <= getScrollY() + i5;
    }

    public final void m(int i, int i5, int[] iArr) {
        int scrollY = getScrollY();
        scrollBy(0, i);
        int scrollY2 = getScrollY() - scrollY;
        if (iArr != null) {
            iArr[1] = iArr[1] + scrollY2;
        }
        this.f7974P.d(0, scrollY2, 0, i - scrollY2, null, i5, iArr);
    }

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

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

    public final void n(MotionEvent motionEvent) {
        int actionIndex = motionEvent.getActionIndex();
        if (motionEvent.getPointerId(actionIndex) == this.f7967I) {
            int i = actionIndex == 0 ? 1 : 0;
            this.f7984x = (int) motionEvent.getY(i);
            this.f7967I = motionEvent.getPointerId(i);
            VelocityTracker velocityTracker = this.f7963C;
            if (velocityTracker != null) {
                velocityTracker.clear();
            }
        }
    }

    public final boolean o(int i, int i5, int i8, int i9) {
        int i10;
        boolean z8;
        int i11;
        boolean z9;
        getOverScrollMode();
        super.computeHorizontalScrollRange();
        super.computeHorizontalScrollExtent();
        computeVerticalScrollRange();
        super.computeVerticalScrollExtent();
        int i12 = i8 + i;
        if (i5 <= 0 && i5 >= 0) {
            i10 = i5;
            z8 = false;
        } else {
            i10 = 0;
            z8 = true;
        }
        if (i12 > i9) {
            i11 = i9;
        } else {
            if (i12 >= 0) {
                i11 = i12;
                z9 = false;
                if (z9 && !this.f7974P.f(1)) {
                    this.f7980t.springBack(i10, i11, 0, 0, 0, getScrollRange());
                }
                super.scrollTo(i10, i11);
                return !z8 || z9;
            }
            i11 = 0;
        }
        z9 = true;
        if (z9) {
            this.f7980t.springBack(i10, i11, 0, 0, 0, getScrollRange());
        }
        super.scrollTo(i10, i11);
        if (z8) {
        }
    }

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

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

    /* JADX WARN: Removed duplicated region for block: B:34:0x0083  */
    /* JADX WARN: Removed duplicated region for block: B:62:0x0119  */
    @Override // android.view.ViewGroup
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final boolean onInterceptTouchEvent(MotionEvent motionEvent) {
        int action = motionEvent.getAction();
        boolean z8 = true;
        if (action == 2 && this.f7962B) {
            return true;
        }
        int i = action & 255;
        if (i == 0) {
            int y8 = (int) motionEvent.getY();
            int x8 = (int) motionEvent.getX();
            if (getChildCount() > 0) {
                int scrollY = getScrollY();
                View childAt = getChildAt(0);
                if (y8 < childAt.getTop() - scrollY || y8 >= childAt.getBottom() - scrollY || x8 < childAt.getLeft() || x8 >= childAt.getRight()) {
                    if (!u(motionEvent) && this.f7980t.isFinished()) {
                        z8 = false;
                    }
                    this.f7962B = z8;
                    VelocityTracker velocityTracker = this.f7963C;
                    if (velocityTracker != null) {
                        velocityTracker.recycle();
                        this.f7963C = null;
                    }
                } else {
                    this.f7984x = y8;
                    this.f7967I = motionEvent.getPointerId(0);
                    VelocityTracker velocityTracker2 = this.f7963C;
                    if (velocityTracker2 == null) {
                        this.f7963C = VelocityTracker.obtain();
                    } else {
                        velocityTracker2.clear();
                    }
                    this.f7963C.addMovement(motionEvent);
                    this.f7980t.computeScrollOffset();
                    if (!u(motionEvent) && this.f7980t.isFinished()) {
                        z8 = false;
                    }
                    this.f7962B = z8;
                    this.f7974P.g(2, 0);
                }
            }
        } else if (i == 1) {
            this.f7962B = false;
            this.f7967I = -1;
            VelocityTracker velocityTracker3 = this.f7963C;
            if (velocityTracker3 != null) {
                velocityTracker3.recycle();
                this.f7963C = null;
            }
            if (this.f7980t.springBack(getScrollX(), getScrollY(), 0, 0, 0, getScrollRange())) {
                postInvalidateOnAnimation();
            }
            v(0);
        } else if (i == 2) {
            int i5 = this.f7967I;
            if (i5 != -1) {
                int iFindPointerIndex = motionEvent.findPointerIndex(i5);
                if (iFindPointerIndex == -1) {
                    Log.e("NestedScrollView", "Invalid pointerId=" + i5 + " in onInterceptTouchEvent");
                } else {
                    int y9 = (int) motionEvent.getY(iFindPointerIndex);
                    if (Math.abs(y9 - this.f7984x) > this.f7965F && (2 & getNestedScrollAxes()) == 0) {
                        this.f7962B = true;
                        this.f7984x = y9;
                        if (this.f7963C == null) {
                            this.f7963C = VelocityTracker.obtain();
                        }
                        this.f7963C.addMovement(motionEvent);
                        this.f7970L = 0;
                        ViewParent parent = getParent();
                        if (parent != null) {
                            parent.requestDisallowInterceptTouchEvent(true);
                        }
                    }
                }
            }
        } else if (i != 3) {
            if (i == 6) {
                n(motionEvent);
            }
        }
        return this.f7962B;
    }

    @Override // android.widget.FrameLayout, android.view.ViewGroup, android.view.View
    public final void onLayout(boolean z8, int i, int i5, int i8, int i9) {
        int measuredHeight;
        super.onLayout(z8, i, i5, i8, i9);
        int i10 = 0;
        this.f7985y = false;
        View view = this.f7961A;
        if (view != null && k(view, this)) {
            View view2 = this.f7961A;
            Rect rect = this.f7979s;
            view2.getDrawingRect(rect);
            offsetDescendantRectToMyCoords(view2, rect);
            int iH = h(rect);
            if (iH != 0) {
                scrollBy(0, iH);
            }
        }
        this.f7961A = null;
        if (!this.f7986z) {
            if (this.f7972N != null) {
                scrollTo(getScrollX(), this.f7972N.f5247q);
                this.f7972N = 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 = ((i9 - i5) - getPaddingTop()) - getPaddingBottom();
            int scrollY = getScrollY();
            if (paddingTop < measuredHeight && scrollY >= 0) {
                i10 = paddingTop + scrollY > measuredHeight ? measuredHeight - paddingTop : scrollY;
            }
            if (i10 != scrollY) {
                scrollTo(getScrollX(), i10);
            }
        }
        scrollTo(getScrollX(), getScrollY());
        this.f7986z = true;
    }

    @Override // android.widget.FrameLayout, android.view.View
    public final void onMeasure(int i, int i5) {
        super.onMeasure(i, i5);
        if (this.D && View.MeasureSpec.getMode(i5) != 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(i, 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 f3, float f7, boolean z8) {
        if (z8) {
            return false;
        }
        dispatchNestedFling(0.0f, f7, true);
        i((int) f7);
        return true;
    }

    @Override // android.view.ViewGroup, android.view.ViewParent
    public final boolean onNestedPreFling(View view, float f3, float f7) {
        return this.f7974P.b(f3, f7);
    }

    @Override // android.view.ViewGroup, android.view.ViewParent
    public final void onNestedPreScroll(View view, int i, int i5, int[] iArr) {
        this.f7974P.c(i, i5, 0, iArr, null);
    }

    @Override // android.view.ViewGroup, android.view.ViewParent
    public final void onNestedScroll(View view, int i, int i5, int i8, int i9) {
        m(i9, 0, null);
    }

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

    @Override // android.view.View
    public final void onOverScrolled(int i, int i5, boolean z8, boolean z9) {
        super.scrollTo(i, i5);
    }

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

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

    @Override // android.view.View
    public final Parcelable onSaveInstanceState() {
        i iVar = new i(super.onSaveInstanceState());
        iVar.f5247q = getScrollY();
        return iVar;
    }

    @Override // android.view.View
    public final void onScrollChanged(int i, int i5, int i8, int i9) {
        super.onScrollChanged(i, i5, i8, i9);
    }

    @Override // android.view.View
    public final void onSizeChanged(int i, int i5, int i8, int i9) {
        super.onSizeChanged(i, i5, i8, i9);
        View viewFindFocus = findFocus();
        if (viewFindFocus == null || this == viewFindFocus || !l(viewFindFocus, 0, i9)) {
            return;
        }
        Rect rect = this.f7979s;
        viewFindFocus.getDrawingRect(rect);
        offsetDescendantRectToMyCoords(viewFindFocus, rect);
        int iH = h(rect);
        if (iH != 0) {
            if (this.f7964E) {
                t(0, iH, false);
            } else {
                scrollBy(0, iH);
            }
        }
    }

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

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

    /* JADX WARN: Removed duplicated region for block: B:49:0x0124  */
    /* JADX WARN: Removed duplicated region for block: B:56:0x013a  */
    /* JADX WARN: Removed duplicated region for block: B:59:0x0141  */
    /* JADX WARN: Removed duplicated region for block: B:60:0x0145  */
    /* JADX WARN: Removed duplicated region for block: B:63:0x014c  */
    @Override // android.view.View
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final boolean onTouchEvent(MotionEvent motionEvent) {
        ViewParent parent;
        float fC;
        int iRound;
        int i;
        ViewParent parent2;
        if (this.f7963C == null) {
            this.f7963C = VelocityTracker.obtain();
        }
        int actionMasked = motionEvent.getActionMasked();
        if (actionMasked == 0) {
            this.f7970L = 0;
        }
        MotionEvent motionEventObtain = MotionEvent.obtain(motionEvent);
        float f3 = 0.0f;
        motionEventObtain.offsetLocation(0.0f, this.f7970L);
        C0180j c0180j = this.f7974P;
        if (actionMasked != 0) {
            EdgeEffect edgeEffect = this.f7982v;
            EdgeEffect edgeEffect2 = this.f7981u;
            if (actionMasked == 1) {
                VelocityTracker velocityTracker = this.f7963C;
                velocityTracker.computeCurrentVelocity(1000, this.H);
                int yVelocity = (int) velocityTracker.getYVelocity(this.f7967I);
                if (Math.abs(yVelocity) >= this.f7966G) {
                    if (W2.g.t(edgeEffect2) != 0.0f) {
                        if (s(edgeEffect2, yVelocity)) {
                            edgeEffect2.onAbsorb(yVelocity);
                        } else {
                            i(-yVelocity);
                        }
                    } else if (W2.g.t(edgeEffect) != 0.0f) {
                        int i5 = -yVelocity;
                        if (s(edgeEffect, i5)) {
                            edgeEffect.onAbsorb(i5);
                        } else {
                            i(i5);
                        }
                    } else {
                        int i8 = -yVelocity;
                        float f7 = i8;
                        if (!c0180j.b(0.0f, f7)) {
                            dispatchNestedFling(0.0f, f7, true);
                            i(i8);
                        }
                    }
                } else if (this.f7980t.springBack(getScrollX(), getScrollY(), 0, 0, 0, getScrollRange())) {
                    postInvalidateOnAnimation();
                }
                this.f7967I = -1;
                this.f7962B = false;
                VelocityTracker velocityTracker2 = this.f7963C;
                if (velocityTracker2 != null) {
                    velocityTracker2.recycle();
                    this.f7963C = null;
                }
                v(0);
                this.f7981u.onRelease();
                this.f7982v.onRelease();
            } else if (actionMasked == 2) {
                int iFindPointerIndex = motionEvent.findPointerIndex(this.f7967I);
                if (iFindPointerIndex == -1) {
                    Log.e("NestedScrollView", "Invalid pointerId=" + this.f7967I + " in onTouchEvent");
                } else {
                    int y8 = (int) motionEvent.getY(iFindPointerIndex);
                    int i9 = this.f7984x - y8;
                    float x8 = motionEvent.getX(iFindPointerIndex) / getWidth();
                    float height = i9 / getHeight();
                    if (W2.g.t(edgeEffect2) != 0.0f) {
                        fC = -W2.g.C(edgeEffect2, -height, x8);
                        if (W2.g.t(edgeEffect2) == 0.0f) {
                            edgeEffect2.onRelease();
                        }
                    } else {
                        if (W2.g.t(edgeEffect) != 0.0f) {
                            fC = W2.g.C(edgeEffect, height, 1.0f - x8);
                            if (W2.g.t(edgeEffect) == 0.0f) {
                                edgeEffect.onRelease();
                            }
                        }
                        iRound = Math.round(f3 * getHeight());
                        if (iRound != 0) {
                            invalidate();
                        }
                        i = i9 - iRound;
                        if (!this.f7962B && Math.abs(i) > this.f7965F) {
                            parent2 = getParent();
                            if (parent2 != null) {
                                parent2.requestDisallowInterceptTouchEvent(true);
                            }
                            this.f7962B = true;
                            i = i <= 0 ? i - this.f7965F : i + this.f7965F;
                        }
                        if (this.f7962B) {
                            int iR = r(i, 1, motionEvent, (int) motionEvent.getX(iFindPointerIndex), 0, false);
                            this.f7984x = y8 - iR;
                            this.f7970L += iR;
                        }
                    }
                    f3 = fC;
                    iRound = Math.round(f3 * getHeight());
                    if (iRound != 0) {
                    }
                    i = i9 - iRound;
                    if (!this.f7962B) {
                        parent2 = getParent();
                        if (parent2 != null) {
                        }
                        this.f7962B = true;
                        if (i <= 0) {
                        }
                    }
                    if (this.f7962B) {
                    }
                }
            } else if (actionMasked == 3) {
                if (this.f7962B && getChildCount() > 0 && this.f7980t.springBack(getScrollX(), getScrollY(), 0, 0, 0, getScrollRange())) {
                    postInvalidateOnAnimation();
                }
                this.f7967I = -1;
                this.f7962B = false;
                VelocityTracker velocityTracker3 = this.f7963C;
                if (velocityTracker3 != null) {
                    velocityTracker3.recycle();
                    this.f7963C = null;
                }
                v(0);
                this.f7981u.onRelease();
                this.f7982v.onRelease();
            } else if (actionMasked == 5) {
                int actionIndex = motionEvent.getActionIndex();
                this.f7984x = (int) motionEvent.getY(actionIndex);
                this.f7967I = motionEvent.getPointerId(actionIndex);
            } else if (actionMasked == 6) {
                n(motionEvent);
                this.f7984x = (int) motionEvent.getY(motionEvent.findPointerIndex(this.f7967I));
            }
        } else {
            if (getChildCount() == 0) {
                return false;
            }
            if (this.f7962B && (parent = getParent()) != null) {
                parent.requestDisallowInterceptTouchEvent(true);
            }
            if (!this.f7980t.isFinished()) {
                this.f7980t.abortAnimation();
                v(1);
            }
            int y9 = (int) motionEvent.getY();
            int pointerId = motionEvent.getPointerId(0);
            this.f7984x = y9;
            this.f7967I = pointerId;
            c0180j.g(2, 0);
        }
        VelocityTracker velocityTracker4 = this.f7963C;
        if (velocityTracker4 != null) {
            velocityTracker4.addMovement(motionEventObtain);
        }
        motionEventObtain.recycle();
        return true;
    }

    public final void p(int i) {
        boolean z8 = i == 130;
        int height = getHeight();
        Rect rect = this.f7979s;
        if (z8) {
            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 i5 = rect.top;
        int i8 = height + i5;
        rect.bottom = i8;
        q(i, i5, i8);
    }

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

    /* JADX WARN: Removed duplicated region for block: B:52:0x0117  */
    /* JADX WARN: Removed duplicated region for block: B:59:0x0128  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final int r(int i, int i5, MotionEvent motionEvent, int i8, int i9, boolean z8) {
        int i10;
        int i11;
        boolean z9;
        boolean z10;
        VelocityTracker velocityTracker;
        C0180j c0180j = this.f7974P;
        if (i9 == 1) {
            c0180j.g(2, i9);
        }
        boolean zC = this.f7974P.c(0, i, i9, this.f7969K, this.f7968J);
        int[] iArr = this.f7969K;
        int[] iArr2 = this.f7968J;
        if (zC) {
            i10 = i - iArr[1];
            i11 = iArr2[1];
        } else {
            i10 = i;
            i11 = 0;
        }
        int scrollY = getScrollY();
        int scrollRange = getScrollRange();
        int overScrollMode = getOverScrollMode();
        boolean z11 = (overScrollMode == 0 || (overScrollMode == 1 && getScrollRange() > 0)) && !z8;
        boolean z12 = o(i10, 0, scrollY, scrollRange) && !c0180j.f(i9);
        int scrollY2 = getScrollY() - scrollY;
        if (motionEvent != null && scrollY2 != 0) {
            getScrollFeedbackProvider().f4128a.l(motionEvent.getDeviceId(), motionEvent.getSource(), i5, scrollY2);
        }
        iArr[1] = 0;
        this.f7974P.d(0, scrollY2, 0, i10 - scrollY2, this.f7968J, i9, iArr);
        int i12 = i11 + iArr2[1];
        int i13 = i10 - iArr[1];
        int i14 = scrollY + i13;
        EdgeEffect edgeEffect = this.f7982v;
        EdgeEffect edgeEffect2 = this.f7981u;
        if (i14 >= 0) {
            if (i14 > scrollRange && z11) {
                W2.g.C(edgeEffect, i13 / getHeight(), 1.0f - (i8 / getWidth()));
                if (motionEvent != null) {
                    z9 = false;
                    getScrollFeedbackProvider().f4128a.b(motionEvent.getDeviceId(), motionEvent.getSource(), i5, false);
                } else {
                    z9 = false;
                }
                if (!edgeEffect2.isFinished()) {
                    edgeEffect2.onRelease();
                }
            }
            if (edgeEffect2.isFinished() || !edgeEffect.isFinished()) {
                postInvalidateOnAnimation();
                z10 = z9;
            } else {
                z10 = z12;
            }
            if (z10 && i9 == 0 && (velocityTracker = this.f7963C) != null) {
                velocityTracker.clear();
            }
            if (i9 == 1) {
                v(i9);
                edgeEffect2.onRelease();
                edgeEffect.onRelease();
            }
            return i12;
        }
        if (z11) {
            W2.g.C(edgeEffect2, (-i13) / getHeight(), i8 / getWidth());
            if (motionEvent != null) {
                getScrollFeedbackProvider().f4128a.b(motionEvent.getDeviceId(), motionEvent.getSource(), i5, true);
            }
            if (!edgeEffect.isFinished()) {
                edgeEffect.onRelease();
            }
        }
        z9 = false;
        if (edgeEffect2.isFinished()) {
            postInvalidateOnAnimation();
            z10 = z9;
        }
        if (z10) {
            velocityTracker.clear();
        }
        if (i9 == 1) {
        }
        return i12;
    }

    @Override // android.view.ViewGroup, android.view.ViewParent
    public final void requestChildFocus(View view, View view2) {
        if (this.f7985y) {
            this.f7961A = view2;
        } else {
            Rect rect = this.f7979s;
            view2.getDrawingRect(rect);
            offsetDescendantRectToMyCoords(view2, rect);
            int iH = h(rect);
            if (iH != 0) {
                scrollBy(0, iH);
            }
        }
        super.requestChildFocus(view, view2);
    }

    @Override // android.view.ViewGroup, android.view.ViewParent
    public final boolean requestChildRectangleOnScreen(View view, Rect rect, boolean z8) {
        rect.offset(view.getLeft() - view.getScrollX(), view.getTop() - view.getScrollY());
        int iH = h(rect);
        boolean z9 = iH != 0;
        if (z9) {
            if (z8) {
                scrollBy(0, iH);
                return z9;
            }
            t(0, iH, false);
        }
        return z9;
    }

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

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

    public final boolean s(EdgeEffect edgeEffect, int i) {
        if (i > 0) {
            return true;
        }
        float fT = W2.g.t(edgeEffect) * getHeight();
        float fAbs = Math.abs(-i) * 0.35f;
        float f3 = this.f7977q * 0.015f;
        double dLog = Math.log(fAbs / f3);
        double d8 = f7958S;
        return ((float) (Math.exp((d8 / (d8 - 1.0d)) * dLog) * ((double) f3))) < fT;
    }

    @Override // android.view.View
    public final void scrollTo(int i, int i5) {
        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 || i < 0) {
                i = 0;
            } else if (width + i > width2) {
                i = width2 - width;
            }
            if (height >= height2 || i5 < 0) {
                i5 = 0;
            } else if (height + i5 > height2) {
                i5 = height2 - height;
            }
            if (i == getScrollX() && i5 == getScrollY()) {
                return;
            }
            super.scrollTo(i, i5);
        }
    }

    public void setFillViewport(boolean z8) {
        if (z8 != this.D) {
            this.D = z8;
            requestLayout();
        }
    }

    @Override // android.view.View
    public void setNestedScrollingEnabled(boolean z8) {
        C0180j c0180j = this.f7974P;
        if (c0180j.f4122d) {
            Field field = J.f4065a;
            B.m(c0180j.f4121c);
        }
        c0180j.f4122d = z8;
    }

    public void setSmoothScrollingEnabled(boolean z8) {
        this.f7964E = z8;
    }

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

    @Override // android.view.View
    public final boolean startNestedScroll(int i) {
        return this.f7974P.g(i, 0);
    }

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

    public final void t(int i, int i5, boolean z8) {
        if (getChildCount() == 0) {
            return;
        }
        if (AnimationUtils.currentAnimationTimeMillis() - this.f7978r > 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.f7980t.startScroll(getScrollX(), scrollY, 0, Math.max(0, Math.min(i5 + scrollY, Math.max(0, height - height2))) - scrollY, 250);
            if (z8) {
                this.f7974P.g(2, 1);
            } else {
                v(1);
            }
            this.f7971M = getScrollY();
            postInvalidateOnAnimation();
        } else {
            if (!this.f7980t.isFinished()) {
                this.f7980t.abortAnimation();
                v(1);
            }
            scrollBy(i, i5);
        }
        this.f7978r = AnimationUtils.currentAnimationTimeMillis();
    }

    public final boolean u(MotionEvent motionEvent) {
        boolean z8;
        EdgeEffect edgeEffect = this.f7981u;
        if (W2.g.t(edgeEffect) != 0.0f) {
            W2.g.C(edgeEffect, 0.0f, motionEvent.getX() / getWidth());
            z8 = true;
        } else {
            z8 = false;
        }
        EdgeEffect edgeEffect2 = this.f7982v;
        if (W2.g.t(edgeEffect2) == 0.0f) {
            return z8;
        }
        W2.g.C(edgeEffect2, 0.0f, 1.0f - (motionEvent.getX() / getWidth()));
        return true;
    }

    public final void v(int i) {
        this.f7974P.h(i);
    }

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

    @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 i, ViewGroup.LayoutParams layoutParams) {
        if (getChildCount() <= 0) {
            super.addView(view, i, layoutParams);
            return;
        }
        throw new IllegalStateException("ScrollView can host only one direct child");
    }

    public void setOnScrollChangeListener(h hVar) {
    }
}
