content: package androidx.recyclerview.widget;
  
  import android.content.Context;
  import android.graphics.PointF;
  import android.graphics.Rect;
  import android.os.Parcel;
  import android.os.Parcelable;
  import android.util.AttributeSet;
  import android.view.View;
  import android.view.ViewGroup;
  import android.view.accessibility.AccessibilityEvent;
  import androidx.constraintlayout.widget.ConstraintLayout;
  import androidx.core.view.accessibility.AccessibilityNodeInfoCompat;
  import androidx.recyclerview.widget.RecyclerView;
  import java.util.ArrayList;
  import java.util.Arrays;
  import java.util.BitSet;
  import java.util.List;
  import mt.Log1F380D;
  
  public class StaggeredGridLayoutManager extends RecyclerView.LayoutManager implements RecyclerView.SmoothScroller.ScrollVectorProvider {
      static final boolean DEBUG = false;
      @Deprecated
      public static final int GAP_HANDLING_LAZY = 1;
      public static final int GAP_HANDLING_MOVE_ITEMS_BETWEEN_SPANS = 2;
      public static final int GAP_HANDLING_NONE = 0;
      public static final int HORIZONTAL = 0;
      static final int INVALID_OFFSET = Integer.MIN_VALUE;
      private static final float MAX_SCROLL_FACTOR = 0.33333334f;
      private static final String TAG = "StaggeredGridLManager";
      public static final int VERTICAL = 1;
      private final AnchorInfo mAnchorInfo = new AnchorInfo();
      private final Runnable mCheckForGapsRunnable = new Runnable() {
          public void run() {
              StaggeredGridLayoutManager.this.checkForGaps();
          }
      };
      private int mFullSizeSpec;
      private int mGapStrategy = 2;
      private boolean mLaidOutInvalidFullSpan = false;
      private boolean mLastLayoutFromEnd;
      private boolean mLastLayoutRTL;
      private final LayoutState mLayoutState;
      LazySpanLookup mLazySpanLookup = new LazySpanLookup();
      private int mOrientation;
      private SavedState mPendingSavedState;
      int mPendingScrollPosition = -1;
      int mPendingScrollPositionOffset = Integer.MIN_VALUE;
      private int[] mPrefetchDistances;
      OrientationHelper mPrimaryOrientation;
      private BitSet mRemainingSpans;
      boolean mReverseLayout = false;
      OrientationHelper mSecondaryOrientation;
      boolean mShouldReverseLayout = false;
      private int mSizePerSpan;
      private boolean mSmoothScrollbarEnabled = true;
      private int mSpanCount = -1;
      Span[] mSpans;
      private final Rect mTmpRect = new Rect();
  
      class AnchorInfo {
          boolean mInvalidateOffsets;
          boolean mLayoutFromEnd;
          int mOffset;
          int mPosition;
          int[] mSpanReferenceLines;
          boolean mValid;
  
          AnchorInfo() {
              reset();
          }
  
          /* access modifiers changed from: package-private */
          public void assignCoordinateFromPadding() {
              this.mOffset = this.mLayoutFromEnd ? StaggeredGridLayoutManager.this.mPrimaryOrientation.getEndAfterPadding() : StaggeredGridLayoutManager.this.mPrimaryOrientation.getStartAfterPadding();
          }
  
          /* access modifiers changed from: package-private */
          public void assignCoordinateFromPadding(int addedDistance) {
              if (this.mLayoutFromEnd) {
                  this.mOffset = StaggeredGridLayoutManager.this.mPrimaryOrientation.getEndAfterPadding() - addedDistance;
              } else {
                  this.mOffset = StaggeredGridLayoutManager.this.mPrimaryOrientation.getStartAfterPadding() + addedDistance;
              }
          }
  
          /* access modifiers changed from: package-private */
          public void reset() {
              this.mPosition = -1;
              this.mOffset = Integer.MIN_VALUE;
              this.mLayoutFromEnd = false;
              this.mInvalidateOffsets = false;
              this.mValid = false;
              int[] iArr = this.mSpanReferenceLines;
              if (iArr != null) {
                  Arrays.fill(iArr, -1);
              }
          }
  
          /* access modifiers changed from: package-private */
          public void saveSpanReferenceLines(Span[] spans) {
              int length = spans.length;
              int[] iArr = this.mSpanReferenceLines;
              if (iArr == null || iArr.length < length) {
                  this.mSpanReferenceLines = new int[StaggeredGridLayoutManager.this.mSpans.length];
              }
              for (int i = 0; i < length; i++) {
                  this.mSpanReferenceLines[i] = spans[i].getStartLine(Integer.MIN_VALUE);
              }
          }
      }
  
      public static class LayoutParams extends RecyclerView.LayoutParams {
          public static final int INVALID_SPAN_ID = -1;
          boolean mFullSpan;
          Span mSpan;
  
          public LayoutParams(int width, int height) {
              super(width, height);
          }
  
          public LayoutParams(Context c, AttributeSet attrs) {
              super(c, attrs);
          }
  
          public LayoutParams(ViewGroup.LayoutParams source) {
              super(source);
          }
  
          public LayoutParams(ViewGroup.MarginLayoutParams source) {
              super(source);
          }
  
          public LayoutParams(RecyclerView.LayoutParams source) {
              super(source);
          }
  
          public final int getSpanIndex() {
              Span span = this.mSpan;
              if (span == null) {
                  return -1;
              }
              return span.mIndex;
          }
  
          public boolean isFullSpan() {
              return this.mFullSpan;
          }
  
          public void setFullSpan(boolean fullSpan) {
              this.mFullSpan = fullSpan;
          }
      }
  
      static class LazySpanLookup {
          private static final int MIN_SIZE = 10;
          int[] mData;
          List<FullSpanItem> mFullSpanItems;
  
          /* compiled from: 008F */
          static class FullSpanItem implements Parcelable {
              public static final Parcelable.Creator<FullSpanItem> CREATOR = new Parcelable.Creator<FullSpanItem>() {
                  public FullSpanItem createFromParcel(Parcel in) {
                      return new FullSpanItem(in);
                  }
  
                  public FullSpanItem[] newArray(int size) {
                      return new FullSpanItem[size];
                  }
              };
              int mGapDir;
              int[] mGapPerSpan;
              boolean mHasUnwantedGapAfter;
              int mPosition;
  
              FullSpanItem() {
              }
  
              FullSpanItem(Parcel in) {
                  this.mPosition = in.readInt();
                  this.mGapDir = in.readInt();
                  this.mHasUnwantedGapAfter = in.readInt() != 1 ? false : true;
                  int readInt = in.readInt();
                  if (readInt > 0) {
                      int[] iArr = new int[readInt];
                      this.mGapPerSpan = iArr;
                      in.readIntArray(iArr);
                  }
              }
  
              public int describeContents() {
                  return 0;
              }
  
              /* access modifiers changed from: package-private */
              public int getGapForSpan(int spanIndex) {
                  int[] iArr = this.mGapPerSpan;
                  if (iArr == null) {
                      return 0;
                  }
                  return iArr[spanIndex];
              }
  
              public String toString() {
                  StringBuilder append = new StringBuilder().append("FullSpanItem{mPosition=").append(this.mPosition).append(", mGapDir=").append(this.mGapDir).append(", mHasUnwantedGapAfter=").append(this.mHasUnwantedGapAfter).append(", mGapPerSpan=");
                  String arrays = Arrays.toString(this.mGapPerSpan);
                  Log1F380D.a((Object) arrays);
                  return append.append(arrays).append('}').toString();
              }
  
              public void writeToParcel(Parcel dest, int flags) {
                  dest.writeInt(this.mPosition);
                  dest.writeInt(this.mGapDir);
                  dest.writeInt(this.mHasUnwantedGapAfter ? 1 : 0);
                  int[] iArr = this.mGapPerSpan;
                  if (iArr == null || iArr.length <= 0) {
                      dest.writeInt(0);
                      return;
                  }
                  dest.writeInt(iArr.length);
                  dest.writeIntArray(this.mGapPerSpan);
              }
          }
  
          LazySpanLookup() {
          }
  
          private int invalidateFullSpansAfter(int position) {
              if (this.mFullSpanItems == null) {
                  return -1;
              }
              FullSpanItem fullSpanItem = getFullSpanItem(position);
              if (fullSpanItem != null) {
                  this.mFullSpanItems.remove(fullSpanItem);
              }
              int i = -1;
              int size = this.mFullSpanItems.size();
              int i2 = 0;
              while (true) {
                  if (i2 >= size) {
                      break;
                  } else if (this.mFullSpanItems.get(i2).mPosition >= position) {
                      i = i2;
                      break;
                  } else {
                      i2++;
                  }
              }
              if (i == -1) {
                  return -1;
              }
              this.mFullSpanItems.remove(i);
              return this.mFullSpanItems.get(i).mPosition;
          }
  
          private void offsetFullSpansForAddition(int positionStart, int itemCount) {
              List<FullSpanItem> list = this.mFullSpanItems;
              if (list != null) {
                  for (int size = list.size() - 1; size >= 0; size--) {
                      FullSpanItem fullSpanItem = this.mFullSpanItems.get(size);
                      if (fullSpanItem.mPosition >= positionStart) {
                          fullSpanItem.mPosition += itemCount;
                      }
                  }
              }
          }
  
          private void offsetFullSpansForRemoval(int positionStart, int itemCount) {
              List<FullSpanItem> list = this.mFullSpanItems;
              if (list != null) {
                  int i = positionStart + itemCount;
                  for (int size = list.size() - 1; size >= 0; size--) {
                      FullSpanItem fullSpanItem = this.mFullSpanItems.get(size);
                      if (fullSpanItem.mPosition >= positionStart) {
                          if (fullSpanItem.mPosition < i) {
                              this.mFullSpanItems.remove(size);
                          } else {
                              fullSpanItem.mPosition -= itemCount;
                          }
                      }
                  }
              }
          }
  
          public void addFullSpanItem(FullSpanItem fullSpanItem) {
              if (this.mFullSpanItems == null) {
                  this.mFullSpanItems = new ArrayList();
              }
              int size = this.mFullSpanItems.size();
              for (int i = 0; i < size; i++) {
                  FullSpanItem fullSpanItem2 = this.mFullSpanItems.get(i);
                  if (fullSpanItem2.mPosition == fullSpanItem.mPosition) {
                      this.mFullSpanItems.remove(i);
                  }
                  if (fullSpanItem2.mPosition >= fullSpanItem.mPosition) {
                      this.mFullSpanItems.add(i, fullSpanItem);
                      return;
                  }
              }
              this.mFullSpanItems.add(fullSpanItem);
          }
  
          /* access modifiers changed from: package-private */
          public void clear() {
              int[] iArr = this.mData;
              if (iArr != null) {
                  Arrays.fill(iArr, -1);
              }
              this.mFullSpanItems = null;
          }
  
          /* access modifiers changed from: package-private */
          public void ensureSize(int position) {
              int[] iArr = this.mData;
              if (iArr == null) {
                  int[] iArr2 = new int[(Math.max(position, 10) + 1)];
                  this.mData = iArr2;
                  Arrays.fill(iArr2, -1);
              } else if (position >= iArr.length) {
                  int[] iArr3 = this.mData;
                  int[] iArr4 = new int[sizeForPosition(position)];
                  this.mData = iArr4;
                  System.arraycopy(iArr3, 0, iArr4, 0, iArr3.length);
                  int[] iArr5 = this.mData;
                  Arrays.fill(iArr5, iArr3.length, iArr5.length, -1);
              }
          }
  
          /* access modifiers changed from: package-private */
          public int forceInvalidateAfter(int position) {
              List<FullSpanItem> list = this.mFullSpanItems;
              if (list != null) {
                  for (int size = list.size() - 1; size >= 0; size--) {
                      if (this.mFullSpanItems.get(size).mPosition >= position) {
                          this.mFullSpanItems.remove(size);
                      }
                  }
              }
              return invalidateAfter(position);
          }
  
          public FullSpanItem getFirstFullSpanItemInRange(int minPos, int maxPos, int gapDir, boolean hasUnwantedGapAfter) {
              List<FullSpanItem> list = this.mFullSpanItems;
              if (list == null) {
                  return null;
              }
              int size = list.size();
              for (int i = 0; i < size; i++) {
                  FullSpanItem fullSpanItem = this.mFullSpanItems.get(i);
                  if (fullSpanItem.mPosition >= maxPos) {
                      return null;
                  }
                  if (fullSpanItem.mPosition >= minPos && (gapDir == 0 || fullSpanItem.mGapDir == gapDir || (hasUnwantedGapAfter && fullSpanItem.mHasUnwantedGapAfter))) {
                      return fullSpanItem;
                  }
              }
              return null;
          }
  
          public FullSpanItem getFullSpanItem(int position) {
              List<FullSpanItem> list = this.mFullSpanItems;
              if (list == null) {
                  return null;
              }
              for (int size = list.size() - 1; size >= 0; size--) {
                  FullSpanItem fullSpanItem = this.mFullSpanItems.get(size);
                  if (fullSpanItem.mPosition == position) {
                      return fullSpanItem;
                  }
              }
              return null;
          }
  
          /* access modifiers changed from: package-private */
          public int getSpan(int position) {
              int[] iArr = this.mData;
              if (iArr == null || position >= iArr.length) {
                  return -1;
              }
              return iArr[position];
          }
  
          /* access modifiers changed from: package-private */
          public int invalidateAfter(int position) {
              int[] iArr = this.mData;
              if (iArr == null || position >= iArr.length) {
                  return -1;
              }
              int invalidateFullSpansAfter = invalidateFullSpansAfter(position);
              if (invalidateFullSpansAfter == -1) {
                  int[] iArr2 = this.mData;
                  Arrays.fill(iArr2, position, iArr2.length, -1);
                  return this.mData.length;
              }
              Arrays.fill(this.mData, position, invalidateFullSpansAfter + 1, -1);
              return invalidateFullSpansAfter + 1;
          }
  
          /* access modifiers changed from: package-private */
          public void offsetForAddition(int positionStart, int itemCount) {
              int[] iArr = this.mData;
              if (iArr != null && positionStart < iArr.length) {
                  ensureSize(positionStart + itemCount);
                  int[] iArr2 = this.mData;
                  System.arraycopy(iArr2, positionStart, iArr2, positionStart + itemCount, (iArr2.length - positionStart) - itemCount);
                  Arrays.fill(this.mData, positionStart, positionStart + itemCount, -1);
                  offsetFullSpansForAddition(positionStart, itemCount);
              }
          }
  
          /* access modifiers changed from: package-private */
          public void offsetForRemoval(int positionStart, int itemCount) {
              int[] iArr = this.mData;
              if (iArr != null && positionStart < iArr.length) {
                  ensureSize(positionStart + itemCount);
                  int[] iArr2 = this.mData;
                  System.arraycopy(iArr2, positionStart + itemCount, iArr2, positionStart, (iArr2.length - positionStart) - itemCount);
                  int[] iArr3 = this.mData;
                  Arrays.fill(iArr3, iArr3.length - itemCount, iArr3.length, -1);
                  offsetFullSpansForRemoval(positionStart, itemCount);
              }
          }
  
          /* access modifiers changed from: package-private */
          public void setSpan(int position, Span span) {
              ensureSize(position);
              this.mData[position] = span.mIndex;
          }
  
          /* access modifiers changed from: package-private */
          public int sizeForPosition(int position) {
              int length = this.mData.length;
              while (length <= position) {
                  length *= 2;
              }
              return length;
          }
      }
  
      public static class SavedState implements Parcelable {
          public static final Parcelable.Creator<SavedState> CREATOR = new Parcelable.Creator<SavedState>() {
              public SavedState createFromParcel(Parcel in) {
                  return new SavedState(in);
              }
  
              public SavedState[] newArray(int size) {
                  return new SavedState[size];
              }
          };
          boolean mAnchorLayoutFromEnd;
          int mAnchorPosition;
          List<LazySpanLookup.FullSpanItem> mFullSpanItems;
          boolean mLastLayoutRTL;
          boolean mReverseLayout;
          int[] mSpanLookup;
          int mSpanLookupSize;
          int[] mSpanOffsets;
          int mSpanOffsetsSize;
          int mVisibleAnchorPosition;
  
          public SavedState() {
          }
  
          SavedState(Parcel in) {
              this.mAnchorPosition = in.readInt();
              this.mVisibleAnchorPosition = in.readInt();
              int readInt = in.readInt();
              this.mSpanOffsetsSize = readInt;
              if (readInt > 0) {
                  int[] iArr = new int[readInt];
                  this.mSpanOffsets = iArr;
                  in.readIntArray(iArr);
              }
              int readInt2 = in.readInt();
              this.mSpanLookupSize = readInt2;
              if (readInt2 > 0) {
                  int[] iArr2 = new int[readInt2];
                  this.mSpanLookup = iArr2;
                  in.readIntArray(iArr2);
              }
              boolean z = false;
              this.mReverseLayout = in.readInt() == 1;
              this.mAnchorLayoutFromEnd = in.readInt() == 1;
              this.mLastLayoutRTL = in.readInt() == 1 ? true : z;
              this.mFullSpanItems = in.readArrayList(LazySpanLookup.FullSpanItem.class.getClassLoader());
          }
  
          public SavedState(SavedState other) {
              this.mSpanOffsetsSize = other.mSpanOffsetsSize;
              this.mAnchorPosition = other.mAnchorPosition;
              this.mVisibleAnchorPosition = other.mVisibleAnchorPosition;
              this.mSpanOffsets = other.mSpanOffsets;
              this.mSpanLookupSize = other.mSpanLookupSize;
              this.mSpanLookup = other.mSpanLookup;
              this.mReverseLayout = other.mReverseLayout;
              this.mAnchorLayoutFromEnd = other.mAnchorLayoutFromEnd;
              this.mLastLayoutRTL = other.mLastLayoutRTL;
              this.mFullSpanItems = other.mFullSpanItems;
          }
  
          public int describeContents() {
              return 0;
          }
  
          /* access modifiers changed from: package-private */
          public void invalidateAnchorPositionInfo() {
              this.mSpanOffsets = null;
              this.mSpanOffsetsSize = 0;
              this.mAnchorPosition = -1;
              this.mVisibleAnchorPosition = -1;
          }
  
          /* access modifiers changed from: package-private */
          public void invalidateSpanInfo() {
              this.mSpanOffsets = null;
              this.mSpanOffsetsSize = 0;
              this.mSpanLookupSize = 0;
              this.mSpanLookup = null;
              this.mFullSpanItems = null;
          }
  
          public void writeToParcel(Parcel dest, int flags) {
              dest.writeInt(this.mAnchorPosition);
              dest.writeInt(this.mVisibleAnchorPosition);
              dest.writeInt(this.mSpanOffsetsSize);
              if (this.mSpanOffsetsSize > 0) {
                  dest.writeIntArray(this.mSpanOffsets);
              }
              dest.writeInt(this.mSpanLookupSize);
              if (this.mSpanLookupSize > 0) {
                  dest.writeIntArray(this.mSpanLookup);
              }
              dest.writeInt(this.mReverseLayout ? 1 : 0);
              dest.writeInt(this.mAnchorLayoutFromEnd ? 1 : 0);
              dest.writeInt(this.mLastLayoutRTL ? 1 : 0);
              dest.writeList(this.mFullSpanItems);
          }
      }
  
      class Span {
          static final int INVALID_LINE = Integer.MIN_VALUE;
          int mCachedEnd = Integer.MIN_VALUE;
          int mCachedStart = Integer.MIN_VALUE;
          int mDeletedSize = 0;
          final int mIndex;
          ArrayList<View> mViews = new ArrayList<>();
  
          Span(int index) {
              this.mIndex = index;
          }
  
          /* access modifiers changed from: package-private */
          public void appendToSpan(View view) {
              LayoutParams layoutParams = getLayoutParams(view);
              layoutParams.mSpan = this;
              this.mViews.add(view);
              this.mCachedEnd = Integer.MIN_VALUE;
              if (this.mViews.size() == 1) {
                  this.mCachedStart = Integer.MIN_VALUE;
              }
              if (layoutParams.isItemRemoved() || layoutParams.isItemChanged()) {
                  this.mDeletedSize += StaggeredGridLayoutManager.this.mPrimaryOrientation.getDecoratedMeasurement(view);
              }
          }
  
          /* access modifiers changed from: package-private */
          public void cacheReferenceLineAndClear(boolean reverseLayout, int offset) {
              int endLine = reverseLayout ? getEndLine(Integer.MIN_VALUE) : getStartLine(Integer.MIN_VALUE);
              clear();
              if (endLine != Integer.MIN_VALUE) {
                  if (reverseLayout && endLine < StaggeredGridLayoutManager.this.mPrimaryOrientation.getEndAfterPadding()) {
                      return;
                  }
                  if (reverseLayout || endLine <= StaggeredGridLayoutManager.this.mPrimaryOrientation.getStartAfterPadding()) {
                      if (offset != Integer.MIN_VALUE) {
                          endLine += offset;
                      }
                      this.mCachedEnd = endLine;
                      this.mCachedStart = endLine;
                  }
              }
          }
  
          /* access modifiers changed from: package-private */
          public void calculateCachedEnd() {
              LazySpanLookup.FullSpanItem fullSpanItem;
              ArrayList<View> arrayList = this.mViews;
              View view = arrayList.get(arrayList.size() - 1);
              LayoutParams layoutParams = getLayoutParams(view);
              this.mCachedEnd = StaggeredGridLayoutManager.this.mPrimaryOrientation.getDecoratedEnd(view);
              if (layoutParams.mFullSpan && (fullSpanItem = StaggeredGridLayoutManager.this.mLazySpanLookup.getFullSpanItem(layoutParams.getViewLayoutPosition())) != null && fullSpanItem.mGapDir == 1) {
                  this.mCachedEnd += fullSpanItem.getGapForSpan(this.mIndex);
              }
          }
  
          /* access modifiers changed from: package-private */
          public void calculateCachedStart() {
              LazySpanLookup.FullSpanItem fullSpanItem;
              View view = this.mViews.get(0);
              LayoutParams layoutParams = getLayoutParams(view);
              this.mCachedStart = StaggeredGridLayoutManager.this.mPrimaryOrientation.getDecoratedStart(view);
              if (layoutParams.mFullSpan && (fullSpanItem = StaggeredGridLayoutManager.this.mLazySpanLookup.getFullSpanItem(layoutParams.getViewLayoutPosition())) != null && fullSpanItem.mGapDir == -1) {
                  this.mCachedStart -= fullSpanItem.getGapForSpan(this.mIndex);
              }
          }
  
          /* access modifiers changed from: package-private */
          public void clear() {
              this.mViews.clear();
              invalidateCache();
              this.mDeletedSize = 0;
          }
  
          public int findFirstCompletelyVisibleItemPosition() {
              return StaggeredGridLayoutManager.this.mReverseLayout ? findOneVisibleChild(this.mViews.size() - 1, -1, true) : findOneVisibleChild(0, this.mViews.size(), true);
          }
  
          public int findFirstPartiallyVisibleItemPosition() {
              return StaggeredGridLayoutManager.this.mReverseLayout ? findOnePartiallyVisibleChild(this.mViews.size() - 1, -1, true) : findOnePartiallyVisibleChild(0, this.mViews.size(), true);
          }
  
          public int findFirstVisibleItemPosition() {
              return StaggeredGridLayoutManager.this.mReverseLayout ? findOneVisibleChild(this.mViews.size() - 1, -1, false) : findOneVisibleChild(0, this.mViews.size(), false);
          }
  
          public int findLastCompletelyVisibleItemPosition() {
              return StaggeredGridLayoutManager.this.mReverseLayout ? findOneVisibleChild(0, this.mViews.size(), true) : findOneVisibleChild(this.mViews.size() - 1, -1, true);
          }
  
          public int findLastPartiallyVisibleItemPosition() {
              return StaggeredGridLayoutManager.this.mReverseLayout ? findOnePartiallyVisibleChild(0, this.mViews.size(), true) : findOnePartiallyVisibleChild(this.mViews.size() - 1, -1, true);
          }
  
          public int findLastVisibleItemPosition() {
              return StaggeredGridLayoutManager.this.mReverseLayout ? findOneVisibleChild(0, this.mViews.size(), false) : findOneVisibleChild(this.mViews.size() - 1, -1, false);
          }
  
          /* access modifiers changed from: package-private */
          public int findOnePartiallyOrCompletelyVisibleChild(int fromIndex, int toIndex, boolean completelyVisible, boolean acceptCompletelyVisible, boolean acceptEndPointInclusion) {
              int i = toIndex;
              int startAfterPadding = StaggeredGridLayoutManager.this.mPrimaryOrientation.getStartAfterPadding();
              int endAfterPadding = StaggeredGridLayoutManager.this.mPrimaryOrientation.getEndAfterPadding();
              int i2 = i > fromIndex ? 1 : -1;
              for (int i3 = fromIndex; i3 != i; i3 += i2) {
                  View view = this.mViews.get(i3);
                  int decoratedStart = StaggeredGridLayoutManager.this.mPrimaryOrientation.getDecoratedStart(view);
                  int decoratedEnd = StaggeredGridLayoutManager.this.mPrimaryOrientation.getDecoratedEnd(view);
                  boolean z = false;
                  boolean z2 = !acceptEndPointInclusion ? decoratedStart < endAfterPadding : decoratedStart <= endAfterPadding;
                  if (!acceptEndPointInclusion ? decoratedEnd > startAfterPadding : decoratedEnd >= startAfterPadding) {
                      z = true;
                  }
                  if (z2 && z) {
                      if (!completelyVisible || !acceptCompletelyVisible) {
                          if (acceptCompletelyVisible) {
                              return StaggeredGridLayoutManager.this.getPosition(view);
                          }
                          if (decoratedStart < startAfterPadding || decoratedEnd > endAfterPadding) {
                              return StaggeredGridLayoutManager.this.getPosition(view);
                          }
                      } else if (decoratedStart >= startAfterPadding && decoratedEnd <= endAfterPadding) {
                          return StaggeredGridLayoutManager.this.getPosition(view);
                      }
                  }
              }
              return -1;
          }
  
          /* access modifiers changed from: package-private */
          public int findOnePartiallyVisibleChild(int fromIndex, int toIndex, boolean acceptEndPointInclusion) {
              return findOnePartiallyOrCompletelyVisibleChild(fromIndex, toIndex, false, false, acceptEndPointInclusion);
          }
  
          /* access modifiers changed from: package-private */
          public int findOneVisibleChild(int fromIndex, int toIndex, boolean completelyVisible) {
              return findOnePartiallyOrCompletelyVisibleChild(fromIndex, toIndex, completelyVisible, true, false);
          }
  
          public int getDeletedSize() {
              return this.mDeletedSize;
          }
  
          /* access modifiers changed from: package-private */
          public int getEndLine() {
              int i = this.mCachedEnd;
              if (i != Integer.MIN_VALUE) {
                  return i;
              }
              calculateCachedEnd();
              return this.mCachedEnd;
          }
  
          /* access modifiers changed from: package-private */
          public int getEndLine(int def) {
              int i = this.mCachedEnd;
              if (i != Integer.MIN_VALUE) {
                  return i;
              }
              if (this.mViews.size() == 0) {
                  return def;
              }
              calculateCachedEnd();
              return this.mCachedEnd;
          }
  
          public View getFocusableViewAfter(int referenceChildPosition, int layoutDir) {
              View view = null;
              if (layoutDir != -1) {
                  for (int size = this.mViews.size() - 1; size >= 0; size--) {
                      View view2 = this.mViews.get(size);
                      if ((StaggeredGridLayoutManager.this.mReverseLayout && StaggeredGridLayoutManager.this.getPosition(view2) >= referenceChildPosition) || ((!StaggeredGridLayoutManager.this.mReverseLayout && StaggeredGridLayoutManager.this.getPosition(view2) <= referenceChildPosition) || !view2.hasFocusable())) {
                          break;
                      }
                      view = view2;
                  }
              } else {
                  int size2 = this.mViews.size();
                  for (int i = 0; i < size2; i++) {
                      View view3 = this.mViews.get(i);
                      if ((StaggeredGridLayoutManager.this.mReverseLayout && StaggeredGridLayoutManager.this.getPosition(view3) <= referenceChildPosition) || ((!StaggeredGridLayoutManager.this.mReverseLayout && StaggeredGridLayoutManager.this.getPosition(view3) >= referenceChildPosition) || !view3.hasFocusable())) {
                          break;
                      }
                      view = view3;
                  }
              }
              return view;
          }
  
          /* access modifiers changed from: package-private */
          public LayoutParams getLayoutParams(View view) {
              return (LayoutParams) view.getLayoutParams();
          }
  
          /* access modifiers changed from: package-private */
          public int getStartLine() {
              int i = this.mCachedStart;
              if (i != Integer.MIN_VALUE) {
                  return i;
              }
              calculateCachedStart();
              return this.mCachedStart;
          }
  
          /* access modifiers changed from: package-private */
          public int getStartLine(int def) {
              int i = this.mCachedStart;
              if (i != Integer.MIN_VALUE) {
                  return i;
              }
              if (this.mViews.size() == 0) {
                  return def;
              }
              calculateCachedStart();
              return this.mCachedStart;
          }
  
          /* access modifiers changed from: package-private */
          public void invalidateCache() {
              this.mCachedStart = Integer.MIN_VALUE;
              this.mCachedEnd = Integer.MIN_VALUE;
          }
  
          /* access modifiers changed from: package-private */
          public void onOffset(int dt) {
              int i = this.mCachedStart;
              if (i != Integer.MIN_VALUE) {
                  this.mCachedStart = i + dt;
              }
              int i2 = this.mCachedEnd;
              if (i2 != Integer.MIN_VALUE) {
                  this.mCachedEnd = i2 + dt;
              }
          }
  
          /* access modifiers changed from: package-private */
          public void popEnd() {
              int size = this.mViews.size();
              View remove = this.mViews.remove(size - 1);
              LayoutParams layoutParams = getLayoutParams(remove);
              layoutParams.mSpan = null;
              if (layoutParams.isItemRemoved() || layoutParams.isItemChanged()) {
                  this.mDeletedSize -= StaggeredGridLayoutManager.this.mPrimaryOrientation.getDecoratedMeasurement(remove);
              }
              if (size == 1) {
                  this.mCachedStart = Integer.MIN_VALUE;
              }
              this.mCachedEnd = Integer.MIN_VALUE;
          }
  
          /* access modifiers changed from: package-private */
          public void popStart() {
              View remove = this.mViews.remove(0);
              LayoutParams layoutParams = getLayoutParams(remove);
              layoutParams.mSpan = null;
              if (this.mViews.size() == 0) {
                  this.mCachedEnd = Integer.MIN_VALUE;
              }
              if (layoutParams.isItemRemoved() || layoutParams.isItemChanged()) {
                  this.mDeletedSize -= StaggeredGridLayoutManager.this.mPrimaryOrientation.getDecoratedMeasurement(remove);
              }
              this.mCachedStart = Integer.MIN_VALUE;
          }
  
          /* access modifiers changed from: package-private */
          public void prependToSpan(View view) {
              LayoutParams layoutParams = getLayoutParams(view);
              layoutParams.mSpan = this;
              this.mViews.add(0, view);
              this.mCachedStart = Integer.MIN_VALUE;
              if (this.mViews.size() == 1) {
                  this.mCachedEnd = Integer.MIN_VALUE;
              }
              if (layoutParams.isItemRemoved() || layoutParams.isItemChanged()) {
                  this.mDeletedSize += StaggeredGridLayoutManager.this.mPrimaryOrientation.getDecoratedMeasurement(view);
              }
          }
  
          /* access modifiers changed from: package-private */
          public void setLine(int line) {
              this.mCachedStart = line;
              this.mCachedEnd = line;
          }
      }
  
      public StaggeredGridLayoutManager(int spanCount, int orientation) {
          this.mOrientation = orientation;
          setSpanCount(spanCount);
          this.mLayoutState = new LayoutState();
          createOrientationHelpers();
      }
  
      public StaggeredGridLayoutManager(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
          RecyclerView.LayoutManager.Properties properties = getProperties(context, attrs, defStyleAttr, defStyleRes);
          setOrientation(properties.orientation);
          setSpanCount(properties.spanCount);
          setReverseLayout(properties.reverseLayout);
          this.mLayoutState = new LayoutState();
          createOrientationHelpers();
      }
  
      private void appendViewToAllSpans(View view) {
          for (int i = this.mSpanCount - 1; i >= 0; i--) {
              this.mSpans[i].appendToSpan(view);
          }
      }
  
      private void applyPendingSavedState(AnchorInfo anchorInfo) {
          if (this.mPendingSavedState.mSpanOffsetsSize > 0) {
              if (this.mPendingSavedState.mSpanOffsetsSize == this.mSpanCount) {
                  for (int i = 0; i < this.mSpanCount; i++) {
                      this.mSpans[i].clear();
                      int i2 = this.mPendingSavedState.mSpanOffsets[i];
                      if (i2 != Integer.MIN_VALUE) {
                          i2 = this.mPendingSavedState.mAnchorLayoutFromEnd ? i2 + this.mPrimaryOrientation.getEndAfterPadding() : i2 + this.mPrimaryOrientation.getStartAfterPadding();
                      }
                      this.mSpans[i].setLine(i2);
                  }
              } else {
                  this.mPendingSavedState.invalidateSpanInfo();
                  SavedState savedState = this.mPendingSavedState;
                  savedState.mAnchorPosition = savedState.mVisibleAnchorPosition;
              }
          }
          this.mLastLayoutRTL = this.mPendingSavedState.mLastLayoutRTL;
          setReverseLayout(this.mPendingSavedState.mReverseLayout);
          resolveShouldLayoutReverse();
          if (this.mPendingSavedState.mAnchorPosition != -1) {
              this.mPendingScrollPosition = this.mPendingSavedState.mAnchorPosition;
              anchorInfo.mLayoutFromEnd = this.mPendingSavedState.mAnchorLayoutFromEnd;
          } else {
              anchorInfo.mLayoutFromEnd = this.mShouldReverseLayout;
          }
          if (this.mPendingSavedState.mSpanLookupSize > 1) {
              this.mLazySpanLookup.mData = this.mPendingSavedState.mSpanLookup;
              this.mLazySpanLookup.mFullSpanItems = this.mPendingSavedState.mFullSpanItems;
          }
      }
  
      private void attachViewToSpans(View view, LayoutParams lp, LayoutState layoutState) {
          if (layoutState.mLayoutDirection == 1) {
              if (lp.mFullSpan) {
                  appendViewToAllSpans(view);
              } else {
                  lp.mSpan.appendToSpan(view);
              }
          } else if (lp.mFullSpan) {
              prependViewToAllSpans(view);
          } else {
              lp.mSpan.prependToSpan(view);
          }
      }
  
      private int calculateScrollDirectionForPosition(int position) {
          if (getChildCount() == 0) {
              return this.mShouldReverseLayout ? 1 : -1;
          }
          return (position < getFirstChildPosition()) != this.mShouldReverseLayout ? -1 : 1;
      }
  
      private boolean checkSpanForGap(Span span) {
          if (this.mShouldReverseLayout) {
              if (span.getEndLine() < this.mPrimaryOrientation.getEndAfterPadding()) {
                  return !span.getLayoutParams(span.mViews.get(span.mViews.size() - 1)).mFullSpan;
              }
          } else if (span.getStartLine() > this.mPrimaryOrientation.getStartAfterPadding()) {
              return !span.getLayoutParams(span.mViews.get(0)).mFullSpan;
          }
          return false;
      }
  
      private int computeScrollExtent(RecyclerView.State state) {
          if (getChildCount() == 0) {
              return 0;
          }
          return ScrollbarHelper.computeScrollExtent(state, this.mPrimaryOrientation, findFirstVisibleItemClosestToStart(!this.mSmoothScrollbarEnabled), findFirstVisibleItemClosestToEnd(!this.mSmoothScrollbarEnabled), this, this.mSmoothScrollbarEnabled);
      }
  
      private int computeScrollOffset(RecyclerView.State state) {
          if (getChildCount() == 0) {
              return 0;
          }
          return ScrollbarHelper.computeScrollOffset(state, this.mPrimaryOrientation, findFirstVisibleItemClosestToStart(!this.mSmoothScrollbarEnabled), findFirstVisibleItemClosestToEnd(!this.mSmoothScrollbarEnabled), this, this.mSmoothScrollbarEnabled, this.mShouldReverseLayout);
      }
  
      private int computeScrollRange(RecyclerView.State state) {
          if (getChildCount() == 0) {
              return 0;
          }
          return ScrollbarHelper.computeScrollRange(state, this.mPrimaryOrientation, findFirstVisibleItemClosestToStart(!this.mSmoothScrollbarEnabled), findFirstVisibleItemClosestToEnd(!this.mSmoothScrollbarEnabled), this, this.mSmoothScrollbarEnabled);
      }
  
      private int convertFocusDirectionToLayoutDirection(int focusDirection) {
          switch (focusDirection) {
              case 1:
                  return (this.mOrientation != 1 && isLayoutRTL()) ? 1 : -1;
              case 2:
                  return (this.mOrientation != 1 && isLayoutRTL()) ? -1 : 1;
              case 17:
                  return this.mOrientation == 0 ? -1 : Integer.MIN_VALUE;
              case 33:
                  return this.mOrientation == 1 ? -1 : Integer.MIN_VALUE;
              case ConstraintLayout.LayoutParams.Table.LAYOUT_WRAP_BEHAVIOR_IN_PARENT:
                  return this.mOrientation == 0 ? 1 : Integer.MIN_VALUE;
              case 130:
                  return this.mOrientation == 1 ? 1 : Integer.MIN_VALUE;
              default:
                  return Integer.MIN_VALUE;
          }
      }
  
      private LazySpanLookup.FullSpanItem createFullSpanItemFromEnd(int newItemTop) {
          LazySpanLookup.FullSpanItem fullSpanItem = new LazySpanLookup.FullSpanItem();
          fullSpanItem.mGapPerSpan = new int[this.mSpanCount];
          for (int i = 0; i < this.mSpanCount; i++) {
              fullSpanItem.mGapPerSpan[i] = newItemTop - this.mSpans[i].getEndLine(newItemTop);
          }
          return fullSpanItem;
      }
  
      private LazySpanLookup.FullSpanItem createFullSpanItemFromStart(int newItemBottom) {
          LazySpanLookup.FullSpanItem fullSpanItem = new LazySpanLookup.FullSpanItem();
          fullSpanItem.mGapPerSpan = new int[this.mSpanCount];
          for (int i = 0; i < this.mSpanCount; i++) {
              fullSpanItem.mGapPerSpan[i] = this.mSpans[i].getStartLine(newItemBottom) - newItemBottom;
          }
          return fullSpanItem;
      }
  
      private void createOrientationHelpers() {
          this.mPrimaryOrientation = OrientationHelper.createOrientationHelper(this, this.mOrientation);
          this.mSecondaryOrientation = OrientationHelper.createOrientationHelper(this, 1 - this.mOrientation);
      }
  
      /* JADX WARNING: type inference failed for: r9v0 */
      /* JADX WARNING: type inference failed for: r9v1, types: [int, boolean] */
      /* JADX WARNING: type inference failed for: r9v5 */
      private int fill(RecyclerView.Recycler recycler, LayoutState layoutState, RecyclerView.State state) {
          int i;
          Span span;
          int i2;
          int i3;
          int i4;
          int i5;
          Span span2;
          boolean z;
          RecyclerView.Recycler recycler2 = recycler;
          LayoutState layoutState2 = layoutState;
          ? r9 = 0;
          boolean z2 = true;
          this.mRemainingSpans.set(0, this.mSpanCount, true);
          int i6 = this.mLayoutState.mInfinite ? layoutState2.mLayoutDirection == 1 ? Integer.MAX_VALUE : Integer.MIN_VALUE : layoutState2.mLayoutDirection == 1 ? layoutState2.mEndLine + layoutState2.mAvailable : layoutState2.mStartLine - layoutState2.mAvailable;
          updateAllRemainingSpans(layoutState2.mLayoutDirection, i6);
          int endAfterPadding = this.mShouldReverseLayout ? this.mPrimaryOrientation.getEndAfterPadding() : this.mPrimaryOrientation.getStartAfterPadding();
          boolean z3 = false;
          while (true) {
              if (layoutState.hasMore(state)) {
                  if (!this.mLayoutState.mInfinite && this.mRemainingSpans.isEmpty()) {
                      i = r9;
                      break;
                  }
                  View next = layoutState2.next(recycler2);
                  LayoutParams layoutParams = (LayoutParams) next.getLayoutParams();
                  int viewLayoutPosition = layoutParams.getViewLayoutPosition();
                  int span3 = this.mLazySpanLookup.getSpan(viewLayoutPosition);
                  boolean z4 = span3 == -1 ? z2 : r9;
                  if (z4) {
                      Span nextSpan = layoutParams.mFullSpan ? this.mSpans[r9] : getNextSpan(layoutState2);
                      this.mLazySpanLookup.setSpan(viewLayoutPosition, nextSpan);
                      span = nextSpan;
                  } else {
                      span = this.mSpans[span3];
                  }
                  layoutParams.mSpan = span;
                  if (layoutState2.mLayoutDirection == z2) {
                      addView(next);
                  } else {
                      addView(next, r9);
                  }
                  measureChildWithDecorationsAndMargin(next, layoutParams, r9);
                  if (layoutState2.mLayoutDirection == z2) {
                      i3 = layoutParams.mFullSpan ? getMaxEnd(endAfterPadding) : span.getEndLine(endAfterPadding);
                      i2 = this.mPrimaryOrientation.getDecoratedMeasurement(next) + i3;
                      if (z4 && layoutParams.mFullSpan) {
                          LazySpanLookup.FullSpanItem createFullSpanItemFromEnd = createFullSpanItemFromEnd(i3);
                          createFullSpanItemFromEnd.mGapDir = -1;
                          createFullSpanItemFromEnd.mPosition = viewLayoutPosition;
                          this.mLazySpanLookup.addFullSpanItem(createFullSpanItemFromEnd);
                      }
                  } else {
                      i2 = layoutParams.mFullSpan ? getMinStart(endAfterPadding) : span.getStartLine(endAfterPadding);
                      i3 = i2 - this.mPrimaryOrientation.getDecoratedMeasurement(next);
                      if (z4 && layoutParams.mFullSpan) {
                          LazySpanLookup.FullSpanItem createFullSpanItemFromStart = createFullSpanItemFromStart(i2);
                          createFullSpanItemFromStart.mGapDir = z2;
                          createFullSpanItemFromStart.mPosition = viewLayoutPosition;
                          this.mLazySpanLookup.addFullSpanItem(createFullSpanItemFromStart);
                      }
                  }
                  int i7 = i3;
                  int i8 = i2;
                  if (layoutParams.mFullSpan && layoutState2.mItemDirection == -1) {
                      if (z4) {
                          this.mLaidOutInvalidFullSpan = z2;
                      } else {
                          if (layoutState2.mLayoutDirection == z2 ? areAllEndsEqual() ^ z2 : areAllStartsEqual() ^ z2) {
                              LazySpanLookup.FullSpanItem fullSpanItem = this.mLazySpanLookup.getFullSpanItem(viewLayoutPosition);
                              if (fullSpanItem != null) {
                                  fullSpanItem.mHasUnwantedGapAfter = z2;
                              }
                              this.mLaidOutInvalidFullSpan = z2;
                          }
                      }
                  }
                  attachViewToSpans(next, layoutParams, layoutState2);
                  if (!isLayoutRTL() || this.mOrientation != z2) {
                      int startAfterPadding = layoutParams.mFullSpan ? this.mSecondaryOrientation.getStartAfterPadding() : (span.mIndex * this.mSizePerSpan) + this.mSecondaryOrientation.getStartAfterPadding();
                      i5 = this.mSecondaryOrientation.getDecoratedMeasurement(next) + startAfterPadding;
                      i4 = startAfterPadding;
                  } else {
                      int endAfterPadding2 = layoutParams.mFullSpan ? this.mSecondaryOrientation.getEndAfterPadding() : this.mSecondaryOrientation.getEndAfterPadding() - (((this.mSpanCount - (z2 ? 1 : 0)) - span.mIndex) * this.mSizePerSpan);
                      i5 = endAfterPadding2;
                      i4 = endAfterPadding2 - this.mSecondaryOrientation.getDecoratedMeasurement(next);
                  }
                  if (this.mOrientation == z2) {
                      span2 = span;
                      int i9 = span3;
                      int i10 = viewLayoutPosition;
                      layoutDecoratedWithMargins(next, i4, i7, i5, i8);
                  } else {
                      span2 = span;
                      int i11 = span3;
                      int i12 = viewLayoutPosition;
                      layoutDecoratedWithMargins(next, i7, i4, i8, i5);
                  }
                  if (layoutParams.mFullSpan) {
                      updateAllRemainingSpans(this.mLayoutState.mLayoutDirection, i6);
                  } else {
                      updateRemainingSpans(span2, this.mLayoutState.mLayoutDirection, i6);
                  }
                  recycle(recycler2, this.mLayoutState);
                  if (!this.mLayoutState.mStopInFocusable || !next.hasFocusable()) {
                      z = false;
                  } else if (layoutParams.mFullSpan) {
                      this.mRemainingSpans.clear();
                      z = false;
                  } else {
                      z = false;
                      this.mRemainingSpans.set(span2.mIndex, false);
                  }
                  z3 = true;
                  r9 = z;
                  z2 = true;
              } else {
                  i = r9;
                  break;
              }
          }
          if (!z3) {
              recycle(recycler2, this.mLayoutState);
          }
          int startAfterPadding2 = this.mLayoutState.mLayoutDirection == -1 ? this.mPrimaryOrientation.getStartAfterPadding() - getMinStart(this.mPrimaryOrientation.getStartAfterPadding()) : getMaxEnd(this.mPrimaryOrientation.getEndAfterPadding()) - this.mPrimaryOrientation.getEndAfterPadding();
          return startAfterPadding2 > 0 ? Math.min(layoutState2.mAvailable, startAfterPadding2) : i;
      }
  
      private int findFirstReferenceChildPosition(int itemCount) {
          int childCount = getChildCount();
          for (int i = 0; i < childCount; i++) {
              int position = getPosition(getChildAt(i));
              if (position >= 0 && position < itemCount) {
                  return position;
              }
          }
          return 0;
      }
  
      private int findLastReferenceChildPosition(int itemCount) {
          for (int childCount = getChildCount() - 1; childCount >= 0; childCount--) {
              int position = getPosition(getChildAt(childCount));
              if (position >= 0 && position < itemCount) {
                  return position;
              }
          }
          return 0;
      }
  
      private void fixEndGap(RecyclerView.Recycler recycler, RecyclerView.State state, boolean canOffsetChildren) {
          int endAfterPadding;
          int maxEnd = getMaxEnd(Integer.MIN_VALUE);
          if (maxEnd != Integer.MIN_VALUE && (endAfterPadding = this.mPrimaryOrientation.getEndAfterPadding() - maxEnd) > 0) {
              int i = endAfterPadding - (-scrollBy(-endAfterPadding, recycler, state));
              if (canOffsetChildren && i > 0) {
                  this.mPrimaryOrientation.offsetChildren(i);
              }
          }
      }
  
      private void fixStartGap(RecyclerView.Recycler recycler, RecyclerView.State state, boolean canOffsetChildren) {
          int startAfterPadding;
          int minStart = getMinStart(Integer.MAX_VALUE);
          if (minStart != Integer.MAX_VALUE && (startAfterPadding = minStart - this.mPrimaryOrientation.getStartAfterPadding()) > 0) {
              int scrollBy = startAfterPadding - scrollBy(startAfterPadding, recycler, state);
              if (canOffsetChildren && scrollBy > 0) {
                  this.mPrimaryOrientation.offsetChildren(-scrollBy);
              }
          }
      }
  
      private int getMaxEnd(int def) {
          int endLine = this.mSpans[0].getEndLine(def);
          for (int i = 1; i < this.mSpanCount; i++) {
              int endLine2 = this.mSpans[i].getEndLine(def);
              if (endLine2 > endLine) {
                  endLine = endLine2;
              }
          }
          return endLine;
      }
  
      private int getMaxStart(int def) {
          int startLine = this.mSpans[0].getStartLine(def);
          for (int i = 1; i < this.mSpanCount; i++) {
              int startLine2 = this.mSpans[i].getStartLine(def);
              if (startLine2 > startLine) {
                  startLine = startLine2;
              }
          }
          return startLine;
      }
  
      private int getMinEnd(int def) {
          int endLine = this.mSpans[0].getEndLine(def);
          for (int i = 1; i < this.mSpanCount; i++) {
              int endLine2 = this.mSpans[i].getEndLine(def);
              if (endLine2 < endLine) {
                  endLine = endLine2;
              }
          }
          return endLine;
      }
  
      private int getMinStart(int def) {
          int startLine = this.mSpans[0].getStartLine(def);
          for (int i = 1; i < this.mSpanCount; i++) {
              int startLine2 = this.mSpans[i].getStartLine(def);
              if (startLine2 < startLine) {
                  startLine = startLine2;
              }
          }
          return startLine;
      }
  
      private Span getNextSpan(LayoutState layoutState) {
          int i;
          int i2;
          int i3;
          if (preferLastSpan(layoutState.mLayoutDirection)) {
              i3 = this.mSpanCount - 1;
              i2 = -1;
              i = -1;
          } else {
              i3 = 0;
              i2 = this.mSpanCount;
              i = 1;
          }
          if (layoutState.mLayoutDirection == 1) {
              Span span = null;
              int i4 = Integer.MAX_VALUE;
              int startAfterPadding = this.mPrimaryOrientation.getStartAfterPadding();
              for (int i5 = i3; i5 != i2; i5 += i) {
                  Span span2 = this.mSpans[i5];
                  int endLine = span2.getEndLine(startAfterPadding);
                  if (endLine < i4) {
                      span = span2;
                      i4 = endLine;
                  }
              }
              return span;
          }
          Span span3 = null;
          int i6 = Integer.MIN_VALUE;
          int endAfterPadding = this.mPrimaryOrientation.getEndAfterPadding();
          for (int i7 = i3; i7 != i2; i7 += i) {
              Span span4 = this.mSpans[i7];
              int startLine = span4.getStartLine(endAfterPadding);
              if (startLine > i6) {
                  span3 = span4;
                  i6 = startLine;
              }
          }
          return span3;
      }
  
      private void handleUpdate(int positionStart, int itemCountOrToPosition, int cmd) {
          int i;
          int i2;
          int lastChildPosition = this.mShouldReverseLayout ? getLastChildPosition() : getFirstChildPosition();
          if (cmd != 8) {
              i = positionStart;
              i2 = positionStart + itemCountOrToPosition;
          } else if (positionStart < itemCountOrToPosition) {
              i2 = itemCountOrToPosition + 1;
              i = positionStart;
          } else {
              i2 = positionStart + 1;
              i = itemCountOrToPosition;
          }
          this.mLazySpanLookup.invalidateAfter(i);
          switch (cmd) {
              case 1:
                  this.mLazySpanLookup.offsetForAddition(positionStart, itemCountOrToPosition);
                  break;
              case 2:
                  this.mLazySpanLookup.offsetForRemoval(positionStart, itemCountOrToPosition);
                  break;
              case 8:
                  this.mLazySpanLookup.offsetForRemoval(positionStart, 1);
                  this.mLazySpanLookup.offsetForAddition(itemCountOrToPosition, 1);
                  break;
          }
          if (i2 > lastChildPosition) {
              if (i <= (this.mShouldReverseLayout ? getFirstChildPosition() : getLastChildPosition())) {
                  requestLayout();
              }
          }
      }
  
      private void measureChildWithDecorationsAndMargin(View child, int widthSpec, int heightSpec, boolean alreadyMeasured) {
          calculateItemDecorationsForChild(child, this.mTmpRect);
          LayoutParams layoutParams = (LayoutParams) child.getLayoutParams();
          int widthSpec2 = updateSpecWithExtra(widthSpec, layoutParams.leftMargin + this.mTmpRect.left, layoutParams.rightMargin + this.mTmpRect.right);
          int heightSpec2 = updateSpecWithExtra(heightSpec, layoutParams.topMargin + this.mTmpRect.top, layoutParams.bottomMargin + this.mTmpRect.bottom);
          if (alreadyMeasured ? shouldReMeasureChild(child, widthSpec2, heightSpec2, layoutParams) : shouldMeasureChild(child, widthSpec2, heightSpec2, layoutParams)) {
              child.measure(widthSpec2, heightSpec2);
          }
      }
  
      private void measureChildWithDecorationsAndMargin(View child, LayoutParams lp, boolean alreadyMeasured) {
          if (lp.mFullSpan) {
              if (this.mOrientation == 1) {
                  measureChildWithDecorationsAndMargin(child, this.mFullSizeSpec, getChildMeasureSpec(getHeight(), getHeightMode(), getPaddingTop() + getPaddingBottom(), lp.height, true), alreadyMeasured);
              } else {
                  measureChildWithDecorationsAndMargin(child, getChildMeasureSpec(getWidth(), getWidthMode(), getPaddingLeft() + getPaddingRight(), lp.width, true), this.mFullSizeSpec, alreadyMeasured);
              }
          } else if (this.mOrientation == 1) {
              measureChildWithDecorationsAndMargin(child, getChildMeasureSpec(this.mSizePerSpan, getWidthMode(), 0, lp.width, false), getChildMeasureSpec(getHeight(), getHeightMode(), getPaddingTop() + getPaddingBottom(), lp.height, true), alreadyMeasured);
          } else {
              measureChildWithDecorationsAndMargin(child, getChildMeasureSpec(getWidth(), getWidthMode(), getPaddingLeft() + getPaddingRight(), lp.width, true), getChildMeasureSpec(this.mSizePerSpan, getHeightMode(), 0, lp.height, false), alreadyMeasured);
          }
      }
  
      private void onLayoutChildren(RecyclerView.Recycler recycler, RecyclerView.State state, boolean shouldCheckForGaps) {
          SavedState savedState;
          AnchorInfo anchorInfo = this.mAnchorInfo;
          if (!(this.mPendingSavedState == null && this.mPendingScrollPosition == -1) && state.getItemCount() == 0) {
              removeAndRecycleAllViews(recycler);
              anchorInfo.reset();
              return;
          }
          boolean z = true;
          boolean z2 = (anchorInfo.mValid && this.mPendingScrollPosition == -1 && this.mPendingSavedState == null) ? false : true;
          if (z2) {
              anchorInfo.reset();
              if (this.mPendingSavedState != null) {
                  applyPendingSavedState(anchorInfo);
              } else {
                  resolveShouldLayoutReverse();
                  anchorInfo.mLayoutFromEnd = this.mShouldReverseLayout;
              }
              updateAnchorInfoForLayout(state, anchorInfo);
              anchorInfo.mValid = true;
          }
          if (this.mPendingSavedState == null && this.mPendingScrollPosition == -1 && !(anchorInfo.mLayoutFromEnd == this.mLastLayoutFromEnd && isLayoutRTL() == this.mLastLayoutRTL)) {
              this.mLazySpanLookup.clear();
              anchorInfo.mInvalidateOffsets = true;
          }
          if (getChildCount() > 0 && ((savedState = this.mPendingSavedState) == null || savedState.mSpanOffsetsSize < 1)) {
              if (anchorInfo.mInvalidateOffsets) {
                  for (int i = 0; i < this.mSpanCount; i++) {
                      this.mSpans[i].clear();
                      if (anchorInfo.mOffset != Integer.MIN_VALUE) {
                          this.mSpans[i].setLine(anchorInfo.mOffset);
                      }
                  }
              } else if (z2 || this.mAnchorInfo.mSpanReferenceLines == null) {
                  for (int i2 = 0; i2 < this.mSpanCount; i2++) {
                      this.mSpans[i2].cacheReferenceLineAndClear(this.mShouldReverseLayout, anchorInfo.mOffset);
                  }
                  this.mAnchorInfo.saveSpanReferenceLines(this.mSpans);
              } else {
                  for (int i3 = 0; i3 < this.mSpanCount; i3++) {
                      Span span = this.mSpans[i3];
                      span.clear();
                      span.setLine(this.mAnchorInfo.mSpanReferenceLines[i3]);
                  }
              }
          }
          detachAndScrapAttachedViews(recycler);
          this.mLayoutState.mRecycle = false;
          this.mLaidOutInvalidFullSpan = false;
          updateMeasureSpecs(this.mSecondaryOrientation.getTotalSpace());
          updateLayoutState(anchorInfo.mPosition, state);
          if (anchorInfo.mLayoutFromEnd) {
              setLayoutStateDirection(-1);
              fill(recycler, this.mLayoutState, state);
              setLayoutStateDirection(1);
              this.mLayoutState.mCurrentPosition = anchorInfo.mPosition + this.mLayoutState.mItemDirection;
              fill(recycler, this.mLayoutState, state);
          } else {
              setLayoutStateDirection(1);
              fill(recycler, this.mLayoutState, state);
              setLayoutStateDirection(-1);
              this.mLayoutState.mCurrentPosition = anchorInfo.mPosition + this.mLayoutState.mItemDirection;
              fill(recycler, this.mLayoutState, state);
          }
          repositionToWrapContentIfNecessary();
          if (getChildCount() > 0) {
              if (this.mShouldReverseLayout) {
                  fixEndGap(recycler, state, true);
                  fixStartGap(recycler, state, false);
              } else {
                  fixStartGap(recycler, state, true);
                  fixEndGap(recycler, state, false);
              }
          }
          boolean z3 = false;
          if (shouldCheckForGaps && !state.isPreLayout()) {
              if (this.mGapStrategy == 0 || getChildCount() <= 0 || (!this.mLaidOutInvalidFullSpan && hasGapsToFix() == null)) {
                  z = false;
              }
              if (z) {
                  removeCallbacks(this.mCheckForGapsRunnable);
                  if (checkForGaps()) {
                      z3 = true;
                  }
              }
          }
          if (state.isPreLayout()) {
              this.mAnchorInfo.reset();
          }
          this.mLastLayoutFromEnd = anchorInfo.mLayoutFromEnd;
          this.mLastLayoutRTL = isLayoutRTL();
          if (z3) {
              this.mAnchorInfo.reset();
              onLayoutChildren(recycler, state, false);
          }
      }
  
      private boolean preferLastSpan(int layoutDir) {
          if (this.mOrientation == 0) {
              return (layoutDir == -1) != this.mShouldReverseLayout;
          }
          return ((layoutDir == -1) == this.mShouldReverseLayout) == isLayoutRTL();
      }
  
      private void prependViewToAllSpans(View view) {
          for (int i = this.mSpanCount - 1; i >= 0; i--) {
              this.mSpans[i].prependToSpan(view);
          }
      }
  
      private void recycle(RecyclerView.Recycler recycler, LayoutState layoutState) {
          if (layoutState.mRecycle && !layoutState.mInfinite) {
              if (layoutState.mAvailable == 0) {
                  if (layoutState.mLayoutDirection == -1) {
                      recycleFromEnd(recycler, layoutState.mEndLine);
                  } else {
                      recycleFromStart(recycler, layoutState.mStartLine);
                  }
              } else if (layoutState.mLayoutDirection == -1) {
                  int maxStart = layoutState.mStartLine - getMaxStart(layoutState.mStartLine);
                  recycleFromEnd(recycler, maxStart < 0 ? layoutState.mEndLine : layoutState.mEndLine - Math.min(maxStart, layoutState.mAvailable));
              } else {
                  int minEnd = getMinEnd(layoutState.mEndLine) - layoutState.mEndLine;
                  recycleFromStart(recycler, minEnd < 0 ? layoutState.mStartLine : layoutState.mStartLine + Math.min(minEnd, layoutState.mAvailable));
              }
          }
      }
  
      private void recycleFromEnd(RecyclerView.Recycler recycler, int line) {
          int childCount = getChildCount() - 1;
          while (childCount >= 0) {
              View childAt = getChildAt(childCount);
              if (this.mPrimaryOrientation.getDecoratedStart(childAt) >= line && this.mPrimaryOrientation.getTransformedStartWithDecoration(childAt) >= line) {
                  LayoutParams layoutParams = (LayoutParams) childAt.getLayoutParams();
                  if (layoutParams.mFullSpan) {
                      int i = 0;
                      while (i < this.mSpanCount) {
                          if (this.mSpans[i].mViews.size() != 1) {
                              i++;
                          } else {
                              return;
                          }
                      }
                      for (int i2 = 0; i2 < this.mSpanCount; i2++) {
                          this.mSpans[i2].popEnd();
                      }
                  } else if (layoutParams.mSpan.mViews.size() != 1) {
                      layoutParams.mSpan.popEnd();
                  } else {
                      return;
                  }
                  removeAndRecycleView(childAt, recycler);
                  childCount--;
              } else {
                  return;
              }
          }
      }
  
      private void recycleFromStart(RecyclerView.Recycler recycler, int line) {
          while (getChildCount() > 0) {
              View childAt = getChildAt(0);
              if (this.mPrimaryOrientation.getDecoratedEnd(childAt) <= line && this.mPrimaryOrientation.getTransformedEndWithDecoration(childAt) <= line) {
                  LayoutParams layoutParams = (LayoutParams) childAt.getLayoutParams();
                  if (layoutParams.mFullSpan) {
                      int i = 0;
                      while (i < this.mSpanCount) {
                          if (this.mSpans[i].mViews.size() != 1) {
                              i++;
                          } else {
                              return;
                          }
                      }
                      for (int i2 = 0; i2 < this.mSpanCount; i2++) {
                          this.mSpans[i2].popStart();
                      }
                  } else if (layoutParams.mSpan.mViews.size() != 1) {
                      layoutParams.mSpan.popStart();
                  } else {
                      return;
                  }
                  removeAndRecycleView(childAt, recycler);
              } else {
                  return;
              }
          }
      }
  
      private void repositionToWrapContentIfNecessary() {
          if (this.mSecondaryOrientation.getMode() != 1073741824) {
              float f = 0.0f;
              int childCount = getChildCount();
              for (int i = 0; i < childCount; i++) {
                  View childAt = getChildAt(i);
                  float decoratedMeasurement = (float) this.mSecondaryOrientation.getDecoratedMeasurement(childAt);
                  if (decoratedMeasurement >= f) {
                      if (((LayoutParams) childAt.getLayoutParams()).isFullSpan()) {
                          decoratedMeasurement = (1.0f * decoratedMeasurement) / ((float) this.mSpanCount);
                      }
                      f = Math.max(f, decoratedMeasurement);
                  }
              }
              int i2 = this.mSizePerSpan;
              int round = Math.round(((float) this.mSpanCount) * f);
              if (this.mSecondaryOrientation.getMode() == Integer.MIN_VALUE) {
                  round = Math.min(round, this.mSecondaryOrientation.getTotalSpace());
              }
              updateMeasureSpecs(round);
              if (this.mSizePerSpan != i2) {
                  for (int i3 = 0; i3 < childCount; i3++) {
                      View childAt2 = getChildAt(i3);
                      LayoutParams layoutParams = (LayoutParams) childAt2.getLayoutParams();
                      if (!layoutParams.mFullSpan) {
                          if (!isLayoutRTL() || this.mOrientation != 1) {
                              int i4 = layoutParams.mSpan.mIndex * this.mSizePerSpan;
                              int i5 = layoutParams.mSpan.mIndex * i2;
                              if (this.mOrientation == 1) {
                                  childAt2.offsetLeftAndRight(i4 - i5);
                              } else {
                                  childAt2.offsetTopAndBottom(i4 - i5);
                              }
                          } else {
                              childAt2.offsetLeftAndRight(((-((this.mSpanCount - 1) - layoutParams.mSpan.mIndex)) * this.mSizePerSpan) - ((-((this.mSpanCount - 1) - layoutParams.mSpan.mIndex)) * i2));
                          }
                      }
                  }
              }
          }
      }
  
      private void resolveShouldLayoutReverse() {
          if (this.mOrientation == 1 || !isLayoutRTL()) {
              this.mShouldReverseLayout = this.mReverseLayout;
          } else {
              this.mShouldReverseLayout = !this.mReverseLayout;
          }
      }
  
      private void setLayoutStateDirection(int direction) {
          this.mLayoutState.mLayoutDirection = direction;
          LayoutState layoutState = this.mLayoutState;
          int i = 1;
          if (this.mShouldReverseLayout != (direction == -1)) {
              i = -1;
          }
          layoutState.mItemDirection = i;
      }
  
      private void updateAllRemainingSpans(int layoutDir, int targetLine) {
          for (int i = 0; i < this.mSpanCount; i++) {
              if (!this.mSpans[i].mViews.isEmpty()) {
                  updateRemainingSpans(this.mSpans[i], layoutDir, targetLine);
              }
          }
      }
  
      private boolean updateAnchorFromChildren(RecyclerView.State state, AnchorInfo anchorInfo) {
          anchorInfo.mPosition = this.mLastLayoutFromEnd ? findLastReferenceChildPosition(state.getItemCount()) : findFirstReferenceChildPosition(state.getItemCount());
          anchorInfo.mOffset = Integer.MIN_VALUE;
          return true;
      }
  
      private void updateLayoutState(int anchorPosition, RecyclerView.State state) {
          int targetScrollPosition;
          boolean z = false;
          this.mLayoutState.mAvailable = 0;
          this.mLayoutState.mCurrentPosition = anchorPosition;
          int i = 0;
          int i2 = 0;
          if (isSmoothScrolling() && (targetScrollPosition = state.getTargetScrollPosition()) != -1) {
              if (this.mShouldReverseLayout == (targetScrollPosition < anchorPosition)) {
                  i2 = this.mPrimaryOrientation.getTotalSpace();
              } else {
                  i = this.mPrimaryOrientation.getTotalSpace();
              }
          }
          if (getClipToPadding()) {
              this.mLayoutState.mStartLine = this.mPrimaryOrientation.getStartAfterPadding() - i;
              this.mLayoutState.mEndLine = this.mPrimaryOrientation.getEndAfterPadding() + i2;
          } else {
              this.mLayoutState.mEndLine = this.mPrimaryOrientation.getEnd() + i2;
              this.mLayoutState.mStartLine = -i;
          }
          this.mLayoutState.mStopInFocusable = false;
          this.mLayoutState.mRecycle = true;
          LayoutState layoutState = this.mLayoutState;
          if (this.mPrimaryOrientation.getMode() == 0 && this.mPrimaryOrientation.getEnd() == 0) {
              z = true;
          }
          layoutState.mInfinite = z;
      }
  
      private void updateRemainingSpans(Span span, int layoutDir, int targetLine) {
          int deletedSize = span.getDeletedSize();
          if (layoutDir == -1) {
              if (span.getStartLine() + deletedSize <= targetLine) {
                  this.mRemainingSpans.set(span.mIndex, false);
              }
          } else if (span.getEndLine() - deletedSize >= targetLine) {
              this.mRemainingSpans.set(span.mIndex, false);
          }
      }
  
      private int updateSpecWithExtra(int spec, int startInset, int endInset) {
          if (startInset == 0 && endInset == 0) {
              return spec;
          }
          int mode = View.MeasureSpec.getMode(spec);
          return (mode == Integer.MIN_VALUE || mode == 1073741824) ? View.MeasureSpec.makeMeasureSpec(Math.max(0, (View.MeasureSpec.getSize(spec) - startInset) - endInset), mode) : spec;
      }
  
      /* access modifiers changed from: package-private */
      public boolean areAllEndsEqual() {
          int endLine = this.mSpans[0].getEndLine(Integer.MIN_VALUE);
          for (int i = 1; i < this.mSpanCount; i++) {
              if (this.mSpans[i].getEndLine(Integer.MIN_VALUE) != endLine) {
                  return false;
              }
          }
          return true;
      }
  
      /* access modifiers changed from: package-private */
      public boolean areAllStartsEqual() {
          int startLine = this.mSpans[0].getStartLine(Integer.MIN_VALUE);
          for (int i = 1; i < this.mSpanCount; i++) {
              if (this.mSpans[i].getStartLine(Integer.MIN_VALUE) != startLine) {
                  return false;
              }
          }
          return true;
      }
  
      public void assertNotInLayoutOrScroll(String message) {
          if (this.mPendingSavedState == null) {
              super.assertNotInLayoutOrScroll(message);
          }
      }
  
      public boolean canScrollHorizontally() {
          return this.mOrientation == 0;
      }
  
      public boolean canScrollVertically() {
          return this.mOrientation == 1;
      }
  
      /* access modifiers changed from: package-private */
      public boolean checkForGaps() {
          int i;
          int i2;
          if (getChildCount() == 0 || this.mGapStrategy == 0 || !isAttachedToWindow()) {
              return false;
          }
          if (this.mShouldReverseLayout) {
              i2 = getLastChildPosition();
              i = getFirstChildPosition();
          } else {
              i2 = getFirstChildPosition();
              i = getLastChildPosition();
          }
          if (i2 == 0 && hasGapsToFix() != null) {
              this.mLazySpanLookup.clear();
              requestSimpleAnimationsInNextLayout();
              requestLayout();
              return true;
          } else if (!this.mLaidOutInvalidFullSpan) {
              return false;
          } else {
              int i3 = this.mShouldReverseLayout ? -1 : 1;
              LazySpanLookup.FullSpanItem firstFullSpanItemInRange = this.mLazySpanLookup.getFirstFullSpanItemInRange(i2, i + 1, i3, true);
              if (firstFullSpanItemInRange == null) {
                  this.mLaidOutInvalidFullSpan = false;
                  this.mLazySpanLookup.forceInvalidateAfter(i + 1);
                  return false;
              }
              LazySpanLookup.FullSpanItem firstFullSpanItemInRange2 = this.mLazySpanLookup.getFirstFullSpanItemInRange(i2, firstFullSpanItemInRange.mPosition, i3 * -1, true);
              if (firstFullSpanItemInRange2 == null) {
                  this.mLazySpanLookup.forceInvalidateAfter(firstFullSpanItemInRange.mPosition);
              } else {
                  this.mLazySpanLookup.forceInvalidateAfter(firstFullSpanItemInRange2.mPosition + 1);
              }
              requestSimpleAnimationsInNextLayout();
              requestLayout();
              return true;
          }
      }
  
      public boolean checkLayoutParams(RecyclerView.LayoutParams lp) {
          return lp instanceof LayoutParams;
      }
  
      public void collectAdjacentPrefetchPositions(int dx, int dy, RecyclerView.State state, RecyclerView.LayoutManager.LayoutPrefetchRegistry layoutPrefetchRegistry) {
          int i = this.mOrientation == 0 ? dx : dy;
          if (getChildCount() != 0 && i != 0) {
              prepareLayoutStateForDelta(i, state);
              int[] iArr = this.mPrefetchDistances;
              if (iArr == null || iArr.length < this.mSpanCount) {
                  this.mPrefetchDistances = new int[this.mSpanCount];
              }
              int i2 = 0;
              for (int i3 = 0; i3 < this.mSpanCount; i3++) {
                  int startLine = this.mLayoutState.mItemDirection == -1 ? this.mLayoutState.mStartLine - this.mSpans[i3].getStartLine(this.mLayoutState.mStartLine) : this.mSpans[i3].getEndLine(this.mLayoutState.mEndLine) - this.mLayoutState.mEndLine;
                  if (startLine >= 0) {
                      this.mPrefetchDistances[i2] = startLine;
                      i2++;
                  }
              }
              Arrays.sort(this.mPrefetchDistances, 0, i2);
              for (int i4 = 0; i4 < i2 && this.mLayoutState.hasMore(state); i4++) {
                  layoutPrefetchRegistry.addPosition(this.mLayoutState.mCurrentPosition, this.mPrefetchDistances[i4]);
                  this.mLayoutState.mCurrentPosition += this.mLayoutState.mItemDirection;
              }
          }
      }
  
      public int computeHorizontalScrollExtent(RecyclerView.State state) {
          return computeScrollExtent(state);
      }
  
      public int computeHorizontalScrollOffset(RecyclerView.State state) {
          return computeScrollOffset(state);
      }
  
      public int computeHorizontalScrollRange(RecyclerView.State state) {
          return computeScrollRange(state);
      }
  
      public PointF computeScrollVectorForPosition(int targetPosition) {
          int calculateScrollDirectionForPosition = calculateScrollDirectionForPosition(targetPosition);
          PointF pointF = new PointF();
          if (calculateScrollDirectionForPosition == 0) {
              return null;
          }
          if (this.mOrientation == 0) {
              pointF.x = (float) calculateScrollDirectionForPosition;
              pointF.y = 0.0f;
          } else {
              pointF.x = 0.0f;
              pointF.y = (float) calculateScrollDirectionForPosition;
          }
          return pointF;
      }
  
      public int computeVerticalScrollExtent(RecyclerView.State state) {
          return computeScrollExtent(state);
      }
  
      public int computeVerticalScrollOffset(RecyclerView.State state) {
          return computeScrollOffset(state);
      }
  
      public int computeVerticalScrollRange(RecyclerView.State state) {
          return computeScrollRange(state);
      }
  
      public int[] findFirstCompletelyVisibleItemPositions(int[] into) {
          if (into == null) {
              into = new int[this.mSpanCount];
          } else if (into.length < this.mSpanCount) {
              throw new IllegalArgumentException("Provided int[]'s size must be more than or equal to span count. Expected:" + this.mSpanCount + ", array size:" + into.length);
          }
          for (int i = 0; i < this.mSpanCount; i++) {
              into[i] = this.mSpans[i].findFirstCompletelyVisibleItemPosition();
          }
          return into;
      }
  
      /* access modifiers changed from: package-private */
      public View findFirstVisibleItemClosestToEnd(boolean fullyVisible) {
          int startAfterPadding = this.mPrimaryOrientation.getStartAfterPadding();
          int endAfterPadding = this.mPrimaryOrientation.getEndAfterPadding();
          View view = null;
          for (int childCount = getChildCount() - 1; childCount >= 0; childCount--) {
              View childAt = getChildAt(childCount);
              int decoratedStart = this.mPrimaryOrientation.getDecoratedStart(childAt);
              int decoratedEnd = this.mPrimaryOrientation.getDecoratedEnd(childAt);
              if (decoratedEnd > startAfterPadding && decoratedStart < endAfterPadding) {
                  if (decoratedEnd <= endAfterPadding || !fullyVisible) {
                      return childAt;
                  }
                  if (view == null) {
                      view = childAt;
                  }
              }
          }
          return view;
      }
  
      /* access modifiers changed from: package-private */
      public View findFirstVisibleItemClosestToStart(boolean fullyVisible) {
          int startAfterPadding = this.mPrimaryOrientation.getStartAfterPadding();
          int endAfterPadding = this.mPrimaryOrientation.getEndAfterPadding();
          int childCount = getChildCount();
          View view = null;
          for (int i = 0; i < childCount; i++) {
              View childAt = getChildAt(i);
              int decoratedStart = this.mPrimaryOrientation.getDecoratedStart(childAt);
              if (this.mPrimaryOrientation.getDecoratedEnd(childAt) > startAfterPadding && decoratedStart < endAfterPadding) {
                  if (decoratedStart >= startAfterPadding || !fullyVisible) {
                      return childAt;
                  }
                  if (view == null) {
                      view = childAt;
                  }
              }
          }
          return view;
      }
  
      /* access modifiers changed from: package-private */
      public int findFirstVisibleItemPositionInt() {
          View findFirstVisibleItemClosestToEnd = this.mShouldReverseLayout ? findFirstVisibleItemClosestToEnd(true) : findFirstVisibleItemClosestToStart(true);
          if (findFirstVisibleItemClosestToEnd == null) {
              return -1;
          }
          return getPosition(findFirstVisibleItemClosestToEnd);
      }
  
      public int[] findFirstVisibleItemPositions(int[] into) {
          if (into == null) {
              into = new int[this.mSpanCount];
          } else if (into.length < this.mSpanCount) {
              throw new IllegalArgumentException("Provided int[]'s size must be more than or equal to span count. Expected:" + this.mSpanCount + ", array size:" + into.length);
          }
          for (int i = 0; i < this.mSpanCount; i++) {
              into[i] = this.mSpans[i].findFirstVisibleItemPosition();
          }
          return into;
      }
  
      public int[] findLastCompletelyVisibleItemPositions(int[] into) {
          if (into == null) {
              into = new int[this.mSpanCount];
          } else if (into.length < this.mSpanCount) {
              throw new IllegalArgumentException("Provided int[]'s size must be more than or equal to span count. Expected:" + this.mSpanCount + ", array size:" + into.length);
          }
          for (int i = 0; i < this.mSpanCount; i++) {
              into[i] = this.mSpans[i].findLastCompletelyVisibleItemPosition();
          }
          return into;
      }
  
      public int[] findLastVisibleItemPositions(int[] into) {
          if (into == null) {
              into = new int[this.mSpanCount];
          } else if (into.length < this.mSpanCount) {
              throw new IllegalArgumentException("Provided int[]'s size must be more than or equal to span count. Expected:" + this.mSpanCount + ", array size:" + into.length);
          }
          for (int i = 0; i < this.mSpanCount; i++) {
              into[i] = this.mSpans[i].findLastVisibleItemPosition();
          }
          return into;
      }
  
      public RecyclerView.LayoutParams generateDefaultLayoutParams() {
          return this.mOrientation == 0 ? new LayoutParams(-2, -1) : new LayoutParams(-1, -2);
      }
  
      public RecyclerView.LayoutParams generateLayoutParams(Context c, AttributeSet attrs) {
          return new LayoutParams(c, attrs);
      }
  
      public RecyclerView.LayoutParams generateLayoutParams(ViewGroup.LayoutParams lp) {
          return lp instanceof ViewGroup.MarginLayoutParams ? new LayoutParams((ViewGroup.MarginLayoutParams) lp) : new LayoutParams(lp);
      }
  
      public int getColumnCountForAccessibility(RecyclerView.Recycler recycler, RecyclerView.State state) {
          return this.mOrientation == 1 ? this.mSpanCount : super.getColumnCountForAccessibility(recycler, state);
      }
  
      /* access modifiers changed from: package-private */
      public int getFirstChildPosition() {
          if (getChildCount() == 0) {
              return 0;
          }
          return getPosition(getChildAt(0));
      }
  
      public int getGapStrategy() {
          return this.mGapStrategy;
      }
  
      /* access modifiers changed from: package-private */
      public int getLastChildPosition() {
          int childCount = getChildCount();
          if (childCount == 0) {
              return 0;
          }
          return getPosition(getChildAt(childCount - 1));
      }
  
      public int getOrientation() {
          return this.mOrientation;
      }
  
      public boolean getReverseLayout() {
          return this.mReverseLayout;
      }
  
      public int getRowCountForAccessibility(RecyclerView.Recycler recycler, RecyclerView.State state) {
          return this.mOrientation == 0 ? this.mSpanCount : super.getRowCountForAccessibility(recycler, state);
      }
  
      public int getSpanCount() {
          return this.mSpanCount;
      }
  
      /* access modifiers changed from: package-private */
      public View hasGapsToFix() {
          int i;
          int i2;
          int childCount = getChildCount() - 1;
          BitSet bitSet = new BitSet(this.mSpanCount);
          bitSet.set(0, this.mSpanCount, true);
          int i3 = -1;
          char c = (this.mOrientation != 1 || !isLayoutRTL()) ? (char) 65535 : 1;
          if (this.mShouldReverseLayout) {
              i2 = childCount;
              i = 0 - 1;
          } else {
              i2 = 0;
              i = childCount + 1;
          }
          if (i2 < i) {
              i3 = 1;
          }
          for (int i4 = i2; i4 != i; i4 += i3) {
              View childAt = getChildAt(i4);
              LayoutParams layoutParams = (LayoutParams) childAt.getLayoutParams();
              if (bitSet.get(layoutParams.mSpan.mIndex)) {
                  if (checkSpanForGap(layoutParams.mSpan)) {
                      return childAt;
                  }
                  bitSet.clear(layoutParams.mSpan.mIndex);
              }
              if (!layoutParams.mFullSpan && i4 + i3 != i) {
                  View childAt2 = getChildAt(i4 + i3);
                  boolean z = false;
                  if (this.mShouldReverseLayout) {
                      int decoratedEnd = this.mPrimaryOrientation.getDecoratedEnd(childAt);
                      int decoratedEnd2 = this.mPrimaryOrientation.getDecoratedEnd(childAt2);
                      if (decoratedEnd < decoratedEnd2) {
                          return childAt;
                      }
                      if (decoratedEnd == decoratedEnd2) {
                          z = true;
                      }
                  } else {
                      int decoratedStart = this.mPrimaryOrientation.getDecoratedStart(childAt);
                      int decoratedStart2 = this.mPrimaryOrientation.getDecoratedStart(childAt2);
                      if (decoratedStart > decoratedStart2) {
                          return childAt;
                      }
                      if (decoratedStart == decoratedStart2) {
                          z = true;
                      }
                  }
                  if (!z) {
                      continue;
                  } else {
                      if ((layoutParams.mSpan.mIndex - ((LayoutParams) childAt2.getLayoutParams()).mSpan.mIndex < 0) != (c < 0)) {
                          return childAt;
                      }
                  }
              }
          }
          return null;
      }
  
      public void invalidateSpanAssignments() {
          this.mLazySpanLookup.clear();
          requestLayout();
      }
  
      public boolean isAutoMeasureEnabled() {
          return this.mGapStrategy != 0;
      }
  
      /* access modifiers changed from: package-private */
      public boolean isLayoutRTL() {
          return getLayoutDirection() == 1;
      }
  
      public void offsetChildrenHorizontal(int dx) {
          super.offsetChildrenHorizontal(dx);
          for (int i = 0; i < this.mSpanCount; i++) {
              this.mSpans[i].onOffset(dx);
          }
      }
  
      public void offsetChildrenVertical(int dy) {
          super.offsetChildrenVertical(dy);
          for (int i = 0; i < this.mSpanCount; i++) {
              this.mSpans[i].onOffset(dy);
          }
      }
  
      public void onDetachedFromWindow(RecyclerView view, RecyclerView.Recycler recycler) {
          super.onDetachedFromWindow(view, recycler);
          removeCallbacks(this.mCheckForGapsRunnable);
          for (int i = 0; i < this.mSpanCount; i++) {
              this.mSpans[i].clear();
          }
          view.requestLayout();
      }
  
      public View onFocusSearchFailed(View focused, int direction, RecyclerView.Recycler recycler, RecyclerView.State state) {
          View findContainingItemView;
          View focusableViewAfter;
          if (getChildCount() == 0 || (findContainingItemView = findContainingItemView(focused)) == null) {
              return null;
          }
          resolveShouldLayoutReverse();
          int convertFocusDirectionToLayoutDirection = convertFocusDirectionToLayoutDirection(direction);
          if (convertFocusDirectionToLayoutDirection == Integer.MIN_VALUE) {
              return null;
          }
          LayoutParams layoutParams = (LayoutParams) findContainingItemView.getLayoutParams();
          boolean z = layoutParams.mFullSpan;
          Span span = layoutParams.mSpan;
          int lastChildPosition = convertFocusDirectionToLayoutDirection == 1 ? getLastChildPosition() : getFirstChildPosition();
          updateLayoutState(lastChildPosition, state);
          setLayoutStateDirection(convertFocusDirectionToLayoutDirection);
          LayoutState layoutState = this.mLayoutState;
          layoutState.mCurrentPosition = layoutState.mItemDirection + lastChildPosition;
          this.mLayoutState.mAvailable = (int) (((float) this.mPrimaryOrientation.getTotalSpace()) * MAX_SCROLL_FACTOR);
          this.mLayoutState.mStopInFocusable = true;
          boolean z2 = false;
          this.mLayoutState.mRecycle = false;
          fill(recycler, this.mLayoutState, state);
          this.mLastLayoutFromEnd = this.mShouldReverseLayout;
          if (!z && (focusableViewAfter = span.getFocusableViewAfter(lastChildPosition, convertFocusDirectionToLayoutDirection)) != null && focusableViewAfter != findContainingItemView) {
              return focusableViewAfter;
          }
          if (preferLastSpan(convertFocusDirectionToLayoutDirection)) {
              for (int i = this.mSpanCount - 1; i >= 0; i--) {
                  View focusableViewAfter2 = this.mSpans[i].getFocusableViewAfter(lastChildPosition, convertFocusDirectionToLayoutDirection);
                  if (focusableViewAfter2 != null && focusableViewAfter2 != findContainingItemView) {
                      return focusableViewAfter2;
                  }
              }
          } else {
              for (int i2 = 0; i2 < this.mSpanCount; i2++) {
                  View focusableViewAfter3 = this.mSpans[i2].getFocusableViewAfter(lastChildPosition, convertFocusDirectionToLayoutDirection);
                  if (focusableViewAfter3 != null && focusableViewAfter3 != findContainingItemView) {
                      return focusableViewAfter3;
                  }
              }
          }
          if ((!this.mReverseLayout) == (convertFocusDirectionToLayoutDirection == -1)) {
              z2 = true;
          }
          boolean z3 = z2;
          if (!z) {
              View findViewByPosition = findViewByPosition(z3 ? span.findFirstPartiallyVisibleItemPosition() : span.findLastPartiallyVisibleItemPosition());
              if (!(findViewByPosition == null || findViewByPosition == findContainingItemView)) {
                  return findViewByPosition;
              }
          }
          if (preferLastSpan(convertFocusDirectionToLayoutDirection)) {
              for (int i3 = this.mSpanCount - 1; i3 >= 0; i3--) {
                  if (i3 != span.mIndex) {
                      View findViewByPosition2 = findViewByPosition(z3 ? this.mSpans[i3].findFirstPartiallyVisibleItemPosition() : this.mSpans[i3].findLastPartiallyVisibleItemPosition());
                      if (findViewByPosition2 != null && findViewByPosition2 != findContainingItemView) {
                          return findViewByPosition2;
                      }
                      View view = findViewByPosition2;
                  }
              }
          } else {
              for (int i4 = 0; i4 < this.mSpanCount; i4++) {
                  View findViewByPosition3 = findViewByPosition(z3 ? this.mSpans[i4].findFirstPartiallyVisibleItemPosition() : this.mSpans[i4].findLastPartiallyVisibleItemPosition());
                  if (findViewByPosition3 != null && findViewByPosition3 != findContainingItemView) {
                      return findViewByPosition3;
                  }
              }
          }
          return null;
      }
  
      public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
          super.onInitializeAccessibilityEvent(event);
          if (getChildCount() > 0) {
              View findFirstVisibleItemClosestToStart = findFirstVisibleItemClosestToStart(false);
              View findFirstVisibleItemClosestToEnd = findFirstVisibleItemClosestToEnd(false);
              if (findFirstVisibleItemClosestToStart != null && findFirstVisibleItemClosestToEnd != null) {
                  int position = getPosition(findFirstVisibleItemClosestToStart);
                  int position2 = getPosition(findFirstVisibleItemClosestToEnd);
                  if (position < position2) {
                      event.setFromIndex(position);
                      event.setToIndex(position2);
                      return;
                  }
                  event.setFromIndex(position2);
                  event.setToIndex(position);
              }
          }
      }
  
      public void onInitializeAccessibilityNodeInfoForItem(RecyclerView.Recycler recycler, RecyclerView.State state, View host, AccessibilityNodeInfoCompat info) {
          ViewGroup.LayoutParams layoutParams = host.getLayoutParams();
          if (!(layoutParams instanceof LayoutParams)) {
              super.onInitializeAccessibilityNodeInfoForItem(host, info);
              return;
          }
          LayoutParams layoutParams2 = (LayoutParams) layoutParams;
          int i = 1;
          if (this.mOrientation == 0) {
              int spanIndex = layoutParams2.getSpanIndex();
              if (layoutParams2.mFullSpan) {
                  i = this.mSpanCount;
              }
              info.setCollectionItemInfo(AccessibilityNodeInfoCompat.CollectionItemInfoCompat.obtain(spanIndex, i, -1, -1, false, false));
              return;
          }
          int spanIndex2 = layoutParams2.getSpanIndex();
          if (layoutParams2.mFullSpan) {
              i = this.mSpanCount;
          }
          info.setCollectionItemInfo(AccessibilityNodeInfoCompat.CollectionItemInfoCompat.obtain(-1, -1, spanIndex2, i, false, false));
      }
  
      public void onItemsAdded(RecyclerView recyclerView, int positionStart, int itemCount) {
          handleUpdate(positionStart, itemCount, 1);
      }
  
      public void onItemsChanged(RecyclerView recyclerView) {
          this.mLazySpanLookup.clear();
          requestLayout();
      }
  
      public void onItemsMoved(RecyclerView recyclerView, int from, int to, int itemCount) {
          handleUpdate(from, to, 8);
      }
  
      public void onItemsRemoved(RecyclerView recyclerView, int positionStart, int itemCount) {
          handleUpdate(positionStart, itemCount, 2);
      }
  
      public void onItemsUpdated(RecyclerView recyclerView, int positionStart, int itemCount, Object payload) {
          handleUpdate(positionStart, itemCount, 4);
      }
  
      public void onLayoutChildren(RecyclerView.Recycler recycler, RecyclerView.State state) {
          onLayoutChildren(recycler, state, true);
      }
  
      public void onLayoutCompleted(RecyclerView.State state) {
          super.onLayoutCompleted(state);
          this.mPendingScrollPosition = -1;
          this.mPendingScrollPositionOffset = Integer.MIN_VALUE;
          this.mPendingSavedState = null;
          this.mAnchorInfo.reset();
      }
  
      public void onRestoreInstanceState(Parcelable state) {
          if (state instanceof SavedState) {
              this.mPendingSavedState = (SavedState) state;
              requestLayout();
          }
      }
  
      public Parcelable onSaveInstanceState() {
          int i;
          if (this.mPendingSavedState != null) {
              return new SavedState(this.mPendingSavedState);
          }
          SavedState savedState = new SavedState();
          savedState.mReverseLayout = this.mReverseLayout;
          savedState.mAnchorLayoutFromEnd = this.mLastLayoutFromEnd;
          savedState.mLastLayoutRTL = this.mLastLayoutRTL;
          LazySpanLookup lazySpanLookup = this.mLazySpanLookup;
          if (lazySpanLookup == null || lazySpanLookup.mData == null) {
              savedState.mSpanLookupSize = 0;
          } else {
              savedState.mSpanLookup = this.mLazySpanLookup.mData;
              savedState.mSpanLookupSize = savedState.mSpanLookup.length;
              savedState.mFullSpanItems = this.mLazySpanLookup.mFullSpanItems;
          }
          if (getChildCount() > 0) {
              savedState.mAnchorPosition = this.mLastLayoutFromEnd ? getLastChildPosition() : getFirstChildPosition();
              savedState.mVisibleAnchorPosition = findFirstVisibleItemPositionInt();
              savedState.mSpanOffsetsSize = this.mSpanCount;
              savedState.mSpanOffsets = new int[this.mSpanCount];
              for (int i2 = 0; i2 < this.mSpanCount; i2++) {
                  if (this.mLastLayoutFromEnd) {
                      i = this.mSpans[i2].getEndLine(Integer.MIN_VALUE);
                      if (i != Integer.MIN_VALUE) {
                          i -= this.mPrimaryOrientation.getEndAfterPadding();
                      }
                  } else {
                      i = this.mSpans[i2].getStartLine(Integer.MIN_VALUE);
                      if (i != Integer.MIN_VALUE) {
                          i -= this.mPrimaryOrientation.getStartAfterPadding();
                      }
                  }
                  savedState.mSpanOffsets[i2] = i;
              }
          } else {
              savedState.mAnchorPosition = -1;
              savedState.mVisibleAnchorPosition = -1;
              savedState.mSpanOffsetsSize = 0;
          }
          return savedState;
      }
  
      public void onScrollStateChanged(int state) {
          if (state == 0) {
              checkForGaps();
          }
      }
  
      /* access modifiers changed from: package-private */
      public void prepareLayoutStateForDelta(int delta, RecyclerView.State state) {
          int i;
          int i2;
          if (delta > 0) {
              i2 = 1;
              i = getLastChildPosition();
          } else {
              i2 = -1;
              i = getFirstChildPosition();
          }
          this.mLayoutState.mRecycle = true;
          updateLayoutState(i, state);
          setLayoutStateDirection(i2);
          LayoutState layoutState = this.mLayoutState;
          layoutState.mCurrentPosition = layoutState.mItemDirection + i;
          this.mLayoutState.mAvailable = Math.abs(delta);
      }
  
      /* access modifiers changed from: package-private */
      public int scrollBy(int dt, RecyclerView.Recycler recycler, RecyclerView.State state) {
          if (getChildCount() == 0 || dt == 0) {
              return 0;
          }
          prepareLayoutStateForDelta(dt, state);
          int fill = fill(recycler, this.mLayoutState, state);
          int i = this.mLayoutState.mAvailable < fill ? dt : dt < 0 ? -fill : fill;
          this.mPrimaryOrientation.offsetChildren(-i);
          this.mLastLayoutFromEnd = this.mShouldReverseLayout;
          this.mLayoutState.mAvailable = 0;
          recycle(recycler, this.mLayoutState);
          return i;
      }
  
      public int scrollHorizontallyBy(int dx, RecyclerView.Recycler recycler, RecyclerView.State state) {
          return scrollBy(dx, recycler, state);
      }
  
      public void scrollToPosition(int position) {
          SavedState savedState = this.mPendingSavedState;
          if (!(savedState == null || savedState.mAnchorPosition == position)) {
              this.mPendingSavedState.invalidateAnchorPositionInfo();
          }
          this.mPendingScrollPosition = position;
          this.mPendingScrollPositionOffset = Integer.MIN_VALUE;
          requestLayout();
      }
  
      public void scrollToPositionWithOffset(int position, int offset) {
          SavedState savedState = this.mPendingSavedState;
          if (savedState != null) {
              savedState.invalidateAnchorPositionInfo();
          }
          this.mPendingScrollPosition = position;
          this.mPendingScrollPositionOffset = offset;
          requestLayout();
      }
  
      public int scrollVerticallyBy(int dy, RecyclerView.Recycler recycler, RecyclerView.State state) {
          return scrollBy(dy, recycler, state);
      }
  
      public void setGapStrategy(int gapStrategy) {
          assertNotInLayoutOrScroll((String) null);
          if (gapStrategy != this.mGapStrategy) {
              if (gapStrategy == 0 || gapStrategy == 2) {
                  this.mGapStrategy = gapStrategy;
                  requestLayout();
                  return;
              }
              throw new IllegalArgumentException("invalid gap strategy. Must be GAP_HANDLING_NONE or GAP_HANDLING_MOVE_ITEMS_BETWEEN_SPANS");
          }
      }
  
      public void setMeasuredDimension(Rect childrenBounds, int wSpec, int hSpec) {
          int i;
          int i2;
          int paddingLeft = getPaddingLeft() + getPaddingRight();
          int paddingTop = getPaddingTop() + getPaddingBottom();
          if (this.mOrientation == 1) {
              i = chooseSize(hSpec, childrenBounds.height() + paddingTop, getMinimumHeight());
              i2 = chooseSize(wSpec, (this.mSizePerSpan * this.mSpanCount) + paddingLeft, getMinimumWidth());
          } else {
              i2 = chooseSize(wSpec, childrenBounds.width() + paddingLeft, getMinimumWidth());
              i = chooseSize(hSpec, (this.mSizePerSpan * this.mSpanCount) + paddingTop, getMinimumHeight());
          }
          setMeasuredDimension(i2, i);
      }
  
      public void setOrientation(int orientation) {
          if (orientation == 0 || orientation == 1) {
              assertNotInLayoutOrScroll((String) null);
              if (orientation != this.mOrientation) {
                  this.mOrientation = orientation;
                  OrientationHelper orientationHelper = this.mPrimaryOrientation;
                  this.mPrimaryOrientation = this.mSecondaryOrientation;
                  this.mSecondaryOrientation = orientationHelper;
                  requestLayout();
                  return;
              }
              return;
          }
          throw new IllegalArgumentException("invalid orientation.");
      }
  
      public void setReverseLayout(boolean reverseLayout) {
          assertNotInLayoutOrScroll((String) null);
          SavedState savedState = this.mPendingSavedState;
          if (!(savedState == null || savedState.mReverseLayout == reverseLayout)) {
              this.mPendingSavedState.mReverseLayout = reverseLayout;
          }
          this.mReverseLayout = reverseLayout;
          requestLayout();
      }
  
      public void setSpanCount(int spanCount) {
          assertNotInLayoutOrScroll((String) null);
          if (spanCount != this.mSpanCount) {
              invalidateSpanAssignments();
              this.mSpanCount = spanCount;
              this.mRemainingSpans = new BitSet(this.mSpanCount);
              this.mSpans = new Span[this.mSpanCount];
              for (int i = 0; i < this.mSpanCount; i++) {
                  this.mSpans[i] = new Span(i);
              }
              requestLayout();
          }
      }
  
      public void smoothScrollToPosition(RecyclerView recyclerView, RecyclerView.State state, int position) {
          LinearSmoothScroller linearSmoothScroller = new LinearSmoothScroller(recyclerView.getContext());
          linearSmoothScroller.setTargetPosition(position);
          startSmoothScroll(linearSmoothScroller);
      }
  
      public boolean supportsPredictiveItemAnimations() {
          return this.mPendingSavedState == null;
      }
  
      /* access modifiers changed from: package-private */
      public boolean updateAnchorFromPendingData(RecyclerView.State state, AnchorInfo anchorInfo) {
          int i;
          boolean z = false;
          if (state.isPreLayout() || (i = this.mPendingScrollPosition) == -1) {
              return false;
          }
          if (i < 0 || i >= state.getItemCount()) {
              this.mPendingScrollPosition = -1;
              this.mPendingScrollPositionOffset = Integer.MIN_VALUE;
              return false;
          }
          SavedState savedState = this.mPendingSavedState;
          if (savedState == null || savedState.mAnchorPosition == -1 || this.mPendingSavedState.mSpanOffsetsSize < 1) {
              View findViewByPosition = findViewByPosition(this.mPendingScrollPosition);
              if (findViewByPosition != null) {
                  anchorInfo.mPosition = this.mShouldReverseLayout ? getLastChildPosition() : getFirstChildPosition();
                  if (this.mPendingScrollPositionOffset != Integer.MIN_VALUE) {
                      if (anchorInfo.mLayoutFromEnd) {
                          anchorInfo.mOffset = (this.mPrimaryOrientation.getEndAfterPadding() - this.mPendingScrollPositionOffset) - this.mPrimaryOrientation.getDecoratedEnd(findViewByPosition);
                      } else {
                          anchorInfo.mOffset = (this.mPrimaryOrientation.getStartAfterPadding() + this.mPendingScrollPositionOffset) - this.mPrimaryOrientation.getDecoratedStart(findViewByPosition);
                      }
                      return true;
                  } else if (this.mPrimaryOrientation.getDecoratedMeasurement(findViewByPosition) > this.mPrimaryOrientation.getTotalSpace()) {
                      anchorInfo.mOffset = anchorInfo.mLayoutFromEnd ? this.mPrimaryOrientation.getEndAfterPadding() : this.mPrimaryOrientation.getStartAfterPadding();
                      return true;
                  } else {
                      int decoratedStart = this.mPrimaryOrientation.getDecoratedStart(findViewByPosition) - this.mPrimaryOrientation.getStartAfterPadding();
                      if (decoratedStart < 0) {
                          anchorInfo.mOffset = -decoratedStart;
                          return true;
                      }
                      int endAfterPadding = this.mPrimaryOrientation.getEndAfterPadding() - this.mPrimaryOrientation.getDecoratedEnd(findViewByPosition);
                      if (endAfterPadding < 0) {
                          anchorInfo.mOffset = endAfterPadding;
                          return true;
                      }
                      anchorInfo.mOffset = Integer.MIN_VALUE;
                  }
              } else {
                  anchorInfo.mPosition = this.mPendingScrollPosition;
                  int i2 = this.mPendingScrollPositionOffset;
                  if (i2 == Integer.MIN_VALUE) {
                      if (calculateScrollDirectionForPosition(anchorInfo.mPosition) == 1) {
                          z = true;
                      }
                      anchorInfo.mLayoutFromEnd = z;
                      anchorInfo.assignCoordinateFromPadding();
                  } else {
                      anchorInfo.assignCoordinateFromPadding(i2);
                  }
                  anchorInfo.mInvalidateOffsets = true;
              }
          } else {
              anchorInfo.mOffset = Integer.MIN_VALUE;
              anchorInfo.mPosition = this.mPendingScrollPosition;
          }
          return true;
      }
  
      /* access modifiers changed from: package-private */
      public void updateAnchorInfoForLayout(RecyclerView.State state, AnchorInfo anchorInfo) {
          if (!updateAnchorFromPendingData(state, anchorInfo) && !updateAnchorFromChildren(state, anchorInfo)) {
              anchorInfo.assignCoordinateFromPadding();
              anchorInfo.mPosition = 0;
          }
      }
  
      /* access modifiers changed from: package-private */
      public void updateMeasureSpecs(int totalSpace) {
          this.mSizePerSpan = totalSpace / this.mSpanCount;
          this.mFullSizeSpec = View.MeasureSpec.makeMeasureSpec(totalSpace, this.mSecondaryOrientation.getMode());
      }
  }
  