Files

375 lines
11 KiB
Java

package androidx.recyclerview.widget;
import android.util.Log;
import android.view.View;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.WeakHashMap;
/* loaded from: classes.dex */
public abstract class I0 {
static final int FLAG_ADAPTER_FULLUPDATE = 1024;
static final int FLAG_ADAPTER_POSITION_UNKNOWN = 512;
static final int FLAG_APPEARED_IN_PRE_LAYOUT = 4096;
static final int FLAG_BOUNCED_FROM_HIDDEN_LIST = 8192;
static final int FLAG_BOUND = 1;
static final int FLAG_IGNORE = 128;
static final int FLAG_INVALID = 4;
static final int FLAG_MOVED = 2048;
static final int FLAG_NOT_RECYCLABLE = 16;
static final int FLAG_REMOVED = 8;
static final int FLAG_RETURNED_FROM_SCRAP = 32;
static final int FLAG_TMP_DETACHED = 256;
static final int FLAG_UPDATE = 2;
private static final List<Object> FULLUPDATE_PAYLOADS = Collections.EMPTY_LIST;
static final int PENDING_ACCESSIBILITY_STATE_NOT_SET = -1;
public final View itemView;
AbstractC0220h0 mBindingAdapter;
int mFlags;
WeakReference<RecyclerView> mNestedRecyclerView;
RecyclerView mOwnerRecyclerView;
int mPosition = -1;
int mOldPosition = -1;
long mItemId = -1;
int mItemViewType = -1;
int mPreLayoutPosition = -1;
I0 mShadowedHolder = null;
I0 mShadowingHolder = null;
List<Object> mPayloads = null;
List<Object> mUnmodifiedPayloads = null;
private int mIsRecyclableCount = 0;
y0 mScrapContainer = null;
boolean mInChangeScrap = false;
private int mWasImportantForAccessibilityBeforeHidden = 0;
int mPendingAccessibilityState = -1;
public I0(View view) {
if (view == null) {
throw new IllegalArgumentException("itemView may not be null");
}
this.itemView = view;
}
public void addChangePayload(Object obj) {
if (obj == null) {
addFlags(1024);
return;
}
if ((1024 & this.mFlags) == 0) {
if (this.mPayloads == null) {
ArrayList arrayList = new ArrayList();
this.mPayloads = arrayList;
this.mUnmodifiedPayloads = Collections.unmodifiableList(arrayList);
}
this.mPayloads.add(obj);
}
}
public void addFlags(int i) {
this.mFlags = i | this.mFlags;
}
public void clearOldPosition() {
this.mOldPosition = -1;
this.mPreLayoutPosition = -1;
}
public void clearPayload() {
List<Object> list = this.mPayloads;
if (list != null) {
list.clear();
}
this.mFlags &= -1025;
}
public void clearReturnedFromScrapFlag() {
this.mFlags &= -33;
}
public void clearTmpDetachFlag() {
this.mFlags &= -257;
}
public boolean doesTransientStatePreventRecycling() {
if ((this.mFlags & 16) != 0) {
return false;
}
View view = this.itemView;
WeakHashMap weakHashMap = O.X.f1226a;
return view.hasTransientState();
}
public void flagRemovedAndOffsetPosition(int i, int i4, boolean z3) {
addFlags(8);
offsetPosition(i4, z3);
this.mPosition = i;
}
public final int getAbsoluteAdapterPosition() {
RecyclerView recyclerView = this.mOwnerRecyclerView;
if (recyclerView == null) {
return -1;
}
return recyclerView.K(this);
}
@Deprecated
public final int getAdapterPosition() {
return getBindingAdapterPosition();
}
public final AbstractC0220h0 getBindingAdapter() {
return this.mBindingAdapter;
}
public final int getBindingAdapterPosition() {
RecyclerView recyclerView;
AbstractC0220h0 adapter;
int K3;
if (this.mBindingAdapter == null || (recyclerView = this.mOwnerRecyclerView) == null || (adapter = recyclerView.getAdapter()) == null || (K3 = this.mOwnerRecyclerView.K(this)) == -1) {
return -1;
}
return adapter.findRelativeAdapterPositionIn(this.mBindingAdapter, this, K3);
}
public final long getItemId() {
return this.mItemId;
}
public final int getItemViewType() {
return this.mItemViewType;
}
public final int getLayoutPosition() {
int i = this.mPreLayoutPosition;
return i == -1 ? this.mPosition : i;
}
public final int getOldPosition() {
return this.mOldPosition;
}
@Deprecated
public final int getPosition() {
int i = this.mPreLayoutPosition;
return i == -1 ? this.mPosition : i;
}
public List<Object> getUnmodifiedPayloads() {
if ((this.mFlags & 1024) != 0) {
return FULLUPDATE_PAYLOADS;
}
List<Object> list = this.mPayloads;
return (list == null || list.size() == 0) ? FULLUPDATE_PAYLOADS : this.mUnmodifiedPayloads;
}
public boolean hasAnyOfTheFlags(int i) {
return (this.mFlags & i) != 0;
}
public boolean isAdapterPositionUnknown() {
return (this.mFlags & 512) != 0 || isInvalid();
}
public boolean isAttachedToTransitionOverlay() {
return (this.itemView.getParent() == null || this.itemView.getParent() == this.mOwnerRecyclerView) ? false : true;
}
public boolean isBound() {
return (this.mFlags & 1) != 0;
}
public boolean isInvalid() {
return (this.mFlags & 4) != 0;
}
public final boolean isRecyclable() {
if ((this.mFlags & 16) != 0) {
return false;
}
View view = this.itemView;
WeakHashMap weakHashMap = O.X.f1226a;
return !view.hasTransientState();
}
public boolean isRemoved() {
return (this.mFlags & 8) != 0;
}
public boolean isScrap() {
return this.mScrapContainer != null;
}
public boolean isTmpDetached() {
return (this.mFlags & FLAG_TMP_DETACHED) != 0;
}
public boolean isUpdated() {
return (this.mFlags & 2) != 0;
}
public boolean needsUpdate() {
return (this.mFlags & 2) != 0;
}
public void offsetPosition(int i, boolean z3) {
if (this.mOldPosition == -1) {
this.mOldPosition = this.mPosition;
}
if (this.mPreLayoutPosition == -1) {
this.mPreLayoutPosition = this.mPosition;
}
if (z3) {
this.mPreLayoutPosition += i;
}
this.mPosition += i;
if (this.itemView.getLayoutParams() != null) {
((C0239r0) this.itemView.getLayoutParams()).f3899c = true;
}
}
public void onEnteredHiddenState(RecyclerView recyclerView) {
int i = this.mPendingAccessibilityState;
if (i != -1) {
this.mWasImportantForAccessibilityBeforeHidden = i;
} else {
View view = this.itemView;
WeakHashMap weakHashMap = O.X.f1226a;
this.mWasImportantForAccessibilityBeforeHidden = view.getImportantForAccessibility();
}
if (recyclerView.R()) {
this.mPendingAccessibilityState = 4;
recyclerView.f3710u0.add(this);
} else {
View view2 = this.itemView;
WeakHashMap weakHashMap2 = O.X.f1226a;
view2.setImportantForAccessibility(4);
}
}
public void onLeftHiddenState(RecyclerView recyclerView) {
int i = this.mWasImportantForAccessibilityBeforeHidden;
if (recyclerView.R()) {
this.mPendingAccessibilityState = i;
recyclerView.f3710u0.add(this);
} else {
View view = this.itemView;
WeakHashMap weakHashMap = O.X.f1226a;
view.setImportantForAccessibility(i);
}
this.mWasImportantForAccessibilityBeforeHidden = 0;
}
public void resetInternal() {
if (RecyclerView.A0 && isTmpDetached()) {
throw new IllegalStateException("Attempting to reset temp-detached ViewHolder: " + this + ". ViewHolders should be fully detached before resetting.");
}
this.mFlags = 0;
this.mPosition = -1;
this.mOldPosition = -1;
this.mItemId = -1L;
this.mPreLayoutPosition = -1;
this.mIsRecyclableCount = 0;
this.mShadowedHolder = null;
this.mShadowingHolder = null;
clearPayload();
this.mWasImportantForAccessibilityBeforeHidden = 0;
this.mPendingAccessibilityState = -1;
RecyclerView.m(this);
}
public void saveOldPosition() {
if (this.mOldPosition == -1) {
this.mOldPosition = this.mPosition;
}
}
public void setFlags(int i, int i4) {
this.mFlags = (i & i4) | (this.mFlags & (~i4));
}
public final void setIsRecyclable(boolean z3) {
int i = this.mIsRecyclableCount;
int i4 = z3 ? i - 1 : i + 1;
this.mIsRecyclableCount = i4;
if (i4 < 0) {
this.mIsRecyclableCount = 0;
if (RecyclerView.A0) {
throw new RuntimeException("isRecyclable decremented below 0: unmatched pair of setIsRecyable() calls for " + this);
}
Log.e("View", "isRecyclable decremented below 0: unmatched pair of setIsRecyable() calls for " + this);
} else if (!z3 && i4 == 1) {
this.mFlags |= 16;
} else if (z3 && i4 == 0) {
this.mFlags &= -17;
}
if (RecyclerView.f3642B0) {
Log.d("RecyclerView", "setIsRecyclable val:" + z3 + ":" + this);
}
}
public void setScrapContainer(y0 y0Var, boolean z3) {
this.mScrapContainer = y0Var;
this.mInChangeScrap = z3;
}
public boolean shouldBeKeptAsChild() {
return (this.mFlags & 16) != 0;
}
public boolean shouldIgnore() {
return (this.mFlags & 128) != 0;
}
public void stopIgnoring() {
this.mFlags &= -129;
}
public String toString() {
StringBuilder sb = new StringBuilder((getClass().isAnonymousClass() ? "ViewHolder" : getClass().getSimpleName()) + "{" + Integer.toHexString(hashCode()) + " position=" + this.mPosition + " id=" + this.mItemId + ", oldPos=" + this.mOldPosition + ", pLpos:" + this.mPreLayoutPosition);
if (isScrap()) {
sb.append(" scrap ");
sb.append(this.mInChangeScrap ? "[changeScrap]" : "[attachedScrap]");
}
if (isInvalid()) {
sb.append(" invalid");
}
if (!isBound()) {
sb.append(" unbound");
}
if (needsUpdate()) {
sb.append(" update");
}
if (isRemoved()) {
sb.append(" removed");
}
if (shouldIgnore()) {
sb.append(" ignored");
}
if (isTmpDetached()) {
sb.append(" tmpDetached");
}
if (!isRecyclable()) {
sb.append(" not recyclable(" + this.mIsRecyclableCount + ")");
}
if (isAdapterPositionUnknown()) {
sb.append(" undefined adapter position");
}
if (this.itemView.getParent() == null) {
sb.append(" no parent");
}
sb.append("}");
return sb.toString();
}
public void unScrap() {
this.mScrapContainer.l(this);
}
public boolean wasReturnedFromScrap() {
return (this.mFlags & 32) != 0;
}
}