package androidx.recyclerview.widget;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Matrix;
import android.graphics.Rect;
import android.graphics.RectF;
import android.os.Bundle;
import android.os.Parcelable;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;
import android.view.accessibility.AccessibilityEvent;
import androidx.annotation.CallSuper;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.Px;
import java.util.ArrayList;
import java.util.Objects;
import java.util.WeakHashMap;

/* JADX INFO: loaded from: classes.dex */
public abstract class q1 {
    boolean mAutoMeasure;
    f mChildHelper;
    private int mHeight;
    private int mHeightMode;
    w2 mHorizontalBoundCheck;
    private final v2 mHorizontalBoundCheckCallback;
    boolean mIsAttachedToWindow;
    private boolean mItemPrefetchEnabled;
    private boolean mMeasurementCacheEnabled;
    int mPrefetchMaxCountObserved;
    boolean mPrefetchMaxObservedInInitialPrefetch;
    RecyclerView mRecyclerView;
    boolean mRequestedSimpleAnimations;

    @Nullable
    e2 mSmoothScroller;
    w2 mVerticalBoundCheck;
    private final v2 mVerticalBoundCheckCallback;
    private int mWidth;
    private int mWidthMode;

    public q1() {
        n1 n1Var = new n1(this, 0);
        this.mHorizontalBoundCheckCallback = n1Var;
        n1 n1Var2 = new n1(this, 1);
        this.mVerticalBoundCheckCallback = n1Var2;
        this.mHorizontalBoundCheck = new w2(n1Var);
        this.mVerticalBoundCheck = new w2(n1Var2);
        this.mRequestedSimpleAnimations = false;
        this.mIsAttachedToWindow = false;
        this.mAutoMeasure = false;
        this.mMeasurementCacheEnabled = true;
        this.mItemPrefetchEnabled = true;
    }

    public static int chooseSize(int i10, int i11, int i12) {
        int mode = View.MeasureSpec.getMode(i10);
        int size = View.MeasureSpec.getSize(i10);
        return mode != Integer.MIN_VALUE ? mode != 1073741824 ? Math.max(i11, i12) : size : Math.min(size, Math.max(i11, i12));
    }

    /* JADX WARN: Removed duplicated region for block: B:5:0x000c A[PHI: r3
      0x000c: PHI (r3v5 int) = (r3v0 int), (r3v2 int), (r3v0 int) binds: [B:7:0x0010, B:11:0x0016, B:4:0x000a] A[DONT_GENERATE, DONT_INLINE]] */
    /* JADX WARN: Removed duplicated region for block: B:6:0x000e  */
    @Deprecated
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public static int getChildMeasureSpec(int i10, int i11, int i12, boolean z10) {
        int i13 = i10 - i11;
        int i14 = 0;
        int iMax = Math.max(0, i13);
        if (z10) {
            if (i12 >= 0) {
                i14 = 1073741824;
            } else {
                i12 = 0;
            }
        } else if (i12 < 0) {
            if (i12 == -1) {
                i12 = iMax;
                i14 = 1073741824;
            } else if (i12 == -2) {
                i14 = Integer.MIN_VALUE;
                i12 = iMax;
            }
        }
        return View.MeasureSpec.makeMeasureSpec(i12, i14);
    }

    public static p1 getProperties(@NonNull Context context, @Nullable AttributeSet attributeSet, int i10, int i11) {
        p1 p1Var = new p1();
        TypedArray typedArrayObtainStyledAttributes = context.obtainStyledAttributes(attributeSet, e3.d.RecyclerView, i10, i11);
        p1Var.f3851a = typedArrayObtainStyledAttributes.getInt(e3.d.RecyclerView_android_orientation, 1);
        p1Var.f3852b = typedArrayObtainStyledAttributes.getInt(e3.d.RecyclerView_spanCount, 1);
        p1Var.f3853c = typedArrayObtainStyledAttributes.getBoolean(e3.d.RecyclerView_reverseLayout, false);
        p1Var.f3854d = typedArrayObtainStyledAttributes.getBoolean(e3.d.RecyclerView_stackFromEnd, false);
        typedArrayObtainStyledAttributes.recycle();
        return p1Var;
    }

    public static boolean l(int i10, int i11, int i12) {
        int mode = View.MeasureSpec.getMode(i11);
        int size = View.MeasureSpec.getSize(i11);
        if (i12 > 0 && i10 != i12) {
            return false;
        }
        if (mode == Integer.MIN_VALUE) {
            return size >= i10;
        }
        if (mode != 0) {
            return mode == 1073741824 && size == i10;
        }
        return true;
    }

    @SuppressLint({"UnknownNullness"})
    public void addDisappearingView(View view) {
        addDisappearingView(view, -1);
    }

    @SuppressLint({"UnknownNullness"})
    public void addView(View view) {
        addView(view, -1);
    }

    public void assertInLayoutOrScroll(String str) {
        RecyclerView recyclerView = this.mRecyclerView;
        if (recyclerView != null) {
            recyclerView.assertInLayoutOrScroll(str);
        }
    }

    @SuppressLint({"UnknownNullness"})
    public void assertNotInLayoutOrScroll(String str) {
        RecyclerView recyclerView = this.mRecyclerView;
        if (recyclerView != null) {
            recyclerView.assertNotInLayoutOrScroll(str);
        }
    }

    public void attachView(@NonNull View view, int i10, r1 r1Var) {
        j2 childViewHolderInt = RecyclerView.getChildViewHolderInt(view);
        if (childViewHolderInt.isRemoved()) {
            androidx.collection.s sVar = this.mRecyclerView.mViewInfoStore.f3982a;
            x2 x2VarA = (x2) sVar.get(childViewHolderInt);
            if (x2VarA == null) {
                x2VarA = x2.a();
                sVar.put(childViewHolderInt, x2VarA);
            }
            x2VarA.f3960a |= 1;
        } else {
            this.mRecyclerView.mViewInfoStore.c(childViewHolderInt);
        }
        this.mChildHelper.b(view, i10, r1Var, childViewHolderInt.isRemoved());
    }

    public void calculateItemDecorationsForChild(@NonNull View view, @NonNull Rect rect) {
        RecyclerView recyclerView = this.mRecyclerView;
        if (recyclerView == null) {
            rect.set(0, 0, 0, 0);
        } else {
            rect.set(recyclerView.getItemDecorInsetsForChild(view));
        }
    }

    public abstract boolean canScrollHorizontally();

    public abstract boolean canScrollVertically();

    public boolean checkLayoutParams(r1 r1Var) {
        return r1Var != null;
    }

    @SuppressLint({"UnknownNullness"})
    public void collectAdjacentPrefetchPositions(int i10, int i11, f2 f2Var, o1 o1Var) {
    }

    @SuppressLint({"UnknownNullness"})
    public void collectInitialPrefetchPositions(int i10, o1 o1Var) {
    }

    public abstract int computeHorizontalScrollExtent(f2 f2Var);

    public int computeHorizontalScrollOffset(@NonNull f2 f2Var) {
        return 0;
    }

    public abstract int computeHorizontalScrollRange(f2 f2Var);

    public abstract int computeVerticalScrollExtent(f2 f2Var);

    public int computeVerticalScrollOffset(@NonNull f2 f2Var) {
        return 0;
    }

    public abstract int computeVerticalScrollRange(f2 f2Var);

    public void detachAndScrapAttachedViews(@NonNull y1 y1Var) {
        for (int childCount = getChildCount() - 1; childCount >= 0; childCount--) {
            m(y1Var, childCount, getChildAt(childCount));
        }
    }

    public void detachAndScrapView(@NonNull View view, @NonNull y1 y1Var) {
        m(y1Var, this.mChildHelper.j(view), view);
    }

    public void detachAndScrapViewAt(int i10, @NonNull y1 y1Var) {
        m(y1Var, i10, getChildAt(i10));
    }

    public void detachView(@NonNull View view) {
        int iJ = this.mChildHelper.j(view);
        if (iJ >= 0) {
            this.mChildHelper.c(iJ);
        }
    }

    public void detachViewAt(int i10) {
        getChildAt(i10);
        this.mChildHelper.c(i10);
    }

    public void dispatchAttachedToWindow(RecyclerView recyclerView) {
        this.mIsAttachedToWindow = true;
        onAttachedToWindow(recyclerView);
    }

    public void dispatchDetachedFromWindow(RecyclerView recyclerView, y1 y1Var) {
        this.mIsAttachedToWindow = false;
        onDetachedFromWindow(recyclerView, y1Var);
    }

    @SuppressLint({"UnknownNullness"})
    public void endAnimation(View view) {
        l1 l1Var = this.mRecyclerView.mItemAnimator;
        if (l1Var != null) {
            l1Var.d(RecyclerView.getChildViewHolderInt(view));
        }
    }

    @Nullable
    public View findContainingItemView(@NonNull View view) {
        View viewFindContainingItemView;
        RecyclerView recyclerView = this.mRecyclerView;
        if (recyclerView == null || (viewFindContainingItemView = recyclerView.findContainingItemView(view)) == null || this.mChildHelper.k(viewFindContainingItemView)) {
            return null;
        }
        return viewFindContainingItemView;
    }

    @Nullable
    public View findViewByPosition(int i10) {
        int childCount = getChildCount();
        for (int i11 = 0; i11 < childCount; i11++) {
            View childAt = getChildAt(i11);
            j2 childViewHolderInt = RecyclerView.getChildViewHolderInt(childAt);
            if (childViewHolderInt != null && childViewHolderInt.getLayoutPosition() == i10 && !childViewHolderInt.shouldIgnore() && (this.mRecyclerView.mState.f3706g || !childViewHolderInt.isRemoved())) {
                return childAt;
            }
        }
        return null;
    }

    public abstract r1 generateDefaultLayoutParams();

    @SuppressLint({"UnknownNullness"})
    public r1 generateLayoutParams(ViewGroup.LayoutParams layoutParams) {
        return layoutParams instanceof r1 ? new r1((r1) layoutParams) : layoutParams instanceof ViewGroup.MarginLayoutParams ? new r1((ViewGroup.MarginLayoutParams) layoutParams) : new r1(layoutParams);
    }

    public int getBaseline() {
        return -1;
    }

    public int getBottomDecorationHeight(@NonNull View view) {
        return ((r1) view.getLayoutParams()).mDecorInsets.bottom;
    }

    @Nullable
    public View getChildAt(int i10) {
        f fVar = this.mChildHelper;
        if (fVar != null) {
            return fVar.d(i10);
        }
        return null;
    }

    public int getChildCount() {
        f fVar = this.mChildHelper;
        if (fVar != null) {
            return fVar.e();
        }
        return 0;
    }

    public boolean getClipToPadding() {
        RecyclerView recyclerView = this.mRecyclerView;
        return recyclerView != null && recyclerView.mClipToPadding;
    }

    public int getColumnCountForAccessibility(@NonNull y1 y1Var, @NonNull f2 f2Var) {
        return -1;
    }

    public int getDecoratedBottom(@NonNull View view) {
        return getBottomDecorationHeight(view) + view.getBottom();
    }

    public void getDecoratedBoundsWithMargins(@NonNull View view, @NonNull Rect rect) {
        RecyclerView.getDecoratedBoundsWithMarginsInt(view, rect);
    }

    public int getDecoratedLeft(@NonNull View view) {
        return view.getLeft() - getLeftDecorationWidth(view);
    }

    public int getDecoratedMeasuredHeight(@NonNull View view) {
        Rect rect = ((r1) view.getLayoutParams()).mDecorInsets;
        return view.getMeasuredHeight() + rect.top + rect.bottom;
    }

    public int getDecoratedMeasuredWidth(@NonNull View view) {
        Rect rect = ((r1) view.getLayoutParams()).mDecorInsets;
        return view.getMeasuredWidth() + rect.left + rect.right;
    }

    public int getDecoratedRight(@NonNull View view) {
        return getRightDecorationWidth(view) + view.getRight();
    }

    public int getDecoratedTop(@NonNull View view) {
        return view.getTop() - getTopDecorationHeight(view);
    }

    @Nullable
    public View getFocusedChild() {
        View focusedChild;
        RecyclerView recyclerView = this.mRecyclerView;
        if (recyclerView == null || (focusedChild = recyclerView.getFocusedChild()) == null || this.mChildHelper.k(focusedChild)) {
            return null;
        }
        return focusedChild;
    }

    @Px
    public int getHeight() {
        return this.mHeight;
    }

    public int getHeightMode() {
        return this.mHeightMode;
    }

    public int getItemCount() {
        RecyclerView recyclerView = this.mRecyclerView;
        d1 adapter = recyclerView != null ? recyclerView.getAdapter() : null;
        if (adapter != null) {
            return adapter.getItemCount();
        }
        return 0;
    }

    public int getItemViewType(@NonNull View view) {
        return RecyclerView.getChildViewHolderInt(view).getItemViewType();
    }

    public int getLayoutDirection() {
        RecyclerView recyclerView = this.mRecyclerView;
        WeakHashMap weakHashMap = androidx.core.view.s1.f1815a;
        return recyclerView.getLayoutDirection();
    }

    public int getLeftDecorationWidth(@NonNull View view) {
        return ((r1) view.getLayoutParams()).mDecorInsets.left;
    }

    @Px
    public int getMinimumHeight() {
        RecyclerView recyclerView = this.mRecyclerView;
        WeakHashMap weakHashMap = androidx.core.view.s1.f1815a;
        return recyclerView.getMinimumHeight();
    }

    @Px
    public int getMinimumWidth() {
        RecyclerView recyclerView = this.mRecyclerView;
        WeakHashMap weakHashMap = androidx.core.view.s1.f1815a;
        return recyclerView.getMinimumWidth();
    }

    @Px
    public int getPaddingBottom() {
        RecyclerView recyclerView = this.mRecyclerView;
        if (recyclerView != null) {
            return recyclerView.getPaddingBottom();
        }
        return 0;
    }

    @Px
    public int getPaddingEnd() {
        RecyclerView recyclerView = this.mRecyclerView;
        if (recyclerView == null) {
            return 0;
        }
        WeakHashMap weakHashMap = androidx.core.view.s1.f1815a;
        return recyclerView.getPaddingEnd();
    }

    @Px
    public int getPaddingLeft() {
        RecyclerView recyclerView = this.mRecyclerView;
        if (recyclerView != null) {
            return recyclerView.getPaddingLeft();
        }
        return 0;
    }

    @Px
    public int getPaddingRight() {
        RecyclerView recyclerView = this.mRecyclerView;
        if (recyclerView != null) {
            return recyclerView.getPaddingRight();
        }
        return 0;
    }

    @Px
    public int getPaddingStart() {
        RecyclerView recyclerView = this.mRecyclerView;
        if (recyclerView == null) {
            return 0;
        }
        WeakHashMap weakHashMap = androidx.core.view.s1.f1815a;
        return recyclerView.getPaddingStart();
    }

    @Px
    public int getPaddingTop() {
        RecyclerView recyclerView = this.mRecyclerView;
        if (recyclerView != null) {
            return recyclerView.getPaddingTop();
        }
        return 0;
    }

    public int getPosition(@NonNull View view) {
        return ((r1) view.getLayoutParams()).getViewLayoutPosition();
    }

    public int getRightDecorationWidth(@NonNull View view) {
        return ((r1) view.getLayoutParams()).mDecorInsets.right;
    }

    public int getRowCountForAccessibility(@NonNull y1 y1Var, @NonNull f2 f2Var) {
        return -1;
    }

    public int getSelectionModeForAccessibility(@NonNull y1 y1Var, @NonNull f2 f2Var) {
        return 0;
    }

    public int getTopDecorationHeight(@NonNull View view) {
        return ((r1) view.getLayoutParams()).mDecorInsets.top;
    }

    public void getTransformedBoundingBox(@NonNull View view, boolean z10, @NonNull Rect rect) {
        Matrix matrix;
        if (z10) {
            Rect rect2 = ((r1) view.getLayoutParams()).mDecorInsets;
            rect.set(-rect2.left, -rect2.top, view.getWidth() + rect2.right, view.getHeight() + rect2.bottom);
        } else {
            rect.set(0, 0, view.getWidth(), view.getHeight());
        }
        if (this.mRecyclerView != null && (matrix = view.getMatrix()) != null && !matrix.isIdentity()) {
            RectF rectF = this.mRecyclerView.mTempRectF;
            rectF.set(rect);
            matrix.mapRect(rectF);
            rect.set((int) Math.floor(rectF.left), (int) Math.floor(rectF.top), (int) Math.ceil(rectF.right), (int) Math.ceil(rectF.bottom));
        }
        rect.offset(view.getLeft(), view.getTop());
    }

    @Px
    public int getWidth() {
        return this.mWidth;
    }

    public int getWidthMode() {
        return this.mWidthMode;
    }

    public boolean hasFlexibleChildInBothOrientations() {
        int childCount = getChildCount();
        for (int i10 = 0; i10 < childCount; i10++) {
            ViewGroup.LayoutParams layoutParams = getChildAt(i10).getLayoutParams();
            if (layoutParams.width < 0 && layoutParams.height < 0) {
                return true;
            }
        }
        return false;
    }

    public boolean hasFocus() {
        RecyclerView recyclerView = this.mRecyclerView;
        return recyclerView != null && recyclerView.hasFocus();
    }

    public void ignoreView(@NonNull View view) {
        ViewParent parent = view.getParent();
        RecyclerView recyclerView = this.mRecyclerView;
        if (parent != recyclerView || recyclerView.indexOfChild(view) == -1) {
            throw new IllegalArgumentException(defpackage.e.d(this.mRecyclerView, new StringBuilder("View should be fully attached to be ignored")));
        }
        j2 childViewHolderInt = RecyclerView.getChildViewHolderInt(view);
        childViewHolderInt.addFlags(128);
        this.mRecyclerView.mViewInfoStore.d(childViewHolderInt);
    }

    public boolean isAttachedToWindow() {
        return this.mIsAttachedToWindow;
    }

    public abstract boolean isAutoMeasureEnabled();

    public boolean isFocused() {
        RecyclerView recyclerView = this.mRecyclerView;
        return recyclerView != null && recyclerView.isFocused();
    }

    public final boolean isItemPrefetchEnabled() {
        return this.mItemPrefetchEnabled;
    }

    public boolean isLayoutHierarchical(@NonNull y1 y1Var, @NonNull f2 f2Var) {
        return false;
    }

    public boolean isMeasurementCacheEnabled() {
        return this.mMeasurementCacheEnabled;
    }

    public boolean isSmoothScrolling() {
        e2 e2Var = this.mSmoothScroller;
        return e2Var != null && e2Var.isRunning();
    }

    public boolean isViewPartiallyVisible(@NonNull View view, boolean z10, boolean z11) {
        boolean z12 = this.mHorizontalBoundCheck.b(view) && this.mVerticalBoundCheck.b(view);
        return z10 ? z12 : !z12;
    }

    public final void k(View view, int i10, boolean z10) {
        j2 childViewHolderInt = RecyclerView.getChildViewHolderInt(view);
        if (z10 || childViewHolderInt.isRemoved()) {
            androidx.collection.s sVar = this.mRecyclerView.mViewInfoStore.f3982a;
            x2 x2VarA = (x2) sVar.get(childViewHolderInt);
            if (x2VarA == null) {
                x2VarA = x2.a();
                sVar.put(childViewHolderInt, x2VarA);
            }
            x2VarA.f3960a |= 1;
        } else {
            this.mRecyclerView.mViewInfoStore.c(childViewHolderInt);
        }
        r1 r1Var = (r1) view.getLayoutParams();
        if (childViewHolderInt.wasReturnedFromScrap() || childViewHolderInt.isScrap()) {
            if (childViewHolderInt.isScrap()) {
                childViewHolderInt.unScrap();
            } else {
                childViewHolderInt.clearReturnedFromScrapFlag();
            }
            this.mChildHelper.b(view, i10, view.getLayoutParams(), false);
        } else if (view.getParent() == this.mRecyclerView) {
            int iJ = this.mChildHelper.j(view);
            if (i10 == -1) {
                i10 = this.mChildHelper.e();
            }
            if (iJ == -1) {
                StringBuilder sb = new StringBuilder("Added View has RecyclerView as parent but view is not a real child. Unfiltered index:");
                sb.append(this.mRecyclerView.indexOfChild(view));
                throw new IllegalStateException(defpackage.e.d(this.mRecyclerView, sb));
            }
            if (iJ != i10) {
                this.mRecyclerView.mLayout.moveView(iJ, i10);
            }
        } else {
            this.mChildHelper.a(view, i10, false);
            r1Var.mInsetsDirty = true;
            e2 e2Var = this.mSmoothScroller;
            if (e2Var != null && e2Var.isRunning()) {
                this.mSmoothScroller.onChildAttachedToWindow(view);
            }
        }
        if (r1Var.mPendingInvalidate) {
            if (RecyclerView.sVerboseLoggingEnabled) {
                Objects.toString(r1Var.mViewHolder);
            }
            childViewHolderInt.itemView.invalidate();
            r1Var.mPendingInvalidate = false;
        }
    }

    public void layoutDecorated(@NonNull View view, int i10, int i11, int i12, int i13) {
        Rect rect = ((r1) view.getLayoutParams()).mDecorInsets;
        view.layout(i10 + rect.left, i11 + rect.top, i12 - rect.right, i13 - rect.bottom);
    }

    public void layoutDecoratedWithMargins(@NonNull View view, int i10, int i11, int i12, int i13) {
        r1 r1Var = (r1) view.getLayoutParams();
        Rect rect = r1Var.mDecorInsets;
        view.layout(i10 + rect.left + ((ViewGroup.MarginLayoutParams) r1Var).leftMargin, i11 + rect.top + ((ViewGroup.MarginLayoutParams) r1Var).topMargin, (i12 - rect.right) - ((ViewGroup.MarginLayoutParams) r1Var).rightMargin, (i13 - rect.bottom) - ((ViewGroup.MarginLayoutParams) r1Var).bottomMargin);
    }

    public final void m(y1 y1Var, int i10, View view) {
        j2 childViewHolderInt = RecyclerView.getChildViewHolderInt(view);
        if (childViewHolderInt.shouldIgnore()) {
            if (RecyclerView.sVerboseLoggingEnabled) {
                childViewHolderInt.toString();
            }
        } else if (childViewHolderInt.isInvalid() && !childViewHolderInt.isRemoved() && !this.mRecyclerView.mAdapter.hasStableIds()) {
            removeViewAt(i10);
            y1Var.k(childViewHolderInt);
        } else {
            detachViewAt(i10);
            y1Var.l(view);
            this.mRecyclerView.mViewInfoStore.c(childViewHolderInt);
        }
    }

    public void measureChild(@NonNull View view, int i10, int i11) {
        r1 r1Var = (r1) view.getLayoutParams();
        Rect itemDecorInsetsForChild = this.mRecyclerView.getItemDecorInsetsForChild(view);
        int i12 = itemDecorInsetsForChild.left + itemDecorInsetsForChild.right + i10;
        int i13 = itemDecorInsetsForChild.top + itemDecorInsetsForChild.bottom + i11;
        int childMeasureSpec = getChildMeasureSpec(getWidth(), getWidthMode(), getPaddingRight() + getPaddingLeft() + i12, ((ViewGroup.MarginLayoutParams) r1Var).width, canScrollHorizontally());
        int childMeasureSpec2 = getChildMeasureSpec(getHeight(), getHeightMode(), getPaddingBottom() + getPaddingTop() + i13, ((ViewGroup.MarginLayoutParams) r1Var).height, canScrollVertically());
        if (shouldMeasureChild(view, childMeasureSpec, childMeasureSpec2, r1Var)) {
            view.measure(childMeasureSpec, childMeasureSpec2);
        }
    }

    public void measureChildWithMargins(@NonNull View view, int i10, int i11) {
        r1 r1Var = (r1) view.getLayoutParams();
        Rect itemDecorInsetsForChild = this.mRecyclerView.getItemDecorInsetsForChild(view);
        int i12 = itemDecorInsetsForChild.left + itemDecorInsetsForChild.right + i10;
        int i13 = itemDecorInsetsForChild.top + itemDecorInsetsForChild.bottom + i11;
        int childMeasureSpec = getChildMeasureSpec(getWidth(), getWidthMode(), getPaddingRight() + getPaddingLeft() + ((ViewGroup.MarginLayoutParams) r1Var).leftMargin + ((ViewGroup.MarginLayoutParams) r1Var).rightMargin + i12, ((ViewGroup.MarginLayoutParams) r1Var).width, canScrollHorizontally());
        int childMeasureSpec2 = getChildMeasureSpec(getHeight(), getHeightMode(), getPaddingBottom() + getPaddingTop() + ((ViewGroup.MarginLayoutParams) r1Var).topMargin + ((ViewGroup.MarginLayoutParams) r1Var).bottomMargin + i13, ((ViewGroup.MarginLayoutParams) r1Var).height, canScrollVertically());
        if (shouldMeasureChild(view, childMeasureSpec, childMeasureSpec2, r1Var)) {
            view.measure(childMeasureSpec, childMeasureSpec2);
        }
    }

    public void moveView(int i10, int i11) {
        View childAt = getChildAt(i10);
        if (childAt != null) {
            detachViewAt(i10);
            attachView(childAt, i11);
        } else {
            throw new IllegalArgumentException("Cannot move a child from non-existing index:" + i10 + this.mRecyclerView.toString());
        }
    }

    public void offsetChildrenHorizontal(@Px int i10) {
        RecyclerView recyclerView = this.mRecyclerView;
        if (recyclerView != null) {
            recyclerView.offsetChildrenHorizontal(i10);
        }
    }

    public void offsetChildrenVertical(@Px int i10) {
        RecyclerView recyclerView = this.mRecyclerView;
        if (recyclerView != null) {
            recyclerView.offsetChildrenVertical(i10);
        }
    }

    public void onAdapterChanged(@Nullable d1 d1Var, @Nullable d1 d1Var2) {
    }

    public boolean onAddFocusables(@NonNull RecyclerView recyclerView, @NonNull ArrayList<View> arrayList, int i10, int i11) {
        return false;
    }

    @CallSuper
    public void onAttachedToWindow(RecyclerView recyclerView) {
    }

    @Deprecated
    public void onDetachedFromWindow(RecyclerView recyclerView) {
    }

    public abstract void onDetachedFromWindow(RecyclerView recyclerView, y1 y1Var);

    @Nullable
    public View onFocusSearchFailed(@NonNull View view, int i10, @NonNull y1 y1Var, @NonNull f2 f2Var) {
        return null;
    }

    public void onInitializeAccessibilityEvent(@NonNull AccessibilityEvent accessibilityEvent) {
        RecyclerView recyclerView = this.mRecyclerView;
        onInitializeAccessibilityEvent(recyclerView.mRecycler, recyclerView.mState, accessibilityEvent);
    }

    public void onInitializeAccessibilityNodeInfo(q0.f fVar) {
        RecyclerView recyclerView = this.mRecyclerView;
        onInitializeAccessibilityNodeInfo(recyclerView.mRecycler, recyclerView.mState, fVar);
    }

    public void onInitializeAccessibilityNodeInfoForItem(@NonNull y1 y1Var, @NonNull f2 f2Var, @NonNull View view, @NonNull q0.f fVar) {
    }

    @Nullable
    public View onInterceptFocusSearch(@NonNull View view, int i10) {
        return null;
    }

    public void onItemsAdded(@NonNull RecyclerView recyclerView, int i10, int i11) {
    }

    public void onItemsChanged(@NonNull RecyclerView recyclerView) {
    }

    public void onItemsMoved(@NonNull RecyclerView recyclerView, int i10, int i11, int i12) {
    }

    public void onItemsRemoved(@NonNull RecyclerView recyclerView, int i10, int i11) {
    }

    public void onItemsUpdated(@NonNull RecyclerView recyclerView, int i10, int i11) {
    }

    public abstract void onLayoutChildren(y1 y1Var, f2 f2Var);

    @SuppressLint({"UnknownNullness"})
    public void onLayoutCompleted(f2 f2Var) {
    }

    public void onMeasure(@NonNull y1 y1Var, @NonNull f2 f2Var, int i10, int i11) {
        this.mRecyclerView.defaultOnMeasure(i10, i11);
    }

    @Deprecated
    public boolean onRequestChildFocus(@NonNull RecyclerView recyclerView, @NonNull View view, @Nullable View view2) {
        return isSmoothScrolling() || recyclerView.isComputingLayout();
    }

    public void onRestoreInstanceState(Parcelable parcelable) {
    }

    @Nullable
    public Parcelable onSaveInstanceState() {
        return null;
    }

    public void onScrollStateChanged(int i10) {
    }

    public void onSmoothScrollerStopped(e2 e2Var) {
        if (this.mSmoothScroller == e2Var) {
            this.mSmoothScroller = null;
        }
    }

    public boolean performAccessibilityAction(int i10, @Nullable Bundle bundle) {
        RecyclerView recyclerView = this.mRecyclerView;
        return performAccessibilityAction(recyclerView.mRecycler, recyclerView.mState, i10, bundle);
    }

    public boolean performAccessibilityActionForItem(@NonNull y1 y1Var, @NonNull f2 f2Var, @NonNull View view, int i10, @Nullable Bundle bundle) {
        return false;
    }

    public void postOnAnimation(Runnable runnable) {
        RecyclerView recyclerView = this.mRecyclerView;
        if (recyclerView != null) {
            WeakHashMap weakHashMap = androidx.core.view.s1.f1815a;
            recyclerView.postOnAnimation(runnable);
        }
    }

    public void removeAllViews() {
        for (int childCount = getChildCount() - 1; childCount >= 0; childCount--) {
            this.mChildHelper.l(childCount);
        }
    }

    public void removeAndRecycleAllViews(@NonNull y1 y1Var) {
        for (int childCount = getChildCount() - 1; childCount >= 0; childCount--) {
            if (!RecyclerView.getChildViewHolderInt(getChildAt(childCount)).shouldIgnore()) {
                removeAndRecycleViewAt(childCount, y1Var);
            }
        }
    }

    public void removeAndRecycleScrapInt(y1 y1Var) {
        ArrayList arrayList;
        int size = y1Var.f3968a.size();
        int i10 = size - 1;
        while (true) {
            arrayList = y1Var.f3968a;
            if (i10 < 0) {
                break;
            }
            View view = ((j2) arrayList.get(i10)).itemView;
            j2 childViewHolderInt = RecyclerView.getChildViewHolderInt(view);
            if (!childViewHolderInt.shouldIgnore()) {
                childViewHolderInt.setIsRecyclable(false);
                if (childViewHolderInt.isTmpDetached()) {
                    this.mRecyclerView.removeDetachedView(view, false);
                }
                l1 l1Var = this.mRecyclerView.mItemAnimator;
                if (l1Var != null) {
                    l1Var.d(childViewHolderInt);
                }
                childViewHolderInt.setIsRecyclable(true);
                j2 childViewHolderInt2 = RecyclerView.getChildViewHolderInt(view);
                childViewHolderInt2.mScrapContainer = null;
                childViewHolderInt2.mInChangeScrap = false;
                childViewHolderInt2.clearReturnedFromScrapFlag();
                y1Var.k(childViewHolderInt2);
            }
            i10--;
        }
        arrayList.clear();
        ArrayList arrayList2 = y1Var.f3969b;
        if (arrayList2 != null) {
            arrayList2.clear();
        }
        if (size > 0) {
            this.mRecyclerView.invalidate();
        }
    }

    public void removeAndRecycleView(@NonNull View view, @NonNull y1 y1Var) {
        removeView(view);
        y1Var.j(view);
    }

    public void removeAndRecycleViewAt(int i10, @NonNull y1 y1Var) {
        View childAt = getChildAt(i10);
        removeViewAt(i10);
        y1Var.j(childAt);
    }

    public boolean removeCallbacks(Runnable runnable) {
        RecyclerView recyclerView = this.mRecyclerView;
        if (recyclerView != null) {
            return recyclerView.removeCallbacks(runnable);
        }
        return false;
    }

    public void removeDetachedView(@NonNull View view) {
        this.mRecyclerView.removeDetachedView(view, false);
    }

    @SuppressLint({"UnknownNullness"})
    public void removeView(View view) {
        f fVar = this.mChildHelper;
        e eVar = fVar.f3692a;
        int i10 = fVar.f3695d;
        if (i10 == 1) {
            throw new IllegalStateException("Cannot call removeView(At) within removeView(At)");
        }
        if (i10 == 2) {
            throw new IllegalStateException("Cannot call removeView(At) within removeViewIfHidden");
        }
        try {
            fVar.f3695d = 1;
            fVar.f3696e = view;
            int iIndexOfChild = ((c1) eVar).f3680a.indexOfChild(view);
            if (iIndexOfChild >= 0) {
                if (fVar.f3693b.f(iIndexOfChild)) {
                    fVar.m(view);
                }
                ((c1) eVar).b(iIndexOfChild);
            }
            fVar.f3695d = 0;
            fVar.f3696e = null;
        } catch (Throwable th) {
            fVar.f3695d = 0;
            fVar.f3696e = null;
            throw th;
        }
    }

    public void removeViewAt(int i10) {
        if (getChildAt(i10) != null) {
            this.mChildHelper.l(i10);
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:27:0x00ae  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public boolean requestChildRectangleOnScreen(@NonNull RecyclerView recyclerView, @NonNull View view, @NonNull Rect rect, boolean z10, boolean z11) {
        int paddingLeft = getPaddingLeft();
        int paddingTop = getPaddingTop();
        int width = getWidth() - getPaddingRight();
        int height = getHeight() - getPaddingBottom();
        int left = (view.getLeft() + rect.left) - view.getScrollX();
        int top = (view.getTop() + rect.top) - view.getScrollY();
        int iWidth = rect.width() + left;
        int iHeight = rect.height() + top;
        int i10 = left - paddingLeft;
        int iMin = Math.min(0, i10);
        int i11 = top - paddingTop;
        int iMin2 = Math.min(0, i11);
        int i12 = iWidth - width;
        int iMax = Math.max(0, i12);
        int iMax2 = Math.max(0, iHeight - height);
        if (getLayoutDirection() != 1) {
            if (iMin == 0) {
                iMin = Math.min(i10, iMax);
            }
            iMax = iMin;
        } else if (iMax == 0) {
            iMax = Math.max(iMin, i12);
        }
        if (iMin2 == 0) {
            iMin2 = Math.min(i11, iMax2);
        }
        if (z11) {
            View focusedChild = recyclerView.getFocusedChild();
            if (focusedChild != null) {
                int paddingLeft2 = getPaddingLeft();
                int paddingTop2 = getPaddingTop();
                int width2 = getWidth() - getPaddingRight();
                int height2 = getHeight() - getPaddingBottom();
                Rect rect2 = this.mRecyclerView.mTempRect;
                getDecoratedBoundsWithMargins(focusedChild, rect2);
                if (rect2.left - iMax < width2 && rect2.right - iMax > paddingLeft2 && rect2.top - iMin2 < height2 && rect2.bottom - iMin2 > paddingTop2) {
                }
            }
        } else if (iMax != 0 || iMin2 != 0) {
            if (z10) {
                recyclerView.scrollBy(iMax, iMin2);
            } else {
                recyclerView.smoothScrollBy(iMax, iMin2);
            }
            return true;
        }
        return false;
    }

    public void requestLayout() {
        RecyclerView recyclerView = this.mRecyclerView;
        if (recyclerView != null) {
            recyclerView.requestLayout();
        }
    }

    public void requestSimpleAnimationsInNextLayout() {
        this.mRequestedSimpleAnimations = true;
    }

    public abstract int scrollHorizontallyBy(int i10, y1 y1Var, f2 f2Var);

    public abstract void scrollToPosition(int i10);

    public abstract int scrollVerticallyBy(int i10, y1 y1Var, f2 f2Var);

    @Deprecated
    public void setAutoMeasureEnabled(boolean z10) {
        this.mAutoMeasure = z10;
    }

    public void setExactMeasureSpecsFrom(RecyclerView recyclerView) {
        setMeasureSpecs(View.MeasureSpec.makeMeasureSpec(recyclerView.getWidth(), 1073741824), View.MeasureSpec.makeMeasureSpec(recyclerView.getHeight(), 1073741824));
    }

    public final void setItemPrefetchEnabled(boolean z10) {
        if (z10 != this.mItemPrefetchEnabled) {
            this.mItemPrefetchEnabled = z10;
            this.mPrefetchMaxCountObserved = 0;
            RecyclerView recyclerView = this.mRecyclerView;
            if (recyclerView != null) {
                recyclerView.mRecycler.n();
            }
        }
    }

    public void setMeasureSpecs(int i10, int i11) {
        this.mWidth = View.MeasureSpec.getSize(i10);
        int mode = View.MeasureSpec.getMode(i10);
        this.mWidthMode = mode;
        if (mode == 0 && !RecyclerView.ALLOW_SIZE_IN_UNSPECIFIED_SPEC) {
            this.mWidth = 0;
        }
        this.mHeight = View.MeasureSpec.getSize(i11);
        int mode2 = View.MeasureSpec.getMode(i11);
        this.mHeightMode = mode2;
        if (mode2 != 0 || RecyclerView.ALLOW_SIZE_IN_UNSPECIFIED_SPEC) {
            return;
        }
        this.mHeight = 0;
    }

    public void setMeasuredDimension(Rect rect, int i10, int i11) {
        setMeasuredDimension(chooseSize(i10, getPaddingRight() + getPaddingLeft() + rect.width(), getMinimumWidth()), chooseSize(i11, getPaddingBottom() + getPaddingTop() + rect.height(), getMinimumHeight()));
    }

    public void setMeasuredDimensionFromChildren(int i10, int i11) {
        int childCount = getChildCount();
        if (childCount == 0) {
            this.mRecyclerView.defaultOnMeasure(i10, i11);
            return;
        }
        int i12 = Integer.MIN_VALUE;
        int i13 = Integer.MAX_VALUE;
        int i14 = Integer.MIN_VALUE;
        int i15 = Integer.MAX_VALUE;
        for (int i16 = 0; i16 < childCount; i16++) {
            View childAt = getChildAt(i16);
            Rect rect = this.mRecyclerView.mTempRect;
            getDecoratedBoundsWithMargins(childAt, rect);
            int i17 = rect.left;
            if (i17 < i15) {
                i15 = i17;
            }
            int i18 = rect.right;
            if (i18 > i12) {
                i12 = i18;
            }
            int i19 = rect.top;
            if (i19 < i13) {
                i13 = i19;
            }
            int i20 = rect.bottom;
            if (i20 > i14) {
                i14 = i20;
            }
        }
        this.mRecyclerView.mTempRect.set(i15, i13, i12, i14);
        setMeasuredDimension(this.mRecyclerView.mTempRect, i10, i11);
    }

    public void setMeasurementCacheEnabled(boolean z10) {
        this.mMeasurementCacheEnabled = z10;
    }

    public void setRecyclerView(RecyclerView recyclerView) {
        if (recyclerView == null) {
            this.mRecyclerView = null;
            this.mChildHelper = null;
            this.mWidth = 0;
            this.mHeight = 0;
        } else {
            this.mRecyclerView = recyclerView;
            this.mChildHelper = recyclerView.mChildHelper;
            this.mWidth = recyclerView.getWidth();
            this.mHeight = recyclerView.getHeight();
        }
        this.mWidthMode = 1073741824;
        this.mHeightMode = 1073741824;
    }

    public boolean shouldMeasureChild(View view, int i10, int i11, r1 r1Var) {
        return (!view.isLayoutRequested() && this.mMeasurementCacheEnabled && l(view.getWidth(), i10, ((ViewGroup.MarginLayoutParams) r1Var).width) && l(view.getHeight(), i11, ((ViewGroup.MarginLayoutParams) r1Var).height)) ? false : true;
    }

    public boolean shouldMeasureTwice() {
        return false;
    }

    public boolean shouldReMeasureChild(View view, int i10, int i11, r1 r1Var) {
        return (this.mMeasurementCacheEnabled && l(view.getMeasuredWidth(), i10, ((ViewGroup.MarginLayoutParams) r1Var).width) && l(view.getMeasuredHeight(), i11, ((ViewGroup.MarginLayoutParams) r1Var).height)) ? false : true;
    }

    public abstract void smoothScrollToPosition(RecyclerView recyclerView, f2 f2Var, int i10);

    @SuppressLint({"UnknownNullness"})
    public void startSmoothScroll(e2 e2Var) {
        e2 e2Var2 = this.mSmoothScroller;
        if (e2Var2 != null && e2Var != e2Var2 && e2Var2.isRunning()) {
            this.mSmoothScroller.stop();
        }
        this.mSmoothScroller = e2Var;
        e2Var.start(this.mRecyclerView, this);
    }

    public void stopIgnoringView(@NonNull View view) {
        j2 childViewHolderInt = RecyclerView.getChildViewHolderInt(view);
        childViewHolderInt.stopIgnoring();
        childViewHolderInt.resetInternal();
        childViewHolderInt.addFlags(4);
    }

    public void stopSmoothScroller() {
        e2 e2Var = this.mSmoothScroller;
        if (e2Var != null) {
            e2Var.stop();
        }
    }

    public boolean supportsPredictiveItemAnimations() {
        return false;
    }

    @SuppressLint({"UnknownNullness"})
    public void addDisappearingView(View view, int i10) {
        k(view, i10, true);
    }

    @SuppressLint({"UnknownNullness"})
    public void addView(View view, int i10) {
        k(view, i10, false);
    }

    public void onInitializeAccessibilityEvent(@NonNull y1 y1Var, @NonNull f2 f2Var, @NonNull AccessibilityEvent accessibilityEvent) {
        RecyclerView recyclerView = this.mRecyclerView;
        if (recyclerView == null || accessibilityEvent == null) {
            return;
        }
        boolean z10 = true;
        if (!recyclerView.canScrollVertically(1) && !this.mRecyclerView.canScrollVertically(-1) && !this.mRecyclerView.canScrollHorizontally(-1) && !this.mRecyclerView.canScrollHorizontally(1)) {
            z10 = false;
        }
        accessibilityEvent.setScrollable(z10);
        d1 d1Var = this.mRecyclerView.mAdapter;
        if (d1Var != null) {
            accessibilityEvent.setItemCount(d1Var.getItemCount());
        }
    }

    public void onInitializeAccessibilityNodeInfo(@NonNull y1 y1Var, @NonNull f2 f2Var, @NonNull q0.f fVar) {
        if (this.mRecyclerView.canScrollVertically(-1) || this.mRecyclerView.canScrollHorizontally(-1)) {
            fVar.a(8192);
            fVar.n(true);
        }
        if (this.mRecyclerView.canScrollVertically(1) || this.mRecyclerView.canScrollHorizontally(1)) {
            fVar.a(4096);
            fVar.n(true);
        }
        fVar.k(xyz.stream.utils.a0.y(getRowCountForAccessibility(y1Var, f2Var), getColumnCountForAccessibility(y1Var, f2Var), getSelectionModeForAccessibility(y1Var, f2Var), isLayoutHierarchical(y1Var, f2Var)));
    }

    public void onInitializeAccessibilityNodeInfoForItem(View view, q0.f fVar) {
        j2 childViewHolderInt = RecyclerView.getChildViewHolderInt(view);
        if (childViewHolderInt == null || childViewHolderInt.isRemoved() || this.mChildHelper.k(childViewHolderInt.itemView)) {
            return;
        }
        RecyclerView recyclerView = this.mRecyclerView;
        onInitializeAccessibilityNodeInfoForItem(recyclerView.mRecycler, recyclerView.mState, view, fVar);
    }

    public void onItemsUpdated(@NonNull RecyclerView recyclerView, int i10, int i11, @Nullable Object obj) {
        onItemsUpdated(recyclerView, i10, i11);
    }

    public boolean onRequestChildFocus(@NonNull RecyclerView recyclerView, @NonNull f2 f2Var, @NonNull View view, @Nullable View view2) {
        return onRequestChildFocus(recyclerView, view, view2);
    }

    public boolean performAccessibilityAction(@NonNull y1 y1Var, @NonNull f2 f2Var, int i10, @Nullable Bundle bundle) {
        int paddingTop;
        int paddingLeft;
        int i11;
        int i12;
        if (this.mRecyclerView == null) {
            return false;
        }
        int height = getHeight();
        int width = getWidth();
        Rect rect = new Rect();
        if (this.mRecyclerView.getMatrix().isIdentity() && this.mRecyclerView.getGlobalVisibleRect(rect)) {
            height = rect.height();
            width = rect.width();
        }
        if (i10 == 4096) {
            paddingTop = this.mRecyclerView.canScrollVertically(1) ? (height - getPaddingTop()) - getPaddingBottom() : 0;
            if (this.mRecyclerView.canScrollHorizontally(1)) {
                paddingLeft = (width - getPaddingLeft()) - getPaddingRight();
                i11 = paddingTop;
                i12 = paddingLeft;
            }
            i11 = paddingTop;
            i12 = 0;
        } else if (i10 != 8192) {
            i12 = 0;
            i11 = 0;
        } else {
            paddingTop = this.mRecyclerView.canScrollVertically(-1) ? -((height - getPaddingTop()) - getPaddingBottom()) : 0;
            if (this.mRecyclerView.canScrollHorizontally(-1)) {
                paddingLeft = -((width - getPaddingLeft()) - getPaddingRight());
                i11 = paddingTop;
                i12 = paddingLeft;
            }
            i11 = paddingTop;
            i12 = 0;
        }
        if (i11 == 0 && i12 == 0) {
            return false;
        }
        this.mRecyclerView.smoothScrollBy(i12, i11, null, Integer.MIN_VALUE, true);
        return true;
    }

    public boolean performAccessibilityActionForItem(@NonNull View view, int i10, @Nullable Bundle bundle) {
        RecyclerView recyclerView = this.mRecyclerView;
        return performAccessibilityActionForItem(recyclerView.mRecycler, recyclerView.mState, view, i10, bundle);
    }

    /* JADX WARN: Removed duplicated region for block: B:10:0x001a  */
    /* JADX WARN: Removed duplicated region for block: B:14:0x0022  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public static int getChildMeasureSpec(int i10, int i11, int i12, int i13, boolean z10) {
        int iMax = Math.max(0, i10 - i12);
        if (z10) {
            if (i13 < 0) {
                if (i13 != -1 || (i11 != Integer.MIN_VALUE && (i11 == 0 || i11 != 1073741824))) {
                    i11 = 0;
                    i13 = 0;
                } else {
                    i13 = iMax;
                }
            }
            i11 = 1073741824;
        } else if (i13 >= 0) {
            i11 = 1073741824;
        } else if (i13 != -1) {
            if (i13 == -2) {
                if (i11 == Integer.MIN_VALUE || i11 == 1073741824) {
                    i13 = iMax;
                    i11 = Integer.MIN_VALUE;
                } else {
                    i13 = iMax;
                    i11 = 0;
                }
            }
        }
        return View.MeasureSpec.makeMeasureSpec(i13, i11);
    }

    @SuppressLint({"UnknownNullness"})
    public r1 generateLayoutParams(Context context, AttributeSet attributeSet) {
        return new r1(context, attributeSet);
    }

    public void setMeasuredDimension(int i10, int i11) {
        this.mRecyclerView.setMeasuredDimension(i10, i11);
    }

    public void attachView(@NonNull View view, int i10) {
        attachView(view, i10, (r1) view.getLayoutParams());
    }

    public void attachView(@NonNull View view) {
        attachView(view, -1);
    }

    public boolean requestChildRectangleOnScreen(@NonNull RecyclerView recyclerView, @NonNull View view, @NonNull Rect rect, boolean z10) {
        return requestChildRectangleOnScreen(recyclerView, view, rect, z10, false);
    }
}
