Add decompiled APK source code (JADX)

- 28,932 files
- Full Java source code
- Smali files
- Resources

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
2026-02-18 14:52:23 -08:00
parent cc210a65ea
commit f9d20bb3fc
26991 changed files with 2541449 additions and 0 deletions

View File

@@ -0,0 +1,275 @@
package androidx.recyclerview;
/* loaded from: classes.dex */
public final class R {
public static final class attr {
public static int alpha = 0x7f040055;
public static int fastScrollEnabled = 0x7f0400d2;
public static int fastScrollHorizontalThumbDrawable = 0x7f0400d3;
public static int fastScrollHorizontalTrackDrawable = 0x7f0400d4;
public static int fastScrollVerticalThumbDrawable = 0x7f0400d5;
public static int fastScrollVerticalTrackDrawable = 0x7f0400d6;
public static int font = 0x7f0400d8;
public static int fontProviderAuthority = 0x7f0400da;
public static int fontProviderCerts = 0x7f0400db;
public static int fontProviderFetchStrategy = 0x7f0400dd;
public static int fontProviderFetchTimeout = 0x7f0400de;
public static int fontProviderPackage = 0x7f0400df;
public static int fontProviderQuery = 0x7f0400e0;
public static int fontStyle = 0x7f0400e2;
public static int fontVariationSettings = 0x7f0400e3;
public static int fontWeight = 0x7f0400e4;
public static int layoutManager = 0x7f0400fd;
public static int recyclerViewStyle = 0x7f04013d;
public static int reverseLayout = 0x7f040140;
public static int spanCount = 0x7f04015d;
public static int stackFromEnd = 0x7f040163;
public static int ttcIndex = 0x7f04019c;
private attr() {
}
}
public static final class color {
public static int androidx_core_ripple_material_light = 0x7f060025;
public static int androidx_core_secondary_text_default_material_light = 0x7f060026;
public static int notification_action_color_filter = 0x7f0600e7;
public static int notification_icon_bg_color = 0x7f0600e8;
public static int ripple_material_light = 0x7f0600f3;
public static int secondary_text_default_material_light = 0x7f0600f5;
private color() {
}
}
public static final class dimen {
public static int compat_button_inset_horizontal_material = 0x7f070095;
public static int compat_button_inset_vertical_material = 0x7f070096;
public static int compat_button_padding_horizontal_material = 0x7f070097;
public static int compat_button_padding_vertical_material = 0x7f070098;
public static int compat_control_corner_material = 0x7f070099;
public static int compat_notification_large_icon_max_height = 0x7f07009a;
public static int compat_notification_large_icon_max_width = 0x7f07009b;
public static int fastscroll_default_thickness = 0x7f0700c2;
public static int fastscroll_margin = 0x7f0700c3;
public static int fastscroll_minimum_range = 0x7f0700c4;
public static int item_touch_helper_max_drag_scroll_per_frame = 0x7f0700f7;
public static int item_touch_helper_swipe_escape_max_velocity = 0x7f0700f8;
public static int item_touch_helper_swipe_escape_velocity = 0x7f0700f9;
public static int notification_action_icon_size = 0x7f070105;
public static int notification_action_text_size = 0x7f070106;
public static int notification_big_circle_margin = 0x7f070107;
public static int notification_content_margin_start = 0x7f070108;
public static int notification_large_icon_height = 0x7f070109;
public static int notification_large_icon_width = 0x7f07010a;
public static int notification_main_column_padding_top = 0x7f07010b;
public static int notification_media_narrow_margin = 0x7f07010c;
public static int notification_right_icon_size = 0x7f07010d;
public static int notification_right_side_padding_top = 0x7f07010e;
public static int notification_small_icon_background_padding = 0x7f07010f;
public static int notification_small_icon_size_as_large = 0x7f070110;
public static int notification_subtext_size = 0x7f070111;
public static int notification_top_pad = 0x7f070112;
public static int notification_top_pad_large_text = 0x7f070113;
private dimen() {
}
}
public static final class drawable {
public static int notification_action_background = 0x7f080241;
public static int notification_bg = 0x7f080242;
public static int notification_bg_low = 0x7f080243;
public static int notification_bg_low_normal = 0x7f080244;
public static int notification_bg_low_pressed = 0x7f080245;
public static int notification_bg_normal = 0x7f080246;
public static int notification_bg_normal_pressed = 0x7f080247;
public static int notification_icon_background = 0x7f080248;
public static int notification_template_icon_bg = 0x7f08024a;
public static int notification_template_icon_low_bg = 0x7f08024b;
public static int notification_tile_bg = 0x7f08024c;
public static int notify_panel_notification_icon_bg = 0x7f08024d;
private drawable() {
}
}
public static final class id {
public static int accessibility_action_clickable_span = 0x7f0a0009;
public static int accessibility_custom_action_0 = 0x7f0a000a;
public static int accessibility_custom_action_1 = 0x7f0a000b;
public static int accessibility_custom_action_10 = 0x7f0a000c;
public static int accessibility_custom_action_11 = 0x7f0a000d;
public static int accessibility_custom_action_12 = 0x7f0a000e;
public static int accessibility_custom_action_13 = 0x7f0a000f;
public static int accessibility_custom_action_14 = 0x7f0a0010;
public static int accessibility_custom_action_15 = 0x7f0a0011;
public static int accessibility_custom_action_16 = 0x7f0a0012;
public static int accessibility_custom_action_17 = 0x7f0a0013;
public static int accessibility_custom_action_18 = 0x7f0a0014;
public static int accessibility_custom_action_19 = 0x7f0a0015;
public static int accessibility_custom_action_2 = 0x7f0a0016;
public static int accessibility_custom_action_20 = 0x7f0a0017;
public static int accessibility_custom_action_21 = 0x7f0a0018;
public static int accessibility_custom_action_22 = 0x7f0a0019;
public static int accessibility_custom_action_23 = 0x7f0a001a;
public static int accessibility_custom_action_24 = 0x7f0a001b;
public static int accessibility_custom_action_25 = 0x7f0a001c;
public static int accessibility_custom_action_26 = 0x7f0a001d;
public static int accessibility_custom_action_27 = 0x7f0a001e;
public static int accessibility_custom_action_28 = 0x7f0a001f;
public static int accessibility_custom_action_29 = 0x7f0a0020;
public static int accessibility_custom_action_3 = 0x7f0a0021;
public static int accessibility_custom_action_30 = 0x7f0a0022;
public static int accessibility_custom_action_31 = 0x7f0a0023;
public static int accessibility_custom_action_4 = 0x7f0a0024;
public static int accessibility_custom_action_5 = 0x7f0a0025;
public static int accessibility_custom_action_6 = 0x7f0a0026;
public static int accessibility_custom_action_7 = 0x7f0a0027;
public static int accessibility_custom_action_8 = 0x7f0a0028;
public static int accessibility_custom_action_9 = 0x7f0a0029;
public static int action_container = 0x7f0a0032;
public static int action_divider = 0x7f0a0034;
public static int action_image = 0x7f0a0035;
public static int action_text = 0x7f0a003c;
public static int actions = 0x7f0a003d;
public static int async = 0x7f0a0088;
public static int blocking = 0x7f0a0091;
public static int chronometer = 0x7f0a00a6;
public static int dialog_button = 0x7f0a00c1;
public static int forever = 0x7f0a0107;
public static int icon = 0x7f0a014a;
public static int icon_group = 0x7f0a014b;
public static int info = 0x7f0a0151;
public static int italic = 0x7f0a0156;
public static int item_touch_helper_previous_elevation = 0x7f0a0158;
public static int line1 = 0x7f0a015d;
public static int line3 = 0x7f0a015e;
public static int normal = 0x7f0a022f;
public static int notification_background = 0x7f0a0230;
public static int notification_main_column = 0x7f0a0231;
public static int notification_main_column_container = 0x7f0a0232;
public static int right_icon = 0x7f0a0248;
public static int right_side = 0x7f0a0249;
public static int tag_accessibility_actions = 0x7f0a0270;
public static int tag_accessibility_clickable_spans = 0x7f0a0271;
public static int tag_accessibility_heading = 0x7f0a0272;
public static int tag_accessibility_pane_title = 0x7f0a0273;
public static int tag_screen_reader_focusable = 0x7f0a0277;
public static int tag_transition_group = 0x7f0a0279;
public static int tag_unhandled_key_event_manager = 0x7f0a027a;
public static int tag_unhandled_key_listeners = 0x7f0a027b;
public static int text = 0x7f0a027d;
public static int text2 = 0x7f0a027e;
public static int time = 0x7f0a0283;
public static int title = 0x7f0a0284;
private id() {
}
}
public static final class integer {
public static int status_bar_notification_info_maxnum = 0x7f0b0014;
private integer() {
}
}
public static final class layout {
public static int custom_dialog = 0x7f0d0033;
public static int notification_action = 0x7f0d009f;
public static int notification_action_tombstone = 0x7f0d00a0;
public static int notification_template_custom_big = 0x7f0d00a7;
public static int notification_template_icon_group = 0x7f0d00a8;
public static int notification_template_part_chronometer = 0x7f0d00ac;
public static int notification_template_part_time = 0x7f0d00ad;
private layout() {
}
}
public static final class string {
public static int status_bar_notification_info_overflow = 0x7f120187;
private string() {
}
}
public static final class style {
public static int TextAppearance_Compat_Notification = 0x7f130147;
public static int TextAppearance_Compat_Notification_Info = 0x7f130148;
public static int TextAppearance_Compat_Notification_Line2 = 0x7f13014a;
public static int TextAppearance_Compat_Notification_Time = 0x7f13014d;
public static int TextAppearance_Compat_Notification_Title = 0x7f13014f;
public static int Widget_Compat_NotificationActionContainer = 0x7f1301c1;
public static int Widget_Compat_NotificationActionText = 0x7f1301c2;
private style() {
}
}
public static final class styleable {
public static int ColorStateListItem_alpha = 0x00000003;
public static int ColorStateListItem_android_alpha = 0x00000001;
public static int ColorStateListItem_android_color = 0x00000000;
public static int ColorStateListItem_android_lStar = 0x00000002;
public static int ColorStateListItem_lStar = 0x00000004;
public static int FontFamilyFont_android_font = 0x00000000;
public static int FontFamilyFont_android_fontStyle = 0x00000002;
public static int FontFamilyFont_android_fontVariationSettings = 0x00000004;
public static int FontFamilyFont_android_fontWeight = 0x00000001;
public static int FontFamilyFont_android_ttcIndex = 0x00000003;
public static int FontFamilyFont_font = 0x00000005;
public static int FontFamilyFont_fontStyle = 0x00000006;
public static int FontFamilyFont_fontVariationSettings = 0x00000007;
public static int FontFamilyFont_fontWeight = 0x00000008;
public static int FontFamilyFont_ttcIndex = 0x00000009;
public static int FontFamily_fontProviderAuthority = 0x00000000;
public static int FontFamily_fontProviderCerts = 0x00000001;
public static int FontFamily_fontProviderFallbackQuery = 0x00000002;
public static int FontFamily_fontProviderFetchStrategy = 0x00000003;
public static int FontFamily_fontProviderFetchTimeout = 0x00000004;
public static int FontFamily_fontProviderPackage = 0x00000005;
public static int FontFamily_fontProviderQuery = 0x00000006;
public static int FontFamily_fontProviderSystemFontFamily = 0x00000007;
public static int GradientColorItem_android_color = 0x00000000;
public static int GradientColorItem_android_offset = 0x00000001;
public static int GradientColor_android_centerColor = 0x00000007;
public static int GradientColor_android_centerX = 0x00000003;
public static int GradientColor_android_centerY = 0x00000004;
public static int GradientColor_android_endColor = 0x00000001;
public static int GradientColor_android_endX = 0x0000000a;
public static int GradientColor_android_endY = 0x0000000b;
public static int GradientColor_android_gradientRadius = 0x00000005;
public static int GradientColor_android_startColor = 0x00000000;
public static int GradientColor_android_startX = 0x00000008;
public static int GradientColor_android_startY = 0x00000009;
public static int GradientColor_android_tileMode = 0x00000006;
public static int GradientColor_android_type = 0x00000002;
public static int RecyclerView_android_clipToPadding = 0x00000001;
public static int RecyclerView_android_descendantFocusability = 0x00000002;
public static int RecyclerView_android_orientation = 0x00000000;
public static int RecyclerView_fastScrollEnabled = 0x00000003;
public static int RecyclerView_fastScrollHorizontalThumbDrawable = 0x00000004;
public static int RecyclerView_fastScrollHorizontalTrackDrawable = 0x00000005;
public static int RecyclerView_fastScrollVerticalThumbDrawable = 0x00000006;
public static int RecyclerView_fastScrollVerticalTrackDrawable = 0x00000007;
public static int RecyclerView_layoutManager = 0x00000008;
public static int RecyclerView_reverseLayout = 0x00000009;
public static int RecyclerView_spanCount = 0x0000000a;
public static int RecyclerView_stackFromEnd = 0x0000000b;
public static int[] ColorStateListItem = {android.R.attr.color, android.R.attr.alpha, android.R.attr.lStar, com.ea.games.r3_row.R.attr.alpha, com.ea.games.r3_row.R.attr.lStar};
public static int[] FontFamily = {com.ea.games.r3_row.R.attr.fontProviderAuthority, com.ea.games.r3_row.R.attr.fontProviderCerts, com.ea.games.r3_row.R.attr.fontProviderFallbackQuery, com.ea.games.r3_row.R.attr.fontProviderFetchStrategy, com.ea.games.r3_row.R.attr.fontProviderFetchTimeout, com.ea.games.r3_row.R.attr.fontProviderPackage, com.ea.games.r3_row.R.attr.fontProviderQuery, com.ea.games.r3_row.R.attr.fontProviderSystemFontFamily};
public static int[] FontFamilyFont = {android.R.attr.font, android.R.attr.fontWeight, android.R.attr.fontStyle, android.R.attr.ttcIndex, android.R.attr.fontVariationSettings, com.ea.games.r3_row.R.attr.font, com.ea.games.r3_row.R.attr.fontStyle, com.ea.games.r3_row.R.attr.fontVariationSettings, com.ea.games.r3_row.R.attr.fontWeight, com.ea.games.r3_row.R.attr.ttcIndex};
public static int[] GradientColor = {android.R.attr.startColor, android.R.attr.endColor, android.R.attr.type, android.R.attr.centerX, android.R.attr.centerY, android.R.attr.gradientRadius, android.R.attr.tileMode, android.R.attr.centerColor, android.R.attr.startX, android.R.attr.startY, android.R.attr.endX, android.R.attr.endY};
public static int[] GradientColorItem = {android.R.attr.color, android.R.attr.offset};
public static int[] RecyclerView = {android.R.attr.orientation, android.R.attr.clipToPadding, android.R.attr.descendantFocusability, com.ea.games.r3_row.R.attr.fastScrollEnabled, com.ea.games.r3_row.R.attr.fastScrollHorizontalThumbDrawable, com.ea.games.r3_row.R.attr.fastScrollHorizontalTrackDrawable, com.ea.games.r3_row.R.attr.fastScrollVerticalThumbDrawable, com.ea.games.r3_row.R.attr.fastScrollVerticalTrackDrawable, com.ea.games.r3_row.R.attr.layoutManager, com.ea.games.r3_row.R.attr.reverseLayout, com.ea.games.r3_row.R.attr.spanCount, com.ea.games.r3_row.R.attr.stackFromEnd};
private styleable() {
}
}
private R() {
}
}

View File

@@ -0,0 +1,615 @@
package androidx.recyclerview.widget;
import androidx.core.util.Pools;
import androidx.recyclerview.widget.OpReorderer;
import androidx.recyclerview.widget.RecyclerView;
import com.ironsource.v8;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/* loaded from: classes.dex */
final class AdapterHelper implements OpReorderer.Callback {
private static final boolean DEBUG = false;
static final int POSITION_TYPE_INVISIBLE = 0;
static final int POSITION_TYPE_NEW_OR_LAID_OUT = 1;
private static final String TAG = "AHT";
final Callback mCallback;
final boolean mDisableRecycler;
private int mExistingUpdateTypes;
Runnable mOnItemProcessedCallback;
final OpReorderer mOpReorderer;
final ArrayList<UpdateOp> mPendingUpdates;
final ArrayList<UpdateOp> mPostponedList;
private Pools.Pool<UpdateOp> mUpdateOpPool;
public interface Callback {
RecyclerView.ViewHolder findViewHolder(int i);
void markViewHoldersUpdated(int i, int i2, Object obj);
void offsetPositionsForAdd(int i, int i2);
void offsetPositionsForMove(int i, int i2);
void offsetPositionsForRemovingInvisible(int i, int i2);
void offsetPositionsForRemovingLaidOutOrNewView(int i, int i2);
void onDispatchFirstPass(UpdateOp updateOp);
void onDispatchSecondPass(UpdateOp updateOp);
}
public boolean hasAnyUpdateTypes(int i) {
return (i & this.mExistingUpdateTypes) != 0;
}
public AdapterHelper(Callback callback) {
this(callback, false);
}
public AdapterHelper(Callback callback, boolean z) {
this.mUpdateOpPool = new Pools.SimplePool(30);
this.mPendingUpdates = new ArrayList<>();
this.mPostponedList = new ArrayList<>();
this.mExistingUpdateTypes = 0;
this.mCallback = callback;
this.mDisableRecycler = z;
this.mOpReorderer = new OpReorderer(this);
}
public AdapterHelper addUpdateOp(UpdateOp... updateOpArr) {
Collections.addAll(this.mPendingUpdates, updateOpArr);
return this;
}
public void reset() {
recycleUpdateOpsAndClearList(this.mPendingUpdates);
recycleUpdateOpsAndClearList(this.mPostponedList);
this.mExistingUpdateTypes = 0;
}
public void preProcess() {
this.mOpReorderer.reorderOps(this.mPendingUpdates);
int size = this.mPendingUpdates.size();
for (int i = 0; i < size; i++) {
UpdateOp updateOp = this.mPendingUpdates.get(i);
int i2 = updateOp.cmd;
if (i2 == 1) {
applyAdd(updateOp);
} else if (i2 == 2) {
applyRemove(updateOp);
} else if (i2 == 4) {
applyUpdate(updateOp);
} else if (i2 == 8) {
applyMove(updateOp);
}
Runnable runnable = this.mOnItemProcessedCallback;
if (runnable != null) {
runnable.run();
}
}
this.mPendingUpdates.clear();
}
public void consumePostponedUpdates() {
int size = this.mPostponedList.size();
for (int i = 0; i < size; i++) {
this.mCallback.onDispatchSecondPass(this.mPostponedList.get(i));
}
recycleUpdateOpsAndClearList(this.mPostponedList);
this.mExistingUpdateTypes = 0;
}
private void applyMove(UpdateOp updateOp) {
postponeAndUpdateViewHolders(updateOp);
}
private void applyRemove(UpdateOp updateOp) {
boolean z;
char c;
int i = updateOp.positionStart;
int i2 = updateOp.itemCount + i;
char c2 = 65535;
int i3 = i;
int i4 = 0;
while (i3 < i2) {
if (this.mCallback.findViewHolder(i3) != null || canFindInPreLayout(i3)) {
if (c2 == 0) {
dispatchAndUpdateViewHolders(obtainUpdateOp(2, i, i4, null));
z = true;
} else {
z = false;
}
c = 1;
} else {
if (c2 == 1) {
postponeAndUpdateViewHolders(obtainUpdateOp(2, i, i4, null));
z = true;
} else {
z = false;
}
c = 0;
}
if (z) {
i3 -= i4;
i2 -= i4;
i4 = 1;
} else {
i4++;
}
i3++;
c2 = c;
}
if (i4 != updateOp.itemCount) {
recycleUpdateOp(updateOp);
updateOp = obtainUpdateOp(2, i, i4, null);
}
if (c2 == 0) {
dispatchAndUpdateViewHolders(updateOp);
} else {
postponeAndUpdateViewHolders(updateOp);
}
}
private void applyUpdate(UpdateOp updateOp) {
int i = updateOp.positionStart;
int i2 = updateOp.itemCount + i;
int i3 = 0;
boolean z = -1;
int i4 = i;
while (i < i2) {
if (this.mCallback.findViewHolder(i) != null || canFindInPreLayout(i)) {
if (!z) {
dispatchAndUpdateViewHolders(obtainUpdateOp(4, i4, i3, updateOp.payload));
i4 = i;
i3 = 0;
}
z = true;
} else {
if (z) {
postponeAndUpdateViewHolders(obtainUpdateOp(4, i4, i3, updateOp.payload));
i4 = i;
i3 = 0;
}
z = false;
}
i3++;
i++;
}
if (i3 != updateOp.itemCount) {
Object obj = updateOp.payload;
recycleUpdateOp(updateOp);
updateOp = obtainUpdateOp(4, i4, i3, obj);
}
if (!z) {
dispatchAndUpdateViewHolders(updateOp);
} else {
postponeAndUpdateViewHolders(updateOp);
}
}
private void dispatchAndUpdateViewHolders(UpdateOp updateOp) {
int i;
int i2 = updateOp.cmd;
if (i2 == 1 || i2 == 8) {
throw new IllegalArgumentException("should not dispatch add or move for pre layout");
}
int updatePositionWithPostponed = updatePositionWithPostponed(updateOp.positionStart, i2);
int i3 = updateOp.positionStart;
int i4 = updateOp.cmd;
if (i4 == 2) {
i = 0;
} else {
if (i4 != 4) {
throw new IllegalArgumentException("op should be remove or update." + updateOp);
}
i = 1;
}
int i5 = 1;
for (int i6 = 1; i6 < updateOp.itemCount; i6++) {
int updatePositionWithPostponed2 = updatePositionWithPostponed(updateOp.positionStart + (i * i6), updateOp.cmd);
int i7 = updateOp.cmd;
if (i7 == 2 ? updatePositionWithPostponed2 != updatePositionWithPostponed : !(i7 == 4 && updatePositionWithPostponed2 == updatePositionWithPostponed + 1)) {
UpdateOp obtainUpdateOp = obtainUpdateOp(i7, updatePositionWithPostponed, i5, updateOp.payload);
dispatchFirstPassAndUpdateViewHolders(obtainUpdateOp, i3);
recycleUpdateOp(obtainUpdateOp);
if (updateOp.cmd == 4) {
i3 += i5;
}
i5 = 1;
updatePositionWithPostponed = updatePositionWithPostponed2;
} else {
i5++;
}
}
Object obj = updateOp.payload;
recycleUpdateOp(updateOp);
if (i5 > 0) {
UpdateOp obtainUpdateOp2 = obtainUpdateOp(updateOp.cmd, updatePositionWithPostponed, i5, obj);
dispatchFirstPassAndUpdateViewHolders(obtainUpdateOp2, i3);
recycleUpdateOp(obtainUpdateOp2);
}
}
public void dispatchFirstPassAndUpdateViewHolders(UpdateOp updateOp, int i) {
this.mCallback.onDispatchFirstPass(updateOp);
int i2 = updateOp.cmd;
if (i2 == 2) {
this.mCallback.offsetPositionsForRemovingInvisible(i, updateOp.itemCount);
} else {
if (i2 == 4) {
this.mCallback.markViewHoldersUpdated(i, updateOp.itemCount, updateOp.payload);
return;
}
throw new IllegalArgumentException("only remove and update ops can be dispatched in first pass");
}
}
private int updatePositionWithPostponed(int i, int i2) {
int i3;
int i4;
for (int size = this.mPostponedList.size() - 1; size >= 0; size--) {
UpdateOp updateOp = this.mPostponedList.get(size);
int i5 = updateOp.cmd;
if (i5 == 8) {
int i6 = updateOp.positionStart;
int i7 = updateOp.itemCount;
if (i6 < i7) {
i4 = i6;
i3 = i7;
} else {
i3 = i6;
i4 = i7;
}
if (i < i4 || i > i3) {
if (i < i6) {
if (i2 == 1) {
updateOp.positionStart = i6 + 1;
updateOp.itemCount = i7 + 1;
} else if (i2 == 2) {
updateOp.positionStart = i6 - 1;
updateOp.itemCount = i7 - 1;
}
}
} else if (i4 == i6) {
if (i2 == 1) {
updateOp.itemCount = i7 + 1;
} else if (i2 == 2) {
updateOp.itemCount = i7 - 1;
}
i++;
} else {
if (i2 == 1) {
updateOp.positionStart = i6 + 1;
} else if (i2 == 2) {
updateOp.positionStart = i6 - 1;
}
i--;
}
} else {
int i8 = updateOp.positionStart;
if (i8 <= i) {
if (i5 == 1) {
i -= updateOp.itemCount;
} else if (i5 == 2) {
i += updateOp.itemCount;
}
} else if (i2 == 1) {
updateOp.positionStart = i8 + 1;
} else if (i2 == 2) {
updateOp.positionStart = i8 - 1;
}
}
}
for (int size2 = this.mPostponedList.size() - 1; size2 >= 0; size2--) {
UpdateOp updateOp2 = this.mPostponedList.get(size2);
if (updateOp2.cmd == 8) {
int i9 = updateOp2.itemCount;
if (i9 == updateOp2.positionStart || i9 < 0) {
this.mPostponedList.remove(size2);
recycleUpdateOp(updateOp2);
}
} else if (updateOp2.itemCount <= 0) {
this.mPostponedList.remove(size2);
recycleUpdateOp(updateOp2);
}
}
return i;
}
private boolean canFindInPreLayout(int i) {
int size = this.mPostponedList.size();
for (int i2 = 0; i2 < size; i2++) {
UpdateOp updateOp = this.mPostponedList.get(i2);
int i3 = updateOp.cmd;
if (i3 == 8) {
if (findPositionOffset(updateOp.itemCount, i2 + 1) == i) {
return true;
}
} else if (i3 == 1) {
int i4 = updateOp.positionStart;
int i5 = updateOp.itemCount + i4;
while (i4 < i5) {
if (findPositionOffset(i4, i2 + 1) == i) {
return true;
}
i4++;
}
} else {
continue;
}
}
return false;
}
private void applyAdd(UpdateOp updateOp) {
postponeAndUpdateViewHolders(updateOp);
}
private void postponeAndUpdateViewHolders(UpdateOp updateOp) {
this.mPostponedList.add(updateOp);
int i = updateOp.cmd;
if (i == 1) {
this.mCallback.offsetPositionsForAdd(updateOp.positionStart, updateOp.itemCount);
return;
}
if (i == 2) {
this.mCallback.offsetPositionsForRemovingLaidOutOrNewView(updateOp.positionStart, updateOp.itemCount);
return;
}
if (i == 4) {
this.mCallback.markViewHoldersUpdated(updateOp.positionStart, updateOp.itemCount, updateOp.payload);
} else {
if (i == 8) {
this.mCallback.offsetPositionsForMove(updateOp.positionStart, updateOp.itemCount);
return;
}
throw new IllegalArgumentException("Unknown update op type for " + updateOp);
}
}
public boolean hasPendingUpdates() {
return this.mPendingUpdates.size() > 0;
}
public int findPositionOffset(int i) {
return findPositionOffset(i, 0);
}
public int findPositionOffset(int i, int i2) {
int size = this.mPostponedList.size();
while (i2 < size) {
UpdateOp updateOp = this.mPostponedList.get(i2);
int i3 = updateOp.cmd;
if (i3 == 8) {
int i4 = updateOp.positionStart;
if (i4 == i) {
i = updateOp.itemCount;
} else {
if (i4 < i) {
i--;
}
if (updateOp.itemCount <= i) {
i++;
}
}
} else {
int i5 = updateOp.positionStart;
if (i5 > i) {
continue;
} else if (i3 == 2) {
int i6 = updateOp.itemCount;
if (i < i5 + i6) {
return -1;
}
i -= i6;
} else if (i3 == 1) {
i += updateOp.itemCount;
}
}
i2++;
}
return i;
}
public boolean onItemRangeChanged(int i, int i2, Object obj) {
if (i2 < 1) {
return false;
}
this.mPendingUpdates.add(obtainUpdateOp(4, i, i2, obj));
this.mExistingUpdateTypes |= 4;
return this.mPendingUpdates.size() == 1;
}
public boolean onItemRangeInserted(int i, int i2) {
if (i2 < 1) {
return false;
}
this.mPendingUpdates.add(obtainUpdateOp(1, i, i2, null));
this.mExistingUpdateTypes |= 1;
return this.mPendingUpdates.size() == 1;
}
public boolean onItemRangeRemoved(int i, int i2) {
if (i2 < 1) {
return false;
}
this.mPendingUpdates.add(obtainUpdateOp(2, i, i2, null));
this.mExistingUpdateTypes |= 2;
return this.mPendingUpdates.size() == 1;
}
public boolean onItemRangeMoved(int i, int i2, int i3) {
if (i == i2) {
return false;
}
if (i3 != 1) {
throw new IllegalArgumentException("Moving more than 1 item is not supported yet");
}
this.mPendingUpdates.add(obtainUpdateOp(8, i, i2, null));
this.mExistingUpdateTypes |= 8;
return this.mPendingUpdates.size() == 1;
}
public void consumeUpdatesInOnePass() {
consumePostponedUpdates();
int size = this.mPendingUpdates.size();
for (int i = 0; i < size; i++) {
UpdateOp updateOp = this.mPendingUpdates.get(i);
int i2 = updateOp.cmd;
if (i2 == 1) {
this.mCallback.onDispatchSecondPass(updateOp);
this.mCallback.offsetPositionsForAdd(updateOp.positionStart, updateOp.itemCount);
} else if (i2 == 2) {
this.mCallback.onDispatchSecondPass(updateOp);
this.mCallback.offsetPositionsForRemovingInvisible(updateOp.positionStart, updateOp.itemCount);
} else if (i2 == 4) {
this.mCallback.onDispatchSecondPass(updateOp);
this.mCallback.markViewHoldersUpdated(updateOp.positionStart, updateOp.itemCount, updateOp.payload);
} else if (i2 == 8) {
this.mCallback.onDispatchSecondPass(updateOp);
this.mCallback.offsetPositionsForMove(updateOp.positionStart, updateOp.itemCount);
}
Runnable runnable = this.mOnItemProcessedCallback;
if (runnable != null) {
runnable.run();
}
}
recycleUpdateOpsAndClearList(this.mPendingUpdates);
this.mExistingUpdateTypes = 0;
}
public int applyPendingUpdatesToPosition(int i) {
int size = this.mPendingUpdates.size();
for (int i2 = 0; i2 < size; i2++) {
UpdateOp updateOp = this.mPendingUpdates.get(i2);
int i3 = updateOp.cmd;
if (i3 != 1) {
if (i3 == 2) {
int i4 = updateOp.positionStart;
if (i4 <= i) {
int i5 = updateOp.itemCount;
if (i4 + i5 > i) {
return -1;
}
i -= i5;
} else {
continue;
}
} else if (i3 == 8) {
int i6 = updateOp.positionStart;
if (i6 == i) {
i = updateOp.itemCount;
} else {
if (i6 < i) {
i--;
}
if (updateOp.itemCount <= i) {
i++;
}
}
}
} else if (updateOp.positionStart <= i) {
i += updateOp.itemCount;
}
}
return i;
}
public boolean hasUpdates() {
return (this.mPostponedList.isEmpty() || this.mPendingUpdates.isEmpty()) ? false : true;
}
public static final class UpdateOp {
static final int ADD = 1;
static final int MOVE = 8;
static final int POOL_SIZE = 30;
static final int REMOVE = 2;
static final int UPDATE = 4;
int cmd;
int itemCount;
Object payload;
int positionStart;
public String cmdToString() {
int i = this.cmd;
return i != 1 ? i != 2 ? i != 4 ? i != 8 ? "??" : "mv" : "up" : "rm" : "add";
}
public int hashCode() {
return (((this.cmd * 31) + this.positionStart) * 31) + this.itemCount;
}
public UpdateOp(int i, int i2, int i3, Object obj) {
this.cmd = i;
this.positionStart = i2;
this.itemCount = i3;
this.payload = obj;
}
public String toString() {
return Integer.toHexString(System.identityHashCode(this)) + v8.i.d + cmdToString() + ",s:" + this.positionStart + "c:" + this.itemCount + ",p:" + this.payload + v8.i.e;
}
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof UpdateOp)) {
return false;
}
UpdateOp updateOp = (UpdateOp) obj;
int i = this.cmd;
if (i != updateOp.cmd) {
return false;
}
if (i == 8 && Math.abs(this.itemCount - this.positionStart) == 1 && this.itemCount == updateOp.positionStart && this.positionStart == updateOp.itemCount) {
return true;
}
if (this.itemCount != updateOp.itemCount || this.positionStart != updateOp.positionStart) {
return false;
}
Object obj2 = this.payload;
if (obj2 != null) {
if (!obj2.equals(updateOp.payload)) {
return false;
}
} else if (updateOp.payload != null) {
return false;
}
return true;
}
}
@Override // androidx.recyclerview.widget.OpReorderer.Callback
public UpdateOp obtainUpdateOp(int i, int i2, int i3, Object obj) {
UpdateOp acquire = this.mUpdateOpPool.acquire();
if (acquire == null) {
return new UpdateOp(i, i2, i3, obj);
}
acquire.cmd = i;
acquire.positionStart = i2;
acquire.itemCount = i3;
acquire.payload = obj;
return acquire;
}
@Override // androidx.recyclerview.widget.OpReorderer.Callback
public void recycleUpdateOp(UpdateOp updateOp) {
if (this.mDisableRecycler) {
return;
}
updateOp.payload = null;
this.mUpdateOpPool.release(updateOp);
}
public void recycleUpdateOpsAndClearList(List<UpdateOp> list) {
int size = list.size();
for (int i = 0; i < size; i++) {
recycleUpdateOp(list.get(i));
}
list.clear();
}
}

View File

@@ -0,0 +1,35 @@
package androidx.recyclerview.widget;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
/* loaded from: classes.dex */
public final class AdapterListUpdateCallback implements ListUpdateCallback {
@NonNull
private final RecyclerView.Adapter mAdapter;
public AdapterListUpdateCallback(@NonNull RecyclerView.Adapter adapter) {
this.mAdapter = adapter;
}
@Override // androidx.recyclerview.widget.ListUpdateCallback
public void onInserted(int i, int i2) {
this.mAdapter.notifyItemRangeInserted(i, i2);
}
@Override // androidx.recyclerview.widget.ListUpdateCallback
public void onRemoved(int i, int i2) {
this.mAdapter.notifyItemRangeRemoved(i, i2);
}
@Override // androidx.recyclerview.widget.ListUpdateCallback
public void onMoved(int i, int i2) {
this.mAdapter.notifyItemMoved(i, i2);
}
@Override // androidx.recyclerview.widget.ListUpdateCallback
public void onChanged(int i, int i2, Object obj) {
this.mAdapter.notifyItemRangeChanged(i, i2, obj);
}
}

View File

@@ -0,0 +1,87 @@
package androidx.recyclerview.widget;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.recyclerview.widget.DiffUtil;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
/* loaded from: classes.dex */
public final class AsyncDifferConfig<T> {
@NonNull
private final Executor mBackgroundThreadExecutor;
@NonNull
private final DiffUtil.ItemCallback<T> mDiffCallback;
@Nullable
private final Executor mMainThreadExecutor;
@NonNull
public Executor getBackgroundThreadExecutor() {
return this.mBackgroundThreadExecutor;
}
@NonNull
public DiffUtil.ItemCallback<T> getDiffCallback() {
return this.mDiffCallback;
}
@Nullable
@RestrictTo({RestrictTo.Scope.LIBRARY})
public Executor getMainThreadExecutor() {
return this.mMainThreadExecutor;
}
public AsyncDifferConfig(@Nullable Executor executor, @NonNull Executor executor2, @NonNull DiffUtil.ItemCallback<T> itemCallback) {
this.mMainThreadExecutor = executor;
this.mBackgroundThreadExecutor = executor2;
this.mDiffCallback = itemCallback;
}
public static final class Builder<T> {
private static Executor sDiffExecutor;
private static final Object sExecutorLock = new Object();
private Executor mBackgroundThreadExecutor;
private final DiffUtil.ItemCallback<T> mDiffCallback;
@Nullable
private Executor mMainThreadExecutor;
@NonNull
public Builder<T> setBackgroundThreadExecutor(Executor executor) {
this.mBackgroundThreadExecutor = executor;
return this;
}
@NonNull
@RestrictTo({RestrictTo.Scope.LIBRARY})
public Builder<T> setMainThreadExecutor(Executor executor) {
this.mMainThreadExecutor = executor;
return this;
}
public Builder(@NonNull DiffUtil.ItemCallback<T> itemCallback) {
this.mDiffCallback = itemCallback;
}
@NonNull
public AsyncDifferConfig<T> build() {
if (this.mBackgroundThreadExecutor == null) {
synchronized (sExecutorLock) {
try {
if (sDiffExecutor == null) {
sDiffExecutor = Executors.newFixedThreadPool(2);
}
} catch (Throwable th) {
throw th;
}
}
this.mBackgroundThreadExecutor = sDiffExecutor;
}
return new AsyncDifferConfig<>(this.mMainThreadExecutor, this.mBackgroundThreadExecutor, this.mDiffCallback);
}
}
}

View File

@@ -0,0 +1,186 @@
package androidx.recyclerview.widget;
import android.os.Handler;
import android.os.Looper;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.AsyncDifferConfig;
import androidx.recyclerview.widget.DiffUtil;
import androidx.recyclerview.widget.RecyclerView;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.Executor;
/* loaded from: classes.dex */
public class AsyncListDiffer<T> {
private static final Executor sMainThreadExecutor = new MainThreadExecutor();
final AsyncDifferConfig<T> mConfig;
@Nullable
private List<T> mList;
private final List<ListListener<T>> mListeners;
Executor mMainThreadExecutor;
int mMaxScheduledGeneration;
@NonNull
private List<T> mReadOnlyList;
private final ListUpdateCallback mUpdateCallback;
public interface ListListener<T> {
void onCurrentListChanged(@NonNull List<T> list, @NonNull List<T> list2);
}
@NonNull
public List<T> getCurrentList() {
return this.mReadOnlyList;
}
public static class MainThreadExecutor implements Executor {
final Handler mHandler = new Handler(Looper.getMainLooper());
@Override // java.util.concurrent.Executor
public void execute(@NonNull Runnable runnable) {
this.mHandler.post(runnable);
}
}
public AsyncListDiffer(@NonNull RecyclerView.Adapter adapter, @NonNull DiffUtil.ItemCallback<T> itemCallback) {
this(new AdapterListUpdateCallback(adapter), new AsyncDifferConfig.Builder(itemCallback).build());
}
public AsyncListDiffer(@NonNull ListUpdateCallback listUpdateCallback, @NonNull AsyncDifferConfig<T> asyncDifferConfig) {
this.mListeners = new CopyOnWriteArrayList();
this.mReadOnlyList = Collections.emptyList();
this.mUpdateCallback = listUpdateCallback;
this.mConfig = asyncDifferConfig;
if (asyncDifferConfig.getMainThreadExecutor() != null) {
this.mMainThreadExecutor = asyncDifferConfig.getMainThreadExecutor();
} else {
this.mMainThreadExecutor = sMainThreadExecutor;
}
}
public void submitList(@Nullable List<T> list) {
submitList(list, null);
}
public void submitList(@Nullable final List<T> list, @Nullable final Runnable runnable) {
final int i = this.mMaxScheduledGeneration + 1;
this.mMaxScheduledGeneration = i;
final List<T> list2 = this.mList;
if (list == list2) {
if (runnable != null) {
runnable.run();
return;
}
return;
}
List<T> list3 = this.mReadOnlyList;
if (list == null) {
int size = list2.size();
this.mList = null;
this.mReadOnlyList = Collections.emptyList();
this.mUpdateCallback.onRemoved(0, size);
onCurrentListChanged(list3, runnable);
return;
}
if (list2 == null) {
this.mList = list;
this.mReadOnlyList = Collections.unmodifiableList(list);
this.mUpdateCallback.onInserted(0, list.size());
onCurrentListChanged(list3, runnable);
return;
}
this.mConfig.getBackgroundThreadExecutor().execute(new Runnable() { // from class: androidx.recyclerview.widget.AsyncListDiffer.1
@Override // java.lang.Runnable
public void run() {
final DiffUtil.DiffResult calculateDiff = DiffUtil.calculateDiff(new DiffUtil.Callback() { // from class: androidx.recyclerview.widget.AsyncListDiffer.1.1
@Override // androidx.recyclerview.widget.DiffUtil.Callback
public int getOldListSize() {
return list2.size();
}
@Override // androidx.recyclerview.widget.DiffUtil.Callback
public int getNewListSize() {
return list.size();
}
/* JADX WARN: Multi-variable type inference failed */
@Override // androidx.recyclerview.widget.DiffUtil.Callback
public boolean areItemsTheSame(int i2, int i3) {
Object obj = list2.get(i2);
Object obj2 = list.get(i3);
if (obj == null || obj2 == null) {
return obj == null && obj2 == null;
}
return AsyncListDiffer.this.mConfig.getDiffCallback().areItemsTheSame(obj, obj2);
}
/* JADX WARN: Multi-variable type inference failed */
@Override // androidx.recyclerview.widget.DiffUtil.Callback
public boolean areContentsTheSame(int i2, int i3) {
Object obj = list2.get(i2);
Object obj2 = list.get(i3);
if (obj != null && obj2 != null) {
return AsyncListDiffer.this.mConfig.getDiffCallback().areContentsTheSame(obj, obj2);
}
if (obj == null && obj2 == null) {
return true;
}
throw new AssertionError();
}
/* JADX WARN: Multi-variable type inference failed */
@Override // androidx.recyclerview.widget.DiffUtil.Callback
@Nullable
public Object getChangePayload(int i2, int i3) {
Object obj = list2.get(i2);
Object obj2 = list.get(i3);
if (obj != null && obj2 != null) {
return AsyncListDiffer.this.mConfig.getDiffCallback().getChangePayload(obj, obj2);
}
throw new AssertionError();
}
});
AsyncListDiffer.this.mMainThreadExecutor.execute(new Runnable() { // from class: androidx.recyclerview.widget.AsyncListDiffer.1.2
@Override // java.lang.Runnable
public void run() {
AnonymousClass1 anonymousClass1 = AnonymousClass1.this;
AsyncListDiffer asyncListDiffer = AsyncListDiffer.this;
if (asyncListDiffer.mMaxScheduledGeneration == i) {
asyncListDiffer.latchList(list, calculateDiff, runnable);
}
}
});
}
});
}
public void latchList(@NonNull List<T> list, @NonNull DiffUtil.DiffResult diffResult, @Nullable Runnable runnable) {
List<T> list2 = this.mReadOnlyList;
this.mList = list;
this.mReadOnlyList = Collections.unmodifiableList(list);
diffResult.dispatchUpdatesTo(this.mUpdateCallback);
onCurrentListChanged(list2, runnable);
}
private void onCurrentListChanged(@NonNull List<T> list, @Nullable Runnable runnable) {
Iterator<ListListener<T>> it = this.mListeners.iterator();
while (it.hasNext()) {
it.next().onCurrentListChanged(list, this.mReadOnlyList);
}
if (runnable != null) {
runnable.run();
}
}
public void addListListener(@NonNull ListListener<T> listListener) {
this.mListeners.add(listListener);
}
public void removeListListener(@NonNull ListListener<T> listListener) {
this.mListeners.remove(listListener);
}
}

View File

@@ -0,0 +1,359 @@
package androidx.recyclerview.widget;
import android.util.Log;
import android.util.SparseBooleanArray;
import android.util.SparseIntArray;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.UiThread;
import androidx.annotation.WorkerThread;
import androidx.recyclerview.widget.ThreadUtil;
import androidx.recyclerview.widget.TileList;
/* loaded from: classes.dex */
public class AsyncListUtil<T> {
static final boolean DEBUG = false;
static final String TAG = "AsyncListUtil";
boolean mAllowScrollHints;
private final ThreadUtil.BackgroundCallback<T> mBackgroundCallback;
final ThreadUtil.BackgroundCallback<T> mBackgroundProxy;
final DataCallback<T> mDataCallback;
private final ThreadUtil.MainThreadCallback<T> mMainThreadCallback;
final ThreadUtil.MainThreadCallback<T> mMainThreadProxy;
final Class<T> mTClass;
final TileList<T> mTileList;
final int mTileSize;
final ViewCallback mViewCallback;
final int[] mTmpRange = new int[2];
final int[] mPrevRange = new int[2];
final int[] mTmpRangeExtended = new int[2];
private int mScrollHint = 0;
int mItemCount = 0;
int mDisplayedGeneration = 0;
int mRequestedGeneration = 0;
final SparseIntArray mMissingPositions = new SparseIntArray();
public static abstract class DataCallback<T> {
@WorkerThread
public abstract void fillData(@NonNull T[] tArr, int i, int i2);
@WorkerThread
public int getMaxCachedTiles() {
return 10;
}
@WorkerThread
public void recycleData(@NonNull T[] tArr, int i) {
}
@WorkerThread
public abstract int refreshData();
}
private boolean isRefreshPending() {
return this.mRequestedGeneration != this.mDisplayedGeneration;
}
public int getItemCount() {
return this.mItemCount;
}
public void log(String str, Object... objArr) {
StringBuilder sb = new StringBuilder();
sb.append("[MAIN] ");
sb.append(String.format(str, objArr));
}
public AsyncListUtil(@NonNull Class<T> cls, int i, @NonNull DataCallback<T> dataCallback, @NonNull ViewCallback viewCallback) {
ThreadUtil.MainThreadCallback<T> mainThreadCallback = new ThreadUtil.MainThreadCallback<T>() { // from class: androidx.recyclerview.widget.AsyncListUtil.1
@Override // androidx.recyclerview.widget.ThreadUtil.MainThreadCallback
public void updateItemCount(int i2, int i3) {
if (isRequestedGeneration(i2)) {
AsyncListUtil asyncListUtil = AsyncListUtil.this;
asyncListUtil.mItemCount = i3;
asyncListUtil.mViewCallback.onDataRefresh();
AsyncListUtil asyncListUtil2 = AsyncListUtil.this;
asyncListUtil2.mDisplayedGeneration = asyncListUtil2.mRequestedGeneration;
recycleAllTiles();
AsyncListUtil asyncListUtil3 = AsyncListUtil.this;
asyncListUtil3.mAllowScrollHints = false;
asyncListUtil3.updateRange();
}
}
@Override // androidx.recyclerview.widget.ThreadUtil.MainThreadCallback
public void addTile(int i2, TileList.Tile<T> tile) {
if (!isRequestedGeneration(i2)) {
AsyncListUtil.this.mBackgroundProxy.recycleTile(tile);
return;
}
TileList.Tile<T> addOrReplace = AsyncListUtil.this.mTileList.addOrReplace(tile);
if (addOrReplace != null) {
Log.e(AsyncListUtil.TAG, "duplicate tile @" + addOrReplace.mStartPosition);
AsyncListUtil.this.mBackgroundProxy.recycleTile(addOrReplace);
}
int i3 = tile.mStartPosition + tile.mItemCount;
int i4 = 0;
while (i4 < AsyncListUtil.this.mMissingPositions.size()) {
int keyAt = AsyncListUtil.this.mMissingPositions.keyAt(i4);
if (tile.mStartPosition > keyAt || keyAt >= i3) {
i4++;
} else {
AsyncListUtil.this.mMissingPositions.removeAt(i4);
AsyncListUtil.this.mViewCallback.onItemLoaded(keyAt);
}
}
}
@Override // androidx.recyclerview.widget.ThreadUtil.MainThreadCallback
public void removeTile(int i2, int i3) {
if (isRequestedGeneration(i2)) {
TileList.Tile<T> removeAtPos = AsyncListUtil.this.mTileList.removeAtPos(i3);
if (removeAtPos == null) {
Log.e(AsyncListUtil.TAG, "tile not found @" + i3);
return;
}
AsyncListUtil.this.mBackgroundProxy.recycleTile(removeAtPos);
}
}
private void recycleAllTiles() {
for (int i2 = 0; i2 < AsyncListUtil.this.mTileList.size(); i2++) {
AsyncListUtil asyncListUtil = AsyncListUtil.this;
asyncListUtil.mBackgroundProxy.recycleTile(asyncListUtil.mTileList.getAtIndex(i2));
}
AsyncListUtil.this.mTileList.clear();
}
private boolean isRequestedGeneration(int i2) {
return i2 == AsyncListUtil.this.mRequestedGeneration;
}
};
this.mMainThreadCallback = mainThreadCallback;
ThreadUtil.BackgroundCallback<T> backgroundCallback = new ThreadUtil.BackgroundCallback<T>() { // from class: androidx.recyclerview.widget.AsyncListUtil.2
private int mFirstRequiredTileStart;
private int mGeneration;
private int mItemCount;
private int mLastRequiredTileStart;
final SparseBooleanArray mLoadedTiles = new SparseBooleanArray();
private TileList.Tile<T> mRecycledRoot;
@Override // androidx.recyclerview.widget.ThreadUtil.BackgroundCallback
public void refresh(int i2) {
this.mGeneration = i2;
this.mLoadedTiles.clear();
int refreshData = AsyncListUtil.this.mDataCallback.refreshData();
this.mItemCount = refreshData;
AsyncListUtil.this.mMainThreadProxy.updateItemCount(this.mGeneration, refreshData);
}
@Override // androidx.recyclerview.widget.ThreadUtil.BackgroundCallback
public void updateRange(int i2, int i3, int i4, int i5, int i6) {
if (i2 > i3) {
return;
}
int tileStart = getTileStart(i2);
int tileStart2 = getTileStart(i3);
this.mFirstRequiredTileStart = getTileStart(i4);
int tileStart3 = getTileStart(i5);
this.mLastRequiredTileStart = tileStart3;
if (i6 == 1) {
requestTiles(this.mFirstRequiredTileStart, tileStart2, i6, true);
requestTiles(tileStart2 + AsyncListUtil.this.mTileSize, this.mLastRequiredTileStart, i6, false);
} else {
requestTiles(tileStart, tileStart3, i6, false);
requestTiles(this.mFirstRequiredTileStart, tileStart - AsyncListUtil.this.mTileSize, i6, true);
}
}
private int getTileStart(int i2) {
return i2 - (i2 % AsyncListUtil.this.mTileSize);
}
private void requestTiles(int i2, int i3, int i4, boolean z) {
int i5 = i2;
while (i5 <= i3) {
AsyncListUtil.this.mBackgroundProxy.loadTile(z ? (i3 + i2) - i5 : i5, i4);
i5 += AsyncListUtil.this.mTileSize;
}
}
@Override // androidx.recyclerview.widget.ThreadUtil.BackgroundCallback
public void loadTile(int i2, int i3) {
if (isTileLoaded(i2)) {
return;
}
TileList.Tile<T> acquireTile = acquireTile();
acquireTile.mStartPosition = i2;
int min = Math.min(AsyncListUtil.this.mTileSize, this.mItemCount - i2);
acquireTile.mItemCount = min;
AsyncListUtil.this.mDataCallback.fillData(acquireTile.mItems, acquireTile.mStartPosition, min);
flushTileCache(i3);
addTile(acquireTile);
}
@Override // androidx.recyclerview.widget.ThreadUtil.BackgroundCallback
public void recycleTile(TileList.Tile<T> tile) {
AsyncListUtil.this.mDataCallback.recycleData(tile.mItems, tile.mItemCount);
tile.mNext = this.mRecycledRoot;
this.mRecycledRoot = tile;
}
private TileList.Tile<T> acquireTile() {
TileList.Tile<T> tile = this.mRecycledRoot;
if (tile != null) {
this.mRecycledRoot = tile.mNext;
return tile;
}
AsyncListUtil asyncListUtil = AsyncListUtil.this;
return new TileList.Tile<>(asyncListUtil.mTClass, asyncListUtil.mTileSize);
}
private boolean isTileLoaded(int i2) {
return this.mLoadedTiles.get(i2);
}
private void addTile(TileList.Tile<T> tile) {
this.mLoadedTiles.put(tile.mStartPosition, true);
AsyncListUtil.this.mMainThreadProxy.addTile(this.mGeneration, tile);
}
private void removeTile(int i2) {
this.mLoadedTiles.delete(i2);
AsyncListUtil.this.mMainThreadProxy.removeTile(this.mGeneration, i2);
}
private void flushTileCache(int i2) {
int maxCachedTiles = AsyncListUtil.this.mDataCallback.getMaxCachedTiles();
while (this.mLoadedTiles.size() >= maxCachedTiles) {
int keyAt = this.mLoadedTiles.keyAt(0);
SparseBooleanArray sparseBooleanArray = this.mLoadedTiles;
int keyAt2 = sparseBooleanArray.keyAt(sparseBooleanArray.size() - 1);
int i3 = this.mFirstRequiredTileStart - keyAt;
int i4 = keyAt2 - this.mLastRequiredTileStart;
if (i3 > 0 && (i3 >= i4 || i2 == 2)) {
removeTile(keyAt);
} else {
if (i4 <= 0) {
return;
}
if (i3 >= i4 && i2 != 1) {
return;
} else {
removeTile(keyAt2);
}
}
}
}
private void log(String str, Object... objArr) {
StringBuilder sb = new StringBuilder();
sb.append("[BKGR] ");
sb.append(String.format(str, objArr));
}
};
this.mBackgroundCallback = backgroundCallback;
this.mTClass = cls;
this.mTileSize = i;
this.mDataCallback = dataCallback;
this.mViewCallback = viewCallback;
this.mTileList = new TileList<>(i);
MessageThreadUtil messageThreadUtil = new MessageThreadUtil();
this.mMainThreadProxy = messageThreadUtil.getMainThreadProxy(mainThreadCallback);
this.mBackgroundProxy = messageThreadUtil.getBackgroundProxy(backgroundCallback);
refresh();
}
public void onRangeChanged() {
if (isRefreshPending()) {
return;
}
updateRange();
this.mAllowScrollHints = true;
}
public void refresh() {
this.mMissingPositions.clear();
ThreadUtil.BackgroundCallback<T> backgroundCallback = this.mBackgroundProxy;
int i = this.mRequestedGeneration + 1;
this.mRequestedGeneration = i;
backgroundCallback.refresh(i);
}
@Nullable
public T getItem(int i) {
if (i < 0 || i >= this.mItemCount) {
throw new IndexOutOfBoundsException(i + " is not within 0 and " + this.mItemCount);
}
T itemAt = this.mTileList.getItemAt(i);
if (itemAt == null && !isRefreshPending()) {
this.mMissingPositions.put(i, 0);
}
return itemAt;
}
public void updateRange() {
int i;
this.mViewCallback.getItemRangeInto(this.mTmpRange);
int[] iArr = this.mTmpRange;
int i2 = iArr[0];
int i3 = iArr[1];
if (i2 > i3 || i2 < 0 || i3 >= this.mItemCount) {
return;
}
if (this.mAllowScrollHints) {
int[] iArr2 = this.mPrevRange;
if (i2 > iArr2[1] || (i = iArr2[0]) > i3) {
this.mScrollHint = 0;
} else if (i2 < i) {
this.mScrollHint = 1;
} else if (i2 > i) {
this.mScrollHint = 2;
}
} else {
this.mScrollHint = 0;
}
int[] iArr3 = this.mPrevRange;
iArr3[0] = i2;
iArr3[1] = i3;
this.mViewCallback.extendRangeInto(iArr, this.mTmpRangeExtended, this.mScrollHint);
int[] iArr4 = this.mTmpRangeExtended;
iArr4[0] = Math.min(this.mTmpRange[0], Math.max(iArr4[0], 0));
int[] iArr5 = this.mTmpRangeExtended;
iArr5[1] = Math.max(this.mTmpRange[1], Math.min(iArr5[1], this.mItemCount - 1));
ThreadUtil.BackgroundCallback<T> backgroundCallback = this.mBackgroundProxy;
int[] iArr6 = this.mTmpRange;
int i4 = iArr6[0];
int i5 = iArr6[1];
int[] iArr7 = this.mTmpRangeExtended;
backgroundCallback.updateRange(i4, i5, iArr7[0], iArr7[1], this.mScrollHint);
}
public static abstract class ViewCallback {
public static final int HINT_SCROLL_ASC = 2;
public static final int HINT_SCROLL_DESC = 1;
public static final int HINT_SCROLL_NONE = 0;
@UiThread
public abstract void getItemRangeInto(@NonNull int[] iArr);
@UiThread
public abstract void onDataRefresh();
@UiThread
public abstract void onItemLoaded(int i);
@UiThread
public void extendRangeInto(@NonNull int[] iArr, @NonNull int[] iArr2, int i) {
int i2 = iArr[1];
int i3 = iArr[0];
int i4 = (i2 - i3) + 1;
int i5 = i4 / 2;
iArr2[0] = i3 - (i == 1 ? i4 : i5);
if (i != 2) {
i4 = i5;
}
iArr2[1] = i2 + i4;
}
}
}

View File

@@ -0,0 +1,92 @@
package androidx.recyclerview.widget;
import androidx.annotation.NonNull;
/* loaded from: classes.dex */
public class BatchingListUpdateCallback implements ListUpdateCallback {
private static final int TYPE_ADD = 1;
private static final int TYPE_CHANGE = 3;
private static final int TYPE_NONE = 0;
private static final int TYPE_REMOVE = 2;
final ListUpdateCallback mWrapped;
int mLastEventType = 0;
int mLastEventPosition = -1;
int mLastEventCount = -1;
Object mLastEventPayload = null;
public BatchingListUpdateCallback(@NonNull ListUpdateCallback listUpdateCallback) {
this.mWrapped = listUpdateCallback;
}
public void dispatchLastEvent() {
int i = this.mLastEventType;
if (i == 0) {
return;
}
if (i == 1) {
this.mWrapped.onInserted(this.mLastEventPosition, this.mLastEventCount);
} else if (i == 2) {
this.mWrapped.onRemoved(this.mLastEventPosition, this.mLastEventCount);
} else if (i == 3) {
this.mWrapped.onChanged(this.mLastEventPosition, this.mLastEventCount, this.mLastEventPayload);
}
this.mLastEventPayload = null;
this.mLastEventType = 0;
}
@Override // androidx.recyclerview.widget.ListUpdateCallback
public void onInserted(int i, int i2) {
int i3;
if (this.mLastEventType == 1 && i >= (i3 = this.mLastEventPosition)) {
int i4 = this.mLastEventCount;
if (i <= i3 + i4) {
this.mLastEventCount = i4 + i2;
this.mLastEventPosition = Math.min(i, i3);
return;
}
}
dispatchLastEvent();
this.mLastEventPosition = i;
this.mLastEventCount = i2;
this.mLastEventType = 1;
}
@Override // androidx.recyclerview.widget.ListUpdateCallback
public void onRemoved(int i, int i2) {
int i3;
if (this.mLastEventType == 2 && (i3 = this.mLastEventPosition) >= i && i3 <= i + i2) {
this.mLastEventCount += i2;
this.mLastEventPosition = i;
} else {
dispatchLastEvent();
this.mLastEventPosition = i;
this.mLastEventCount = i2;
this.mLastEventType = 2;
}
}
@Override // androidx.recyclerview.widget.ListUpdateCallback
public void onMoved(int i, int i2) {
dispatchLastEvent();
this.mWrapped.onMoved(i, i2);
}
@Override // androidx.recyclerview.widget.ListUpdateCallback
public void onChanged(int i, int i2, Object obj) {
int i3;
if (this.mLastEventType == 3) {
int i4 = this.mLastEventPosition;
int i5 = this.mLastEventCount;
if (i <= i4 + i5 && (i3 = i + i2) >= i4 && this.mLastEventPayload == obj) {
this.mLastEventPosition = Math.min(i, i4);
this.mLastEventCount = Math.max(i5 + i4, i3) - this.mLastEventPosition;
return;
}
}
dispatchLastEvent();
this.mLastEventPosition = i;
this.mLastEventCount = i2;
this.mLastEventPayload = obj;
this.mLastEventType = 3;
}
}

View File

@@ -0,0 +1,339 @@
package androidx.recyclerview.widget;
import android.view.View;
import android.view.ViewGroup;
import androidx.recyclerview.widget.RecyclerView;
import java.util.ArrayList;
import java.util.List;
/* loaded from: classes.dex */
class ChildHelper {
private static final boolean DEBUG = false;
private static final String TAG = "ChildrenHelper";
final Callback mCallback;
final Bucket mBucket = new Bucket();
final List<View> mHiddenViews = new ArrayList();
public interface Callback {
void addView(View view, int i);
void attachViewToParent(View view, int i, ViewGroup.LayoutParams layoutParams);
void detachViewFromParent(int i);
View getChildAt(int i);
int getChildCount();
RecyclerView.ViewHolder getChildViewHolder(View view);
int indexOfChild(View view);
void onEnteredHiddenState(View view);
void onLeftHiddenState(View view);
void removeAllViews();
void removeViewAt(int i);
}
public ChildHelper(Callback callback) {
this.mCallback = callback;
}
private void hideViewInternal(View view) {
this.mHiddenViews.add(view);
this.mCallback.onEnteredHiddenState(view);
}
private boolean unhideViewInternal(View view) {
if (!this.mHiddenViews.remove(view)) {
return false;
}
this.mCallback.onLeftHiddenState(view);
return true;
}
public void addView(View view, boolean z) {
addView(view, -1, z);
}
public void addView(View view, int i, boolean z) {
int offset;
if (i < 0) {
offset = this.mCallback.getChildCount();
} else {
offset = getOffset(i);
}
this.mBucket.insert(offset, z);
if (z) {
hideViewInternal(view);
}
this.mCallback.addView(view, offset);
}
private int getOffset(int i) {
if (i < 0) {
return -1;
}
int childCount = this.mCallback.getChildCount();
int i2 = i;
while (i2 < childCount) {
int countOnesBefore = i - (i2 - this.mBucket.countOnesBefore(i2));
if (countOnesBefore == 0) {
while (this.mBucket.get(i2)) {
i2++;
}
return i2;
}
i2 += countOnesBefore;
}
return -1;
}
public void removeView(View view) {
int indexOfChild = this.mCallback.indexOfChild(view);
if (indexOfChild < 0) {
return;
}
if (this.mBucket.remove(indexOfChild)) {
unhideViewInternal(view);
}
this.mCallback.removeViewAt(indexOfChild);
}
public void removeViewAt(int i) {
int offset = getOffset(i);
View childAt = this.mCallback.getChildAt(offset);
if (childAt == null) {
return;
}
if (this.mBucket.remove(offset)) {
unhideViewInternal(childAt);
}
this.mCallback.removeViewAt(offset);
}
public View getChildAt(int i) {
return this.mCallback.getChildAt(getOffset(i));
}
public void removeAllViewsUnfiltered() {
this.mBucket.reset();
for (int size = this.mHiddenViews.size() - 1; size >= 0; size--) {
this.mCallback.onLeftHiddenState(this.mHiddenViews.get(size));
this.mHiddenViews.remove(size);
}
this.mCallback.removeAllViews();
}
public View findHiddenNonRemovedView(int i) {
int size = this.mHiddenViews.size();
for (int i2 = 0; i2 < size; i2++) {
View view = this.mHiddenViews.get(i2);
RecyclerView.ViewHolder childViewHolder = this.mCallback.getChildViewHolder(view);
if (childViewHolder.getLayoutPosition() == i && !childViewHolder.isInvalid() && !childViewHolder.isRemoved()) {
return view;
}
}
return null;
}
public void attachViewToParent(View view, int i, ViewGroup.LayoutParams layoutParams, boolean z) {
int offset;
if (i < 0) {
offset = this.mCallback.getChildCount();
} else {
offset = getOffset(i);
}
this.mBucket.insert(offset, z);
if (z) {
hideViewInternal(view);
}
this.mCallback.attachViewToParent(view, offset, layoutParams);
}
public int getChildCount() {
return this.mCallback.getChildCount() - this.mHiddenViews.size();
}
public int getUnfilteredChildCount() {
return this.mCallback.getChildCount();
}
public View getUnfilteredChildAt(int i) {
return this.mCallback.getChildAt(i);
}
public void detachViewFromParent(int i) {
int offset = getOffset(i);
this.mBucket.remove(offset);
this.mCallback.detachViewFromParent(offset);
}
public int indexOfChild(View view) {
int indexOfChild = this.mCallback.indexOfChild(view);
if (indexOfChild == -1 || this.mBucket.get(indexOfChild)) {
return -1;
}
return indexOfChild - this.mBucket.countOnesBefore(indexOfChild);
}
public boolean isHidden(View view) {
return this.mHiddenViews.contains(view);
}
public void hide(View view) {
int indexOfChild = this.mCallback.indexOfChild(view);
if (indexOfChild < 0) {
throw new IllegalArgumentException("view is not a child, cannot hide " + view);
}
this.mBucket.set(indexOfChild);
hideViewInternal(view);
}
public void unhide(View view) {
int indexOfChild = this.mCallback.indexOfChild(view);
if (indexOfChild < 0) {
throw new IllegalArgumentException("view is not a child, cannot hide " + view);
}
if (!this.mBucket.get(indexOfChild)) {
throw new RuntimeException("trying to unhide a view that was not hidden" + view);
}
this.mBucket.clear(indexOfChild);
unhideViewInternal(view);
}
public String toString() {
return this.mBucket.toString() + ", hidden list:" + this.mHiddenViews.size();
}
public boolean removeViewIfHidden(View view) {
int indexOfChild = this.mCallback.indexOfChild(view);
if (indexOfChild == -1) {
unhideViewInternal(view);
return true;
}
if (!this.mBucket.get(indexOfChild)) {
return false;
}
this.mBucket.remove(indexOfChild);
unhideViewInternal(view);
this.mCallback.removeViewAt(indexOfChild);
return true;
}
public static class Bucket {
static final int BITS_PER_WORD = 64;
static final long LAST_BIT = Long.MIN_VALUE;
long mData = 0;
Bucket mNext;
public void set(int i) {
if (i < 64) {
this.mData |= 1 << i;
} else {
ensureNext();
this.mNext.set(i - 64);
}
}
private void ensureNext() {
if (this.mNext == null) {
this.mNext = new Bucket();
}
}
public void clear(int i) {
if (i < 64) {
this.mData &= ~(1 << i);
return;
}
Bucket bucket = this.mNext;
if (bucket != null) {
bucket.clear(i - 64);
}
}
public boolean get(int i) {
if (i < 64) {
return (this.mData & (1 << i)) != 0;
}
ensureNext();
return this.mNext.get(i - 64);
}
public void reset() {
this.mData = 0L;
Bucket bucket = this.mNext;
if (bucket != null) {
bucket.reset();
}
}
public void insert(int i, boolean z) {
if (i >= 64) {
ensureNext();
this.mNext.insert(i - 64, z);
return;
}
long j = this.mData;
boolean z2 = (Long.MIN_VALUE & j) != 0;
long j2 = (1 << i) - 1;
this.mData = ((j & (~j2)) << 1) | (j & j2);
if (z) {
set(i);
} else {
clear(i);
}
if (z2 || this.mNext != null) {
ensureNext();
this.mNext.insert(0, z2);
}
}
public boolean remove(int i) {
if (i >= 64) {
ensureNext();
return this.mNext.remove(i - 64);
}
long j = 1 << i;
long j2 = this.mData;
boolean z = (j2 & j) != 0;
long j3 = j2 & (~j);
this.mData = j3;
long j4 = j - 1;
this.mData = (j3 & j4) | Long.rotateRight((~j4) & j3, 1);
Bucket bucket = this.mNext;
if (bucket != null) {
if (bucket.get(0)) {
set(63);
}
this.mNext.remove(0);
}
return z;
}
public int countOnesBefore(int i) {
Bucket bucket = this.mNext;
if (bucket == null) {
if (i >= 64) {
return Long.bitCount(this.mData);
}
return Long.bitCount(this.mData & ((1 << i) - 1));
}
if (i < 64) {
return Long.bitCount(this.mData & ((1 << i) - 1));
}
return bucket.countOnesBefore(i - 64) + Long.bitCount(this.mData);
}
public String toString() {
if (this.mNext == null) {
return Long.toBinaryString(this.mData);
}
return this.mNext.toString() + "xx" + Long.toBinaryString(this.mData);
}
}
}

View File

@@ -0,0 +1,179 @@
package androidx.recyclerview.widget;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
/* loaded from: classes.dex */
public final class ConcatAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
static final String TAG = "ConcatAdapter";
private final ConcatAdapterController mController;
@SafeVarargs
public ConcatAdapter(@NonNull RecyclerView.Adapter<? extends RecyclerView.ViewHolder>... adapterArr) {
this(Config.DEFAULT, adapterArr);
}
@SafeVarargs
public ConcatAdapter(@NonNull Config config, @NonNull RecyclerView.Adapter<? extends RecyclerView.ViewHolder>... adapterArr) {
this(config, (List<? extends RecyclerView.Adapter<? extends RecyclerView.ViewHolder>>) Arrays.asList(adapterArr));
}
public ConcatAdapter(@NonNull List<? extends RecyclerView.Adapter<? extends RecyclerView.ViewHolder>> list) {
this(Config.DEFAULT, list);
}
public ConcatAdapter(@NonNull Config config, @NonNull List<? extends RecyclerView.Adapter<? extends RecyclerView.ViewHolder>> list) {
this.mController = new ConcatAdapterController(this, config);
Iterator<? extends RecyclerView.Adapter<? extends RecyclerView.ViewHolder>> it = list.iterator();
while (it.hasNext()) {
addAdapter(it.next());
}
super.setHasStableIds(this.mController.hasStableIds());
}
public boolean addAdapter(@NonNull RecyclerView.Adapter<? extends RecyclerView.ViewHolder> adapter) {
return this.mController.addAdapter(adapter);
}
public boolean addAdapter(int i, @NonNull RecyclerView.Adapter<? extends RecyclerView.ViewHolder> adapter) {
return this.mController.addAdapter(i, adapter);
}
public boolean removeAdapter(@NonNull RecyclerView.Adapter<? extends RecyclerView.ViewHolder> adapter) {
return this.mController.removeAdapter(adapter);
}
@Override // androidx.recyclerview.widget.RecyclerView.Adapter
public int getItemViewType(int i) {
return this.mController.getItemViewType(i);
}
@Override // androidx.recyclerview.widget.RecyclerView.Adapter
@NonNull
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
return this.mController.onCreateViewHolder(viewGroup, i);
}
@Override // androidx.recyclerview.widget.RecyclerView.Adapter
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder viewHolder, int i) {
this.mController.onBindViewHolder(viewHolder, i);
}
@Override // androidx.recyclerview.widget.RecyclerView.Adapter
public void setHasStableIds(boolean z) {
throw new UnsupportedOperationException("Calling setHasStableIds is not allowed on the ConcatAdapter. Use the Config object passed in the constructor to control this behavior");
}
@Override // androidx.recyclerview.widget.RecyclerView.Adapter
public void setStateRestorationPolicy(@NonNull RecyclerView.Adapter.StateRestorationPolicy stateRestorationPolicy) {
throw new UnsupportedOperationException("Calling setStateRestorationPolicy is not allowed on the ConcatAdapter. This value is inferred from added adapters");
}
@Override // androidx.recyclerview.widget.RecyclerView.Adapter
public long getItemId(int i) {
return this.mController.getItemId(i);
}
public void internalSetStateRestorationPolicy(@NonNull RecyclerView.Adapter.StateRestorationPolicy stateRestorationPolicy) {
super.setStateRestorationPolicy(stateRestorationPolicy);
}
@Override // androidx.recyclerview.widget.RecyclerView.Adapter
public int getItemCount() {
return this.mController.getTotalCount();
}
@Override // androidx.recyclerview.widget.RecyclerView.Adapter
public boolean onFailedToRecycleView(@NonNull RecyclerView.ViewHolder viewHolder) {
return this.mController.onFailedToRecycleView(viewHolder);
}
@Override // androidx.recyclerview.widget.RecyclerView.Adapter
public void onViewAttachedToWindow(@NonNull RecyclerView.ViewHolder viewHolder) {
this.mController.onViewAttachedToWindow(viewHolder);
}
@Override // androidx.recyclerview.widget.RecyclerView.Adapter
public void onViewDetachedFromWindow(@NonNull RecyclerView.ViewHolder viewHolder) {
this.mController.onViewDetachedFromWindow(viewHolder);
}
@Override // androidx.recyclerview.widget.RecyclerView.Adapter
public void onViewRecycled(@NonNull RecyclerView.ViewHolder viewHolder) {
this.mController.onViewRecycled(viewHolder);
}
@Override // androidx.recyclerview.widget.RecyclerView.Adapter
public void onAttachedToRecyclerView(@NonNull RecyclerView recyclerView) {
this.mController.onAttachedToRecyclerView(recyclerView);
}
@Override // androidx.recyclerview.widget.RecyclerView.Adapter
public void onDetachedFromRecyclerView(@NonNull RecyclerView recyclerView) {
this.mController.onDetachedFromRecyclerView(recyclerView);
}
@NonNull
public List<? extends RecyclerView.Adapter<? extends RecyclerView.ViewHolder>> getAdapters() {
return Collections.unmodifiableList(this.mController.getCopyOfAdapters());
}
@Override // androidx.recyclerview.widget.RecyclerView.Adapter
public int findRelativeAdapterPositionIn(@NonNull RecyclerView.Adapter<? extends RecyclerView.ViewHolder> adapter, @NonNull RecyclerView.ViewHolder viewHolder, int i) {
return this.mController.getLocalAdapterPosition(adapter, viewHolder, i);
}
public static final class Config {
@NonNull
public static final Config DEFAULT = new Config(true, StableIdMode.NO_STABLE_IDS);
public final boolean isolateViewTypes;
@NonNull
public final StableIdMode stableIdMode;
public enum StableIdMode {
NO_STABLE_IDS,
ISOLATED_STABLE_IDS,
SHARED_STABLE_IDS
}
public Config(boolean z, @NonNull StableIdMode stableIdMode) {
this.isolateViewTypes = z;
this.stableIdMode = stableIdMode;
}
public static final class Builder {
private boolean mIsolateViewTypes;
private StableIdMode mStableIdMode;
@NonNull
public Builder setIsolateViewTypes(boolean z) {
this.mIsolateViewTypes = z;
return this;
}
@NonNull
public Builder setStableIdMode(@NonNull StableIdMode stableIdMode) {
this.mStableIdMode = stableIdMode;
return this;
}
public Builder() {
Config config = Config.DEFAULT;
this.mIsolateViewTypes = config.isolateViewTypes;
this.mStableIdMode = config.stableIdMode;
}
@NonNull
public Config build() {
return new Config(this.mIsolateViewTypes, this.mStableIdMode);
}
}
}
}

View File

@@ -0,0 +1,395 @@
package androidx.recyclerview.widget;
import android.util.Log;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.util.Preconditions;
import androidx.recyclerview.widget.ConcatAdapter;
import androidx.recyclerview.widget.NestedAdapterWrapper;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.StableIdStorage;
import androidx.recyclerview.widget.ViewTypeStorage;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Collections;
import java.util.IdentityHashMap;
import java.util.Iterator;
import java.util.List;
/* loaded from: classes.dex */
class ConcatAdapterController implements NestedAdapterWrapper.Callback {
private final ConcatAdapter mConcatAdapter;
@NonNull
private final ConcatAdapter.Config.StableIdMode mStableIdMode;
private final StableIdStorage mStableIdStorage;
private final ViewTypeStorage mViewTypeStorage;
private List<WeakReference<RecyclerView>> mAttachedRecyclerViews = new ArrayList();
private final IdentityHashMap<RecyclerView.ViewHolder, NestedAdapterWrapper> mBinderLookup = new IdentityHashMap<>();
private List<NestedAdapterWrapper> mWrappers = new ArrayList();
private WrapperAndLocalPosition mReusableHolder = new WrapperAndLocalPosition();
public static class WrapperAndLocalPosition {
boolean mInUse;
int mLocalPosition;
NestedAdapterWrapper mWrapper;
}
public ConcatAdapterController(ConcatAdapter concatAdapter, ConcatAdapter.Config config) {
this.mConcatAdapter = concatAdapter;
if (config.isolateViewTypes) {
this.mViewTypeStorage = new ViewTypeStorage.IsolatedViewTypeStorage();
} else {
this.mViewTypeStorage = new ViewTypeStorage.SharedIdRangeViewTypeStorage();
}
ConcatAdapter.Config.StableIdMode stableIdMode = config.stableIdMode;
this.mStableIdMode = stableIdMode;
if (stableIdMode == ConcatAdapter.Config.StableIdMode.NO_STABLE_IDS) {
this.mStableIdStorage = new StableIdStorage.NoStableIdStorage();
} else if (stableIdMode == ConcatAdapter.Config.StableIdMode.ISOLATED_STABLE_IDS) {
this.mStableIdStorage = new StableIdStorage.IsolatedStableIdStorage();
} else {
if (stableIdMode == ConcatAdapter.Config.StableIdMode.SHARED_STABLE_IDS) {
this.mStableIdStorage = new StableIdStorage.SharedPoolStableIdStorage();
return;
}
throw new IllegalArgumentException("unknown stable id mode");
}
}
@Nullable
private NestedAdapterWrapper findWrapperFor(RecyclerView.Adapter<RecyclerView.ViewHolder> adapter) {
int indexOfWrapper = indexOfWrapper(adapter);
if (indexOfWrapper == -1) {
return null;
}
return this.mWrappers.get(indexOfWrapper);
}
private int indexOfWrapper(RecyclerView.Adapter<RecyclerView.ViewHolder> adapter) {
int size = this.mWrappers.size();
for (int i = 0; i < size; i++) {
if (this.mWrappers.get(i).adapter == adapter) {
return i;
}
}
return -1;
}
public boolean addAdapter(RecyclerView.Adapter<RecyclerView.ViewHolder> adapter) {
return addAdapter(this.mWrappers.size(), adapter);
}
public boolean addAdapter(int i, RecyclerView.Adapter<RecyclerView.ViewHolder> adapter) {
if (i < 0 || i > this.mWrappers.size()) {
throw new IndexOutOfBoundsException("Index must be between 0 and " + this.mWrappers.size() + ". Given:" + i);
}
if (hasStableIds()) {
Preconditions.checkArgument(adapter.hasStableIds(), "All sub adapters must have stable ids when stable id mode is ISOLATED_STABLE_IDS or SHARED_STABLE_IDS");
} else if (adapter.hasStableIds()) {
Log.w("ConcatAdapter", "Stable ids in the adapter will be ignored as the ConcatAdapter is configured not to have stable ids");
}
if (findWrapperFor(adapter) != null) {
return false;
}
NestedAdapterWrapper nestedAdapterWrapper = new NestedAdapterWrapper(adapter, this, this.mViewTypeStorage, this.mStableIdStorage.createStableIdLookup());
this.mWrappers.add(i, nestedAdapterWrapper);
Iterator<WeakReference<RecyclerView>> it = this.mAttachedRecyclerViews.iterator();
while (it.hasNext()) {
RecyclerView recyclerView = it.next().get();
if (recyclerView != null) {
adapter.onAttachedToRecyclerView(recyclerView);
}
}
if (nestedAdapterWrapper.getCachedItemCount() > 0) {
this.mConcatAdapter.notifyItemRangeInserted(countItemsBefore(nestedAdapterWrapper), nestedAdapterWrapper.getCachedItemCount());
}
calculateAndUpdateStateRestorationPolicy();
return true;
}
public boolean removeAdapter(RecyclerView.Adapter<RecyclerView.ViewHolder> adapter) {
int indexOfWrapper = indexOfWrapper(adapter);
if (indexOfWrapper == -1) {
return false;
}
NestedAdapterWrapper nestedAdapterWrapper = this.mWrappers.get(indexOfWrapper);
int countItemsBefore = countItemsBefore(nestedAdapterWrapper);
this.mWrappers.remove(indexOfWrapper);
this.mConcatAdapter.notifyItemRangeRemoved(countItemsBefore, nestedAdapterWrapper.getCachedItemCount());
Iterator<WeakReference<RecyclerView>> it = this.mAttachedRecyclerViews.iterator();
while (it.hasNext()) {
RecyclerView recyclerView = it.next().get();
if (recyclerView != null) {
adapter.onDetachedFromRecyclerView(recyclerView);
}
}
nestedAdapterWrapper.dispose();
calculateAndUpdateStateRestorationPolicy();
return true;
}
private int countItemsBefore(NestedAdapterWrapper nestedAdapterWrapper) {
NestedAdapterWrapper next;
Iterator<NestedAdapterWrapper> it = this.mWrappers.iterator();
int i = 0;
while (it.hasNext() && (next = it.next()) != nestedAdapterWrapper) {
i += next.getCachedItemCount();
}
return i;
}
public long getItemId(int i) {
WrapperAndLocalPosition findWrapperAndLocalPosition = findWrapperAndLocalPosition(i);
long itemId = findWrapperAndLocalPosition.mWrapper.getItemId(findWrapperAndLocalPosition.mLocalPosition);
releaseWrapperAndLocalPosition(findWrapperAndLocalPosition);
return itemId;
}
@Override // androidx.recyclerview.widget.NestedAdapterWrapper.Callback
public void onChanged(@NonNull NestedAdapterWrapper nestedAdapterWrapper) {
this.mConcatAdapter.notifyDataSetChanged();
calculateAndUpdateStateRestorationPolicy();
}
@Override // androidx.recyclerview.widget.NestedAdapterWrapper.Callback
public void onItemRangeChanged(@NonNull NestedAdapterWrapper nestedAdapterWrapper, int i, int i2) {
this.mConcatAdapter.notifyItemRangeChanged(i + countItemsBefore(nestedAdapterWrapper), i2);
}
@Override // androidx.recyclerview.widget.NestedAdapterWrapper.Callback
public void onItemRangeChanged(@NonNull NestedAdapterWrapper nestedAdapterWrapper, int i, int i2, @Nullable Object obj) {
this.mConcatAdapter.notifyItemRangeChanged(i + countItemsBefore(nestedAdapterWrapper), i2, obj);
}
@Override // androidx.recyclerview.widget.NestedAdapterWrapper.Callback
public void onItemRangeInserted(@NonNull NestedAdapterWrapper nestedAdapterWrapper, int i, int i2) {
this.mConcatAdapter.notifyItemRangeInserted(i + countItemsBefore(nestedAdapterWrapper), i2);
}
@Override // androidx.recyclerview.widget.NestedAdapterWrapper.Callback
public void onItemRangeRemoved(@NonNull NestedAdapterWrapper nestedAdapterWrapper, int i, int i2) {
this.mConcatAdapter.notifyItemRangeRemoved(i + countItemsBefore(nestedAdapterWrapper), i2);
}
@Override // androidx.recyclerview.widget.NestedAdapterWrapper.Callback
public void onItemRangeMoved(@NonNull NestedAdapterWrapper nestedAdapterWrapper, int i, int i2) {
int countItemsBefore = countItemsBefore(nestedAdapterWrapper);
this.mConcatAdapter.notifyItemMoved(i + countItemsBefore, i2 + countItemsBefore);
}
@Override // androidx.recyclerview.widget.NestedAdapterWrapper.Callback
public void onStateRestorationPolicyChanged(NestedAdapterWrapper nestedAdapterWrapper) {
calculateAndUpdateStateRestorationPolicy();
}
private void calculateAndUpdateStateRestorationPolicy() {
RecyclerView.Adapter.StateRestorationPolicy computeStateRestorationPolicy = computeStateRestorationPolicy();
if (computeStateRestorationPolicy != this.mConcatAdapter.getStateRestorationPolicy()) {
this.mConcatAdapter.internalSetStateRestorationPolicy(computeStateRestorationPolicy);
}
}
private RecyclerView.Adapter.StateRestorationPolicy computeStateRestorationPolicy() {
for (NestedAdapterWrapper nestedAdapterWrapper : this.mWrappers) {
RecyclerView.Adapter.StateRestorationPolicy stateRestorationPolicy = nestedAdapterWrapper.adapter.getStateRestorationPolicy();
RecyclerView.Adapter.StateRestorationPolicy stateRestorationPolicy2 = RecyclerView.Adapter.StateRestorationPolicy.PREVENT;
if (stateRestorationPolicy == stateRestorationPolicy2) {
return stateRestorationPolicy2;
}
if (stateRestorationPolicy == RecyclerView.Adapter.StateRestorationPolicy.PREVENT_WHEN_EMPTY && nestedAdapterWrapper.getCachedItemCount() == 0) {
return stateRestorationPolicy2;
}
}
return RecyclerView.Adapter.StateRestorationPolicy.ALLOW;
}
public int getTotalCount() {
Iterator<NestedAdapterWrapper> it = this.mWrappers.iterator();
int i = 0;
while (it.hasNext()) {
i += it.next().getCachedItemCount();
}
return i;
}
public int getItemViewType(int i) {
WrapperAndLocalPosition findWrapperAndLocalPosition = findWrapperAndLocalPosition(i);
int itemViewType = findWrapperAndLocalPosition.mWrapper.getItemViewType(findWrapperAndLocalPosition.mLocalPosition);
releaseWrapperAndLocalPosition(findWrapperAndLocalPosition);
return itemViewType;
}
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
return this.mViewTypeStorage.getWrapperForGlobalType(i).onCreateViewHolder(viewGroup, i);
}
@NonNull
private WrapperAndLocalPosition findWrapperAndLocalPosition(int i) {
WrapperAndLocalPosition wrapperAndLocalPosition = this.mReusableHolder;
if (wrapperAndLocalPosition.mInUse) {
wrapperAndLocalPosition = new WrapperAndLocalPosition();
} else {
wrapperAndLocalPosition.mInUse = true;
}
Iterator<NestedAdapterWrapper> it = this.mWrappers.iterator();
int i2 = i;
while (true) {
if (!it.hasNext()) {
break;
}
NestedAdapterWrapper next = it.next();
if (next.getCachedItemCount() > i2) {
wrapperAndLocalPosition.mWrapper = next;
wrapperAndLocalPosition.mLocalPosition = i2;
break;
}
i2 -= next.getCachedItemCount();
}
if (wrapperAndLocalPosition.mWrapper != null) {
return wrapperAndLocalPosition;
}
throw new IllegalArgumentException("Cannot find wrapper for " + i);
}
private void releaseWrapperAndLocalPosition(WrapperAndLocalPosition wrapperAndLocalPosition) {
wrapperAndLocalPosition.mInUse = false;
wrapperAndLocalPosition.mWrapper = null;
wrapperAndLocalPosition.mLocalPosition = -1;
this.mReusableHolder = wrapperAndLocalPosition;
}
public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, int i) {
WrapperAndLocalPosition findWrapperAndLocalPosition = findWrapperAndLocalPosition(i);
this.mBinderLookup.put(viewHolder, findWrapperAndLocalPosition.mWrapper);
findWrapperAndLocalPosition.mWrapper.onBindViewHolder(viewHolder, findWrapperAndLocalPosition.mLocalPosition);
releaseWrapperAndLocalPosition(findWrapperAndLocalPosition);
}
public boolean canRestoreState() {
Iterator<NestedAdapterWrapper> it = this.mWrappers.iterator();
while (it.hasNext()) {
if (!it.next().adapter.canRestoreState()) {
return false;
}
}
return true;
}
public void onViewAttachedToWindow(RecyclerView.ViewHolder viewHolder) {
getWrapper(viewHolder).adapter.onViewAttachedToWindow(viewHolder);
}
public void onViewDetachedFromWindow(RecyclerView.ViewHolder viewHolder) {
getWrapper(viewHolder).adapter.onViewDetachedFromWindow(viewHolder);
}
public void onViewRecycled(RecyclerView.ViewHolder viewHolder) {
NestedAdapterWrapper nestedAdapterWrapper = this.mBinderLookup.get(viewHolder);
if (nestedAdapterWrapper == null) {
throw new IllegalStateException("Cannot find wrapper for " + viewHolder + ", seems like it is not bound by this adapter: " + this);
}
nestedAdapterWrapper.adapter.onViewRecycled(viewHolder);
this.mBinderLookup.remove(viewHolder);
}
public boolean onFailedToRecycleView(RecyclerView.ViewHolder viewHolder) {
NestedAdapterWrapper nestedAdapterWrapper = this.mBinderLookup.get(viewHolder);
if (nestedAdapterWrapper == null) {
throw new IllegalStateException("Cannot find wrapper for " + viewHolder + ", seems like it is not bound by this adapter: " + this);
}
boolean onFailedToRecycleView = nestedAdapterWrapper.adapter.onFailedToRecycleView(viewHolder);
this.mBinderLookup.remove(viewHolder);
return onFailedToRecycleView;
}
@NonNull
private NestedAdapterWrapper getWrapper(RecyclerView.ViewHolder viewHolder) {
NestedAdapterWrapper nestedAdapterWrapper = this.mBinderLookup.get(viewHolder);
if (nestedAdapterWrapper != null) {
return nestedAdapterWrapper;
}
throw new IllegalStateException("Cannot find wrapper for " + viewHolder + ", seems like it is not bound by this adapter: " + this);
}
private boolean isAttachedTo(RecyclerView recyclerView) {
Iterator<WeakReference<RecyclerView>> it = this.mAttachedRecyclerViews.iterator();
while (it.hasNext()) {
if (it.next().get() == recyclerView) {
return true;
}
}
return false;
}
public void onAttachedToRecyclerView(RecyclerView recyclerView) {
if (isAttachedTo(recyclerView)) {
return;
}
this.mAttachedRecyclerViews.add(new WeakReference<>(recyclerView));
Iterator<NestedAdapterWrapper> it = this.mWrappers.iterator();
while (it.hasNext()) {
it.next().adapter.onAttachedToRecyclerView(recyclerView);
}
}
public void onDetachedFromRecyclerView(RecyclerView recyclerView) {
int size = this.mAttachedRecyclerViews.size() - 1;
while (true) {
if (size < 0) {
break;
}
WeakReference<RecyclerView> weakReference = this.mAttachedRecyclerViews.get(size);
if (weakReference.get() == null) {
this.mAttachedRecyclerViews.remove(size);
} else if (weakReference.get() == recyclerView) {
this.mAttachedRecyclerViews.remove(size);
break;
}
size--;
}
Iterator<NestedAdapterWrapper> it = this.mWrappers.iterator();
while (it.hasNext()) {
it.next().adapter.onDetachedFromRecyclerView(recyclerView);
}
}
public int getLocalAdapterPosition(RecyclerView.Adapter<? extends RecyclerView.ViewHolder> adapter, RecyclerView.ViewHolder viewHolder, int i) {
NestedAdapterWrapper nestedAdapterWrapper = this.mBinderLookup.get(viewHolder);
if (nestedAdapterWrapper == null) {
return -1;
}
int countItemsBefore = i - countItemsBefore(nestedAdapterWrapper);
int itemCount = nestedAdapterWrapper.adapter.getItemCount();
if (countItemsBefore < 0 || countItemsBefore >= itemCount) {
throw new IllegalStateException("Detected inconsistent adapter updates. The local position of the view holder maps to " + countItemsBefore + " which is out of bounds for the adapter with size " + itemCount + ".Make sure to immediately call notify methods in your adapter when you change the backing dataviewHolder:" + viewHolder + "adapter:" + adapter);
}
return nestedAdapterWrapper.adapter.findRelativeAdapterPositionIn(adapter, viewHolder, countItemsBefore);
}
@Nullable
public RecyclerView.Adapter<? extends RecyclerView.ViewHolder> getBoundAdapter(RecyclerView.ViewHolder viewHolder) {
NestedAdapterWrapper nestedAdapterWrapper = this.mBinderLookup.get(viewHolder);
if (nestedAdapterWrapper == null) {
return null;
}
return nestedAdapterWrapper.adapter;
}
public List<RecyclerView.Adapter<? extends RecyclerView.ViewHolder>> getCopyOfAdapters() {
if (this.mWrappers.isEmpty()) {
return Collections.emptyList();
}
ArrayList arrayList = new ArrayList(this.mWrappers.size());
Iterator<NestedAdapterWrapper> it = this.mWrappers.iterator();
while (it.hasNext()) {
arrayList.add(it.next().adapter);
}
return arrayList;
}
public boolean hasStableIds() {
return this.mStableIdMode != ConcatAdapter.Config.StableIdMode.NO_STABLE_IDS;
}
}

View File

@@ -0,0 +1,568 @@
package androidx.recyclerview.widget;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.TimeInterpolator;
import android.animation.ValueAnimator;
import android.view.View;
import android.view.ViewPropertyAnimator;
import androidx.annotation.NonNull;
import androidx.core.view.ViewCompat;
import androidx.recyclerview.widget.RecyclerView;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
/* loaded from: classes.dex */
public class DefaultItemAnimator extends SimpleItemAnimator {
private static final boolean DEBUG = false;
private static TimeInterpolator sDefaultInterpolator;
private ArrayList<RecyclerView.ViewHolder> mPendingRemovals = new ArrayList<>();
private ArrayList<RecyclerView.ViewHolder> mPendingAdditions = new ArrayList<>();
private ArrayList<MoveInfo> mPendingMoves = new ArrayList<>();
private ArrayList<ChangeInfo> mPendingChanges = new ArrayList<>();
ArrayList<ArrayList<RecyclerView.ViewHolder>> mAdditionsList = new ArrayList<>();
ArrayList<ArrayList<MoveInfo>> mMovesList = new ArrayList<>();
ArrayList<ArrayList<ChangeInfo>> mChangesList = new ArrayList<>();
ArrayList<RecyclerView.ViewHolder> mAddAnimations = new ArrayList<>();
ArrayList<RecyclerView.ViewHolder> mMoveAnimations = new ArrayList<>();
ArrayList<RecyclerView.ViewHolder> mRemoveAnimations = new ArrayList<>();
ArrayList<RecyclerView.ViewHolder> mChangeAnimations = new ArrayList<>();
public static class MoveInfo {
public int fromX;
public int fromY;
public RecyclerView.ViewHolder holder;
public int toX;
public int toY;
public MoveInfo(RecyclerView.ViewHolder viewHolder, int i, int i2, int i3, int i4) {
this.holder = viewHolder;
this.fromX = i;
this.fromY = i2;
this.toX = i3;
this.toY = i4;
}
}
public static class ChangeInfo {
public int fromX;
public int fromY;
public RecyclerView.ViewHolder newHolder;
public RecyclerView.ViewHolder oldHolder;
public int toX;
public int toY;
private ChangeInfo(RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder viewHolder2) {
this.oldHolder = viewHolder;
this.newHolder = viewHolder2;
}
public ChangeInfo(RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder viewHolder2, int i, int i2, int i3, int i4) {
this(viewHolder, viewHolder2);
this.fromX = i;
this.fromY = i2;
this.toX = i3;
this.toY = i4;
}
public String toString() {
return "ChangeInfo{oldHolder=" + this.oldHolder + ", newHolder=" + this.newHolder + ", fromX=" + this.fromX + ", fromY=" + this.fromY + ", toX=" + this.toX + ", toY=" + this.toY + '}';
}
}
@Override // androidx.recyclerview.widget.RecyclerView.ItemAnimator
public void runPendingAnimations() {
boolean z = !this.mPendingRemovals.isEmpty();
boolean z2 = !this.mPendingMoves.isEmpty();
boolean z3 = !this.mPendingChanges.isEmpty();
boolean z4 = !this.mPendingAdditions.isEmpty();
if (z || z2 || z4 || z3) {
Iterator<RecyclerView.ViewHolder> it = this.mPendingRemovals.iterator();
while (it.hasNext()) {
animateRemoveImpl(it.next());
}
this.mPendingRemovals.clear();
if (z2) {
final ArrayList<MoveInfo> arrayList = new ArrayList<>();
arrayList.addAll(this.mPendingMoves);
this.mMovesList.add(arrayList);
this.mPendingMoves.clear();
Runnable runnable = new Runnable() { // from class: androidx.recyclerview.widget.DefaultItemAnimator.1
@Override // java.lang.Runnable
public void run() {
Iterator it2 = arrayList.iterator();
while (it2.hasNext()) {
MoveInfo moveInfo = (MoveInfo) it2.next();
DefaultItemAnimator.this.animateMoveImpl(moveInfo.holder, moveInfo.fromX, moveInfo.fromY, moveInfo.toX, moveInfo.toY);
}
arrayList.clear();
DefaultItemAnimator.this.mMovesList.remove(arrayList);
}
};
if (z) {
ViewCompat.postOnAnimationDelayed(arrayList.get(0).holder.itemView, runnable, getRemoveDuration());
} else {
runnable.run();
}
}
if (z3) {
final ArrayList<ChangeInfo> arrayList2 = new ArrayList<>();
arrayList2.addAll(this.mPendingChanges);
this.mChangesList.add(arrayList2);
this.mPendingChanges.clear();
Runnable runnable2 = new Runnable() { // from class: androidx.recyclerview.widget.DefaultItemAnimator.2
@Override // java.lang.Runnable
public void run() {
Iterator it2 = arrayList2.iterator();
while (it2.hasNext()) {
DefaultItemAnimator.this.animateChangeImpl((ChangeInfo) it2.next());
}
arrayList2.clear();
DefaultItemAnimator.this.mChangesList.remove(arrayList2);
}
};
if (z) {
ViewCompat.postOnAnimationDelayed(arrayList2.get(0).oldHolder.itemView, runnable2, getRemoveDuration());
} else {
runnable2.run();
}
}
if (z4) {
final ArrayList<RecyclerView.ViewHolder> arrayList3 = new ArrayList<>();
arrayList3.addAll(this.mPendingAdditions);
this.mAdditionsList.add(arrayList3);
this.mPendingAdditions.clear();
Runnable runnable3 = new Runnable() { // from class: androidx.recyclerview.widget.DefaultItemAnimator.3
@Override // java.lang.Runnable
public void run() {
Iterator it2 = arrayList3.iterator();
while (it2.hasNext()) {
DefaultItemAnimator.this.animateAddImpl((RecyclerView.ViewHolder) it2.next());
}
arrayList3.clear();
DefaultItemAnimator.this.mAdditionsList.remove(arrayList3);
}
};
if (z || z2 || z3) {
ViewCompat.postOnAnimationDelayed(arrayList3.get(0).itemView, runnable3, (z ? getRemoveDuration() : 0L) + Math.max(z2 ? getMoveDuration() : 0L, z3 ? getChangeDuration() : 0L));
} else {
runnable3.run();
}
}
}
}
@Override // androidx.recyclerview.widget.SimpleItemAnimator
public boolean animateRemove(RecyclerView.ViewHolder viewHolder) {
resetAnimation(viewHolder);
this.mPendingRemovals.add(viewHolder);
return true;
}
private void animateRemoveImpl(final RecyclerView.ViewHolder viewHolder) {
final View view = viewHolder.itemView;
final ViewPropertyAnimator animate = view.animate();
this.mRemoveAnimations.add(viewHolder);
animate.setDuration(getRemoveDuration()).alpha(0.0f).setListener(new AnimatorListenerAdapter() { // from class: androidx.recyclerview.widget.DefaultItemAnimator.4
@Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
public void onAnimationStart(Animator animator) {
DefaultItemAnimator.this.dispatchRemoveStarting(viewHolder);
}
@Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
public void onAnimationEnd(Animator animator) {
animate.setListener(null);
view.setAlpha(1.0f);
DefaultItemAnimator.this.dispatchRemoveFinished(viewHolder);
DefaultItemAnimator.this.mRemoveAnimations.remove(viewHolder);
DefaultItemAnimator.this.dispatchFinishedWhenDone();
}
}).start();
}
@Override // androidx.recyclerview.widget.SimpleItemAnimator
public boolean animateAdd(RecyclerView.ViewHolder viewHolder) {
resetAnimation(viewHolder);
viewHolder.itemView.setAlpha(0.0f);
this.mPendingAdditions.add(viewHolder);
return true;
}
public void animateAddImpl(final RecyclerView.ViewHolder viewHolder) {
final View view = viewHolder.itemView;
final ViewPropertyAnimator animate = view.animate();
this.mAddAnimations.add(viewHolder);
animate.alpha(1.0f).setDuration(getAddDuration()).setListener(new AnimatorListenerAdapter() { // from class: androidx.recyclerview.widget.DefaultItemAnimator.5
@Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
public void onAnimationStart(Animator animator) {
DefaultItemAnimator.this.dispatchAddStarting(viewHolder);
}
@Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
public void onAnimationCancel(Animator animator) {
view.setAlpha(1.0f);
}
@Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
public void onAnimationEnd(Animator animator) {
animate.setListener(null);
DefaultItemAnimator.this.dispatchAddFinished(viewHolder);
DefaultItemAnimator.this.mAddAnimations.remove(viewHolder);
DefaultItemAnimator.this.dispatchFinishedWhenDone();
}
}).start();
}
@Override // androidx.recyclerview.widget.SimpleItemAnimator
public boolean animateMove(RecyclerView.ViewHolder viewHolder, int i, int i2, int i3, int i4) {
View view = viewHolder.itemView;
int translationX = i + ((int) view.getTranslationX());
int translationY = i2 + ((int) viewHolder.itemView.getTranslationY());
resetAnimation(viewHolder);
int i5 = i3 - translationX;
int i6 = i4 - translationY;
if (i5 == 0 && i6 == 0) {
dispatchMoveFinished(viewHolder);
return false;
}
if (i5 != 0) {
view.setTranslationX(-i5);
}
if (i6 != 0) {
view.setTranslationY(-i6);
}
this.mPendingMoves.add(new MoveInfo(viewHolder, translationX, translationY, i3, i4));
return true;
}
public void animateMoveImpl(final RecyclerView.ViewHolder viewHolder, int i, int i2, int i3, int i4) {
final View view = viewHolder.itemView;
final int i5 = i3 - i;
final int i6 = i4 - i2;
if (i5 != 0) {
view.animate().translationX(0.0f);
}
if (i6 != 0) {
view.animate().translationY(0.0f);
}
final ViewPropertyAnimator animate = view.animate();
this.mMoveAnimations.add(viewHolder);
animate.setDuration(getMoveDuration()).setListener(new AnimatorListenerAdapter() { // from class: androidx.recyclerview.widget.DefaultItemAnimator.6
@Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
public void onAnimationStart(Animator animator) {
DefaultItemAnimator.this.dispatchMoveStarting(viewHolder);
}
@Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
public void onAnimationCancel(Animator animator) {
if (i5 != 0) {
view.setTranslationX(0.0f);
}
if (i6 != 0) {
view.setTranslationY(0.0f);
}
}
@Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
public void onAnimationEnd(Animator animator) {
animate.setListener(null);
DefaultItemAnimator.this.dispatchMoveFinished(viewHolder);
DefaultItemAnimator.this.mMoveAnimations.remove(viewHolder);
DefaultItemAnimator.this.dispatchFinishedWhenDone();
}
}).start();
}
@Override // androidx.recyclerview.widget.SimpleItemAnimator
public boolean animateChange(RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder viewHolder2, int i, int i2, int i3, int i4) {
if (viewHolder == viewHolder2) {
return animateMove(viewHolder, i, i2, i3, i4);
}
float translationX = viewHolder.itemView.getTranslationX();
float translationY = viewHolder.itemView.getTranslationY();
float alpha = viewHolder.itemView.getAlpha();
resetAnimation(viewHolder);
int i5 = (int) ((i3 - i) - translationX);
int i6 = (int) ((i4 - i2) - translationY);
viewHolder.itemView.setTranslationX(translationX);
viewHolder.itemView.setTranslationY(translationY);
viewHolder.itemView.setAlpha(alpha);
if (viewHolder2 != null) {
resetAnimation(viewHolder2);
viewHolder2.itemView.setTranslationX(-i5);
viewHolder2.itemView.setTranslationY(-i6);
viewHolder2.itemView.setAlpha(0.0f);
}
this.mPendingChanges.add(new ChangeInfo(viewHolder, viewHolder2, i, i2, i3, i4));
return true;
}
public void animateChangeImpl(final ChangeInfo changeInfo) {
RecyclerView.ViewHolder viewHolder = changeInfo.oldHolder;
final View view = viewHolder == null ? null : viewHolder.itemView;
RecyclerView.ViewHolder viewHolder2 = changeInfo.newHolder;
final View view2 = viewHolder2 != null ? viewHolder2.itemView : null;
if (view != null) {
final ViewPropertyAnimator duration = view.animate().setDuration(getChangeDuration());
this.mChangeAnimations.add(changeInfo.oldHolder);
duration.translationX(changeInfo.toX - changeInfo.fromX);
duration.translationY(changeInfo.toY - changeInfo.fromY);
duration.alpha(0.0f).setListener(new AnimatorListenerAdapter() { // from class: androidx.recyclerview.widget.DefaultItemAnimator.7
@Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
public void onAnimationStart(Animator animator) {
DefaultItemAnimator.this.dispatchChangeStarting(changeInfo.oldHolder, true);
}
@Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
public void onAnimationEnd(Animator animator) {
duration.setListener(null);
view.setAlpha(1.0f);
view.setTranslationX(0.0f);
view.setTranslationY(0.0f);
DefaultItemAnimator.this.dispatchChangeFinished(changeInfo.oldHolder, true);
DefaultItemAnimator.this.mChangeAnimations.remove(changeInfo.oldHolder);
DefaultItemAnimator.this.dispatchFinishedWhenDone();
}
}).start();
}
if (view2 != null) {
final ViewPropertyAnimator animate = view2.animate();
this.mChangeAnimations.add(changeInfo.newHolder);
animate.translationX(0.0f).translationY(0.0f).setDuration(getChangeDuration()).alpha(1.0f).setListener(new AnimatorListenerAdapter() { // from class: androidx.recyclerview.widget.DefaultItemAnimator.8
@Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
public void onAnimationStart(Animator animator) {
DefaultItemAnimator.this.dispatchChangeStarting(changeInfo.newHolder, false);
}
@Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
public void onAnimationEnd(Animator animator) {
animate.setListener(null);
view2.setAlpha(1.0f);
view2.setTranslationX(0.0f);
view2.setTranslationY(0.0f);
DefaultItemAnimator.this.dispatchChangeFinished(changeInfo.newHolder, false);
DefaultItemAnimator.this.mChangeAnimations.remove(changeInfo.newHolder);
DefaultItemAnimator.this.dispatchFinishedWhenDone();
}
}).start();
}
}
private void endChangeAnimation(List<ChangeInfo> list, RecyclerView.ViewHolder viewHolder) {
for (int size = list.size() - 1; size >= 0; size--) {
ChangeInfo changeInfo = list.get(size);
if (endChangeAnimationIfNecessary(changeInfo, viewHolder) && changeInfo.oldHolder == null && changeInfo.newHolder == null) {
list.remove(changeInfo);
}
}
}
private void endChangeAnimationIfNecessary(ChangeInfo changeInfo) {
RecyclerView.ViewHolder viewHolder = changeInfo.oldHolder;
if (viewHolder != null) {
endChangeAnimationIfNecessary(changeInfo, viewHolder);
}
RecyclerView.ViewHolder viewHolder2 = changeInfo.newHolder;
if (viewHolder2 != null) {
endChangeAnimationIfNecessary(changeInfo, viewHolder2);
}
}
private boolean endChangeAnimationIfNecessary(ChangeInfo changeInfo, RecyclerView.ViewHolder viewHolder) {
boolean z = false;
if (changeInfo.newHolder == viewHolder) {
changeInfo.newHolder = null;
} else {
if (changeInfo.oldHolder != viewHolder) {
return false;
}
changeInfo.oldHolder = null;
z = true;
}
viewHolder.itemView.setAlpha(1.0f);
viewHolder.itemView.setTranslationX(0.0f);
viewHolder.itemView.setTranslationY(0.0f);
dispatchChangeFinished(viewHolder, z);
return true;
}
@Override // androidx.recyclerview.widget.RecyclerView.ItemAnimator
public void endAnimation(RecyclerView.ViewHolder viewHolder) {
View view = viewHolder.itemView;
view.animate().cancel();
int size = this.mPendingMoves.size();
while (true) {
size--;
if (size < 0) {
break;
}
if (this.mPendingMoves.get(size).holder == viewHolder) {
view.setTranslationY(0.0f);
view.setTranslationX(0.0f);
dispatchMoveFinished(viewHolder);
this.mPendingMoves.remove(size);
}
}
endChangeAnimation(this.mPendingChanges, viewHolder);
if (this.mPendingRemovals.remove(viewHolder)) {
view.setAlpha(1.0f);
dispatchRemoveFinished(viewHolder);
}
if (this.mPendingAdditions.remove(viewHolder)) {
view.setAlpha(1.0f);
dispatchAddFinished(viewHolder);
}
for (int size2 = this.mChangesList.size() - 1; size2 >= 0; size2--) {
ArrayList<ChangeInfo> arrayList = this.mChangesList.get(size2);
endChangeAnimation(arrayList, viewHolder);
if (arrayList.isEmpty()) {
this.mChangesList.remove(size2);
}
}
for (int size3 = this.mMovesList.size() - 1; size3 >= 0; size3--) {
ArrayList<MoveInfo> arrayList2 = this.mMovesList.get(size3);
int size4 = arrayList2.size() - 1;
while (true) {
if (size4 < 0) {
break;
}
if (arrayList2.get(size4).holder == viewHolder) {
view.setTranslationY(0.0f);
view.setTranslationX(0.0f);
dispatchMoveFinished(viewHolder);
arrayList2.remove(size4);
if (arrayList2.isEmpty()) {
this.mMovesList.remove(size3);
}
} else {
size4--;
}
}
}
for (int size5 = this.mAdditionsList.size() - 1; size5 >= 0; size5--) {
ArrayList<RecyclerView.ViewHolder> arrayList3 = this.mAdditionsList.get(size5);
if (arrayList3.remove(viewHolder)) {
view.setAlpha(1.0f);
dispatchAddFinished(viewHolder);
if (arrayList3.isEmpty()) {
this.mAdditionsList.remove(size5);
}
}
}
this.mRemoveAnimations.remove(viewHolder);
this.mAddAnimations.remove(viewHolder);
this.mChangeAnimations.remove(viewHolder);
this.mMoveAnimations.remove(viewHolder);
dispatchFinishedWhenDone();
}
private void resetAnimation(RecyclerView.ViewHolder viewHolder) {
if (sDefaultInterpolator == null) {
sDefaultInterpolator = new ValueAnimator().getInterpolator();
}
viewHolder.itemView.animate().setInterpolator(sDefaultInterpolator);
endAnimation(viewHolder);
}
@Override // androidx.recyclerview.widget.RecyclerView.ItemAnimator
public boolean isRunning() {
return (this.mPendingAdditions.isEmpty() && this.mPendingChanges.isEmpty() && this.mPendingMoves.isEmpty() && this.mPendingRemovals.isEmpty() && this.mMoveAnimations.isEmpty() && this.mRemoveAnimations.isEmpty() && this.mAddAnimations.isEmpty() && this.mChangeAnimations.isEmpty() && this.mMovesList.isEmpty() && this.mAdditionsList.isEmpty() && this.mChangesList.isEmpty()) ? false : true;
}
public void dispatchFinishedWhenDone() {
if (isRunning()) {
return;
}
dispatchAnimationsFinished();
}
@Override // androidx.recyclerview.widget.RecyclerView.ItemAnimator
public void endAnimations() {
int size = this.mPendingMoves.size();
while (true) {
size--;
if (size < 0) {
break;
}
MoveInfo moveInfo = this.mPendingMoves.get(size);
View view = moveInfo.holder.itemView;
view.setTranslationY(0.0f);
view.setTranslationX(0.0f);
dispatchMoveFinished(moveInfo.holder);
this.mPendingMoves.remove(size);
}
for (int size2 = this.mPendingRemovals.size() - 1; size2 >= 0; size2--) {
dispatchRemoveFinished(this.mPendingRemovals.get(size2));
this.mPendingRemovals.remove(size2);
}
int size3 = this.mPendingAdditions.size();
while (true) {
size3--;
if (size3 < 0) {
break;
}
RecyclerView.ViewHolder viewHolder = this.mPendingAdditions.get(size3);
viewHolder.itemView.setAlpha(1.0f);
dispatchAddFinished(viewHolder);
this.mPendingAdditions.remove(size3);
}
for (int size4 = this.mPendingChanges.size() - 1; size4 >= 0; size4--) {
endChangeAnimationIfNecessary(this.mPendingChanges.get(size4));
}
this.mPendingChanges.clear();
if (isRunning()) {
for (int size5 = this.mMovesList.size() - 1; size5 >= 0; size5--) {
ArrayList<MoveInfo> arrayList = this.mMovesList.get(size5);
for (int size6 = arrayList.size() - 1; size6 >= 0; size6--) {
MoveInfo moveInfo2 = arrayList.get(size6);
View view2 = moveInfo2.holder.itemView;
view2.setTranslationY(0.0f);
view2.setTranslationX(0.0f);
dispatchMoveFinished(moveInfo2.holder);
arrayList.remove(size6);
if (arrayList.isEmpty()) {
this.mMovesList.remove(arrayList);
}
}
}
for (int size7 = this.mAdditionsList.size() - 1; size7 >= 0; size7--) {
ArrayList<RecyclerView.ViewHolder> arrayList2 = this.mAdditionsList.get(size7);
for (int size8 = arrayList2.size() - 1; size8 >= 0; size8--) {
RecyclerView.ViewHolder viewHolder2 = arrayList2.get(size8);
viewHolder2.itemView.setAlpha(1.0f);
dispatchAddFinished(viewHolder2);
arrayList2.remove(size8);
if (arrayList2.isEmpty()) {
this.mAdditionsList.remove(arrayList2);
}
}
}
for (int size9 = this.mChangesList.size() - 1; size9 >= 0; size9--) {
ArrayList<ChangeInfo> arrayList3 = this.mChangesList.get(size9);
for (int size10 = arrayList3.size() - 1; size10 >= 0; size10--) {
endChangeAnimationIfNecessary(arrayList3.get(size10));
if (arrayList3.isEmpty()) {
this.mChangesList.remove(arrayList3);
}
}
}
cancelAll(this.mRemoveAnimations);
cancelAll(this.mMoveAnimations);
cancelAll(this.mAddAnimations);
cancelAll(this.mChangeAnimations);
dispatchAnimationsFinished();
}
}
public void cancelAll(List<RecyclerView.ViewHolder> list) {
for (int size = list.size() - 1; size >= 0; size--) {
list.get(size).itemView.animate().cancel();
}
}
@Override // androidx.recyclerview.widget.RecyclerView.ItemAnimator
public boolean canReuseUpdatedViewHolder(@NonNull RecyclerView.ViewHolder viewHolder, @NonNull List<Object> list) {
return !list.isEmpty() || super.canReuseUpdatedViewHolder(viewHolder, list);
}
}

View File

@@ -0,0 +1,517 @@
package androidx.recyclerview.widget;
import androidx.annotation.IntRange;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
/* loaded from: classes.dex */
public class DiffUtil {
private static final Comparator<Diagonal> DIAGONAL_COMPARATOR = new Comparator<Diagonal>() { // from class: androidx.recyclerview.widget.DiffUtil.1
@Override // java.util.Comparator
public int compare(Diagonal diagonal, Diagonal diagonal2) {
return diagonal.x - diagonal2.x;
}
};
public static abstract class Callback {
public abstract boolean areContentsTheSame(int i, int i2);
public abstract boolean areItemsTheSame(int i, int i2);
@Nullable
public Object getChangePayload(int i, int i2) {
return null;
}
public abstract int getNewListSize();
public abstract int getOldListSize();
}
public static abstract class ItemCallback<T> {
public abstract boolean areContentsTheSame(@NonNull T t, @NonNull T t2);
public abstract boolean areItemsTheSame(@NonNull T t, @NonNull T t2);
@Nullable
public Object getChangePayload(@NonNull T t, @NonNull T t2) {
return null;
}
}
private DiffUtil() {
}
@NonNull
public static DiffResult calculateDiff(@NonNull Callback callback) {
return calculateDiff(callback, true);
}
@NonNull
public static DiffResult calculateDiff(@NonNull Callback callback, boolean z) {
int oldListSize = callback.getOldListSize();
int newListSize = callback.getNewListSize();
ArrayList arrayList = new ArrayList();
ArrayList arrayList2 = new ArrayList();
arrayList2.add(new Range(0, oldListSize, 0, newListSize));
int i = ((((oldListSize + newListSize) + 1) / 2) * 2) + 1;
CenteredArray centeredArray = new CenteredArray(i);
CenteredArray centeredArray2 = new CenteredArray(i);
ArrayList arrayList3 = new ArrayList();
while (!arrayList2.isEmpty()) {
Range range = (Range) arrayList2.remove(arrayList2.size() - 1);
Snake midPoint = midPoint(range, callback, centeredArray, centeredArray2);
if (midPoint != null) {
if (midPoint.diagonalSize() > 0) {
arrayList.add(midPoint.toDiagonal());
}
Range range2 = arrayList3.isEmpty() ? new Range() : (Range) arrayList3.remove(arrayList3.size() - 1);
range2.oldListStart = range.oldListStart;
range2.newListStart = range.newListStart;
range2.oldListEnd = midPoint.startX;
range2.newListEnd = midPoint.startY;
arrayList2.add(range2);
range.oldListEnd = range.oldListEnd;
range.newListEnd = range.newListEnd;
range.oldListStart = midPoint.endX;
range.newListStart = midPoint.endY;
arrayList2.add(range);
} else {
arrayList3.add(range);
}
}
Collections.sort(arrayList, DIAGONAL_COMPARATOR);
return new DiffResult(callback, arrayList, centeredArray.backingData(), centeredArray2.backingData(), z);
}
@Nullable
private static Snake midPoint(Range range, Callback callback, CenteredArray centeredArray, CenteredArray centeredArray2) {
if (range.oldSize() >= 1 && range.newSize() >= 1) {
int oldSize = ((range.oldSize() + range.newSize()) + 1) / 2;
centeredArray.set(1, range.oldListStart);
centeredArray2.set(1, range.oldListEnd);
for (int i = 0; i < oldSize; i++) {
Snake forward = forward(range, callback, centeredArray, centeredArray2, i);
if (forward != null) {
return forward;
}
Snake backward = backward(range, callback, centeredArray, centeredArray2, i);
if (backward != null) {
return backward;
}
}
}
return null;
}
@Nullable
private static Snake forward(Range range, Callback callback, CenteredArray centeredArray, CenteredArray centeredArray2, int i) {
int i2;
int i3;
int i4;
boolean z = Math.abs(range.oldSize() - range.newSize()) % 2 == 1;
int oldSize = range.oldSize() - range.newSize();
int i5 = -i;
for (int i6 = i5; i6 <= i; i6 += 2) {
if (i6 == i5 || (i6 != i && centeredArray.get(i6 + 1) > centeredArray.get(i6 - 1))) {
i2 = centeredArray.get(i6 + 1);
i3 = i2;
} else {
i2 = centeredArray.get(i6 - 1);
i3 = i2 + 1;
}
int i7 = (range.newListStart + (i3 - range.oldListStart)) - i6;
int i8 = (i == 0 || i3 != i2) ? i7 : i7 - 1;
while (i3 < range.oldListEnd && i7 < range.newListEnd && callback.areItemsTheSame(i3, i7)) {
i3++;
i7++;
}
centeredArray.set(i6, i3);
if (z && (i4 = oldSize - i6) >= i5 + 1 && i4 <= i - 1 && centeredArray2.get(i4) <= i3) {
Snake snake = new Snake();
snake.startX = i2;
snake.startY = i8;
snake.endX = i3;
snake.endY = i7;
snake.reverse = false;
return snake;
}
}
return null;
}
@Nullable
private static Snake backward(Range range, Callback callback, CenteredArray centeredArray, CenteredArray centeredArray2, int i) {
int i2;
int i3;
int i4;
boolean z = (range.oldSize() - range.newSize()) % 2 == 0;
int oldSize = range.oldSize() - range.newSize();
int i5 = -i;
for (int i6 = i5; i6 <= i; i6 += 2) {
if (i6 == i5 || (i6 != i && centeredArray2.get(i6 + 1) < centeredArray2.get(i6 - 1))) {
i2 = centeredArray2.get(i6 + 1);
i3 = i2;
} else {
i2 = centeredArray2.get(i6 - 1);
i3 = i2 - 1;
}
int i7 = range.newListEnd - ((range.oldListEnd - i3) - i6);
int i8 = (i == 0 || i3 != i2) ? i7 : i7 + 1;
while (i3 > range.oldListStart && i7 > range.newListStart && callback.areItemsTheSame(i3 - 1, i7 - 1)) {
i3--;
i7--;
}
centeredArray2.set(i6, i3);
if (z && (i4 = oldSize - i6) >= i5 && i4 <= i && centeredArray.get(i4) >= i3) {
Snake snake = new Snake();
snake.startX = i3;
snake.startY = i7;
snake.endX = i2;
snake.endY = i8;
snake.reverse = true;
return snake;
}
}
return null;
}
public static class Diagonal {
public final int size;
public final int x;
public final int y;
public int endX() {
return this.x + this.size;
}
public int endY() {
return this.y + this.size;
}
public Diagonal(int i, int i2, int i3) {
this.x = i;
this.y = i2;
this.size = i3;
}
}
public static class Snake {
public int endX;
public int endY;
public boolean reverse;
public int startX;
public int startY;
public boolean hasAdditionOrRemoval() {
return this.endY - this.startY != this.endX - this.startX;
}
public boolean isAddition() {
return this.endY - this.startY > this.endX - this.startX;
}
public int diagonalSize() {
return Math.min(this.endX - this.startX, this.endY - this.startY);
}
@NonNull
public Diagonal toDiagonal() {
if (!hasAdditionOrRemoval()) {
int i = this.startX;
return new Diagonal(i, this.startY, this.endX - i);
}
if (this.reverse) {
return new Diagonal(this.startX, this.startY, diagonalSize());
}
if (isAddition()) {
return new Diagonal(this.startX, this.startY + 1, diagonalSize());
}
return new Diagonal(this.startX + 1, this.startY, diagonalSize());
}
}
public static class Range {
int newListEnd;
int newListStart;
int oldListEnd;
int oldListStart;
public int newSize() {
return this.newListEnd - this.newListStart;
}
public int oldSize() {
return this.oldListEnd - this.oldListStart;
}
public Range() {
}
public Range(int i, int i2, int i3, int i4) {
this.oldListStart = i;
this.oldListEnd = i2;
this.newListStart = i3;
this.newListEnd = i4;
}
}
public static class DiffResult {
private static final int FLAG_CHANGED = 2;
private static final int FLAG_MASK = 15;
private static final int FLAG_MOVED = 12;
private static final int FLAG_MOVED_CHANGED = 4;
private static final int FLAG_MOVED_NOT_CHANGED = 8;
private static final int FLAG_NOT_CHANGED = 1;
private static final int FLAG_OFFSET = 4;
public static final int NO_POSITION = -1;
private final Callback mCallback;
private final boolean mDetectMoves;
private final List<Diagonal> mDiagonals;
private final int[] mNewItemStatuses;
private final int mNewListSize;
private final int[] mOldItemStatuses;
private final int mOldListSize;
public DiffResult(Callback callback, List<Diagonal> list, int[] iArr, int[] iArr2, boolean z) {
this.mDiagonals = list;
this.mOldItemStatuses = iArr;
this.mNewItemStatuses = iArr2;
Arrays.fill(iArr, 0);
Arrays.fill(iArr2, 0);
this.mCallback = callback;
this.mOldListSize = callback.getOldListSize();
this.mNewListSize = callback.getNewListSize();
this.mDetectMoves = z;
addEdgeDiagonals();
findMatchingItems();
}
private void addEdgeDiagonals() {
Diagonal diagonal = this.mDiagonals.isEmpty() ? null : this.mDiagonals.get(0);
if (diagonal == null || diagonal.x != 0 || diagonal.y != 0) {
this.mDiagonals.add(0, new Diagonal(0, 0, 0));
}
this.mDiagonals.add(new Diagonal(this.mOldListSize, this.mNewListSize, 0));
}
private void findMatchingItems() {
for (Diagonal diagonal : this.mDiagonals) {
for (int i = 0; i < diagonal.size; i++) {
int i2 = diagonal.x + i;
int i3 = diagonal.y + i;
int i4 = this.mCallback.areContentsTheSame(i2, i3) ? 1 : 2;
this.mOldItemStatuses[i2] = (i3 << 4) | i4;
this.mNewItemStatuses[i3] = (i2 << 4) | i4;
}
}
if (this.mDetectMoves) {
findMoveMatches();
}
}
private void findMoveMatches() {
int i = 0;
for (Diagonal diagonal : this.mDiagonals) {
while (i < diagonal.x) {
if (this.mOldItemStatuses[i] == 0) {
findMatchingAddition(i);
}
i++;
}
i = diagonal.endX();
}
}
private void findMatchingAddition(int i) {
int size = this.mDiagonals.size();
int i2 = 0;
for (int i3 = 0; i3 < size; i3++) {
Diagonal diagonal = this.mDiagonals.get(i3);
while (i2 < diagonal.y) {
if (this.mNewItemStatuses[i2] == 0 && this.mCallback.areItemsTheSame(i, i2)) {
int i4 = this.mCallback.areContentsTheSame(i, i2) ? 8 : 4;
this.mOldItemStatuses[i] = (i2 << 4) | i4;
this.mNewItemStatuses[i2] = (i << 4) | i4;
return;
}
i2++;
}
i2 = diagonal.endY();
}
}
public int convertOldPositionToNew(@IntRange(from = 0) int i) {
if (i < 0 || i >= this.mOldListSize) {
throw new IndexOutOfBoundsException("Index out of bounds - passed position = " + i + ", old list size = " + this.mOldListSize);
}
int i2 = this.mOldItemStatuses[i];
if ((i2 & 15) == 0) {
return -1;
}
return i2 >> 4;
}
public int convertNewPositionToOld(@IntRange(from = 0) int i) {
if (i < 0 || i >= this.mNewListSize) {
throw new IndexOutOfBoundsException("Index out of bounds - passed position = " + i + ", new list size = " + this.mNewListSize);
}
int i2 = this.mNewItemStatuses[i];
if ((i2 & 15) == 0) {
return -1;
}
return i2 >> 4;
}
public void dispatchUpdatesTo(@NonNull RecyclerView.Adapter adapter) {
dispatchUpdatesTo(new AdapterListUpdateCallback(adapter));
}
public void dispatchUpdatesTo(@NonNull ListUpdateCallback listUpdateCallback) {
BatchingListUpdateCallback batchingListUpdateCallback;
int i;
if (listUpdateCallback instanceof BatchingListUpdateCallback) {
batchingListUpdateCallback = (BatchingListUpdateCallback) listUpdateCallback;
} else {
batchingListUpdateCallback = new BatchingListUpdateCallback(listUpdateCallback);
}
int i2 = this.mOldListSize;
ArrayDeque arrayDeque = new ArrayDeque();
int i3 = this.mOldListSize;
int i4 = this.mNewListSize;
for (int size = this.mDiagonals.size() - 1; size >= 0; size--) {
Diagonal diagonal = this.mDiagonals.get(size);
int endX = diagonal.endX();
int endY = diagonal.endY();
while (true) {
if (i3 <= endX) {
break;
}
i3--;
int i5 = this.mOldItemStatuses[i3];
if ((i5 & 12) != 0) {
int i6 = i5 >> 4;
PostponedUpdate postponedUpdate = getPostponedUpdate(arrayDeque, i6, false);
if (postponedUpdate != null) {
int i7 = (i2 - postponedUpdate.currentPos) - 1;
batchingListUpdateCallback.onMoved(i3, i7);
if ((i5 & 4) != 0) {
batchingListUpdateCallback.onChanged(i7, 1, this.mCallback.getChangePayload(i3, i6));
}
} else {
arrayDeque.add(new PostponedUpdate(i3, (i2 - i3) - 1, true));
}
} else {
batchingListUpdateCallback.onRemoved(i3, 1);
i2--;
}
}
while (i4 > endY) {
i4--;
int i8 = this.mNewItemStatuses[i4];
if ((i8 & 12) != 0) {
int i9 = i8 >> 4;
PostponedUpdate postponedUpdate2 = getPostponedUpdate(arrayDeque, i9, true);
if (postponedUpdate2 == null) {
arrayDeque.add(new PostponedUpdate(i4, i2 - i3, false));
} else {
batchingListUpdateCallback.onMoved((i2 - postponedUpdate2.currentPos) - 1, i3);
if ((i8 & 4) != 0) {
batchingListUpdateCallback.onChanged(i3, 1, this.mCallback.getChangePayload(i9, i4));
}
}
} else {
batchingListUpdateCallback.onInserted(i3, 1);
i2++;
}
}
int i10 = diagonal.x;
int i11 = diagonal.y;
for (i = 0; i < diagonal.size; i++) {
if ((this.mOldItemStatuses[i10] & 15) == 2) {
batchingListUpdateCallback.onChanged(i10, 1, this.mCallback.getChangePayload(i10, i11));
}
i10++;
i11++;
}
i3 = diagonal.x;
i4 = diagonal.y;
}
batchingListUpdateCallback.dispatchLastEvent();
}
@Nullable
private static PostponedUpdate getPostponedUpdate(Collection<PostponedUpdate> collection, int i, boolean z) {
PostponedUpdate postponedUpdate;
Iterator<PostponedUpdate> it = collection.iterator();
while (true) {
if (!it.hasNext()) {
postponedUpdate = null;
break;
}
postponedUpdate = it.next();
if (postponedUpdate.posInOwnerList == i && postponedUpdate.removal == z) {
it.remove();
break;
}
}
while (it.hasNext()) {
PostponedUpdate next = it.next();
if (z) {
next.currentPos--;
} else {
next.currentPos++;
}
}
return postponedUpdate;
}
}
public static class PostponedUpdate {
int currentPos;
int posInOwnerList;
boolean removal;
public PostponedUpdate(int i, int i2, boolean z) {
this.posInOwnerList = i;
this.currentPos = i2;
this.removal = z;
}
}
public static class CenteredArray {
private final int[] mData;
private final int mMid;
public int[] backingData() {
return this.mData;
}
public CenteredArray(int i) {
int[] iArr = new int[i];
this.mData = iArr;
this.mMid = iArr.length / 2;
}
public int get(int i) {
return this.mData[i + this.mMid];
}
public void set(int i, int i2) {
this.mData[i + this.mMid] = i2;
}
public void fill(int i) {
Arrays.fill(this.mData, i);
}
}
}

View File

@@ -0,0 +1,124 @@
package androidx.recyclerview.widget;
import android.R;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.util.Log;
import android.view.View;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView;
/* loaded from: classes.dex */
public class DividerItemDecoration extends RecyclerView.ItemDecoration {
private static final int[] ATTRS = {R.attr.listDivider};
public static final int HORIZONTAL = 0;
private static final String TAG = "DividerItem";
public static final int VERTICAL = 1;
private final Rect mBounds = new Rect();
private Drawable mDivider;
private int mOrientation;
@Nullable
public Drawable getDrawable() {
return this.mDivider;
}
public DividerItemDecoration(Context context, int i) {
TypedArray obtainStyledAttributes = context.obtainStyledAttributes(ATTRS);
Drawable drawable = obtainStyledAttributes.getDrawable(0);
this.mDivider = drawable;
if (drawable == null) {
Log.w(TAG, "@android:attr/listDivider was not set in the theme used for this DividerItemDecoration. Please set that attribute all call setDrawable()");
}
obtainStyledAttributes.recycle();
setOrientation(i);
}
public void setOrientation(int i) {
if (i != 0 && i != 1) {
throw new IllegalArgumentException("Invalid orientation. It should be either HORIZONTAL or VERTICAL");
}
this.mOrientation = i;
}
public void setDrawable(@NonNull Drawable drawable) {
if (drawable == null) {
throw new IllegalArgumentException("Drawable cannot be null.");
}
this.mDivider = drawable;
}
@Override // androidx.recyclerview.widget.RecyclerView.ItemDecoration
public void onDraw(Canvas canvas, RecyclerView recyclerView, RecyclerView.State state) {
if (recyclerView.getLayoutManager() == null || this.mDivider == null) {
return;
}
if (this.mOrientation == 1) {
drawVertical(canvas, recyclerView);
} else {
drawHorizontal(canvas, recyclerView);
}
}
private void drawVertical(Canvas canvas, RecyclerView recyclerView) {
int width;
int i;
canvas.save();
if (recyclerView.getClipToPadding()) {
i = recyclerView.getPaddingLeft();
width = recyclerView.getWidth() - recyclerView.getPaddingRight();
canvas.clipRect(i, recyclerView.getPaddingTop(), width, recyclerView.getHeight() - recyclerView.getPaddingBottom());
} else {
width = recyclerView.getWidth();
i = 0;
}
int childCount = recyclerView.getChildCount();
for (int i2 = 0; i2 < childCount; i2++) {
View childAt = recyclerView.getChildAt(i2);
recyclerView.getDecoratedBoundsWithMargins(childAt, this.mBounds);
int round = this.mBounds.bottom + Math.round(childAt.getTranslationY());
this.mDivider.setBounds(i, round - this.mDivider.getIntrinsicHeight(), width, round);
this.mDivider.draw(canvas);
}
canvas.restore();
}
private void drawHorizontal(Canvas canvas, RecyclerView recyclerView) {
int height;
int i;
canvas.save();
if (recyclerView.getClipToPadding()) {
i = recyclerView.getPaddingTop();
height = recyclerView.getHeight() - recyclerView.getPaddingBottom();
canvas.clipRect(recyclerView.getPaddingLeft(), i, recyclerView.getWidth() - recyclerView.getPaddingRight(), height);
} else {
height = recyclerView.getHeight();
i = 0;
}
int childCount = recyclerView.getChildCount();
for (int i2 = 0; i2 < childCount; i2++) {
View childAt = recyclerView.getChildAt(i2);
recyclerView.getLayoutManager().getDecoratedBoundsWithMargins(childAt, this.mBounds);
int round = this.mBounds.right + Math.round(childAt.getTranslationX());
this.mDivider.setBounds(round - this.mDivider.getIntrinsicWidth(), i, round, height);
this.mDivider.draw(canvas);
}
canvas.restore();
}
@Override // androidx.recyclerview.widget.RecyclerView.ItemDecoration
public void getItemOffsets(Rect rect, View view, RecyclerView recyclerView, RecyclerView.State state) {
Drawable drawable = this.mDivider;
if (drawable == null) {
rect.set(0, 0, 0, 0);
} else if (this.mOrientation == 1) {
rect.set(0, 0, 0, drawable.getIntrinsicHeight());
} else {
rect.set(0, 0, drawable.getIntrinsicWidth(), 0);
}
}
}

View File

@@ -0,0 +1,513 @@
package androidx.recyclerview.widget;
import android.R;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ValueAnimator;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.StateListDrawable;
import android.view.MotionEvent;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import androidx.core.view.ViewCompat;
import androidx.recyclerview.widget.RecyclerView;
@VisibleForTesting
/* loaded from: classes.dex */
class FastScroller extends RecyclerView.ItemDecoration implements RecyclerView.OnItemTouchListener {
private static final int ANIMATION_STATE_FADING_IN = 1;
private static final int ANIMATION_STATE_FADING_OUT = 3;
private static final int ANIMATION_STATE_IN = 2;
private static final int ANIMATION_STATE_OUT = 0;
private static final int DRAG_NONE = 0;
private static final int DRAG_X = 1;
private static final int DRAG_Y = 2;
private static final int HIDE_DELAY_AFTER_DRAGGING_MS = 1200;
private static final int HIDE_DELAY_AFTER_VISIBLE_MS = 1500;
private static final int HIDE_DURATION_MS = 500;
private static final int SCROLLBAR_FULL_OPAQUE = 255;
private static final int SHOW_DURATION_MS = 500;
private static final int STATE_DRAGGING = 2;
private static final int STATE_HIDDEN = 0;
private static final int STATE_VISIBLE = 1;
int mAnimationState;
private final Runnable mHideRunnable;
@VisibleForTesting
float mHorizontalDragX;
@VisibleForTesting
int mHorizontalThumbCenterX;
private final StateListDrawable mHorizontalThumbDrawable;
private final int mHorizontalThumbHeight;
@VisibleForTesting
int mHorizontalThumbWidth;
private final Drawable mHorizontalTrackDrawable;
private final int mHorizontalTrackHeight;
private final int mMargin;
private final RecyclerView.OnScrollListener mOnScrollListener;
private RecyclerView mRecyclerView;
private final int mScrollbarMinimumRange;
final ValueAnimator mShowHideAnimator;
@VisibleForTesting
float mVerticalDragY;
@VisibleForTesting
int mVerticalThumbCenterY;
final StateListDrawable mVerticalThumbDrawable;
@VisibleForTesting
int mVerticalThumbHeight;
private final int mVerticalThumbWidth;
final Drawable mVerticalTrackDrawable;
private final int mVerticalTrackWidth;
private static final int[] PRESSED_STATE_SET = {R.attr.state_pressed};
private static final int[] EMPTY_STATE_SET = new int[0];
private int mRecyclerViewWidth = 0;
private int mRecyclerViewHeight = 0;
private boolean mNeedVerticalScrollbar = false;
private boolean mNeedHorizontalScrollbar = false;
private int mState = 0;
private int mDragState = 0;
private final int[] mVerticalRange = new int[2];
private final int[] mHorizontalRange = new int[2];
@VisibleForTesting
public Drawable getHorizontalThumbDrawable() {
return this.mHorizontalThumbDrawable;
}
@VisibleForTesting
public Drawable getHorizontalTrackDrawable() {
return this.mHorizontalTrackDrawable;
}
@VisibleForTesting
public Drawable getVerticalThumbDrawable() {
return this.mVerticalThumbDrawable;
}
@VisibleForTesting
public Drawable getVerticalTrackDrawable() {
return this.mVerticalTrackDrawable;
}
public boolean isDragging() {
return this.mState == 2;
}
@VisibleForTesting
public boolean isVisible() {
return this.mState == 1;
}
@Override // androidx.recyclerview.widget.RecyclerView.OnItemTouchListener
public void onRequestDisallowInterceptTouchEvent(boolean z) {
}
public FastScroller(RecyclerView recyclerView, StateListDrawable stateListDrawable, Drawable drawable, StateListDrawable stateListDrawable2, Drawable drawable2, int i, int i2, int i3) {
ValueAnimator ofFloat = ValueAnimator.ofFloat(0.0f, 1.0f);
this.mShowHideAnimator = ofFloat;
this.mAnimationState = 0;
this.mHideRunnable = new Runnable() { // from class: androidx.recyclerview.widget.FastScroller.1
@Override // java.lang.Runnable
public void run() {
FastScroller.this.hide(500);
}
};
this.mOnScrollListener = new RecyclerView.OnScrollListener() { // from class: androidx.recyclerview.widget.FastScroller.2
@Override // androidx.recyclerview.widget.RecyclerView.OnScrollListener
public void onScrolled(RecyclerView recyclerView2, int i4, int i5) {
FastScroller.this.updateScrollPosition(recyclerView2.computeHorizontalScrollOffset(), recyclerView2.computeVerticalScrollOffset());
}
};
this.mVerticalThumbDrawable = stateListDrawable;
this.mVerticalTrackDrawable = drawable;
this.mHorizontalThumbDrawable = stateListDrawable2;
this.mHorizontalTrackDrawable = drawable2;
this.mVerticalThumbWidth = Math.max(i, stateListDrawable.getIntrinsicWidth());
this.mVerticalTrackWidth = Math.max(i, drawable.getIntrinsicWidth());
this.mHorizontalThumbHeight = Math.max(i, stateListDrawable2.getIntrinsicWidth());
this.mHorizontalTrackHeight = Math.max(i, drawable2.getIntrinsicWidth());
this.mScrollbarMinimumRange = i2;
this.mMargin = i3;
stateListDrawable.setAlpha(255);
drawable.setAlpha(255);
ofFloat.addListener(new AnimatorListener());
ofFloat.addUpdateListener(new AnimatorUpdater());
attachToRecyclerView(recyclerView);
}
public void attachToRecyclerView(@Nullable RecyclerView recyclerView) {
RecyclerView recyclerView2 = this.mRecyclerView;
if (recyclerView2 == recyclerView) {
return;
}
if (recyclerView2 != null) {
destroyCallbacks();
}
this.mRecyclerView = recyclerView;
if (recyclerView != null) {
setupCallbacks();
}
}
private void setupCallbacks() {
this.mRecyclerView.addItemDecoration(this);
this.mRecyclerView.addOnItemTouchListener(this);
this.mRecyclerView.addOnScrollListener(this.mOnScrollListener);
}
private void destroyCallbacks() {
this.mRecyclerView.removeItemDecoration(this);
this.mRecyclerView.removeOnItemTouchListener(this);
this.mRecyclerView.removeOnScrollListener(this.mOnScrollListener);
cancelHide();
}
public void requestRedraw() {
this.mRecyclerView.invalidate();
}
public void setState(int i) {
if (i == 2 && this.mState != 2) {
this.mVerticalThumbDrawable.setState(PRESSED_STATE_SET);
cancelHide();
}
if (i == 0) {
requestRedraw();
} else {
show();
}
if (this.mState == 2 && i != 2) {
this.mVerticalThumbDrawable.setState(EMPTY_STATE_SET);
resetHideDelay(1200);
} else if (i == 1) {
resetHideDelay(1500);
}
this.mState = i;
}
private boolean isLayoutRTL() {
return ViewCompat.getLayoutDirection(this.mRecyclerView) == 1;
}
public void show() {
int i = this.mAnimationState;
if (i != 0) {
if (i != 3) {
return;
} else {
this.mShowHideAnimator.cancel();
}
}
this.mAnimationState = 1;
ValueAnimator valueAnimator = this.mShowHideAnimator;
valueAnimator.setFloatValues(((Float) valueAnimator.getAnimatedValue()).floatValue(), 1.0f);
this.mShowHideAnimator.setDuration(500L);
this.mShowHideAnimator.setStartDelay(0L);
this.mShowHideAnimator.start();
}
@VisibleForTesting
public void hide(int i) {
int i2 = this.mAnimationState;
if (i2 == 1) {
this.mShowHideAnimator.cancel();
} else if (i2 != 2) {
return;
}
this.mAnimationState = 3;
ValueAnimator valueAnimator = this.mShowHideAnimator;
valueAnimator.setFloatValues(((Float) valueAnimator.getAnimatedValue()).floatValue(), 0.0f);
this.mShowHideAnimator.setDuration(i);
this.mShowHideAnimator.start();
}
private void cancelHide() {
this.mRecyclerView.removeCallbacks(this.mHideRunnable);
}
private void resetHideDelay(int i) {
cancelHide();
this.mRecyclerView.postDelayed(this.mHideRunnable, i);
}
@Override // androidx.recyclerview.widget.RecyclerView.ItemDecoration
public void onDrawOver(Canvas canvas, RecyclerView recyclerView, RecyclerView.State state) {
if (this.mRecyclerViewWidth != this.mRecyclerView.getWidth() || this.mRecyclerViewHeight != this.mRecyclerView.getHeight()) {
this.mRecyclerViewWidth = this.mRecyclerView.getWidth();
this.mRecyclerViewHeight = this.mRecyclerView.getHeight();
setState(0);
} else if (this.mAnimationState != 0) {
if (this.mNeedVerticalScrollbar) {
drawVerticalScrollbar(canvas);
}
if (this.mNeedHorizontalScrollbar) {
drawHorizontalScrollbar(canvas);
}
}
}
private void drawVerticalScrollbar(Canvas canvas) {
int i = this.mRecyclerViewWidth;
int i2 = this.mVerticalThumbWidth;
int i3 = i - i2;
int i4 = this.mVerticalThumbCenterY;
int i5 = this.mVerticalThumbHeight;
int i6 = i4 - (i5 / 2);
this.mVerticalThumbDrawable.setBounds(0, 0, i2, i5);
this.mVerticalTrackDrawable.setBounds(0, 0, this.mVerticalTrackWidth, this.mRecyclerViewHeight);
if (isLayoutRTL()) {
this.mVerticalTrackDrawable.draw(canvas);
canvas.translate(this.mVerticalThumbWidth, i6);
canvas.scale(-1.0f, 1.0f);
this.mVerticalThumbDrawable.draw(canvas);
canvas.scale(-1.0f, 1.0f);
canvas.translate(-this.mVerticalThumbWidth, -i6);
return;
}
canvas.translate(i3, 0.0f);
this.mVerticalTrackDrawable.draw(canvas);
canvas.translate(0.0f, i6);
this.mVerticalThumbDrawable.draw(canvas);
canvas.translate(-i3, -i6);
}
private void drawHorizontalScrollbar(Canvas canvas) {
int i = this.mRecyclerViewHeight;
int i2 = this.mHorizontalThumbHeight;
int i3 = this.mHorizontalThumbCenterX;
int i4 = this.mHorizontalThumbWidth;
this.mHorizontalThumbDrawable.setBounds(0, 0, i4, i2);
this.mHorizontalTrackDrawable.setBounds(0, 0, this.mRecyclerViewWidth, this.mHorizontalTrackHeight);
canvas.translate(0.0f, i - i2);
this.mHorizontalTrackDrawable.draw(canvas);
canvas.translate(i3 - (i4 / 2), 0.0f);
this.mHorizontalThumbDrawable.draw(canvas);
canvas.translate(-r2, -r0);
}
public void updateScrollPosition(int i, int i2) {
int computeVerticalScrollRange = this.mRecyclerView.computeVerticalScrollRange();
int i3 = this.mRecyclerViewHeight;
this.mNeedVerticalScrollbar = computeVerticalScrollRange - i3 > 0 && i3 >= this.mScrollbarMinimumRange;
int computeHorizontalScrollRange = this.mRecyclerView.computeHorizontalScrollRange();
int i4 = this.mRecyclerViewWidth;
boolean z = computeHorizontalScrollRange - i4 > 0 && i4 >= this.mScrollbarMinimumRange;
this.mNeedHorizontalScrollbar = z;
boolean z2 = this.mNeedVerticalScrollbar;
if (!z2 && !z) {
if (this.mState != 0) {
setState(0);
return;
}
return;
}
if (z2) {
float f = i3;
this.mVerticalThumbCenterY = (int) ((f * (i2 + (f / 2.0f))) / computeVerticalScrollRange);
this.mVerticalThumbHeight = Math.min(i3, (i3 * i3) / computeVerticalScrollRange);
}
if (this.mNeedHorizontalScrollbar) {
float f2 = i4;
this.mHorizontalThumbCenterX = (int) ((f2 * (i + (f2 / 2.0f))) / computeHorizontalScrollRange);
this.mHorizontalThumbWidth = Math.min(i4, (i4 * i4) / computeHorizontalScrollRange);
}
int i5 = this.mState;
if (i5 == 0 || i5 == 1) {
setState(1);
}
}
@Override // androidx.recyclerview.widget.RecyclerView.OnItemTouchListener
public boolean onInterceptTouchEvent(@NonNull RecyclerView recyclerView, @NonNull MotionEvent motionEvent) {
int i = this.mState;
if (i == 1) {
boolean isPointInsideVerticalThumb = isPointInsideVerticalThumb(motionEvent.getX(), motionEvent.getY());
boolean isPointInsideHorizontalThumb = isPointInsideHorizontalThumb(motionEvent.getX(), motionEvent.getY());
if (motionEvent.getAction() != 0) {
return false;
}
if (!isPointInsideVerticalThumb && !isPointInsideHorizontalThumb) {
return false;
}
if (isPointInsideHorizontalThumb) {
this.mDragState = 1;
this.mHorizontalDragX = (int) motionEvent.getX();
} else if (isPointInsideVerticalThumb) {
this.mDragState = 2;
this.mVerticalDragY = (int) motionEvent.getY();
}
setState(2);
} else if (i != 2) {
return false;
}
return true;
}
@Override // androidx.recyclerview.widget.RecyclerView.OnItemTouchListener
public void onTouchEvent(@NonNull RecyclerView recyclerView, @NonNull MotionEvent motionEvent) {
if (this.mState == 0) {
return;
}
if (motionEvent.getAction() == 0) {
boolean isPointInsideVerticalThumb = isPointInsideVerticalThumb(motionEvent.getX(), motionEvent.getY());
boolean isPointInsideHorizontalThumb = isPointInsideHorizontalThumb(motionEvent.getX(), motionEvent.getY());
if (isPointInsideVerticalThumb || isPointInsideHorizontalThumb) {
if (isPointInsideHorizontalThumb) {
this.mDragState = 1;
this.mHorizontalDragX = (int) motionEvent.getX();
} else if (isPointInsideVerticalThumb) {
this.mDragState = 2;
this.mVerticalDragY = (int) motionEvent.getY();
}
setState(2);
return;
}
return;
}
if (motionEvent.getAction() == 1 && this.mState == 2) {
this.mVerticalDragY = 0.0f;
this.mHorizontalDragX = 0.0f;
setState(1);
this.mDragState = 0;
return;
}
if (motionEvent.getAction() == 2 && this.mState == 2) {
show();
if (this.mDragState == 1) {
horizontalScrollTo(motionEvent.getX());
}
if (this.mDragState == 2) {
verticalScrollTo(motionEvent.getY());
}
}
}
private void verticalScrollTo(float f) {
int[] verticalRange = getVerticalRange();
float max = Math.max(verticalRange[0], Math.min(verticalRange[1], f));
if (Math.abs(this.mVerticalThumbCenterY - max) < 2.0f) {
return;
}
int scrollTo = scrollTo(this.mVerticalDragY, max, verticalRange, this.mRecyclerView.computeVerticalScrollRange(), this.mRecyclerView.computeVerticalScrollOffset(), this.mRecyclerViewHeight);
if (scrollTo != 0) {
this.mRecyclerView.scrollBy(0, scrollTo);
}
this.mVerticalDragY = max;
}
private void horizontalScrollTo(float f) {
int[] horizontalRange = getHorizontalRange();
float max = Math.max(horizontalRange[0], Math.min(horizontalRange[1], f));
if (Math.abs(this.mHorizontalThumbCenterX - max) < 2.0f) {
return;
}
int scrollTo = scrollTo(this.mHorizontalDragX, max, horizontalRange, this.mRecyclerView.computeHorizontalScrollRange(), this.mRecyclerView.computeHorizontalScrollOffset(), this.mRecyclerViewWidth);
if (scrollTo != 0) {
this.mRecyclerView.scrollBy(scrollTo, 0);
}
this.mHorizontalDragX = max;
}
private int scrollTo(float f, float f2, int[] iArr, int i, int i2, int i3) {
int i4 = iArr[1] - iArr[0];
if (i4 == 0) {
return 0;
}
int i5 = i - i3;
int i6 = (int) (((f2 - f) / i4) * i5);
int i7 = i2 + i6;
if (i7 >= i5 || i7 < 0) {
return 0;
}
return i6;
}
@VisibleForTesting
public boolean isPointInsideVerticalThumb(float f, float f2) {
if (!isLayoutRTL() ? f >= this.mRecyclerViewWidth - this.mVerticalThumbWidth : f <= this.mVerticalThumbWidth) {
int i = this.mVerticalThumbCenterY;
int i2 = this.mVerticalThumbHeight;
if (f2 >= i - (i2 / 2) && f2 <= i + (i2 / 2)) {
return true;
}
}
return false;
}
@VisibleForTesting
public boolean isPointInsideHorizontalThumb(float f, float f2) {
if (f2 >= this.mRecyclerViewHeight - this.mHorizontalThumbHeight) {
int i = this.mHorizontalThumbCenterX;
int i2 = this.mHorizontalThumbWidth;
if (f >= i - (i2 / 2) && f <= i + (i2 / 2)) {
return true;
}
}
return false;
}
private int[] getVerticalRange() {
int[] iArr = this.mVerticalRange;
int i = this.mMargin;
iArr[0] = i;
iArr[1] = this.mRecyclerViewHeight - i;
return iArr;
}
private int[] getHorizontalRange() {
int[] iArr = this.mHorizontalRange;
int i = this.mMargin;
iArr[0] = i;
iArr[1] = this.mRecyclerViewWidth - i;
return iArr;
}
public class AnimatorListener extends AnimatorListenerAdapter {
private boolean mCanceled = false;
@Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
public void onAnimationCancel(Animator animator) {
this.mCanceled = true;
}
public AnimatorListener() {
}
@Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
public void onAnimationEnd(Animator animator) {
if (this.mCanceled) {
this.mCanceled = false;
return;
}
if (((Float) FastScroller.this.mShowHideAnimator.getAnimatedValue()).floatValue() == 0.0f) {
FastScroller fastScroller = FastScroller.this;
fastScroller.mAnimationState = 0;
fastScroller.setState(0);
} else {
FastScroller fastScroller2 = FastScroller.this;
fastScroller2.mAnimationState = 2;
fastScroller2.requestRedraw();
}
}
}
public class AnimatorUpdater implements ValueAnimator.AnimatorUpdateListener {
public AnimatorUpdater() {
}
@Override // android.animation.ValueAnimator.AnimatorUpdateListener
public void onAnimationUpdate(ValueAnimator valueAnimator) {
int floatValue = (int) (((Float) valueAnimator.getAnimatedValue()).floatValue() * 255.0f);
FastScroller.this.mVerticalThumbDrawable.setAlpha(floatValue);
FastScroller.this.mVerticalTrackDrawable.setAlpha(floatValue);
FastScroller.this.requestRedraw();
}
}
}

View File

@@ -0,0 +1,302 @@
package androidx.recyclerview.widget;
import android.annotation.SuppressLint;
import androidx.annotation.Nullable;
import androidx.core.os.TraceCompat;
import androidx.recyclerview.widget.RecyclerView;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.concurrent.TimeUnit;
/* loaded from: classes.dex */
final class GapWorker implements Runnable {
static final ThreadLocal<GapWorker> sGapWorker = new ThreadLocal<>();
static Comparator<Task> sTaskComparator = new Comparator<Task>() { // from class: androidx.recyclerview.widget.GapWorker.1
@Override // java.util.Comparator
public int compare(Task task, Task task2) {
RecyclerView recyclerView = task.view;
if ((recyclerView == null) != (task2.view == null)) {
return recyclerView == null ? 1 : -1;
}
boolean z = task.immediate;
if (z != task2.immediate) {
return z ? -1 : 1;
}
int i = task2.viewVelocity - task.viewVelocity;
if (i != 0) {
return i;
}
int i2 = task.distanceToItem - task2.distanceToItem;
if (i2 != 0) {
return i2;
}
return 0;
}
};
long mFrameIntervalNs;
long mPostTimeNs;
ArrayList<RecyclerView> mRecyclerViews = new ArrayList<>();
private ArrayList<Task> mTasks = new ArrayList<>();
public static class Task {
public int distanceToItem;
public boolean immediate;
public int position;
public RecyclerView view;
public int viewVelocity;
public void clear() {
this.immediate = false;
this.viewVelocity = 0;
this.distanceToItem = 0;
this.view = null;
this.position = 0;
}
}
@SuppressLint({"VisibleForTests"})
public static class LayoutPrefetchRegistryImpl implements RecyclerView.LayoutManager.LayoutPrefetchRegistry {
int mCount;
int[] mPrefetchArray;
int mPrefetchDx;
int mPrefetchDy;
public void setPrefetchVector(int i, int i2) {
this.mPrefetchDx = i;
this.mPrefetchDy = i2;
}
public void collectPrefetchPositionsFromView(RecyclerView recyclerView, boolean z) {
this.mCount = 0;
int[] iArr = this.mPrefetchArray;
if (iArr != null) {
Arrays.fill(iArr, -1);
}
RecyclerView.LayoutManager layoutManager = recyclerView.mLayout;
if (recyclerView.mAdapter == null || layoutManager == null || !layoutManager.isItemPrefetchEnabled()) {
return;
}
if (z) {
if (!recyclerView.mAdapterHelper.hasPendingUpdates()) {
layoutManager.collectInitialPrefetchPositions(recyclerView.mAdapter.getItemCount(), this);
}
} else if (!recyclerView.hasPendingAdapterUpdates()) {
layoutManager.collectAdjacentPrefetchPositions(this.mPrefetchDx, this.mPrefetchDy, recyclerView.mState, this);
}
int i = this.mCount;
if (i > layoutManager.mPrefetchMaxCountObserved) {
layoutManager.mPrefetchMaxCountObserved = i;
layoutManager.mPrefetchMaxObservedInInitialPrefetch = z;
recyclerView.mRecycler.updateViewCacheSize();
}
}
@Override // androidx.recyclerview.widget.RecyclerView.LayoutManager.LayoutPrefetchRegistry
public void addPosition(int i, int i2) {
if (i < 0) {
throw new IllegalArgumentException("Layout positions must be non-negative");
}
if (i2 < 0) {
throw new IllegalArgumentException("Pixel distance must be non-negative");
}
int i3 = this.mCount;
int i4 = i3 * 2;
int[] iArr = this.mPrefetchArray;
if (iArr == null) {
int[] iArr2 = new int[4];
this.mPrefetchArray = iArr2;
Arrays.fill(iArr2, -1);
} else if (i4 >= iArr.length) {
int[] iArr3 = new int[i3 * 4];
this.mPrefetchArray = iArr3;
System.arraycopy(iArr, 0, iArr3, 0, iArr.length);
}
int[] iArr4 = this.mPrefetchArray;
iArr4[i4] = i;
iArr4[i4 + 1] = i2;
this.mCount++;
}
public boolean lastPrefetchIncludedPosition(int i) {
if (this.mPrefetchArray != null) {
int i2 = this.mCount * 2;
for (int i3 = 0; i3 < i2; i3 += 2) {
if (this.mPrefetchArray[i3] == i) {
return true;
}
}
}
return false;
}
public void clearPrefetchPositions() {
int[] iArr = this.mPrefetchArray;
if (iArr != null) {
Arrays.fill(iArr, -1);
}
this.mCount = 0;
}
}
public void add(RecyclerView recyclerView) {
this.mRecyclerViews.add(recyclerView);
}
public void remove(RecyclerView recyclerView) {
this.mRecyclerViews.remove(recyclerView);
}
public void postFromTraversal(RecyclerView recyclerView, int i, int i2) {
if (recyclerView.isAttachedToWindow() && this.mPostTimeNs == 0) {
this.mPostTimeNs = recyclerView.getNanoTime();
recyclerView.post(this);
}
recyclerView.mPrefetchRegistry.setPrefetchVector(i, i2);
}
private void buildTaskList() {
Task task;
int size = this.mRecyclerViews.size();
int i = 0;
for (int i2 = 0; i2 < size; i2++) {
RecyclerView recyclerView = this.mRecyclerViews.get(i2);
if (recyclerView.getWindowVisibility() == 0) {
recyclerView.mPrefetchRegistry.collectPrefetchPositionsFromView(recyclerView, false);
i += recyclerView.mPrefetchRegistry.mCount;
}
}
this.mTasks.ensureCapacity(i);
int i3 = 0;
for (int i4 = 0; i4 < size; i4++) {
RecyclerView recyclerView2 = this.mRecyclerViews.get(i4);
if (recyclerView2.getWindowVisibility() == 0) {
LayoutPrefetchRegistryImpl layoutPrefetchRegistryImpl = recyclerView2.mPrefetchRegistry;
int abs = Math.abs(layoutPrefetchRegistryImpl.mPrefetchDx) + Math.abs(layoutPrefetchRegistryImpl.mPrefetchDy);
for (int i5 = 0; i5 < layoutPrefetchRegistryImpl.mCount * 2; i5 += 2) {
if (i3 >= this.mTasks.size()) {
task = new Task();
this.mTasks.add(task);
} else {
task = this.mTasks.get(i3);
}
int[] iArr = layoutPrefetchRegistryImpl.mPrefetchArray;
int i6 = iArr[i5 + 1];
task.immediate = i6 <= abs;
task.viewVelocity = abs;
task.distanceToItem = i6;
task.view = recyclerView2;
task.position = iArr[i5];
i3++;
}
}
}
Collections.sort(this.mTasks, sTaskComparator);
}
public static boolean isPrefetchPositionAttached(RecyclerView recyclerView, int i) {
int unfilteredChildCount = recyclerView.mChildHelper.getUnfilteredChildCount();
for (int i2 = 0; i2 < unfilteredChildCount; i2++) {
RecyclerView.ViewHolder childViewHolderInt = RecyclerView.getChildViewHolderInt(recyclerView.mChildHelper.getUnfilteredChildAt(i2));
if (childViewHolderInt.mPosition == i && !childViewHolderInt.isInvalid()) {
return true;
}
}
return false;
}
private RecyclerView.ViewHolder prefetchPositionWithDeadline(RecyclerView recyclerView, int i, long j) {
if (isPrefetchPositionAttached(recyclerView, i)) {
return null;
}
RecyclerView.Recycler recycler = recyclerView.mRecycler;
try {
recyclerView.onEnterLayoutOrScroll();
RecyclerView.ViewHolder tryGetViewHolderForPositionByDeadline = recycler.tryGetViewHolderForPositionByDeadline(i, false, j);
if (tryGetViewHolderForPositionByDeadline != null) {
if (tryGetViewHolderForPositionByDeadline.isBound() && !tryGetViewHolderForPositionByDeadline.isInvalid()) {
recycler.recycleView(tryGetViewHolderForPositionByDeadline.itemView);
} else {
recycler.addViewHolderToRecycledViewPool(tryGetViewHolderForPositionByDeadline, false);
}
}
recyclerView.onExitLayoutOrScroll(false);
return tryGetViewHolderForPositionByDeadline;
} catch (Throwable th) {
recyclerView.onExitLayoutOrScroll(false);
throw th;
}
}
private void prefetchInnerRecyclerViewWithDeadline(@Nullable RecyclerView recyclerView, long j) {
if (recyclerView == null) {
return;
}
if (recyclerView.mDataSetHasChangedAfterLayout && recyclerView.mChildHelper.getUnfilteredChildCount() != 0) {
recyclerView.removeAndRecycleViews();
}
LayoutPrefetchRegistryImpl layoutPrefetchRegistryImpl = recyclerView.mPrefetchRegistry;
layoutPrefetchRegistryImpl.collectPrefetchPositionsFromView(recyclerView, true);
if (layoutPrefetchRegistryImpl.mCount != 0) {
try {
TraceCompat.beginSection("RV Nested Prefetch");
recyclerView.mState.prepareForNestedPrefetch(recyclerView.mAdapter);
for (int i = 0; i < layoutPrefetchRegistryImpl.mCount * 2; i += 2) {
prefetchPositionWithDeadline(recyclerView, layoutPrefetchRegistryImpl.mPrefetchArray[i], j);
}
} finally {
TraceCompat.endSection();
}
}
}
private void flushTaskWithDeadline(Task task, long j) {
RecyclerView.ViewHolder prefetchPositionWithDeadline = prefetchPositionWithDeadline(task.view, task.position, task.immediate ? Long.MAX_VALUE : j);
if (prefetchPositionWithDeadline == null || prefetchPositionWithDeadline.mNestedRecyclerView == null || !prefetchPositionWithDeadline.isBound() || prefetchPositionWithDeadline.isInvalid()) {
return;
}
prefetchInnerRecyclerViewWithDeadline(prefetchPositionWithDeadline.mNestedRecyclerView.get(), j);
}
private void flushTasksWithDeadline(long j) {
for (int i = 0; i < this.mTasks.size(); i++) {
Task task = this.mTasks.get(i);
if (task.view == null) {
return;
}
flushTaskWithDeadline(task, j);
task.clear();
}
}
public void prefetch(long j) {
buildTaskList();
flushTasksWithDeadline(j);
}
@Override // java.lang.Runnable
public void run() {
try {
TraceCompat.beginSection("RV Prefetch");
if (!this.mRecyclerViews.isEmpty()) {
int size = this.mRecyclerViews.size();
long j = 0;
for (int i = 0; i < size; i++) {
RecyclerView recyclerView = this.mRecyclerViews.get(i);
if (recyclerView.getWindowVisibility() == 0) {
j = Math.max(recyclerView.getDrawingTime(), j);
}
}
if (j != 0) {
prefetch(TimeUnit.MILLISECONDS.toNanos(j) + this.mFrameIntervalNs);
this.mPostTimeNs = 0L;
TraceCompat.endSection();
}
}
} finally {
this.mPostTimeNs = 0L;
TraceCompat.endSection();
}
}
}

View File

@@ -0,0 +1,868 @@
package androidx.recyclerview.widget;
import android.content.Context;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.util.Log;
import android.util.SparseIntArray;
import android.view.View;
import android.view.ViewGroup;
import androidx.core.view.accessibility.AccessibilityNodeInfoCompat;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
/* loaded from: classes.dex */
public class GridLayoutManager extends LinearLayoutManager {
private static final boolean DEBUG = false;
public static final int DEFAULT_SPAN_COUNT = -1;
private static final String TAG = "GridLayoutManager";
int[] mCachedBorders;
final Rect mDecorInsets;
boolean mPendingSpanCountChange;
final SparseIntArray mPreLayoutSpanIndexCache;
final SparseIntArray mPreLayoutSpanSizeCache;
View[] mSet;
int mSpanCount;
SpanSizeLookup mSpanSizeLookup;
private boolean mUsingSpansToEstimateScrollBarDimensions;
public int getSpanCount() {
return this.mSpanCount;
}
public SpanSizeLookup getSpanSizeLookup() {
return this.mSpanSizeLookup;
}
public boolean isUsingSpansToEstimateScrollbarDimensions() {
return this.mUsingSpansToEstimateScrollBarDimensions;
}
public void setSpanSizeLookup(SpanSizeLookup spanSizeLookup) {
this.mSpanSizeLookup = spanSizeLookup;
}
public void setUsingSpansToEstimateScrollbarDimensions(boolean z) {
this.mUsingSpansToEstimateScrollBarDimensions = z;
}
@Override // androidx.recyclerview.widget.LinearLayoutManager, androidx.recyclerview.widget.RecyclerView.LayoutManager
public boolean supportsPredictiveItemAnimations() {
return this.mPendingSavedState == null && !this.mPendingSpanCountChange;
}
public GridLayoutManager(Context context, AttributeSet attributeSet, int i, int i2) {
super(context, attributeSet, i, i2);
this.mPendingSpanCountChange = false;
this.mSpanCount = -1;
this.mPreLayoutSpanSizeCache = new SparseIntArray();
this.mPreLayoutSpanIndexCache = new SparseIntArray();
this.mSpanSizeLookup = new DefaultSpanSizeLookup();
this.mDecorInsets = new Rect();
setSpanCount(RecyclerView.LayoutManager.getProperties(context, attributeSet, i, i2).spanCount);
}
public GridLayoutManager(Context context, int i) {
super(context);
this.mPendingSpanCountChange = false;
this.mSpanCount = -1;
this.mPreLayoutSpanSizeCache = new SparseIntArray();
this.mPreLayoutSpanIndexCache = new SparseIntArray();
this.mSpanSizeLookup = new DefaultSpanSizeLookup();
this.mDecorInsets = new Rect();
setSpanCount(i);
}
public GridLayoutManager(Context context, int i, int i2, boolean z) {
super(context, i2, z);
this.mPendingSpanCountChange = false;
this.mSpanCount = -1;
this.mPreLayoutSpanSizeCache = new SparseIntArray();
this.mPreLayoutSpanIndexCache = new SparseIntArray();
this.mSpanSizeLookup = new DefaultSpanSizeLookup();
this.mDecorInsets = new Rect();
setSpanCount(i);
}
@Override // androidx.recyclerview.widget.LinearLayoutManager
public void setStackFromEnd(boolean z) {
if (z) {
throw new UnsupportedOperationException("GridLayoutManager does not support stack from end. Consider using reverse layout");
}
super.setStackFromEnd(false);
}
@Override // androidx.recyclerview.widget.RecyclerView.LayoutManager
public int getRowCountForAccessibility(RecyclerView.Recycler recycler, RecyclerView.State state) {
if (this.mOrientation == 0) {
return this.mSpanCount;
}
if (state.getItemCount() < 1) {
return 0;
}
return getSpanGroupIndex(recycler, state, state.getItemCount() - 1) + 1;
}
@Override // androidx.recyclerview.widget.RecyclerView.LayoutManager
public int getColumnCountForAccessibility(RecyclerView.Recycler recycler, RecyclerView.State state) {
if (this.mOrientation == 1) {
return this.mSpanCount;
}
if (state.getItemCount() < 1) {
return 0;
}
return getSpanGroupIndex(recycler, state, state.getItemCount() - 1) + 1;
}
@Override // androidx.recyclerview.widget.RecyclerView.LayoutManager
public void onInitializeAccessibilityNodeInfoForItem(RecyclerView.Recycler recycler, RecyclerView.State state, View view, AccessibilityNodeInfoCompat accessibilityNodeInfoCompat) {
ViewGroup.LayoutParams layoutParams = view.getLayoutParams();
if (!(layoutParams instanceof LayoutParams)) {
super.onInitializeAccessibilityNodeInfoForItem(view, accessibilityNodeInfoCompat);
return;
}
LayoutParams layoutParams2 = (LayoutParams) layoutParams;
int spanGroupIndex = getSpanGroupIndex(recycler, state, layoutParams2.getViewLayoutPosition());
if (this.mOrientation == 0) {
accessibilityNodeInfoCompat.setCollectionItemInfo(AccessibilityNodeInfoCompat.CollectionItemInfoCompat.obtain(layoutParams2.getSpanIndex(), layoutParams2.getSpanSize(), spanGroupIndex, 1, false, false));
} else {
accessibilityNodeInfoCompat.setCollectionItemInfo(AccessibilityNodeInfoCompat.CollectionItemInfoCompat.obtain(spanGroupIndex, 1, layoutParams2.getSpanIndex(), layoutParams2.getSpanSize(), false, false));
}
}
@Override // androidx.recyclerview.widget.LinearLayoutManager, androidx.recyclerview.widget.RecyclerView.LayoutManager
public void onLayoutChildren(RecyclerView.Recycler recycler, RecyclerView.State state) {
if (state.isPreLayout()) {
cachePreLayoutSpanMapping();
}
super.onLayoutChildren(recycler, state);
clearPreLayoutSpanMappingCache();
}
@Override // androidx.recyclerview.widget.LinearLayoutManager, androidx.recyclerview.widget.RecyclerView.LayoutManager
public void onLayoutCompleted(RecyclerView.State state) {
super.onLayoutCompleted(state);
this.mPendingSpanCountChange = false;
}
private void clearPreLayoutSpanMappingCache() {
this.mPreLayoutSpanSizeCache.clear();
this.mPreLayoutSpanIndexCache.clear();
}
private void cachePreLayoutSpanMapping() {
int childCount = getChildCount();
for (int i = 0; i < childCount; i++) {
LayoutParams layoutParams = (LayoutParams) getChildAt(i).getLayoutParams();
int viewLayoutPosition = layoutParams.getViewLayoutPosition();
this.mPreLayoutSpanSizeCache.put(viewLayoutPosition, layoutParams.getSpanSize());
this.mPreLayoutSpanIndexCache.put(viewLayoutPosition, layoutParams.getSpanIndex());
}
}
@Override // androidx.recyclerview.widget.RecyclerView.LayoutManager
public void onItemsAdded(RecyclerView recyclerView, int i, int i2) {
this.mSpanSizeLookup.invalidateSpanIndexCache();
this.mSpanSizeLookup.invalidateSpanGroupIndexCache();
}
@Override // androidx.recyclerview.widget.RecyclerView.LayoutManager
public void onItemsChanged(RecyclerView recyclerView) {
this.mSpanSizeLookup.invalidateSpanIndexCache();
this.mSpanSizeLookup.invalidateSpanGroupIndexCache();
}
@Override // androidx.recyclerview.widget.RecyclerView.LayoutManager
public void onItemsRemoved(RecyclerView recyclerView, int i, int i2) {
this.mSpanSizeLookup.invalidateSpanIndexCache();
this.mSpanSizeLookup.invalidateSpanGroupIndexCache();
}
@Override // androidx.recyclerview.widget.RecyclerView.LayoutManager
public void onItemsUpdated(RecyclerView recyclerView, int i, int i2, Object obj) {
this.mSpanSizeLookup.invalidateSpanIndexCache();
this.mSpanSizeLookup.invalidateSpanGroupIndexCache();
}
@Override // androidx.recyclerview.widget.RecyclerView.LayoutManager
public void onItemsMoved(RecyclerView recyclerView, int i, int i2, int i3) {
this.mSpanSizeLookup.invalidateSpanIndexCache();
this.mSpanSizeLookup.invalidateSpanGroupIndexCache();
}
@Override // androidx.recyclerview.widget.LinearLayoutManager, androidx.recyclerview.widget.RecyclerView.LayoutManager
public RecyclerView.LayoutParams generateDefaultLayoutParams() {
if (this.mOrientation == 0) {
return new LayoutParams(-2, -1);
}
return new LayoutParams(-1, -2);
}
@Override // androidx.recyclerview.widget.RecyclerView.LayoutManager
public RecyclerView.LayoutParams generateLayoutParams(Context context, AttributeSet attributeSet) {
return new LayoutParams(context, attributeSet);
}
@Override // androidx.recyclerview.widget.RecyclerView.LayoutManager
public RecyclerView.LayoutParams generateLayoutParams(ViewGroup.LayoutParams layoutParams) {
if (layoutParams instanceof ViewGroup.MarginLayoutParams) {
return new LayoutParams((ViewGroup.MarginLayoutParams) layoutParams);
}
return new LayoutParams(layoutParams);
}
@Override // androidx.recyclerview.widget.RecyclerView.LayoutManager
public boolean checkLayoutParams(RecyclerView.LayoutParams layoutParams) {
return layoutParams instanceof LayoutParams;
}
private void updateMeasurements() {
int height;
int paddingTop;
if (getOrientation() == 1) {
height = getWidth() - getPaddingRight();
paddingTop = getPaddingLeft();
} else {
height = getHeight() - getPaddingBottom();
paddingTop = getPaddingTop();
}
calculateItemBorders(height - paddingTop);
}
@Override // androidx.recyclerview.widget.RecyclerView.LayoutManager
public void setMeasuredDimension(Rect rect, int i, int i2) {
int chooseSize;
int chooseSize2;
if (this.mCachedBorders == null) {
super.setMeasuredDimension(rect, i, i2);
}
int paddingLeft = getPaddingLeft() + getPaddingRight();
int paddingTop = getPaddingTop() + getPaddingBottom();
if (this.mOrientation == 1) {
chooseSize2 = RecyclerView.LayoutManager.chooseSize(i2, rect.height() + paddingTop, getMinimumHeight());
int[] iArr = this.mCachedBorders;
chooseSize = RecyclerView.LayoutManager.chooseSize(i, iArr[iArr.length - 1] + paddingLeft, getMinimumWidth());
} else {
chooseSize = RecyclerView.LayoutManager.chooseSize(i, rect.width() + paddingLeft, getMinimumWidth());
int[] iArr2 = this.mCachedBorders;
chooseSize2 = RecyclerView.LayoutManager.chooseSize(i2, iArr2[iArr2.length - 1] + paddingTop, getMinimumHeight());
}
setMeasuredDimension(chooseSize, chooseSize2);
}
private void calculateItemBorders(int i) {
this.mCachedBorders = calculateItemBorders(this.mCachedBorders, this.mSpanCount, i);
}
public static int[] calculateItemBorders(int[] iArr, int i, int i2) {
int i3;
if (iArr == null || iArr.length != i + 1 || iArr[iArr.length - 1] != i2) {
iArr = new int[i + 1];
}
int i4 = 0;
iArr[0] = 0;
int i5 = i2 / i;
int i6 = i2 % i;
int i7 = 0;
for (int i8 = 1; i8 <= i; i8++) {
i4 += i6;
if (i4 <= 0 || i - i4 >= i6) {
i3 = i5;
} else {
i3 = i5 + 1;
i4 -= i;
}
i7 += i3;
iArr[i8] = i7;
}
return iArr;
}
public int getSpaceForSpanRange(int i, int i2) {
if (this.mOrientation == 1 && isLayoutRTL()) {
int[] iArr = this.mCachedBorders;
int i3 = this.mSpanCount;
return iArr[i3 - i] - iArr[(i3 - i) - i2];
}
int[] iArr2 = this.mCachedBorders;
return iArr2[i2 + i] - iArr2[i];
}
@Override // androidx.recyclerview.widget.LinearLayoutManager
public void onAnchorReady(RecyclerView.Recycler recycler, RecyclerView.State state, LinearLayoutManager.AnchorInfo anchorInfo, int i) {
super.onAnchorReady(recycler, state, anchorInfo, i);
updateMeasurements();
if (state.getItemCount() > 0 && !state.isPreLayout()) {
ensureAnchorIsInCorrectSpan(recycler, state, anchorInfo, i);
}
ensureViewSet();
}
private void ensureViewSet() {
View[] viewArr = this.mSet;
if (viewArr == null || viewArr.length != this.mSpanCount) {
this.mSet = new View[this.mSpanCount];
}
}
@Override // androidx.recyclerview.widget.LinearLayoutManager, androidx.recyclerview.widget.RecyclerView.LayoutManager
public int scrollHorizontallyBy(int i, RecyclerView.Recycler recycler, RecyclerView.State state) {
updateMeasurements();
ensureViewSet();
return super.scrollHorizontallyBy(i, recycler, state);
}
@Override // androidx.recyclerview.widget.LinearLayoutManager, androidx.recyclerview.widget.RecyclerView.LayoutManager
public int scrollVerticallyBy(int i, RecyclerView.Recycler recycler, RecyclerView.State state) {
updateMeasurements();
ensureViewSet();
return super.scrollVerticallyBy(i, recycler, state);
}
private void ensureAnchorIsInCorrectSpan(RecyclerView.Recycler recycler, RecyclerView.State state, LinearLayoutManager.AnchorInfo anchorInfo, int i) {
boolean z = i == 1;
int spanIndex = getSpanIndex(recycler, state, anchorInfo.mPosition);
if (z) {
while (spanIndex > 0) {
int i2 = anchorInfo.mPosition;
if (i2 <= 0) {
return;
}
int i3 = i2 - 1;
anchorInfo.mPosition = i3;
spanIndex = getSpanIndex(recycler, state, i3);
}
return;
}
int itemCount = state.getItemCount() - 1;
int i4 = anchorInfo.mPosition;
while (i4 < itemCount) {
int i5 = i4 + 1;
int spanIndex2 = getSpanIndex(recycler, state, i5);
if (spanIndex2 <= spanIndex) {
break;
}
i4 = i5;
spanIndex = spanIndex2;
}
anchorInfo.mPosition = i4;
}
@Override // androidx.recyclerview.widget.LinearLayoutManager
public View findReferenceChild(RecyclerView.Recycler recycler, RecyclerView.State state, boolean z, boolean z2) {
int i;
int i2;
int childCount = getChildCount();
int i3 = 1;
if (z2) {
i2 = getChildCount() - 1;
i = -1;
i3 = -1;
} else {
i = childCount;
i2 = 0;
}
int itemCount = state.getItemCount();
ensureLayoutState();
int startAfterPadding = this.mOrientationHelper.getStartAfterPadding();
int endAfterPadding = this.mOrientationHelper.getEndAfterPadding();
View view = null;
View view2 = null;
while (i2 != i) {
View childAt = getChildAt(i2);
int position = getPosition(childAt);
if (position >= 0 && position < itemCount && getSpanIndex(recycler, state, position) == 0) {
if (((RecyclerView.LayoutParams) childAt.getLayoutParams()).isItemRemoved()) {
if (view2 == null) {
view2 = childAt;
}
} else {
if (this.mOrientationHelper.getDecoratedStart(childAt) < endAfterPadding && this.mOrientationHelper.getDecoratedEnd(childAt) >= startAfterPadding) {
return childAt;
}
if (view == null) {
view = childAt;
}
}
}
i2 += i3;
}
return view != null ? view : view2;
}
private int getSpanGroupIndex(RecyclerView.Recycler recycler, RecyclerView.State state, int i) {
if (!state.isPreLayout()) {
return this.mSpanSizeLookup.getCachedSpanGroupIndex(i, this.mSpanCount);
}
int convertPreLayoutPositionToPostLayout = recycler.convertPreLayoutPositionToPostLayout(i);
if (convertPreLayoutPositionToPostLayout == -1) {
Log.w(TAG, "Cannot find span size for pre layout position. " + i);
return 0;
}
return this.mSpanSizeLookup.getCachedSpanGroupIndex(convertPreLayoutPositionToPostLayout, this.mSpanCount);
}
private int getSpanIndex(RecyclerView.Recycler recycler, RecyclerView.State state, int i) {
if (!state.isPreLayout()) {
return this.mSpanSizeLookup.getCachedSpanIndex(i, this.mSpanCount);
}
int i2 = this.mPreLayoutSpanIndexCache.get(i, -1);
if (i2 != -1) {
return i2;
}
int convertPreLayoutPositionToPostLayout = recycler.convertPreLayoutPositionToPostLayout(i);
if (convertPreLayoutPositionToPostLayout == -1) {
Log.w(TAG, "Cannot find span size for pre layout position. It is not cached, not in the adapter. Pos:" + i);
return 0;
}
return this.mSpanSizeLookup.getCachedSpanIndex(convertPreLayoutPositionToPostLayout, this.mSpanCount);
}
private int getSpanSize(RecyclerView.Recycler recycler, RecyclerView.State state, int i) {
if (!state.isPreLayout()) {
return this.mSpanSizeLookup.getSpanSize(i);
}
int i2 = this.mPreLayoutSpanSizeCache.get(i, -1);
if (i2 != -1) {
return i2;
}
int convertPreLayoutPositionToPostLayout = recycler.convertPreLayoutPositionToPostLayout(i);
if (convertPreLayoutPositionToPostLayout == -1) {
Log.w(TAG, "Cannot find span size for pre layout position. It is not cached, not in the adapter. Pos:" + i);
return 1;
}
return this.mSpanSizeLookup.getSpanSize(convertPreLayoutPositionToPostLayout);
}
@Override // androidx.recyclerview.widget.LinearLayoutManager
public void collectPrefetchPositionsForLayoutState(RecyclerView.State state, LinearLayoutManager.LayoutState layoutState, RecyclerView.LayoutManager.LayoutPrefetchRegistry layoutPrefetchRegistry) {
int i = this.mSpanCount;
for (int i2 = 0; i2 < this.mSpanCount && layoutState.hasMore(state) && i > 0; i2++) {
int i3 = layoutState.mCurrentPosition;
layoutPrefetchRegistry.addPosition(i3, Math.max(0, layoutState.mScrollingOffset));
i -= this.mSpanSizeLookup.getSpanSize(i3);
layoutState.mCurrentPosition += layoutState.mItemDirection;
}
}
/* JADX WARN: Code restructure failed: missing block: B:30:0x009f, code lost:
r21.mFinished = true;
*/
/* JADX WARN: Code restructure failed: missing block: B:31:0x00a1, code lost:
return;
*/
@Override // androidx.recyclerview.widget.LinearLayoutManager
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
public void layoutChunk(androidx.recyclerview.widget.RecyclerView.Recycler r18, androidx.recyclerview.widget.RecyclerView.State r19, androidx.recyclerview.widget.LinearLayoutManager.LayoutState r20, androidx.recyclerview.widget.LinearLayoutManager.LayoutChunkResult r21) {
/*
Method dump skipped, instructions count: 557
To view this dump add '--comments-level debug' option
*/
throw new UnsupportedOperationException("Method not decompiled: androidx.recyclerview.widget.GridLayoutManager.layoutChunk(androidx.recyclerview.widget.RecyclerView$Recycler, androidx.recyclerview.widget.RecyclerView$State, androidx.recyclerview.widget.LinearLayoutManager$LayoutState, androidx.recyclerview.widget.LinearLayoutManager$LayoutChunkResult):void");
}
private void measureChild(View view, int i, boolean z) {
int i2;
int i3;
LayoutParams layoutParams = (LayoutParams) view.getLayoutParams();
Rect rect = layoutParams.mDecorInsets;
int i4 = rect.top + rect.bottom + ((ViewGroup.MarginLayoutParams) layoutParams).topMargin + ((ViewGroup.MarginLayoutParams) layoutParams).bottomMargin;
int i5 = rect.left + rect.right + ((ViewGroup.MarginLayoutParams) layoutParams).leftMargin + ((ViewGroup.MarginLayoutParams) layoutParams).rightMargin;
int spaceForSpanRange = getSpaceForSpanRange(layoutParams.mSpanIndex, layoutParams.mSpanSize);
if (this.mOrientation == 1) {
i3 = RecyclerView.LayoutManager.getChildMeasureSpec(spaceForSpanRange, i, i5, ((ViewGroup.MarginLayoutParams) layoutParams).width, false);
i2 = RecyclerView.LayoutManager.getChildMeasureSpec(this.mOrientationHelper.getTotalSpace(), getHeightMode(), i4, ((ViewGroup.MarginLayoutParams) layoutParams).height, true);
} else {
int childMeasureSpec = RecyclerView.LayoutManager.getChildMeasureSpec(spaceForSpanRange, i, i4, ((ViewGroup.MarginLayoutParams) layoutParams).height, false);
int childMeasureSpec2 = RecyclerView.LayoutManager.getChildMeasureSpec(this.mOrientationHelper.getTotalSpace(), getWidthMode(), i5, ((ViewGroup.MarginLayoutParams) layoutParams).width, true);
i2 = childMeasureSpec;
i3 = childMeasureSpec2;
}
measureChildWithDecorationsAndMargin(view, i3, i2, z);
}
private void guessMeasurement(float f, int i) {
calculateItemBorders(Math.max(Math.round(f * this.mSpanCount), i));
}
private void measureChildWithDecorationsAndMargin(View view, int i, int i2, boolean z) {
boolean shouldMeasureChild;
RecyclerView.LayoutParams layoutParams = (RecyclerView.LayoutParams) view.getLayoutParams();
if (z) {
shouldMeasureChild = shouldReMeasureChild(view, i, i2, layoutParams);
} else {
shouldMeasureChild = shouldMeasureChild(view, i, i2, layoutParams);
}
if (shouldMeasureChild) {
view.measure(i, i2);
}
}
private void assignSpans(RecyclerView.Recycler recycler, RecyclerView.State state, int i, boolean z) {
int i2;
int i3;
int i4;
int i5 = 0;
if (z) {
i4 = 1;
i3 = i;
i2 = 0;
} else {
i2 = i - 1;
i3 = -1;
i4 = -1;
}
while (i2 != i3) {
View view = this.mSet[i2];
LayoutParams layoutParams = (LayoutParams) view.getLayoutParams();
int spanSize = getSpanSize(recycler, state, getPosition(view));
layoutParams.mSpanSize = spanSize;
layoutParams.mSpanIndex = i5;
i5 += spanSize;
i2 += i4;
}
}
public void setSpanCount(int i) {
if (i == this.mSpanCount) {
return;
}
this.mPendingSpanCountChange = true;
if (i < 1) {
throw new IllegalArgumentException("Span count should be at least 1. Provided " + i);
}
this.mSpanCount = i;
this.mSpanSizeLookup.invalidateSpanIndexCache();
requestLayout();
}
public static abstract class SpanSizeLookup {
final SparseIntArray mSpanIndexCache = new SparseIntArray();
final SparseIntArray mSpanGroupIndexCache = new SparseIntArray();
private boolean mCacheSpanIndices = false;
private boolean mCacheSpanGroupIndices = false;
public abstract int getSpanSize(int i);
public boolean isSpanGroupIndexCacheEnabled() {
return this.mCacheSpanGroupIndices;
}
public boolean isSpanIndexCacheEnabled() {
return this.mCacheSpanIndices;
}
public void setSpanIndexCacheEnabled(boolean z) {
if (!z) {
this.mSpanGroupIndexCache.clear();
}
this.mCacheSpanIndices = z;
}
public void setSpanGroupIndexCacheEnabled(boolean z) {
if (!z) {
this.mSpanGroupIndexCache.clear();
}
this.mCacheSpanGroupIndices = z;
}
public void invalidateSpanIndexCache() {
this.mSpanIndexCache.clear();
}
public void invalidateSpanGroupIndexCache() {
this.mSpanGroupIndexCache.clear();
}
public int getCachedSpanIndex(int i, int i2) {
if (!this.mCacheSpanIndices) {
return getSpanIndex(i, i2);
}
int i3 = this.mSpanIndexCache.get(i, -1);
if (i3 != -1) {
return i3;
}
int spanIndex = getSpanIndex(i, i2);
this.mSpanIndexCache.put(i, spanIndex);
return spanIndex;
}
public int getCachedSpanGroupIndex(int i, int i2) {
if (!this.mCacheSpanGroupIndices) {
return getSpanGroupIndex(i, i2);
}
int i3 = this.mSpanGroupIndexCache.get(i, -1);
if (i3 != -1) {
return i3;
}
int spanGroupIndex = getSpanGroupIndex(i, i2);
this.mSpanGroupIndexCache.put(i, spanGroupIndex);
return spanGroupIndex;
}
/* JADX WARN: Removed duplicated region for block: B:12:0x0024 */
/* JADX WARN: Removed duplicated region for block: B:17:0x0033 */
/* JADX WARN: Unsupported multi-entry loop pattern (BACK_EDGE: B:14:0x002b -> B:10:0x0030). Please report as a decompilation issue!!! */
/* JADX WARN: Unsupported multi-entry loop pattern (BACK_EDGE: B:15:0x002d -> B:10:0x0030). Please report as a decompilation issue!!! */
/* JADX WARN: Unsupported multi-entry loop pattern (BACK_EDGE: B:16:0x002f -> B:10:0x0030). Please report as a decompilation issue!!! */
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
public int getSpanIndex(int r6, int r7) {
/*
r5 = this;
int r0 = r5.getSpanSize(r6)
r1 = 0
if (r0 != r7) goto L8
return r1
L8:
boolean r2 = r5.mCacheSpanIndices
if (r2 == 0) goto L20
android.util.SparseIntArray r2 = r5.mSpanIndexCache
int r2 = findFirstKeyLessThan(r2, r6)
if (r2 < 0) goto L20
android.util.SparseIntArray r3 = r5.mSpanIndexCache
int r3 = r3.get(r2)
int r4 = r5.getSpanSize(r2)
int r3 = r3 + r4
goto L30
L20:
r2 = r1
r3 = r2
L22:
if (r2 >= r6) goto L33
int r4 = r5.getSpanSize(r2)
int r3 = r3 + r4
if (r3 != r7) goto L2d
r3 = r1
goto L30
L2d:
if (r3 <= r7) goto L30
r3 = r4
L30:
int r2 = r2 + 1
goto L22
L33:
int r0 = r0 + r3
if (r0 > r7) goto L37
return r3
L37:
return r1
*/
throw new UnsupportedOperationException("Method not decompiled: androidx.recyclerview.widget.GridLayoutManager.SpanSizeLookup.getSpanIndex(int, int):int");
}
public static int findFirstKeyLessThan(SparseIntArray sparseIntArray, int i) {
int size = sparseIntArray.size() - 1;
int i2 = 0;
while (i2 <= size) {
int i3 = (i2 + size) >>> 1;
if (sparseIntArray.keyAt(i3) < i) {
i2 = i3 + 1;
} else {
size = i3 - 1;
}
}
int i4 = i2 - 1;
if (i4 < 0 || i4 >= sparseIntArray.size()) {
return -1;
}
return sparseIntArray.keyAt(i4);
}
public int getSpanGroupIndex(int i, int i2) {
int i3;
int i4;
int i5;
int findFirstKeyLessThan;
if (!this.mCacheSpanGroupIndices || (findFirstKeyLessThan = findFirstKeyLessThan(this.mSpanGroupIndexCache, i)) == -1) {
i3 = 0;
i4 = 0;
i5 = 0;
} else {
i3 = this.mSpanGroupIndexCache.get(findFirstKeyLessThan);
i4 = findFirstKeyLessThan + 1;
i5 = getCachedSpanIndex(findFirstKeyLessThan, i2) + getSpanSize(findFirstKeyLessThan);
if (i5 == i2) {
i3++;
i5 = 0;
}
}
int spanSize = getSpanSize(i);
while (i4 < i) {
int spanSize2 = getSpanSize(i4);
i5 += spanSize2;
if (i5 == i2) {
i3++;
i5 = 0;
} else if (i5 > i2) {
i3++;
i5 = spanSize2;
}
i4++;
}
return i5 + spanSize > i2 ? i3 + 1 : i3;
}
}
/* JADX WARN: Code restructure failed: missing block: B:65:0x00d1, code lost:
if (r13 == (r2 > r15)) goto L47;
*/
/* JADX WARN: Code restructure failed: missing block: B:77:0x00f1, code lost:
if (r13 == (r2 > r7)) goto L70;
*/
/* JADX WARN: Removed duplicated region for block: B:52:0x00f9 */
/* JADX WARN: Removed duplicated region for block: B:54:0x010f */
@Override // androidx.recyclerview.widget.LinearLayoutManager, androidx.recyclerview.widget.RecyclerView.LayoutManager
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
public android.view.View onFocusSearchFailed(android.view.View r24, int r25, androidx.recyclerview.widget.RecyclerView.Recycler r26, androidx.recyclerview.widget.RecyclerView.State r27) {
/*
Method dump skipped, instructions count: 317
To view this dump add '--comments-level debug' option
*/
throw new UnsupportedOperationException("Method not decompiled: androidx.recyclerview.widget.GridLayoutManager.onFocusSearchFailed(android.view.View, int, androidx.recyclerview.widget.RecyclerView$Recycler, androidx.recyclerview.widget.RecyclerView$State):android.view.View");
}
@Override // androidx.recyclerview.widget.LinearLayoutManager, androidx.recyclerview.widget.RecyclerView.LayoutManager
public int computeHorizontalScrollRange(RecyclerView.State state) {
if (this.mUsingSpansToEstimateScrollBarDimensions) {
return computeScrollRangeWithSpanInfo(state);
}
return super.computeHorizontalScrollRange(state);
}
@Override // androidx.recyclerview.widget.LinearLayoutManager, androidx.recyclerview.widget.RecyclerView.LayoutManager
public int computeVerticalScrollRange(RecyclerView.State state) {
if (this.mUsingSpansToEstimateScrollBarDimensions) {
return computeScrollRangeWithSpanInfo(state);
}
return super.computeVerticalScrollRange(state);
}
@Override // androidx.recyclerview.widget.LinearLayoutManager, androidx.recyclerview.widget.RecyclerView.LayoutManager
public int computeHorizontalScrollOffset(RecyclerView.State state) {
if (this.mUsingSpansToEstimateScrollBarDimensions) {
return computeScrollOffsetWithSpanInfo(state);
}
return super.computeHorizontalScrollOffset(state);
}
@Override // androidx.recyclerview.widget.LinearLayoutManager, androidx.recyclerview.widget.RecyclerView.LayoutManager
public int computeVerticalScrollOffset(RecyclerView.State state) {
if (this.mUsingSpansToEstimateScrollBarDimensions) {
return computeScrollOffsetWithSpanInfo(state);
}
return super.computeVerticalScrollOffset(state);
}
private int computeScrollRangeWithSpanInfo(RecyclerView.State state) {
if (getChildCount() != 0 && state.getItemCount() != 0) {
ensureLayoutState();
View findFirstVisibleChildClosestToStart = findFirstVisibleChildClosestToStart(!isSmoothScrollbarEnabled(), true);
View findFirstVisibleChildClosestToEnd = findFirstVisibleChildClosestToEnd(!isSmoothScrollbarEnabled(), true);
if (findFirstVisibleChildClosestToStart != null && findFirstVisibleChildClosestToEnd != null) {
if (!isSmoothScrollbarEnabled()) {
return this.mSpanSizeLookup.getCachedSpanGroupIndex(state.getItemCount() - 1, this.mSpanCount) + 1;
}
int decoratedEnd = this.mOrientationHelper.getDecoratedEnd(findFirstVisibleChildClosestToEnd) - this.mOrientationHelper.getDecoratedStart(findFirstVisibleChildClosestToStart);
int cachedSpanGroupIndex = this.mSpanSizeLookup.getCachedSpanGroupIndex(getPosition(findFirstVisibleChildClosestToStart), this.mSpanCount);
return (int) ((decoratedEnd / ((this.mSpanSizeLookup.getCachedSpanGroupIndex(getPosition(findFirstVisibleChildClosestToEnd), this.mSpanCount) - cachedSpanGroupIndex) + 1)) * (this.mSpanSizeLookup.getCachedSpanGroupIndex(state.getItemCount() - 1, this.mSpanCount) + 1));
}
}
return 0;
}
private int computeScrollOffsetWithSpanInfo(RecyclerView.State state) {
int max;
if (getChildCount() != 0 && state.getItemCount() != 0) {
ensureLayoutState();
boolean isSmoothScrollbarEnabled = isSmoothScrollbarEnabled();
View findFirstVisibleChildClosestToStart = findFirstVisibleChildClosestToStart(!isSmoothScrollbarEnabled, true);
View findFirstVisibleChildClosestToEnd = findFirstVisibleChildClosestToEnd(!isSmoothScrollbarEnabled, true);
if (findFirstVisibleChildClosestToStart != null && findFirstVisibleChildClosestToEnd != null) {
int cachedSpanGroupIndex = this.mSpanSizeLookup.getCachedSpanGroupIndex(getPosition(findFirstVisibleChildClosestToStart), this.mSpanCount);
int cachedSpanGroupIndex2 = this.mSpanSizeLookup.getCachedSpanGroupIndex(getPosition(findFirstVisibleChildClosestToEnd), this.mSpanCount);
int min = Math.min(cachedSpanGroupIndex, cachedSpanGroupIndex2);
int max2 = Math.max(cachedSpanGroupIndex, cachedSpanGroupIndex2);
int cachedSpanGroupIndex3 = this.mSpanSizeLookup.getCachedSpanGroupIndex(state.getItemCount() - 1, this.mSpanCount) + 1;
if (this.mShouldReverseLayout) {
max = Math.max(0, (cachedSpanGroupIndex3 - max2) - 1);
} else {
max = Math.max(0, min);
}
if (!isSmoothScrollbarEnabled) {
return max;
}
return Math.round((max * (Math.abs(this.mOrientationHelper.getDecoratedEnd(findFirstVisibleChildClosestToEnd) - this.mOrientationHelper.getDecoratedStart(findFirstVisibleChildClosestToStart)) / ((this.mSpanSizeLookup.getCachedSpanGroupIndex(getPosition(findFirstVisibleChildClosestToEnd), this.mSpanCount) - this.mSpanSizeLookup.getCachedSpanGroupIndex(getPosition(findFirstVisibleChildClosestToStart), this.mSpanCount)) + 1))) + (this.mOrientationHelper.getStartAfterPadding() - this.mOrientationHelper.getDecoratedStart(findFirstVisibleChildClosestToStart)));
}
}
return 0;
}
public static final class DefaultSpanSizeLookup extends SpanSizeLookup {
@Override // androidx.recyclerview.widget.GridLayoutManager.SpanSizeLookup
public int getSpanSize(int i) {
return 1;
}
@Override // androidx.recyclerview.widget.GridLayoutManager.SpanSizeLookup
public int getSpanIndex(int i, int i2) {
return i % i2;
}
}
public static class LayoutParams extends RecyclerView.LayoutParams {
public static final int INVALID_SPAN_ID = -1;
int mSpanIndex;
int mSpanSize;
public int getSpanIndex() {
return this.mSpanIndex;
}
public int getSpanSize() {
return this.mSpanSize;
}
public LayoutParams(Context context, AttributeSet attributeSet) {
super(context, attributeSet);
this.mSpanIndex = -1;
this.mSpanSize = 0;
}
public LayoutParams(int i, int i2) {
super(i, i2);
this.mSpanIndex = -1;
this.mSpanSize = 0;
}
public LayoutParams(ViewGroup.MarginLayoutParams marginLayoutParams) {
super(marginLayoutParams);
this.mSpanIndex = -1;
this.mSpanSize = 0;
}
public LayoutParams(ViewGroup.LayoutParams layoutParams) {
super(layoutParams);
this.mSpanIndex = -1;
this.mSpanSize = 0;
}
public LayoutParams(RecyclerView.LayoutParams layoutParams) {
super(layoutParams);
this.mSpanIndex = -1;
this.mSpanSize = 0;
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,15 @@
package androidx.recyclerview.widget;
import android.graphics.Canvas;
import android.view.View;
/* loaded from: classes.dex */
public interface ItemTouchUIUtil {
void clearView(View view);
void onDraw(Canvas canvas, RecyclerView recyclerView, View view, float f, float f2, int i, boolean z);
void onDrawOver(Canvas canvas, RecyclerView recyclerView, View view, float f, float f2, int i, boolean z);
void onSelected(View view);
}

View File

@@ -0,0 +1,56 @@
package androidx.recyclerview.widget;
import android.graphics.Canvas;
import android.view.View;
import androidx.core.view.ViewCompat;
import androidx.recyclerview.R;
/* loaded from: classes.dex */
class ItemTouchUIUtilImpl implements ItemTouchUIUtil {
static final ItemTouchUIUtil INSTANCE = new ItemTouchUIUtilImpl();
@Override // androidx.recyclerview.widget.ItemTouchUIUtil
public void onDrawOver(Canvas canvas, RecyclerView recyclerView, View view, float f, float f2, int i, boolean z) {
}
@Override // androidx.recyclerview.widget.ItemTouchUIUtil
public void onSelected(View view) {
}
@Override // androidx.recyclerview.widget.ItemTouchUIUtil
public void onDraw(Canvas canvas, RecyclerView recyclerView, View view, float f, float f2, int i, boolean z) {
if (z && view.getTag(R.id.item_touch_helper_previous_elevation) == null) {
Float valueOf = Float.valueOf(ViewCompat.getElevation(view));
ViewCompat.setElevation(view, findMaxElevation(recyclerView, view) + 1.0f);
view.setTag(R.id.item_touch_helper_previous_elevation, valueOf);
}
view.setTranslationX(f);
view.setTranslationY(f2);
}
private static float findMaxElevation(RecyclerView recyclerView, View view) {
int childCount = recyclerView.getChildCount();
float f = 0.0f;
for (int i = 0; i < childCount; i++) {
View childAt = recyclerView.getChildAt(i);
if (childAt != view) {
float elevation = ViewCompat.getElevation(childAt);
if (elevation > f) {
f = elevation;
}
}
}
return f;
}
@Override // androidx.recyclerview.widget.ItemTouchUIUtil
public void clearView(View view) {
Object tag = view.getTag(R.id.item_touch_helper_previous_elevation);
if (tag instanceof Float) {
ViewCompat.setElevation(view, ((Float) tag).floatValue());
}
view.setTag(R.id.item_touch_helper_previous_elevation, null);
view.setTranslationX(0.0f);
view.setTranslationY(0.0f);
}
}

View File

@@ -0,0 +1,37 @@
package androidx.recyclerview.widget;
import android.view.View;
import androidx.recyclerview.widget.RecyclerView;
/* loaded from: classes.dex */
class LayoutState {
static final int INVALID_LAYOUT = Integer.MIN_VALUE;
static final int ITEM_DIRECTION_HEAD = -1;
static final int ITEM_DIRECTION_TAIL = 1;
static final int LAYOUT_END = 1;
static final int LAYOUT_START = -1;
int mAvailable;
int mCurrentPosition;
boolean mInfinite;
int mItemDirection;
int mLayoutDirection;
boolean mStopInFocusable;
boolean mRecycle = true;
int mStartLine = 0;
int mEndLine = 0;
public boolean hasMore(RecyclerView.State state) {
int i = this.mCurrentPosition;
return i >= 0 && i < state.getItemCount();
}
public View next(RecyclerView.Recycler recycler) {
View viewForPosition = recycler.getViewForPosition(this.mCurrentPosition);
this.mCurrentPosition += this.mItemDirection;
return viewForPosition;
}
public String toString() {
return "LayoutState{mAvailable=" + this.mAvailable + ", mCurrentPosition=" + this.mCurrentPosition + ", mItemDirection=" + this.mItemDirection + ", mLayoutDirection=" + this.mLayoutDirection + ", mStartLine=" + this.mStartLine + ", mEndLine=" + this.mEndLine + '}';
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,171 @@
package androidx.recyclerview.widget;
import android.content.Context;
import android.graphics.PointF;
import android.util.DisplayMetrics;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.DecelerateInterpolator;
import android.view.animation.LinearInterpolator;
import androidx.recyclerview.widget.RecyclerView;
/* loaded from: classes.dex */
public class LinearSmoothScroller extends RecyclerView.SmoothScroller {
private static final boolean DEBUG = false;
private static final float MILLISECONDS_PER_INCH = 25.0f;
public static final int SNAP_TO_ANY = 0;
public static final int SNAP_TO_END = 1;
public static final int SNAP_TO_START = -1;
private static final float TARGET_SEEK_EXTRA_SCROLL_RATIO = 1.2f;
private static final int TARGET_SEEK_SCROLL_DISTANCE_PX = 10000;
private final DisplayMetrics mDisplayMetrics;
private float mMillisPerPixel;
protected PointF mTargetVector;
protected final LinearInterpolator mLinearInterpolator = new LinearInterpolator();
protected final DecelerateInterpolator mDecelerateInterpolator = new DecelerateInterpolator();
private boolean mHasCalculatedMillisPerPixel = false;
protected int mInterimTargetDx = 0;
protected int mInterimTargetDy = 0;
private int clampApplyScroll(int i, int i2) {
int i3 = i - i2;
if (i * i3 <= 0) {
return 0;
}
return i3;
}
@Override // androidx.recyclerview.widget.RecyclerView.SmoothScroller
public void onStart() {
}
@Override // androidx.recyclerview.widget.RecyclerView.SmoothScroller
public void onStop() {
this.mInterimTargetDy = 0;
this.mInterimTargetDx = 0;
this.mTargetVector = null;
}
public LinearSmoothScroller(Context context) {
this.mDisplayMetrics = context.getResources().getDisplayMetrics();
}
@Override // androidx.recyclerview.widget.RecyclerView.SmoothScroller
public void onTargetFound(View view, RecyclerView.State state, RecyclerView.SmoothScroller.Action action) {
int calculateDxToMakeVisible = calculateDxToMakeVisible(view, getHorizontalSnapPreference());
int calculateDyToMakeVisible = calculateDyToMakeVisible(view, getVerticalSnapPreference());
int calculateTimeForDeceleration = calculateTimeForDeceleration((int) Math.sqrt((calculateDxToMakeVisible * calculateDxToMakeVisible) + (calculateDyToMakeVisible * calculateDyToMakeVisible)));
if (calculateTimeForDeceleration > 0) {
action.update(-calculateDxToMakeVisible, -calculateDyToMakeVisible, calculateTimeForDeceleration, this.mDecelerateInterpolator);
}
}
@Override // androidx.recyclerview.widget.RecyclerView.SmoothScroller
public void onSeekTargetStep(int i, int i2, RecyclerView.State state, RecyclerView.SmoothScroller.Action action) {
if (getChildCount() == 0) {
stop();
return;
}
this.mInterimTargetDx = clampApplyScroll(this.mInterimTargetDx, i);
int clampApplyScroll = clampApplyScroll(this.mInterimTargetDy, i2);
this.mInterimTargetDy = clampApplyScroll;
if (this.mInterimTargetDx == 0 && clampApplyScroll == 0) {
updateActionForInterimTarget(action);
}
}
public float calculateSpeedPerPixel(DisplayMetrics displayMetrics) {
return MILLISECONDS_PER_INCH / displayMetrics.densityDpi;
}
private float getSpeedPerPixel() {
if (!this.mHasCalculatedMillisPerPixel) {
this.mMillisPerPixel = calculateSpeedPerPixel(this.mDisplayMetrics);
this.mHasCalculatedMillisPerPixel = true;
}
return this.mMillisPerPixel;
}
public int calculateTimeForDeceleration(int i) {
return (int) Math.ceil(calculateTimeForScrolling(i) / 0.3356d);
}
public int calculateTimeForScrolling(int i) {
return (int) Math.ceil(Math.abs(i) * getSpeedPerPixel());
}
public int getHorizontalSnapPreference() {
PointF pointF = this.mTargetVector;
if (pointF != null) {
float f = pointF.x;
if (f != 0.0f) {
return f > 0.0f ? 1 : -1;
}
}
return 0;
}
public int getVerticalSnapPreference() {
PointF pointF = this.mTargetVector;
if (pointF != null) {
float f = pointF.y;
if (f != 0.0f) {
return f > 0.0f ? 1 : -1;
}
}
return 0;
}
public void updateActionForInterimTarget(RecyclerView.SmoothScroller.Action action) {
PointF computeScrollVectorForPosition = computeScrollVectorForPosition(getTargetPosition());
if (computeScrollVectorForPosition == null || (computeScrollVectorForPosition.x == 0.0f && computeScrollVectorForPosition.y == 0.0f)) {
action.jumpTo(getTargetPosition());
stop();
return;
}
normalize(computeScrollVectorForPosition);
this.mTargetVector = computeScrollVectorForPosition;
this.mInterimTargetDx = (int) (computeScrollVectorForPosition.x * 10000.0f);
this.mInterimTargetDy = (int) (computeScrollVectorForPosition.y * 10000.0f);
action.update((int) (this.mInterimTargetDx * TARGET_SEEK_EXTRA_SCROLL_RATIO), (int) (this.mInterimTargetDy * TARGET_SEEK_EXTRA_SCROLL_RATIO), (int) (calculateTimeForScrolling(10000) * TARGET_SEEK_EXTRA_SCROLL_RATIO), this.mLinearInterpolator);
}
public int calculateDtToFit(int i, int i2, int i3, int i4, int i5) {
if (i5 == -1) {
return i3 - i;
}
if (i5 != 0) {
if (i5 == 1) {
return i4 - i2;
}
throw new IllegalArgumentException("snap preference should be one of the constants defined in SmoothScroller, starting with SNAP_");
}
int i6 = i3 - i;
if (i6 > 0) {
return i6;
}
int i7 = i4 - i2;
if (i7 < 0) {
return i7;
}
return 0;
}
public int calculateDyToMakeVisible(View view, int i) {
RecyclerView.LayoutManager layoutManager = getLayoutManager();
if (layoutManager == null || !layoutManager.canScrollVertically()) {
return 0;
}
RecyclerView.LayoutParams layoutParams = (RecyclerView.LayoutParams) view.getLayoutParams();
return calculateDtToFit(layoutManager.getDecoratedTop(view) - ((ViewGroup.MarginLayoutParams) layoutParams).topMargin, layoutManager.getDecoratedBottom(view) + ((ViewGroup.MarginLayoutParams) layoutParams).bottomMargin, layoutManager.getPaddingTop(), layoutManager.getHeight() - layoutManager.getPaddingBottom(), i);
}
public int calculateDxToMakeVisible(View view, int i) {
RecyclerView.LayoutManager layoutManager = getLayoutManager();
if (layoutManager == null || !layoutManager.canScrollHorizontally()) {
return 0;
}
RecyclerView.LayoutParams layoutParams = (RecyclerView.LayoutParams) view.getLayoutParams();
return calculateDtToFit(layoutManager.getDecoratedLeft(view) - ((ViewGroup.MarginLayoutParams) layoutParams).leftMargin, layoutManager.getDecoratedRight(view) + ((ViewGroup.MarginLayoutParams) layoutParams).rightMargin, layoutManager.getPaddingLeft(), layoutManager.getWidth() - layoutManager.getPaddingRight(), i);
}
}

View File

@@ -0,0 +1,166 @@
package androidx.recyclerview.widget;
import android.graphics.PointF;
import android.view.View;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView;
/* loaded from: classes.dex */
public class LinearSnapHelper extends SnapHelper {
private static final float INVALID_DISTANCE = 1.0f;
@Nullable
private OrientationHelper mHorizontalHelper;
@Nullable
private OrientationHelper mVerticalHelper;
@Override // androidx.recyclerview.widget.SnapHelper
public int[] calculateDistanceToFinalSnap(@NonNull RecyclerView.LayoutManager layoutManager, @NonNull View view) {
int[] iArr = new int[2];
if (layoutManager.canScrollHorizontally()) {
iArr[0] = distanceToCenter(view, getHorizontalHelper(layoutManager));
} else {
iArr[0] = 0;
}
if (layoutManager.canScrollVertically()) {
iArr[1] = distanceToCenter(view, getVerticalHelper(layoutManager));
} else {
iArr[1] = 0;
}
return iArr;
}
/* JADX WARN: Multi-variable type inference failed */
@Override // androidx.recyclerview.widget.SnapHelper
public int findTargetSnapPosition(RecyclerView.LayoutManager layoutManager, int i, int i2) {
int itemCount;
View findSnapView;
int position;
int i3;
PointF computeScrollVectorForPosition;
int i4;
int i5;
if (!(layoutManager instanceof RecyclerView.SmoothScroller.ScrollVectorProvider) || (itemCount = layoutManager.getItemCount()) == 0 || (findSnapView = findSnapView(layoutManager)) == null || (position = layoutManager.getPosition(findSnapView)) == -1 || (computeScrollVectorForPosition = ((RecyclerView.SmoothScroller.ScrollVectorProvider) layoutManager).computeScrollVectorForPosition(itemCount - 1)) == null) {
return -1;
}
if (layoutManager.canScrollHorizontally()) {
i4 = estimateNextPositionDiffForFling(layoutManager, getHorizontalHelper(layoutManager), i, 0);
if (computeScrollVectorForPosition.x < 0.0f) {
i4 = -i4;
}
} else {
i4 = 0;
}
if (layoutManager.canScrollVertically()) {
i5 = estimateNextPositionDiffForFling(layoutManager, getVerticalHelper(layoutManager), 0, i2);
if (computeScrollVectorForPosition.y < 0.0f) {
i5 = -i5;
}
} else {
i5 = 0;
}
if (layoutManager.canScrollVertically()) {
i4 = i5;
}
if (i4 == 0) {
return -1;
}
int i6 = position + i4;
int i7 = i6 >= 0 ? i6 : 0;
return i7 >= itemCount ? i3 : i7;
}
@Override // androidx.recyclerview.widget.SnapHelper
public View findSnapView(RecyclerView.LayoutManager layoutManager) {
if (layoutManager.canScrollVertically()) {
return findCenterView(layoutManager, getVerticalHelper(layoutManager));
}
if (layoutManager.canScrollHorizontally()) {
return findCenterView(layoutManager, getHorizontalHelper(layoutManager));
}
return null;
}
private int distanceToCenter(@NonNull View view, OrientationHelper orientationHelper) {
return (orientationHelper.getDecoratedStart(view) + (orientationHelper.getDecoratedMeasurement(view) / 2)) - (orientationHelper.getStartAfterPadding() + (orientationHelper.getTotalSpace() / 2));
}
private int estimateNextPositionDiffForFling(RecyclerView.LayoutManager layoutManager, OrientationHelper orientationHelper, int i, int i2) {
int[] calculateScrollDistance = calculateScrollDistance(i, i2);
float computeDistancePerChild = computeDistancePerChild(layoutManager, orientationHelper);
if (computeDistancePerChild <= 0.0f) {
return 0;
}
return Math.round((Math.abs(calculateScrollDistance[0]) > Math.abs(calculateScrollDistance[1]) ? calculateScrollDistance[0] : calculateScrollDistance[1]) / computeDistancePerChild);
}
@Nullable
private View findCenterView(RecyclerView.LayoutManager layoutManager, OrientationHelper orientationHelper) {
int childCount = layoutManager.getChildCount();
View view = null;
if (childCount == 0) {
return null;
}
int startAfterPadding = orientationHelper.getStartAfterPadding() + (orientationHelper.getTotalSpace() / 2);
int i = Integer.MAX_VALUE;
for (int i2 = 0; i2 < childCount; i2++) {
View childAt = layoutManager.getChildAt(i2);
int abs = Math.abs((orientationHelper.getDecoratedStart(childAt) + (orientationHelper.getDecoratedMeasurement(childAt) / 2)) - startAfterPadding);
if (abs < i) {
view = childAt;
i = abs;
}
}
return view;
}
private float computeDistancePerChild(RecyclerView.LayoutManager layoutManager, OrientationHelper orientationHelper) {
int childCount = layoutManager.getChildCount();
if (childCount == 0) {
return INVALID_DISTANCE;
}
View view = null;
int i = Integer.MIN_VALUE;
int i2 = Integer.MAX_VALUE;
View view2 = null;
for (int i3 = 0; i3 < childCount; i3++) {
View childAt = layoutManager.getChildAt(i3);
int position = layoutManager.getPosition(childAt);
if (position != -1) {
if (position < i2) {
view = childAt;
i2 = position;
}
if (position > i) {
view2 = childAt;
i = position;
}
}
}
if (view == null || view2 == null) {
return INVALID_DISTANCE;
}
int max = Math.max(orientationHelper.getDecoratedEnd(view), orientationHelper.getDecoratedEnd(view2)) - Math.min(orientationHelper.getDecoratedStart(view), orientationHelper.getDecoratedStart(view2));
return max == 0 ? INVALID_DISTANCE : (max * INVALID_DISTANCE) / ((i - i2) + 1);
}
@NonNull
private OrientationHelper getVerticalHelper(@NonNull RecyclerView.LayoutManager layoutManager) {
OrientationHelper orientationHelper = this.mVerticalHelper;
if (orientationHelper == null || orientationHelper.mLayoutManager != layoutManager) {
this.mVerticalHelper = OrientationHelper.createVerticalHelper(layoutManager);
}
return this.mVerticalHelper;
}
@NonNull
private OrientationHelper getHorizontalHelper(@NonNull RecyclerView.LayoutManager layoutManager) {
OrientationHelper orientationHelper = this.mHorizontalHelper;
if (orientationHelper == null || orientationHelper.mLayoutManager != layoutManager) {
this.mHorizontalHelper = OrientationHelper.createHorizontalHelper(layoutManager);
}
return this.mHorizontalHelper;
}
}

View File

@@ -0,0 +1,67 @@
package androidx.recyclerview.widget;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.AsyncDifferConfig;
import androidx.recyclerview.widget.AsyncListDiffer;
import androidx.recyclerview.widget.DiffUtil;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.RecyclerView.ViewHolder;
import java.util.List;
/* loaded from: classes.dex */
public abstract class ListAdapter<T, VH extends RecyclerView.ViewHolder> extends RecyclerView.Adapter<VH> {
final AsyncListDiffer<T> mDiffer;
private final AsyncListDiffer.ListListener<T> mListener;
public void onCurrentListChanged(@NonNull List<T> list, @NonNull List<T> list2) {
}
public ListAdapter(@NonNull DiffUtil.ItemCallback<T> itemCallback) {
AsyncListDiffer.ListListener<T> listListener = new AsyncListDiffer.ListListener<T>() { // from class: androidx.recyclerview.widget.ListAdapter.1
@Override // androidx.recyclerview.widget.AsyncListDiffer.ListListener
public void onCurrentListChanged(@NonNull List<T> list, @NonNull List<T> list2) {
ListAdapter.this.onCurrentListChanged(list, list2);
}
};
this.mListener = listListener;
AsyncListDiffer<T> asyncListDiffer = new AsyncListDiffer<>(new AdapterListUpdateCallback(this), new AsyncDifferConfig.Builder(itemCallback).build());
this.mDiffer = asyncListDiffer;
asyncListDiffer.addListListener(listListener);
}
public ListAdapter(@NonNull AsyncDifferConfig<T> asyncDifferConfig) {
AsyncListDiffer.ListListener<T> listListener = new AsyncListDiffer.ListListener<T>() { // from class: androidx.recyclerview.widget.ListAdapter.1
@Override // androidx.recyclerview.widget.AsyncListDiffer.ListListener
public void onCurrentListChanged(@NonNull List<T> list, @NonNull List<T> list2) {
ListAdapter.this.onCurrentListChanged(list, list2);
}
};
this.mListener = listListener;
AsyncListDiffer<T> asyncListDiffer = new AsyncListDiffer<>(new AdapterListUpdateCallback(this), asyncDifferConfig);
this.mDiffer = asyncListDiffer;
asyncListDiffer.addListListener(listListener);
}
public void submitList(@Nullable List<T> list) {
this.mDiffer.submitList(list);
}
public void submitList(@Nullable List<T> list, @Nullable Runnable runnable) {
this.mDiffer.submitList(list, runnable);
}
public T getItem(int i) {
return this.mDiffer.getCurrentList().get(i);
}
@Override // androidx.recyclerview.widget.RecyclerView.Adapter
public int getItemCount() {
return this.mDiffer.getCurrentList().size();
}
@NonNull
public List<T> getCurrentList() {
return this.mDiffer.getCurrentList();
}
}

View File

@@ -0,0 +1,14 @@
package androidx.recyclerview.widget;
import androidx.annotation.Nullable;
/* loaded from: classes.dex */
public interface ListUpdateCallback {
void onChanged(int i, int i2, @Nullable Object obj);
void onInserted(int i, int i2);
void onMoved(int i, int i2);
void onRemoved(int i, int i2);
}

View File

@@ -0,0 +1,288 @@
package androidx.recyclerview.widget;
import android.os.AsyncTask;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;
import androidx.recyclerview.widget.ThreadUtil;
import androidx.recyclerview.widget.TileList;
import java.util.concurrent.Executor;
import java.util.concurrent.atomic.AtomicBoolean;
/* loaded from: classes.dex */
class MessageThreadUtil<T> implements ThreadUtil<T> {
/* renamed from: androidx.recyclerview.widget.MessageThreadUtil$1, reason: invalid class name */
public class AnonymousClass1 implements ThreadUtil.MainThreadCallback<T> {
static final int ADD_TILE = 2;
static final int REMOVE_TILE = 3;
static final int UPDATE_ITEM_COUNT = 1;
final /* synthetic */ ThreadUtil.MainThreadCallback val$callback;
final MessageQueue mQueue = new MessageQueue();
private final Handler mMainThreadHandler = new Handler(Looper.getMainLooper());
private Runnable mMainThreadRunnable = new Runnable() { // from class: androidx.recyclerview.widget.MessageThreadUtil.1.1
@Override // java.lang.Runnable
public void run() {
SyncQueueItem next = AnonymousClass1.this.mQueue.next();
while (next != null) {
int i = next.what;
if (i == 1) {
AnonymousClass1.this.val$callback.updateItemCount(next.arg1, next.arg2);
} else if (i == 2) {
AnonymousClass1.this.val$callback.addTile(next.arg1, (TileList.Tile) next.data);
} else if (i == 3) {
AnonymousClass1.this.val$callback.removeTile(next.arg1, next.arg2);
} else {
Log.e("ThreadUtil", "Unsupported message, what=" + next.what);
}
next = AnonymousClass1.this.mQueue.next();
}
}
};
public AnonymousClass1(ThreadUtil.MainThreadCallback mainThreadCallback) {
this.val$callback = mainThreadCallback;
}
@Override // androidx.recyclerview.widget.ThreadUtil.MainThreadCallback
public void updateItemCount(int i, int i2) {
sendMessage(SyncQueueItem.obtainMessage(1, i, i2));
}
@Override // androidx.recyclerview.widget.ThreadUtil.MainThreadCallback
public void addTile(int i, TileList.Tile<T> tile) {
sendMessage(SyncQueueItem.obtainMessage(2, i, tile));
}
@Override // androidx.recyclerview.widget.ThreadUtil.MainThreadCallback
public void removeTile(int i, int i2) {
sendMessage(SyncQueueItem.obtainMessage(3, i, i2));
}
private void sendMessage(SyncQueueItem syncQueueItem) {
this.mQueue.sendMessage(syncQueueItem);
this.mMainThreadHandler.post(this.mMainThreadRunnable);
}
}
@Override // androidx.recyclerview.widget.ThreadUtil
public ThreadUtil.MainThreadCallback<T> getMainThreadProxy(ThreadUtil.MainThreadCallback<T> mainThreadCallback) {
return new AnonymousClass1(mainThreadCallback);
}
/* renamed from: androidx.recyclerview.widget.MessageThreadUtil$2, reason: invalid class name */
public class AnonymousClass2 implements ThreadUtil.BackgroundCallback<T> {
static final int LOAD_TILE = 3;
static final int RECYCLE_TILE = 4;
static final int REFRESH = 1;
static final int UPDATE_RANGE = 2;
final /* synthetic */ ThreadUtil.BackgroundCallback val$callback;
final MessageQueue mQueue = new MessageQueue();
private final Executor mExecutor = AsyncTask.THREAD_POOL_EXECUTOR;
AtomicBoolean mBackgroundRunning = new AtomicBoolean(false);
private Runnable mBackgroundRunnable = new Runnable() { // from class: androidx.recyclerview.widget.MessageThreadUtil.2.1
@Override // java.lang.Runnable
public void run() {
while (true) {
SyncQueueItem next = AnonymousClass2.this.mQueue.next();
if (next != null) {
int i = next.what;
if (i == 1) {
AnonymousClass2.this.mQueue.removeMessages(1);
AnonymousClass2.this.val$callback.refresh(next.arg1);
} else if (i == 2) {
AnonymousClass2.this.mQueue.removeMessages(2);
AnonymousClass2.this.mQueue.removeMessages(3);
AnonymousClass2.this.val$callback.updateRange(next.arg1, next.arg2, next.arg3, next.arg4, next.arg5);
} else if (i == 3) {
AnonymousClass2.this.val$callback.loadTile(next.arg1, next.arg2);
} else if (i == 4) {
AnonymousClass2.this.val$callback.recycleTile((TileList.Tile) next.data);
} else {
Log.e("ThreadUtil", "Unsupported message, what=" + next.what);
}
} else {
AnonymousClass2.this.mBackgroundRunning.set(false);
return;
}
}
}
};
public AnonymousClass2(ThreadUtil.BackgroundCallback backgroundCallback) {
this.val$callback = backgroundCallback;
}
@Override // androidx.recyclerview.widget.ThreadUtil.BackgroundCallback
public void refresh(int i) {
sendMessageAtFrontOfQueue(SyncQueueItem.obtainMessage(1, i, (Object) null));
}
@Override // androidx.recyclerview.widget.ThreadUtil.BackgroundCallback
public void updateRange(int i, int i2, int i3, int i4, int i5) {
sendMessageAtFrontOfQueue(SyncQueueItem.obtainMessage(2, i, i2, i3, i4, i5, null));
}
@Override // androidx.recyclerview.widget.ThreadUtil.BackgroundCallback
public void loadTile(int i, int i2) {
sendMessage(SyncQueueItem.obtainMessage(3, i, i2));
}
@Override // androidx.recyclerview.widget.ThreadUtil.BackgroundCallback
public void recycleTile(TileList.Tile<T> tile) {
sendMessage(SyncQueueItem.obtainMessage(4, 0, tile));
}
private void sendMessage(SyncQueueItem syncQueueItem) {
this.mQueue.sendMessage(syncQueueItem);
maybeExecuteBackgroundRunnable();
}
private void sendMessageAtFrontOfQueue(SyncQueueItem syncQueueItem) {
this.mQueue.sendMessageAtFrontOfQueue(syncQueueItem);
maybeExecuteBackgroundRunnable();
}
private void maybeExecuteBackgroundRunnable() {
if (this.mBackgroundRunning.compareAndSet(false, true)) {
this.mExecutor.execute(this.mBackgroundRunnable);
}
}
}
@Override // androidx.recyclerview.widget.ThreadUtil
public ThreadUtil.BackgroundCallback<T> getBackgroundProxy(ThreadUtil.BackgroundCallback<T> backgroundCallback) {
return new AnonymousClass2(backgroundCallback);
}
public static class SyncQueueItem {
private static SyncQueueItem sPool;
private static final Object sPoolLock = new Object();
public int arg1;
public int arg2;
public int arg3;
public int arg4;
public int arg5;
public Object data;
SyncQueueItem next;
public int what;
public void recycle() {
this.next = null;
this.arg5 = 0;
this.arg4 = 0;
this.arg3 = 0;
this.arg2 = 0;
this.arg1 = 0;
this.what = 0;
this.data = null;
synchronized (sPoolLock) {
try {
SyncQueueItem syncQueueItem = sPool;
if (syncQueueItem != null) {
this.next = syncQueueItem;
}
sPool = this;
} catch (Throwable th) {
throw th;
}
}
}
public static SyncQueueItem obtainMessage(int i, int i2, int i3, int i4, int i5, int i6, Object obj) {
SyncQueueItem syncQueueItem;
synchronized (sPoolLock) {
try {
syncQueueItem = sPool;
if (syncQueueItem == null) {
syncQueueItem = new SyncQueueItem();
} else {
sPool = syncQueueItem.next;
syncQueueItem.next = null;
}
syncQueueItem.what = i;
syncQueueItem.arg1 = i2;
syncQueueItem.arg2 = i3;
syncQueueItem.arg3 = i4;
syncQueueItem.arg4 = i5;
syncQueueItem.arg5 = i6;
syncQueueItem.data = obj;
} catch (Throwable th) {
throw th;
}
}
return syncQueueItem;
}
public static SyncQueueItem obtainMessage(int i, int i2, int i3) {
return obtainMessage(i, i2, i3, 0, 0, 0, null);
}
public static SyncQueueItem obtainMessage(int i, int i2, Object obj) {
return obtainMessage(i, i2, 0, 0, 0, 0, obj);
}
}
public static class MessageQueue {
private SyncQueueItem mRoot;
public synchronized SyncQueueItem next() {
SyncQueueItem syncQueueItem = this.mRoot;
if (syncQueueItem == null) {
return null;
}
this.mRoot = syncQueueItem.next;
return syncQueueItem;
}
public synchronized void sendMessageAtFrontOfQueue(SyncQueueItem syncQueueItem) {
syncQueueItem.next = this.mRoot;
this.mRoot = syncQueueItem;
}
public synchronized void sendMessage(SyncQueueItem syncQueueItem) {
SyncQueueItem syncQueueItem2 = this.mRoot;
if (syncQueueItem2 == null) {
this.mRoot = syncQueueItem;
return;
}
while (true) {
SyncQueueItem syncQueueItem3 = syncQueueItem2.next;
if (syncQueueItem3 == null) {
syncQueueItem2.next = syncQueueItem;
return;
}
syncQueueItem2 = syncQueueItem3;
}
}
public synchronized void removeMessages(int i) {
SyncQueueItem syncQueueItem;
while (true) {
try {
syncQueueItem = this.mRoot;
if (syncQueueItem == null || syncQueueItem.what != i) {
break;
}
this.mRoot = syncQueueItem.next;
syncQueueItem.recycle();
} catch (Throwable th) {
throw th;
}
}
if (syncQueueItem != null) {
SyncQueueItem syncQueueItem2 = syncQueueItem.next;
while (syncQueueItem2 != null) {
SyncQueueItem syncQueueItem3 = syncQueueItem2.next;
if (syncQueueItem2.what == i) {
syncQueueItem.next = syncQueueItem3;
syncQueueItem2.recycle();
} else {
syncQueueItem = syncQueueItem2;
}
syncQueueItem2 = syncQueueItem3;
}
}
}
}
}

View File

@@ -0,0 +1,132 @@
package androidx.recyclerview.widget;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.util.Preconditions;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.StableIdStorage;
import androidx.recyclerview.widget.ViewTypeStorage;
/* loaded from: classes.dex */
class NestedAdapterWrapper {
public final RecyclerView.Adapter<RecyclerView.ViewHolder> adapter;
private RecyclerView.AdapterDataObserver mAdapterObserver = new RecyclerView.AdapterDataObserver() { // from class: androidx.recyclerview.widget.NestedAdapterWrapper.1
@Override // androidx.recyclerview.widget.RecyclerView.AdapterDataObserver
public void onChanged() {
NestedAdapterWrapper nestedAdapterWrapper = NestedAdapterWrapper.this;
nestedAdapterWrapper.mCachedItemCount = nestedAdapterWrapper.adapter.getItemCount();
NestedAdapterWrapper nestedAdapterWrapper2 = NestedAdapterWrapper.this;
nestedAdapterWrapper2.mCallback.onChanged(nestedAdapterWrapper2);
}
@Override // androidx.recyclerview.widget.RecyclerView.AdapterDataObserver
public void onItemRangeChanged(int i, int i2) {
NestedAdapterWrapper nestedAdapterWrapper = NestedAdapterWrapper.this;
nestedAdapterWrapper.mCallback.onItemRangeChanged(nestedAdapterWrapper, i, i2, null);
}
@Override // androidx.recyclerview.widget.RecyclerView.AdapterDataObserver
public void onItemRangeChanged(int i, int i2, @Nullable Object obj) {
NestedAdapterWrapper nestedAdapterWrapper = NestedAdapterWrapper.this;
nestedAdapterWrapper.mCallback.onItemRangeChanged(nestedAdapterWrapper, i, i2, obj);
}
@Override // androidx.recyclerview.widget.RecyclerView.AdapterDataObserver
public void onItemRangeInserted(int i, int i2) {
NestedAdapterWrapper nestedAdapterWrapper = NestedAdapterWrapper.this;
nestedAdapterWrapper.mCachedItemCount += i2;
nestedAdapterWrapper.mCallback.onItemRangeInserted(nestedAdapterWrapper, i, i2);
NestedAdapterWrapper nestedAdapterWrapper2 = NestedAdapterWrapper.this;
if (nestedAdapterWrapper2.mCachedItemCount <= 0 || nestedAdapterWrapper2.adapter.getStateRestorationPolicy() != RecyclerView.Adapter.StateRestorationPolicy.PREVENT_WHEN_EMPTY) {
return;
}
NestedAdapterWrapper nestedAdapterWrapper3 = NestedAdapterWrapper.this;
nestedAdapterWrapper3.mCallback.onStateRestorationPolicyChanged(nestedAdapterWrapper3);
}
@Override // androidx.recyclerview.widget.RecyclerView.AdapterDataObserver
public void onItemRangeRemoved(int i, int i2) {
NestedAdapterWrapper nestedAdapterWrapper = NestedAdapterWrapper.this;
nestedAdapterWrapper.mCachedItemCount -= i2;
nestedAdapterWrapper.mCallback.onItemRangeRemoved(nestedAdapterWrapper, i, i2);
NestedAdapterWrapper nestedAdapterWrapper2 = NestedAdapterWrapper.this;
if (nestedAdapterWrapper2.mCachedItemCount >= 1 || nestedAdapterWrapper2.adapter.getStateRestorationPolicy() != RecyclerView.Adapter.StateRestorationPolicy.PREVENT_WHEN_EMPTY) {
return;
}
NestedAdapterWrapper nestedAdapterWrapper3 = NestedAdapterWrapper.this;
nestedAdapterWrapper3.mCallback.onStateRestorationPolicyChanged(nestedAdapterWrapper3);
}
@Override // androidx.recyclerview.widget.RecyclerView.AdapterDataObserver
public void onItemRangeMoved(int i, int i2, int i3) {
Preconditions.checkArgument(i3 == 1, "moving more than 1 item is not supported in RecyclerView");
NestedAdapterWrapper nestedAdapterWrapper = NestedAdapterWrapper.this;
nestedAdapterWrapper.mCallback.onItemRangeMoved(nestedAdapterWrapper, i, i2);
}
@Override // androidx.recyclerview.widget.RecyclerView.AdapterDataObserver
public void onStateRestorationPolicyChanged() {
NestedAdapterWrapper nestedAdapterWrapper = NestedAdapterWrapper.this;
nestedAdapterWrapper.mCallback.onStateRestorationPolicyChanged(nestedAdapterWrapper);
}
};
int mCachedItemCount;
final Callback mCallback;
@NonNull
private final StableIdStorage.StableIdLookup mStableIdLookup;
@NonNull
private final ViewTypeStorage.ViewTypeLookup mViewTypeLookup;
public interface Callback {
void onChanged(@NonNull NestedAdapterWrapper nestedAdapterWrapper);
void onItemRangeChanged(@NonNull NestedAdapterWrapper nestedAdapterWrapper, int i, int i2);
void onItemRangeChanged(@NonNull NestedAdapterWrapper nestedAdapterWrapper, int i, int i2, @Nullable Object obj);
void onItemRangeInserted(@NonNull NestedAdapterWrapper nestedAdapterWrapper, int i, int i2);
void onItemRangeMoved(@NonNull NestedAdapterWrapper nestedAdapterWrapper, int i, int i2);
void onItemRangeRemoved(@NonNull NestedAdapterWrapper nestedAdapterWrapper, int i, int i2);
void onStateRestorationPolicyChanged(NestedAdapterWrapper nestedAdapterWrapper);
}
public int getCachedItemCount() {
return this.mCachedItemCount;
}
public NestedAdapterWrapper(RecyclerView.Adapter<RecyclerView.ViewHolder> adapter, Callback callback, ViewTypeStorage viewTypeStorage, StableIdStorage.StableIdLookup stableIdLookup) {
this.adapter = adapter;
this.mCallback = callback;
this.mViewTypeLookup = viewTypeStorage.createViewTypeWrapper(this);
this.mStableIdLookup = stableIdLookup;
this.mCachedItemCount = adapter.getItemCount();
adapter.registerAdapterDataObserver(this.mAdapterObserver);
}
public void dispose() {
this.adapter.unregisterAdapterDataObserver(this.mAdapterObserver);
this.mViewTypeLookup.dispose();
}
public int getItemViewType(int i) {
return this.mViewTypeLookup.localToGlobal(this.adapter.getItemViewType(i));
}
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
return this.adapter.onCreateViewHolder(viewGroup, this.mViewTypeLookup.globalToLocal(i));
}
public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, int i) {
this.adapter.bindViewHolder(viewHolder, i);
}
public long getItemId(int i) {
return this.mStableIdLookup.localToGlobal(this.adapter.getItemId(i));
}
}

View File

@@ -0,0 +1,259 @@
package androidx.recyclerview.widget;
import androidx.recyclerview.widget.AdapterHelper;
import java.util.List;
/* loaded from: classes.dex */
class OpReorderer {
final Callback mCallback;
public interface Callback {
AdapterHelper.UpdateOp obtainUpdateOp(int i, int i2, int i3, Object obj);
void recycleUpdateOp(AdapterHelper.UpdateOp updateOp);
}
public OpReorderer(Callback callback) {
this.mCallback = callback;
}
public void reorderOps(List<AdapterHelper.UpdateOp> list) {
while (true) {
int lastMoveOutOfOrder = getLastMoveOutOfOrder(list);
if (lastMoveOutOfOrder == -1) {
return;
} else {
swapMoveOp(list, lastMoveOutOfOrder, lastMoveOutOfOrder + 1);
}
}
}
private void swapMoveOp(List<AdapterHelper.UpdateOp> list, int i, int i2) {
AdapterHelper.UpdateOp updateOp = list.get(i);
AdapterHelper.UpdateOp updateOp2 = list.get(i2);
int i3 = updateOp2.cmd;
if (i3 == 1) {
swapMoveAdd(list, i, updateOp, i2, updateOp2);
} else if (i3 == 2) {
swapMoveRemove(list, i, updateOp, i2, updateOp2);
} else {
if (i3 != 4) {
return;
}
swapMoveUpdate(list, i, updateOp, i2, updateOp2);
}
}
public void swapMoveRemove(List<AdapterHelper.UpdateOp> list, int i, AdapterHelper.UpdateOp updateOp, int i2, AdapterHelper.UpdateOp updateOp2) {
boolean z;
int i3 = updateOp.positionStart;
int i4 = updateOp.itemCount;
boolean z2 = false;
if (i3 < i4) {
if (updateOp2.positionStart == i3 && updateOp2.itemCount == i4 - i3) {
z = false;
z2 = true;
} else {
z = false;
}
} else if (updateOp2.positionStart == i4 + 1 && updateOp2.itemCount == i3 - i4) {
z = true;
z2 = true;
} else {
z = true;
}
int i5 = updateOp2.positionStart;
if (i4 < i5) {
updateOp2.positionStart = i5 - 1;
} else {
int i6 = updateOp2.itemCount;
if (i4 < i5 + i6) {
updateOp2.itemCount = i6 - 1;
updateOp.cmd = 2;
updateOp.itemCount = 1;
if (updateOp2.itemCount == 0) {
list.remove(i2);
this.mCallback.recycleUpdateOp(updateOp2);
return;
}
return;
}
}
int i7 = updateOp.positionStart;
int i8 = updateOp2.positionStart;
AdapterHelper.UpdateOp updateOp3 = null;
if (i7 <= i8) {
updateOp2.positionStart = i8 + 1;
} else {
int i9 = updateOp2.itemCount;
if (i7 < i8 + i9) {
updateOp3 = this.mCallback.obtainUpdateOp(2, i7 + 1, (i8 + i9) - i7, null);
updateOp2.itemCount = updateOp.positionStart - updateOp2.positionStart;
}
}
if (z2) {
list.set(i, updateOp2);
list.remove(i2);
this.mCallback.recycleUpdateOp(updateOp);
return;
}
if (z) {
if (updateOp3 != null) {
int i10 = updateOp.positionStart;
if (i10 > updateOp3.positionStart) {
updateOp.positionStart = i10 - updateOp3.itemCount;
}
int i11 = updateOp.itemCount;
if (i11 > updateOp3.positionStart) {
updateOp.itemCount = i11 - updateOp3.itemCount;
}
}
int i12 = updateOp.positionStart;
if (i12 > updateOp2.positionStart) {
updateOp.positionStart = i12 - updateOp2.itemCount;
}
int i13 = updateOp.itemCount;
if (i13 > updateOp2.positionStart) {
updateOp.itemCount = i13 - updateOp2.itemCount;
}
} else {
if (updateOp3 != null) {
int i14 = updateOp.positionStart;
if (i14 >= updateOp3.positionStart) {
updateOp.positionStart = i14 - updateOp3.itemCount;
}
int i15 = updateOp.itemCount;
if (i15 >= updateOp3.positionStart) {
updateOp.itemCount = i15 - updateOp3.itemCount;
}
}
int i16 = updateOp.positionStart;
if (i16 >= updateOp2.positionStart) {
updateOp.positionStart = i16 - updateOp2.itemCount;
}
int i17 = updateOp.itemCount;
if (i17 >= updateOp2.positionStart) {
updateOp.itemCount = i17 - updateOp2.itemCount;
}
}
list.set(i, updateOp2);
if (updateOp.positionStart != updateOp.itemCount) {
list.set(i2, updateOp);
} else {
list.remove(i2);
}
if (updateOp3 != null) {
list.add(i, updateOp3);
}
}
private void swapMoveAdd(List<AdapterHelper.UpdateOp> list, int i, AdapterHelper.UpdateOp updateOp, int i2, AdapterHelper.UpdateOp updateOp2) {
int i3 = updateOp.itemCount;
int i4 = updateOp2.positionStart;
int i5 = i3 < i4 ? -1 : 0;
int i6 = updateOp.positionStart;
if (i6 < i4) {
i5++;
}
if (i4 <= i6) {
updateOp.positionStart = i6 + updateOp2.itemCount;
}
int i7 = updateOp2.positionStart;
if (i7 <= i3) {
updateOp.itemCount = i3 + updateOp2.itemCount;
}
updateOp2.positionStart = i7 + i5;
list.set(i, updateOp2);
list.set(i2, updateOp);
}
/* JADX WARN: Removed duplicated region for block: B:10:0x0048 */
/* JADX WARN: Removed duplicated region for block: B:12:0x0056 */
/* JADX WARN: Removed duplicated region for block: B:14:0x005b */
/* JADX WARN: Removed duplicated region for block: B:17:? A[RETURN, SYNTHETIC] */
/* JADX WARN: Removed duplicated region for block: B:18:0x004c */
/* JADX WARN: Removed duplicated region for block: B:19:0x002b */
/* JADX WARN: Removed duplicated region for block: B:7:0x0027 */
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
public void swapMoveUpdate(java.util.List<androidx.recyclerview.widget.AdapterHelper.UpdateOp> r9, int r10, androidx.recyclerview.widget.AdapterHelper.UpdateOp r11, int r12, androidx.recyclerview.widget.AdapterHelper.UpdateOp r13) {
/*
r8 = this;
int r0 = r11.itemCount
int r1 = r13.positionStart
r2 = 4
r3 = 1
r4 = 0
if (r0 >= r1) goto Ld
int r1 = r1 - r3
r13.positionStart = r1
goto L20
Ld:
int r5 = r13.itemCount
int r1 = r1 + r5
if (r0 >= r1) goto L20
int r5 = r5 - r3
r13.itemCount = r5
androidx.recyclerview.widget.OpReorderer$Callback r0 = r8.mCallback
int r1 = r11.positionStart
java.lang.Object r5 = r13.payload
androidx.recyclerview.widget.AdapterHelper$UpdateOp r0 = r0.obtainUpdateOp(r2, r1, r3, r5)
goto L21
L20:
r0 = r4
L21:
int r1 = r11.positionStart
int r5 = r13.positionStart
if (r1 > r5) goto L2b
int r5 = r5 + r3
r13.positionStart = r5
goto L41
L2b:
int r6 = r13.itemCount
int r7 = r5 + r6
if (r1 >= r7) goto L41
int r5 = r5 + r6
int r5 = r5 - r1
androidx.recyclerview.widget.OpReorderer$Callback r4 = r8.mCallback
int r1 = r1 + r3
java.lang.Object r3 = r13.payload
androidx.recyclerview.widget.AdapterHelper$UpdateOp r4 = r4.obtainUpdateOp(r2, r1, r5, r3)
int r1 = r13.itemCount
int r1 = r1 - r5
r13.itemCount = r1
L41:
r9.set(r12, r11)
int r11 = r13.itemCount
if (r11 <= 0) goto L4c
r9.set(r10, r13)
goto L54
L4c:
r9.remove(r10)
androidx.recyclerview.widget.OpReorderer$Callback r11 = r8.mCallback
r11.recycleUpdateOp(r13)
L54:
if (r0 == 0) goto L59
r9.add(r10, r0)
L59:
if (r4 == 0) goto L5e
r9.add(r10, r4)
L5e:
return
*/
throw new UnsupportedOperationException("Method not decompiled: androidx.recyclerview.widget.OpReorderer.swapMoveUpdate(java.util.List, int, androidx.recyclerview.widget.AdapterHelper$UpdateOp, int, androidx.recyclerview.widget.AdapterHelper$UpdateOp):void");
}
private int getLastMoveOutOfOrder(List<AdapterHelper.UpdateOp> list) {
boolean z = false;
for (int size = list.size() - 1; size >= 0; size--) {
if (list.get(size).cmd != 8) {
z = true;
} else if (z) {
return size;
}
}
return -1;
}
}

View File

@@ -0,0 +1,243 @@
package androidx.recyclerview.widget;
import android.graphics.Rect;
import android.view.View;
import android.view.ViewGroup;
import androidx.recyclerview.widget.RecyclerView;
/* loaded from: classes.dex */
public abstract class OrientationHelper {
public static final int HORIZONTAL = 0;
private static final int INVALID_SIZE = Integer.MIN_VALUE;
public static final int VERTICAL = 1;
private int mLastTotalSpace;
protected final RecyclerView.LayoutManager mLayoutManager;
final Rect mTmpRect;
public abstract int getDecoratedEnd(View view);
public abstract int getDecoratedMeasurement(View view);
public abstract int getDecoratedMeasurementInOther(View view);
public abstract int getDecoratedStart(View view);
public abstract int getEnd();
public abstract int getEndAfterPadding();
public abstract int getEndPadding();
public RecyclerView.LayoutManager getLayoutManager() {
return this.mLayoutManager;
}
public abstract int getMode();
public abstract int getModeInOther();
public abstract int getStartAfterPadding();
public abstract int getTotalSpace();
public abstract int getTransformedEndWithDecoration(View view);
public abstract int getTransformedStartWithDecoration(View view);
public abstract void offsetChild(View view, int i);
public abstract void offsetChildren(int i);
private OrientationHelper(RecyclerView.LayoutManager layoutManager) {
this.mLastTotalSpace = Integer.MIN_VALUE;
this.mTmpRect = new Rect();
this.mLayoutManager = layoutManager;
}
public void onLayoutComplete() {
this.mLastTotalSpace = getTotalSpace();
}
public int getTotalSpaceChange() {
if (Integer.MIN_VALUE == this.mLastTotalSpace) {
return 0;
}
return getTotalSpace() - this.mLastTotalSpace;
}
public static OrientationHelper createOrientationHelper(RecyclerView.LayoutManager layoutManager, int i) {
if (i == 0) {
return createHorizontalHelper(layoutManager);
}
if (i == 1) {
return createVerticalHelper(layoutManager);
}
throw new IllegalArgumentException("invalid orientation");
}
public static OrientationHelper createHorizontalHelper(RecyclerView.LayoutManager layoutManager) {
return new OrientationHelper(layoutManager) { // from class: androidx.recyclerview.widget.OrientationHelper.1
@Override // androidx.recyclerview.widget.OrientationHelper
public int getEndAfterPadding() {
return this.mLayoutManager.getWidth() - this.mLayoutManager.getPaddingRight();
}
@Override // androidx.recyclerview.widget.OrientationHelper
public int getEnd() {
return this.mLayoutManager.getWidth();
}
@Override // androidx.recyclerview.widget.OrientationHelper
public void offsetChildren(int i) {
this.mLayoutManager.offsetChildrenHorizontal(i);
}
@Override // androidx.recyclerview.widget.OrientationHelper
public int getStartAfterPadding() {
return this.mLayoutManager.getPaddingLeft();
}
@Override // androidx.recyclerview.widget.OrientationHelper
public int getDecoratedMeasurement(View view) {
RecyclerView.LayoutParams layoutParams = (RecyclerView.LayoutParams) view.getLayoutParams();
return this.mLayoutManager.getDecoratedMeasuredWidth(view) + ((ViewGroup.MarginLayoutParams) layoutParams).leftMargin + ((ViewGroup.MarginLayoutParams) layoutParams).rightMargin;
}
@Override // androidx.recyclerview.widget.OrientationHelper
public int getDecoratedMeasurementInOther(View view) {
RecyclerView.LayoutParams layoutParams = (RecyclerView.LayoutParams) view.getLayoutParams();
return this.mLayoutManager.getDecoratedMeasuredHeight(view) + ((ViewGroup.MarginLayoutParams) layoutParams).topMargin + ((ViewGroup.MarginLayoutParams) layoutParams).bottomMargin;
}
@Override // androidx.recyclerview.widget.OrientationHelper
public int getDecoratedEnd(View view) {
return this.mLayoutManager.getDecoratedRight(view) + ((ViewGroup.MarginLayoutParams) ((RecyclerView.LayoutParams) view.getLayoutParams())).rightMargin;
}
@Override // androidx.recyclerview.widget.OrientationHelper
public int getDecoratedStart(View view) {
return this.mLayoutManager.getDecoratedLeft(view) - ((ViewGroup.MarginLayoutParams) ((RecyclerView.LayoutParams) view.getLayoutParams())).leftMargin;
}
@Override // androidx.recyclerview.widget.OrientationHelper
public int getTransformedEndWithDecoration(View view) {
this.mLayoutManager.getTransformedBoundingBox(view, true, this.mTmpRect);
return this.mTmpRect.right;
}
@Override // androidx.recyclerview.widget.OrientationHelper
public int getTransformedStartWithDecoration(View view) {
this.mLayoutManager.getTransformedBoundingBox(view, true, this.mTmpRect);
return this.mTmpRect.left;
}
@Override // androidx.recyclerview.widget.OrientationHelper
public int getTotalSpace() {
return (this.mLayoutManager.getWidth() - this.mLayoutManager.getPaddingLeft()) - this.mLayoutManager.getPaddingRight();
}
@Override // androidx.recyclerview.widget.OrientationHelper
public void offsetChild(View view, int i) {
view.offsetLeftAndRight(i);
}
@Override // androidx.recyclerview.widget.OrientationHelper
public int getEndPadding() {
return this.mLayoutManager.getPaddingRight();
}
@Override // androidx.recyclerview.widget.OrientationHelper
public int getMode() {
return this.mLayoutManager.getWidthMode();
}
@Override // androidx.recyclerview.widget.OrientationHelper
public int getModeInOther() {
return this.mLayoutManager.getHeightMode();
}
};
}
public static OrientationHelper createVerticalHelper(RecyclerView.LayoutManager layoutManager) {
return new OrientationHelper(layoutManager) { // from class: androidx.recyclerview.widget.OrientationHelper.2
@Override // androidx.recyclerview.widget.OrientationHelper
public int getEndAfterPadding() {
return this.mLayoutManager.getHeight() - this.mLayoutManager.getPaddingBottom();
}
@Override // androidx.recyclerview.widget.OrientationHelper
public int getEnd() {
return this.mLayoutManager.getHeight();
}
@Override // androidx.recyclerview.widget.OrientationHelper
public void offsetChildren(int i) {
this.mLayoutManager.offsetChildrenVertical(i);
}
@Override // androidx.recyclerview.widget.OrientationHelper
public int getStartAfterPadding() {
return this.mLayoutManager.getPaddingTop();
}
@Override // androidx.recyclerview.widget.OrientationHelper
public int getDecoratedMeasurement(View view) {
RecyclerView.LayoutParams layoutParams = (RecyclerView.LayoutParams) view.getLayoutParams();
return this.mLayoutManager.getDecoratedMeasuredHeight(view) + ((ViewGroup.MarginLayoutParams) layoutParams).topMargin + ((ViewGroup.MarginLayoutParams) layoutParams).bottomMargin;
}
@Override // androidx.recyclerview.widget.OrientationHelper
public int getDecoratedMeasurementInOther(View view) {
RecyclerView.LayoutParams layoutParams = (RecyclerView.LayoutParams) view.getLayoutParams();
return this.mLayoutManager.getDecoratedMeasuredWidth(view) + ((ViewGroup.MarginLayoutParams) layoutParams).leftMargin + ((ViewGroup.MarginLayoutParams) layoutParams).rightMargin;
}
@Override // androidx.recyclerview.widget.OrientationHelper
public int getDecoratedEnd(View view) {
return this.mLayoutManager.getDecoratedBottom(view) + ((ViewGroup.MarginLayoutParams) ((RecyclerView.LayoutParams) view.getLayoutParams())).bottomMargin;
}
@Override // androidx.recyclerview.widget.OrientationHelper
public int getDecoratedStart(View view) {
return this.mLayoutManager.getDecoratedTop(view) - ((ViewGroup.MarginLayoutParams) ((RecyclerView.LayoutParams) view.getLayoutParams())).topMargin;
}
@Override // androidx.recyclerview.widget.OrientationHelper
public int getTransformedEndWithDecoration(View view) {
this.mLayoutManager.getTransformedBoundingBox(view, true, this.mTmpRect);
return this.mTmpRect.bottom;
}
@Override // androidx.recyclerview.widget.OrientationHelper
public int getTransformedStartWithDecoration(View view) {
this.mLayoutManager.getTransformedBoundingBox(view, true, this.mTmpRect);
return this.mTmpRect.top;
}
@Override // androidx.recyclerview.widget.OrientationHelper
public int getTotalSpace() {
return (this.mLayoutManager.getHeight() - this.mLayoutManager.getPaddingTop()) - this.mLayoutManager.getPaddingBottom();
}
@Override // androidx.recyclerview.widget.OrientationHelper
public void offsetChild(View view, int i) {
view.offsetTopAndBottom(i);
}
@Override // androidx.recyclerview.widget.OrientationHelper
public int getEndPadding() {
return this.mLayoutManager.getPaddingBottom();
}
@Override // androidx.recyclerview.widget.OrientationHelper
public int getMode() {
return this.mLayoutManager.getHeightMode();
}
@Override // androidx.recyclerview.widget.OrientationHelper
public int getModeInOther() {
return this.mLayoutManager.getWidthMode();
}
};
}
}

View File

@@ -0,0 +1,192 @@
package androidx.recyclerview.widget;
import android.graphics.PointF;
import android.util.DisplayMetrics;
import android.view.View;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView;
/* loaded from: classes.dex */
public class PagerSnapHelper extends SnapHelper {
private static final int MAX_SCROLL_ON_FLING_DURATION = 100;
@Nullable
private OrientationHelper mHorizontalHelper;
@Nullable
private OrientationHelper mVerticalHelper;
@Override // androidx.recyclerview.widget.SnapHelper
@Nullable
public int[] calculateDistanceToFinalSnap(@NonNull RecyclerView.LayoutManager layoutManager, @NonNull View view) {
int[] iArr = new int[2];
if (layoutManager.canScrollHorizontally()) {
iArr[0] = distanceToCenter(view, getHorizontalHelper(layoutManager));
} else {
iArr[0] = 0;
}
if (layoutManager.canScrollVertically()) {
iArr[1] = distanceToCenter(view, getVerticalHelper(layoutManager));
} else {
iArr[1] = 0;
}
return iArr;
}
@Override // androidx.recyclerview.widget.SnapHelper
@Nullable
public View findSnapView(RecyclerView.LayoutManager layoutManager) {
if (layoutManager.canScrollVertically()) {
return findCenterView(layoutManager, getVerticalHelper(layoutManager));
}
if (layoutManager.canScrollHorizontally()) {
return findCenterView(layoutManager, getHorizontalHelper(layoutManager));
}
return null;
}
@Override // androidx.recyclerview.widget.SnapHelper
public int findTargetSnapPosition(RecyclerView.LayoutManager layoutManager, int i, int i2) {
OrientationHelper orientationHelper;
int itemCount = layoutManager.getItemCount();
if (itemCount == 0 || (orientationHelper = getOrientationHelper(layoutManager)) == null) {
return -1;
}
int childCount = layoutManager.getChildCount();
View view = null;
int i3 = Integer.MAX_VALUE;
int i4 = Integer.MIN_VALUE;
View view2 = null;
for (int i5 = 0; i5 < childCount; i5++) {
View childAt = layoutManager.getChildAt(i5);
if (childAt != null) {
int distanceToCenter = distanceToCenter(childAt, orientationHelper);
if (distanceToCenter <= 0 && distanceToCenter > i4) {
view2 = childAt;
i4 = distanceToCenter;
}
if (distanceToCenter >= 0 && distanceToCenter < i3) {
view = childAt;
i3 = distanceToCenter;
}
}
}
boolean isForwardFling = isForwardFling(layoutManager, i, i2);
if (isForwardFling && view != null) {
return layoutManager.getPosition(view);
}
if (!isForwardFling && view2 != null) {
return layoutManager.getPosition(view2);
}
if (isForwardFling) {
view = view2;
}
if (view == null) {
return -1;
}
int position = layoutManager.getPosition(view) + (isReverseLayout(layoutManager) == isForwardFling ? -1 : 1);
if (position < 0 || position >= itemCount) {
return -1;
}
return position;
}
private boolean isForwardFling(RecyclerView.LayoutManager layoutManager, int i, int i2) {
return layoutManager.canScrollHorizontally() ? i > 0 : i2 > 0;
}
/* JADX WARN: Multi-variable type inference failed */
private boolean isReverseLayout(RecyclerView.LayoutManager layoutManager) {
PointF computeScrollVectorForPosition;
int itemCount = layoutManager.getItemCount();
if (!(layoutManager instanceof RecyclerView.SmoothScroller.ScrollVectorProvider) || (computeScrollVectorForPosition = ((RecyclerView.SmoothScroller.ScrollVectorProvider) layoutManager).computeScrollVectorForPosition(itemCount - 1)) == null) {
return false;
}
return computeScrollVectorForPosition.x < 0.0f || computeScrollVectorForPosition.y < 0.0f;
}
@Override // androidx.recyclerview.widget.SnapHelper
@Nullable
public RecyclerView.SmoothScroller createScroller(@NonNull RecyclerView.LayoutManager layoutManager) {
if (layoutManager instanceof RecyclerView.SmoothScroller.ScrollVectorProvider) {
return new LinearSmoothScroller(this.mRecyclerView.getContext()) { // from class: androidx.recyclerview.widget.PagerSnapHelper.1
@Override // androidx.recyclerview.widget.LinearSmoothScroller, androidx.recyclerview.widget.RecyclerView.SmoothScroller
public void onTargetFound(View view, RecyclerView.State state, RecyclerView.SmoothScroller.Action action) {
PagerSnapHelper pagerSnapHelper = PagerSnapHelper.this;
int[] calculateDistanceToFinalSnap = pagerSnapHelper.calculateDistanceToFinalSnap(pagerSnapHelper.mRecyclerView.getLayoutManager(), view);
int i = calculateDistanceToFinalSnap[0];
int i2 = calculateDistanceToFinalSnap[1];
int calculateTimeForDeceleration = calculateTimeForDeceleration(Math.max(Math.abs(i), Math.abs(i2)));
if (calculateTimeForDeceleration > 0) {
action.update(i, i2, calculateTimeForDeceleration, this.mDecelerateInterpolator);
}
}
@Override // androidx.recyclerview.widget.LinearSmoothScroller
public float calculateSpeedPerPixel(DisplayMetrics displayMetrics) {
return 100.0f / displayMetrics.densityDpi;
}
@Override // androidx.recyclerview.widget.LinearSmoothScroller
public int calculateTimeForScrolling(int i) {
return Math.min(100, super.calculateTimeForScrolling(i));
}
};
}
return null;
}
private int distanceToCenter(@NonNull View view, OrientationHelper orientationHelper) {
return (orientationHelper.getDecoratedStart(view) + (orientationHelper.getDecoratedMeasurement(view) / 2)) - (orientationHelper.getStartAfterPadding() + (orientationHelper.getTotalSpace() / 2));
}
@Nullable
private View findCenterView(RecyclerView.LayoutManager layoutManager, OrientationHelper orientationHelper) {
int childCount = layoutManager.getChildCount();
View view = null;
if (childCount == 0) {
return null;
}
int startAfterPadding = orientationHelper.getStartAfterPadding() + (orientationHelper.getTotalSpace() / 2);
int i = Integer.MAX_VALUE;
for (int i2 = 0; i2 < childCount; i2++) {
View childAt = layoutManager.getChildAt(i2);
int abs = Math.abs((orientationHelper.getDecoratedStart(childAt) + (orientationHelper.getDecoratedMeasurement(childAt) / 2)) - startAfterPadding);
if (abs < i) {
view = childAt;
i = abs;
}
}
return view;
}
@Nullable
private OrientationHelper getOrientationHelper(RecyclerView.LayoutManager layoutManager) {
if (layoutManager.canScrollVertically()) {
return getVerticalHelper(layoutManager);
}
if (layoutManager.canScrollHorizontally()) {
return getHorizontalHelper(layoutManager);
}
return null;
}
@NonNull
private OrientationHelper getVerticalHelper(@NonNull RecyclerView.LayoutManager layoutManager) {
OrientationHelper orientationHelper = this.mVerticalHelper;
if (orientationHelper == null || orientationHelper.mLayoutManager != layoutManager) {
this.mVerticalHelper = OrientationHelper.createVerticalHelper(layoutManager);
}
return this.mVerticalHelper;
}
@NonNull
private OrientationHelper getHorizontalHelper(@NonNull RecyclerView.LayoutManager layoutManager) {
OrientationHelper orientationHelper = this.mHorizontalHelper;
if (orientationHelper == null || orientationHelper.mLayoutManager != layoutManager) {
this.mHorizontalHelper = OrientationHelper.createHorizontalHelper(layoutManager);
}
return this.mHorizontalHelper;
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,192 @@
package androidx.recyclerview.widget;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.view.accessibility.AccessibilityEvent;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.view.AccessibilityDelegateCompat;
import androidx.core.view.ViewCompat;
import androidx.core.view.accessibility.AccessibilityNodeInfoCompat;
import androidx.core.view.accessibility.AccessibilityNodeProviderCompat;
import java.util.Map;
import java.util.WeakHashMap;
/* loaded from: classes.dex */
public class RecyclerViewAccessibilityDelegate extends AccessibilityDelegateCompat {
private final ItemDelegate mItemDelegate;
final RecyclerView mRecyclerView;
@NonNull
public AccessibilityDelegateCompat getItemDelegate() {
return this.mItemDelegate;
}
public RecyclerViewAccessibilityDelegate(@NonNull RecyclerView recyclerView) {
this.mRecyclerView = recyclerView;
AccessibilityDelegateCompat itemDelegate = getItemDelegate();
if (itemDelegate != null && (itemDelegate instanceof ItemDelegate)) {
this.mItemDelegate = (ItemDelegate) itemDelegate;
} else {
this.mItemDelegate = new ItemDelegate(this);
}
}
public boolean shouldIgnore() {
return this.mRecyclerView.hasPendingAdapterUpdates();
}
@Override // androidx.core.view.AccessibilityDelegateCompat
public boolean performAccessibilityAction(View view, int i, Bundle bundle) {
if (super.performAccessibilityAction(view, i, bundle)) {
return true;
}
if (shouldIgnore() || this.mRecyclerView.getLayoutManager() == null) {
return false;
}
return this.mRecyclerView.getLayoutManager().performAccessibilityAction(i, bundle);
}
@Override // androidx.core.view.AccessibilityDelegateCompat
public void onInitializeAccessibilityNodeInfo(View view, AccessibilityNodeInfoCompat accessibilityNodeInfoCompat) {
super.onInitializeAccessibilityNodeInfo(view, accessibilityNodeInfoCompat);
if (shouldIgnore() || this.mRecyclerView.getLayoutManager() == null) {
return;
}
this.mRecyclerView.getLayoutManager().onInitializeAccessibilityNodeInfo(accessibilityNodeInfoCompat);
}
@Override // androidx.core.view.AccessibilityDelegateCompat
public void onInitializeAccessibilityEvent(View view, AccessibilityEvent accessibilityEvent) {
super.onInitializeAccessibilityEvent(view, accessibilityEvent);
if (!(view instanceof RecyclerView) || shouldIgnore()) {
return;
}
RecyclerView recyclerView = (RecyclerView) view;
if (recyclerView.getLayoutManager() != null) {
recyclerView.getLayoutManager().onInitializeAccessibilityEvent(accessibilityEvent);
}
}
public static class ItemDelegate extends AccessibilityDelegateCompat {
private Map<View, AccessibilityDelegateCompat> mOriginalItemDelegates = new WeakHashMap();
final RecyclerViewAccessibilityDelegate mRecyclerViewDelegate;
public ItemDelegate(@NonNull RecyclerViewAccessibilityDelegate recyclerViewAccessibilityDelegate) {
this.mRecyclerViewDelegate = recyclerViewAccessibilityDelegate;
}
public void saveOriginalDelegate(View view) {
AccessibilityDelegateCompat accessibilityDelegate = ViewCompat.getAccessibilityDelegate(view);
if (accessibilityDelegate == null || accessibilityDelegate == this) {
return;
}
this.mOriginalItemDelegates.put(view, accessibilityDelegate);
}
public AccessibilityDelegateCompat getAndRemoveOriginalDelegateForItem(View view) {
return this.mOriginalItemDelegates.remove(view);
}
@Override // androidx.core.view.AccessibilityDelegateCompat
public void onInitializeAccessibilityNodeInfo(View view, AccessibilityNodeInfoCompat accessibilityNodeInfoCompat) {
if (!this.mRecyclerViewDelegate.shouldIgnore() && this.mRecyclerViewDelegate.mRecyclerView.getLayoutManager() != null) {
this.mRecyclerViewDelegate.mRecyclerView.getLayoutManager().onInitializeAccessibilityNodeInfoForItem(view, accessibilityNodeInfoCompat);
AccessibilityDelegateCompat accessibilityDelegateCompat = this.mOriginalItemDelegates.get(view);
if (accessibilityDelegateCompat != null) {
accessibilityDelegateCompat.onInitializeAccessibilityNodeInfo(view, accessibilityNodeInfoCompat);
return;
} else {
super.onInitializeAccessibilityNodeInfo(view, accessibilityNodeInfoCompat);
return;
}
}
super.onInitializeAccessibilityNodeInfo(view, accessibilityNodeInfoCompat);
}
@Override // androidx.core.view.AccessibilityDelegateCompat
public boolean performAccessibilityAction(View view, int i, Bundle bundle) {
if (!this.mRecyclerViewDelegate.shouldIgnore() && this.mRecyclerViewDelegate.mRecyclerView.getLayoutManager() != null) {
AccessibilityDelegateCompat accessibilityDelegateCompat = this.mOriginalItemDelegates.get(view);
if (accessibilityDelegateCompat != null) {
if (accessibilityDelegateCompat.performAccessibilityAction(view, i, bundle)) {
return true;
}
} else if (super.performAccessibilityAction(view, i, bundle)) {
return true;
}
return this.mRecyclerViewDelegate.mRecyclerView.getLayoutManager().performAccessibilityActionForItem(view, i, bundle);
}
return super.performAccessibilityAction(view, i, bundle);
}
@Override // androidx.core.view.AccessibilityDelegateCompat
public void sendAccessibilityEvent(@NonNull View view, int i) {
AccessibilityDelegateCompat accessibilityDelegateCompat = this.mOriginalItemDelegates.get(view);
if (accessibilityDelegateCompat != null) {
accessibilityDelegateCompat.sendAccessibilityEvent(view, i);
} else {
super.sendAccessibilityEvent(view, i);
}
}
@Override // androidx.core.view.AccessibilityDelegateCompat
public void sendAccessibilityEventUnchecked(@NonNull View view, @NonNull AccessibilityEvent accessibilityEvent) {
AccessibilityDelegateCompat accessibilityDelegateCompat = this.mOriginalItemDelegates.get(view);
if (accessibilityDelegateCompat != null) {
accessibilityDelegateCompat.sendAccessibilityEventUnchecked(view, accessibilityEvent);
} else {
super.sendAccessibilityEventUnchecked(view, accessibilityEvent);
}
}
@Override // androidx.core.view.AccessibilityDelegateCompat
public boolean dispatchPopulateAccessibilityEvent(@NonNull View view, @NonNull AccessibilityEvent accessibilityEvent) {
AccessibilityDelegateCompat accessibilityDelegateCompat = this.mOriginalItemDelegates.get(view);
if (accessibilityDelegateCompat != null) {
return accessibilityDelegateCompat.dispatchPopulateAccessibilityEvent(view, accessibilityEvent);
}
return super.dispatchPopulateAccessibilityEvent(view, accessibilityEvent);
}
@Override // androidx.core.view.AccessibilityDelegateCompat
public void onPopulateAccessibilityEvent(@NonNull View view, @NonNull AccessibilityEvent accessibilityEvent) {
AccessibilityDelegateCompat accessibilityDelegateCompat = this.mOriginalItemDelegates.get(view);
if (accessibilityDelegateCompat != null) {
accessibilityDelegateCompat.onPopulateAccessibilityEvent(view, accessibilityEvent);
} else {
super.onPopulateAccessibilityEvent(view, accessibilityEvent);
}
}
@Override // androidx.core.view.AccessibilityDelegateCompat
public void onInitializeAccessibilityEvent(@NonNull View view, @NonNull AccessibilityEvent accessibilityEvent) {
AccessibilityDelegateCompat accessibilityDelegateCompat = this.mOriginalItemDelegates.get(view);
if (accessibilityDelegateCompat != null) {
accessibilityDelegateCompat.onInitializeAccessibilityEvent(view, accessibilityEvent);
} else {
super.onInitializeAccessibilityEvent(view, accessibilityEvent);
}
}
@Override // androidx.core.view.AccessibilityDelegateCompat
public boolean onRequestSendAccessibilityEvent(@NonNull ViewGroup viewGroup, @NonNull View view, @NonNull AccessibilityEvent accessibilityEvent) {
AccessibilityDelegateCompat accessibilityDelegateCompat = this.mOriginalItemDelegates.get(viewGroup);
if (accessibilityDelegateCompat != null) {
return accessibilityDelegateCompat.onRequestSendAccessibilityEvent(viewGroup, view, accessibilityEvent);
}
return super.onRequestSendAccessibilityEvent(viewGroup, view, accessibilityEvent);
}
@Override // androidx.core.view.AccessibilityDelegateCompat
@Nullable
public AccessibilityNodeProviderCompat getAccessibilityNodeProvider(@NonNull View view) {
AccessibilityDelegateCompat accessibilityDelegateCompat = this.mOriginalItemDelegates.get(view);
if (accessibilityDelegateCompat != null) {
return accessibilityDelegateCompat.getAccessibilityNodeProvider(view);
}
return super.getAccessibilityNodeProvider(view);
}
}
}

View File

@@ -0,0 +1,48 @@
package androidx.recyclerview.widget;
import android.view.View;
import androidx.recyclerview.widget.RecyclerView;
/* loaded from: classes.dex */
class ScrollbarHelper {
public static int computeScrollOffset(RecyclerView.State state, OrientationHelper orientationHelper, View view, View view2, RecyclerView.LayoutManager layoutManager, boolean z, boolean z2) {
int max;
if (layoutManager.getChildCount() == 0 || state.getItemCount() == 0 || view == null || view2 == null) {
return 0;
}
int min = Math.min(layoutManager.getPosition(view), layoutManager.getPosition(view2));
int max2 = Math.max(layoutManager.getPosition(view), layoutManager.getPosition(view2));
if (z2) {
max = Math.max(0, (state.getItemCount() - max2) - 1);
} else {
max = Math.max(0, min);
}
if (!z) {
return max;
}
return Math.round((max * (Math.abs(orientationHelper.getDecoratedEnd(view2) - orientationHelper.getDecoratedStart(view)) / (Math.abs(layoutManager.getPosition(view) - layoutManager.getPosition(view2)) + 1))) + (orientationHelper.getStartAfterPadding() - orientationHelper.getDecoratedStart(view)));
}
public static int computeScrollExtent(RecyclerView.State state, OrientationHelper orientationHelper, View view, View view2, RecyclerView.LayoutManager layoutManager, boolean z) {
if (layoutManager.getChildCount() == 0 || state.getItemCount() == 0 || view == null || view2 == null) {
return 0;
}
if (!z) {
return Math.abs(layoutManager.getPosition(view) - layoutManager.getPosition(view2)) + 1;
}
return Math.min(orientationHelper.getTotalSpace(), orientationHelper.getDecoratedEnd(view2) - orientationHelper.getDecoratedStart(view));
}
public static int computeScrollRange(RecyclerView.State state, OrientationHelper orientationHelper, View view, View view2, RecyclerView.LayoutManager layoutManager, boolean z) {
if (layoutManager.getChildCount() == 0 || state.getItemCount() == 0 || view == null || view2 == null) {
return 0;
}
if (!z) {
return state.getItemCount();
}
return (int) (((orientationHelper.getDecoratedEnd(view2) - orientationHelper.getDecoratedStart(view)) / (Math.abs(layoutManager.getPosition(view) - layoutManager.getPosition(view2)) + 1)) * state.getItemCount());
}
private ScrollbarHelper() {
}
}

View File

@@ -0,0 +1,146 @@
package androidx.recyclerview.widget;
import android.view.View;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView;
/* loaded from: classes.dex */
public abstract class SimpleItemAnimator extends RecyclerView.ItemAnimator {
private static final boolean DEBUG = false;
private static final String TAG = "SimpleItemAnimator";
boolean mSupportsChangeAnimations = true;
public abstract boolean animateAdd(RecyclerView.ViewHolder viewHolder);
public abstract boolean animateChange(RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder viewHolder2, int i, int i2, int i3, int i4);
public abstract boolean animateMove(RecyclerView.ViewHolder viewHolder, int i, int i2, int i3, int i4);
public abstract boolean animateRemove(RecyclerView.ViewHolder viewHolder);
public boolean getSupportsChangeAnimations() {
return this.mSupportsChangeAnimations;
}
public void onAddFinished(RecyclerView.ViewHolder viewHolder) {
}
public void onAddStarting(RecyclerView.ViewHolder viewHolder) {
}
public void onChangeFinished(RecyclerView.ViewHolder viewHolder, boolean z) {
}
public void onChangeStarting(RecyclerView.ViewHolder viewHolder, boolean z) {
}
public void onMoveFinished(RecyclerView.ViewHolder viewHolder) {
}
public void onMoveStarting(RecyclerView.ViewHolder viewHolder) {
}
public void onRemoveFinished(RecyclerView.ViewHolder viewHolder) {
}
public void onRemoveStarting(RecyclerView.ViewHolder viewHolder) {
}
public void setSupportsChangeAnimations(boolean z) {
this.mSupportsChangeAnimations = z;
}
@Override // androidx.recyclerview.widget.RecyclerView.ItemAnimator
public boolean canReuseUpdatedViewHolder(@NonNull RecyclerView.ViewHolder viewHolder) {
return !this.mSupportsChangeAnimations || viewHolder.isInvalid();
}
@Override // androidx.recyclerview.widget.RecyclerView.ItemAnimator
public boolean animateDisappearance(@NonNull RecyclerView.ViewHolder viewHolder, @NonNull RecyclerView.ItemAnimator.ItemHolderInfo itemHolderInfo, @Nullable RecyclerView.ItemAnimator.ItemHolderInfo itemHolderInfo2) {
int i = itemHolderInfo.left;
int i2 = itemHolderInfo.top;
View view = viewHolder.itemView;
int left = itemHolderInfo2 == null ? view.getLeft() : itemHolderInfo2.left;
int top = itemHolderInfo2 == null ? view.getTop() : itemHolderInfo2.top;
if (!viewHolder.isRemoved() && (i != left || i2 != top)) {
view.layout(left, top, view.getWidth() + left, view.getHeight() + top);
return animateMove(viewHolder, i, i2, left, top);
}
return animateRemove(viewHolder);
}
@Override // androidx.recyclerview.widget.RecyclerView.ItemAnimator
public boolean animateAppearance(@NonNull RecyclerView.ViewHolder viewHolder, @Nullable RecyclerView.ItemAnimator.ItemHolderInfo itemHolderInfo, @NonNull RecyclerView.ItemAnimator.ItemHolderInfo itemHolderInfo2) {
int i;
int i2;
if (itemHolderInfo != null && ((i = itemHolderInfo.left) != (i2 = itemHolderInfo2.left) || itemHolderInfo.top != itemHolderInfo2.top)) {
return animateMove(viewHolder, i, itemHolderInfo.top, i2, itemHolderInfo2.top);
}
return animateAdd(viewHolder);
}
@Override // androidx.recyclerview.widget.RecyclerView.ItemAnimator
public boolean animatePersistence(@NonNull RecyclerView.ViewHolder viewHolder, @NonNull RecyclerView.ItemAnimator.ItemHolderInfo itemHolderInfo, @NonNull RecyclerView.ItemAnimator.ItemHolderInfo itemHolderInfo2) {
int i = itemHolderInfo.left;
int i2 = itemHolderInfo2.left;
if (i != i2 || itemHolderInfo.top != itemHolderInfo2.top) {
return animateMove(viewHolder, i, itemHolderInfo.top, i2, itemHolderInfo2.top);
}
dispatchMoveFinished(viewHolder);
return false;
}
@Override // androidx.recyclerview.widget.RecyclerView.ItemAnimator
public boolean animateChange(@NonNull RecyclerView.ViewHolder viewHolder, @NonNull RecyclerView.ViewHolder viewHolder2, @NonNull RecyclerView.ItemAnimator.ItemHolderInfo itemHolderInfo, @NonNull RecyclerView.ItemAnimator.ItemHolderInfo itemHolderInfo2) {
int i;
int i2;
int i3 = itemHolderInfo.left;
int i4 = itemHolderInfo.top;
if (viewHolder2.shouldIgnore()) {
int i5 = itemHolderInfo.left;
i2 = itemHolderInfo.top;
i = i5;
} else {
i = itemHolderInfo2.left;
i2 = itemHolderInfo2.top;
}
return animateChange(viewHolder, viewHolder2, i3, i4, i, i2);
}
public final void dispatchRemoveFinished(RecyclerView.ViewHolder viewHolder) {
onRemoveFinished(viewHolder);
dispatchAnimationFinished(viewHolder);
}
public final void dispatchMoveFinished(RecyclerView.ViewHolder viewHolder) {
onMoveFinished(viewHolder);
dispatchAnimationFinished(viewHolder);
}
public final void dispatchAddFinished(RecyclerView.ViewHolder viewHolder) {
onAddFinished(viewHolder);
dispatchAnimationFinished(viewHolder);
}
public final void dispatchChangeFinished(RecyclerView.ViewHolder viewHolder, boolean z) {
onChangeFinished(viewHolder, z);
dispatchAnimationFinished(viewHolder);
}
public final void dispatchRemoveStarting(RecyclerView.ViewHolder viewHolder) {
onRemoveStarting(viewHolder);
}
public final void dispatchMoveStarting(RecyclerView.ViewHolder viewHolder) {
onMoveStarting(viewHolder);
}
public final void dispatchAddStarting(RecyclerView.ViewHolder viewHolder) {
onAddStarting(viewHolder);
}
public final void dispatchChangeStarting(RecyclerView.ViewHolder viewHolder, boolean z) {
onChangeStarting(viewHolder, z);
}
}

View File

@@ -0,0 +1,149 @@
package androidx.recyclerview.widget;
import android.util.DisplayMetrics;
import android.view.View;
import android.view.animation.DecelerateInterpolator;
import android.widget.Scroller;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView;
/* loaded from: classes.dex */
public abstract class SnapHelper extends RecyclerView.OnFlingListener {
static final float MILLISECONDS_PER_INCH = 100.0f;
private Scroller mGravityScroller;
RecyclerView mRecyclerView;
private final RecyclerView.OnScrollListener mScrollListener = new RecyclerView.OnScrollListener() { // from class: androidx.recyclerview.widget.SnapHelper.1
boolean mScrolled = false;
@Override // androidx.recyclerview.widget.RecyclerView.OnScrollListener
public void onScrolled(RecyclerView recyclerView, int i, int i2) {
if (i == 0 && i2 == 0) {
return;
}
this.mScrolled = true;
}
@Override // androidx.recyclerview.widget.RecyclerView.OnScrollListener
public void onScrollStateChanged(RecyclerView recyclerView, int i) {
super.onScrollStateChanged(recyclerView, i);
if (i == 0 && this.mScrolled) {
this.mScrolled = false;
SnapHelper.this.snapToTargetExistingView();
}
}
};
@Nullable
public abstract int[] calculateDistanceToFinalSnap(@NonNull RecyclerView.LayoutManager layoutManager, @NonNull View view);
@Nullable
public abstract View findSnapView(RecyclerView.LayoutManager layoutManager);
public abstract int findTargetSnapPosition(RecyclerView.LayoutManager layoutManager, int i, int i2);
@Override // androidx.recyclerview.widget.RecyclerView.OnFlingListener
public boolean onFling(int i, int i2) {
RecyclerView.LayoutManager layoutManager = this.mRecyclerView.getLayoutManager();
if (layoutManager == null || this.mRecyclerView.getAdapter() == null) {
return false;
}
int minFlingVelocity = this.mRecyclerView.getMinFlingVelocity();
return (Math.abs(i2) > minFlingVelocity || Math.abs(i) > minFlingVelocity) && snapFromFling(layoutManager, i, i2);
}
public void attachToRecyclerView(@Nullable RecyclerView recyclerView) throws IllegalStateException {
RecyclerView recyclerView2 = this.mRecyclerView;
if (recyclerView2 == recyclerView) {
return;
}
if (recyclerView2 != null) {
destroyCallbacks();
}
this.mRecyclerView = recyclerView;
if (recyclerView != null) {
setupCallbacks();
this.mGravityScroller = new Scroller(this.mRecyclerView.getContext(), new DecelerateInterpolator());
snapToTargetExistingView();
}
}
private void setupCallbacks() throws IllegalStateException {
if (this.mRecyclerView.getOnFlingListener() != null) {
throw new IllegalStateException("An instance of OnFlingListener already set.");
}
this.mRecyclerView.addOnScrollListener(this.mScrollListener);
this.mRecyclerView.setOnFlingListener(this);
}
private void destroyCallbacks() {
this.mRecyclerView.removeOnScrollListener(this.mScrollListener);
this.mRecyclerView.setOnFlingListener(null);
}
public int[] calculateScrollDistance(int i, int i2) {
this.mGravityScroller.fling(0, 0, i, i2, Integer.MIN_VALUE, Integer.MAX_VALUE, Integer.MIN_VALUE, Integer.MAX_VALUE);
return new int[]{this.mGravityScroller.getFinalX(), this.mGravityScroller.getFinalY()};
}
private boolean snapFromFling(@NonNull RecyclerView.LayoutManager layoutManager, int i, int i2) {
RecyclerView.SmoothScroller createScroller;
int findTargetSnapPosition;
if (!(layoutManager instanceof RecyclerView.SmoothScroller.ScrollVectorProvider) || (createScroller = createScroller(layoutManager)) == null || (findTargetSnapPosition = findTargetSnapPosition(layoutManager, i, i2)) == -1) {
return false;
}
createScroller.setTargetPosition(findTargetSnapPosition);
layoutManager.startSmoothScroll(createScroller);
return true;
}
public void snapToTargetExistingView() {
RecyclerView.LayoutManager layoutManager;
View findSnapView;
RecyclerView recyclerView = this.mRecyclerView;
if (recyclerView == null || (layoutManager = recyclerView.getLayoutManager()) == null || (findSnapView = findSnapView(layoutManager)) == null) {
return;
}
int[] calculateDistanceToFinalSnap = calculateDistanceToFinalSnap(layoutManager, findSnapView);
int i = calculateDistanceToFinalSnap[0];
if (i == 0 && calculateDistanceToFinalSnap[1] == 0) {
return;
}
this.mRecyclerView.smoothScrollBy(i, calculateDistanceToFinalSnap[1]);
}
@Nullable
public RecyclerView.SmoothScroller createScroller(@NonNull RecyclerView.LayoutManager layoutManager) {
return createSnapScroller(layoutManager);
}
@Nullable
@Deprecated
public LinearSmoothScroller createSnapScroller(@NonNull RecyclerView.LayoutManager layoutManager) {
if (layoutManager instanceof RecyclerView.SmoothScroller.ScrollVectorProvider) {
return new LinearSmoothScroller(this.mRecyclerView.getContext()) { // from class: androidx.recyclerview.widget.SnapHelper.2
@Override // androidx.recyclerview.widget.LinearSmoothScroller, androidx.recyclerview.widget.RecyclerView.SmoothScroller
public void onTargetFound(View view, RecyclerView.State state, RecyclerView.SmoothScroller.Action action) {
SnapHelper snapHelper = SnapHelper.this;
RecyclerView recyclerView = snapHelper.mRecyclerView;
if (recyclerView == null) {
return;
}
int[] calculateDistanceToFinalSnap = snapHelper.calculateDistanceToFinalSnap(recyclerView.getLayoutManager(), view);
int i = calculateDistanceToFinalSnap[0];
int i2 = calculateDistanceToFinalSnap[1];
int calculateTimeForDeceleration = calculateTimeForDeceleration(Math.max(Math.abs(i), Math.abs(i2)));
if (calculateTimeForDeceleration > 0) {
action.update(i, i2, calculateTimeForDeceleration, this.mDecelerateInterpolator);
}
}
@Override // androidx.recyclerview.widget.LinearSmoothScroller
public float calculateSpeedPerPixel(DisplayMetrics displayMetrics) {
return SnapHelper.MILLISECONDS_PER_INCH / displayMetrics.densityDpi;
}
};
}
return null;
}
}

View File

@@ -0,0 +1,596 @@
package androidx.recyclerview.widget;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.Collection;
import java.util.Comparator;
/* loaded from: classes.dex */
public class SortedList<T> {
private static final int CAPACITY_GROWTH = 10;
private static final int DELETION = 2;
private static final int INSERTION = 1;
public static final int INVALID_POSITION = -1;
private static final int LOOKUP = 4;
private static final int MIN_CAPACITY = 10;
private BatchedCallback mBatchedCallback;
private Callback mCallback;
T[] mData;
private int mNewDataStart;
private T[] mOldData;
private int mOldDataSize;
private int mOldDataStart;
private int mSize;
private final Class<T> mTClass;
public int size() {
return this.mSize;
}
public SortedList(@NonNull Class<T> cls, @NonNull Callback<T> callback) {
this(cls, callback, 10);
}
public SortedList(@NonNull Class<T> cls, @NonNull Callback<T> callback, int i) {
this.mTClass = cls;
this.mData = (T[]) ((Object[]) Array.newInstance((Class<?>) cls, i));
this.mCallback = callback;
this.mSize = 0;
}
public int add(T t) {
throwIfInMutationOperation();
return add(t, true);
}
public void addAll(@NonNull T[] tArr, boolean z) {
throwIfInMutationOperation();
if (tArr.length == 0) {
return;
}
if (z) {
addAllInternal(tArr);
} else {
addAllInternal(copyArray(tArr));
}
}
public void addAll(@NonNull T... tArr) {
addAll(tArr, false);
}
/* JADX WARN: Multi-variable type inference failed */
public void addAll(@NonNull Collection<T> collection) {
addAll(collection.toArray((Object[]) Array.newInstance((Class<?>) this.mTClass, collection.size())), true);
}
public void replaceAll(@NonNull T[] tArr, boolean z) {
throwIfInMutationOperation();
if (z) {
replaceAllInternal(tArr);
} else {
replaceAllInternal(copyArray(tArr));
}
}
public void replaceAll(@NonNull T... tArr) {
replaceAll(tArr, false);
}
/* JADX WARN: Multi-variable type inference failed */
public void replaceAll(@NonNull Collection<T> collection) {
replaceAll(collection.toArray((Object[]) Array.newInstance((Class<?>) this.mTClass, collection.size())), true);
}
private void addAllInternal(T[] tArr) {
if (tArr.length < 1) {
return;
}
int sortAndDedup = sortAndDedup(tArr);
if (this.mSize == 0) {
this.mData = tArr;
this.mSize = sortAndDedup;
this.mCallback.onInserted(0, sortAndDedup);
return;
}
merge(tArr, sortAndDedup);
}
private void replaceAllInternal(@NonNull T[] tArr) {
boolean z = !(this.mCallback instanceof BatchedCallback);
if (z) {
beginBatchedUpdates();
}
this.mOldDataStart = 0;
this.mOldDataSize = this.mSize;
this.mOldData = this.mData;
this.mNewDataStart = 0;
int sortAndDedup = sortAndDedup(tArr);
this.mData = (T[]) ((Object[]) Array.newInstance((Class<?>) this.mTClass, sortAndDedup));
while (true) {
int i = this.mNewDataStart;
if (i >= sortAndDedup && this.mOldDataStart >= this.mOldDataSize) {
break;
}
int i2 = this.mOldDataStart;
int i3 = this.mOldDataSize;
if (i2 >= i3) {
int i4 = sortAndDedup - i;
System.arraycopy(tArr, i, this.mData, i, i4);
this.mNewDataStart += i4;
this.mSize += i4;
this.mCallback.onInserted(i, i4);
break;
}
if (i >= sortAndDedup) {
int i5 = i3 - i2;
this.mSize -= i5;
this.mCallback.onRemoved(i, i5);
break;
}
T t = this.mOldData[i2];
T t2 = tArr[i];
int compare = this.mCallback.compare(t, t2);
if (compare < 0) {
replaceAllRemove();
} else if (compare > 0) {
replaceAllInsert(t2);
} else if (!this.mCallback.areItemsTheSame(t, t2)) {
replaceAllRemove();
replaceAllInsert(t2);
} else {
T[] tArr2 = this.mData;
int i6 = this.mNewDataStart;
tArr2[i6] = t2;
this.mOldDataStart++;
this.mNewDataStart = i6 + 1;
if (!this.mCallback.areContentsTheSame(t, t2)) {
Callback callback = this.mCallback;
callback.onChanged(this.mNewDataStart - 1, 1, callback.getChangePayload(t, t2));
}
}
}
this.mOldData = null;
if (z) {
endBatchedUpdates();
}
}
private void replaceAllInsert(T t) {
T[] tArr = this.mData;
int i = this.mNewDataStart;
tArr[i] = t;
this.mNewDataStart = i + 1;
this.mSize++;
this.mCallback.onInserted(i, 1);
}
private void replaceAllRemove() {
this.mSize--;
this.mOldDataStart++;
this.mCallback.onRemoved(this.mNewDataStart, 1);
}
private int sortAndDedup(@NonNull T[] tArr) {
if (tArr.length == 0) {
return 0;
}
Arrays.sort(tArr, this.mCallback);
int i = 0;
int i2 = 1;
for (int i3 = 1; i3 < tArr.length; i3++) {
T t = tArr[i3];
if (this.mCallback.compare(tArr[i], t) == 0) {
int findSameItem = findSameItem(t, tArr, i, i2);
if (findSameItem != -1) {
tArr[findSameItem] = t;
} else {
if (i2 != i3) {
tArr[i2] = t;
}
i2++;
}
} else {
if (i2 != i3) {
tArr[i2] = t;
}
i = i2;
i2++;
}
}
return i2;
}
private int findSameItem(T t, T[] tArr, int i, int i2) {
while (i < i2) {
if (this.mCallback.areItemsTheSame(tArr[i], t)) {
return i;
}
i++;
}
return -1;
}
private void merge(T[] tArr, int i) {
boolean z = !(this.mCallback instanceof BatchedCallback);
if (z) {
beginBatchedUpdates();
}
this.mOldData = this.mData;
int i2 = 0;
this.mOldDataStart = 0;
int i3 = this.mSize;
this.mOldDataSize = i3;
this.mData = (T[]) ((Object[]) Array.newInstance((Class<?>) this.mTClass, i3 + i + 10));
this.mNewDataStart = 0;
while (true) {
int i4 = this.mOldDataStart;
int i5 = this.mOldDataSize;
if (i4 >= i5 && i2 >= i) {
break;
}
if (i4 == i5) {
int i6 = i - i2;
System.arraycopy(tArr, i2, this.mData, this.mNewDataStart, i6);
int i7 = this.mNewDataStart + i6;
this.mNewDataStart = i7;
this.mSize += i6;
this.mCallback.onInserted(i7 - i6, i6);
break;
}
if (i2 == i) {
int i8 = i5 - i4;
System.arraycopy(this.mOldData, i4, this.mData, this.mNewDataStart, i8);
this.mNewDataStart += i8;
break;
}
T t = this.mOldData[i4];
T t2 = tArr[i2];
int compare = this.mCallback.compare(t, t2);
if (compare > 0) {
T[] tArr2 = this.mData;
int i9 = this.mNewDataStart;
this.mNewDataStart = i9 + 1;
tArr2[i9] = t2;
this.mSize++;
i2++;
this.mCallback.onInserted(i9, 1);
} else if (compare == 0 && this.mCallback.areItemsTheSame(t, t2)) {
T[] tArr3 = this.mData;
int i10 = this.mNewDataStart;
this.mNewDataStart = i10 + 1;
tArr3[i10] = t2;
i2++;
this.mOldDataStart++;
if (!this.mCallback.areContentsTheSame(t, t2)) {
Callback callback = this.mCallback;
callback.onChanged(this.mNewDataStart - 1, 1, callback.getChangePayload(t, t2));
}
} else {
T[] tArr4 = this.mData;
int i11 = this.mNewDataStart;
this.mNewDataStart = i11 + 1;
tArr4[i11] = t;
this.mOldDataStart++;
}
}
this.mOldData = null;
if (z) {
endBatchedUpdates();
}
}
private void throwIfInMutationOperation() {
if (this.mOldData != null) {
throw new IllegalStateException("Data cannot be mutated in the middle of a batch update operation such as addAll or replaceAll.");
}
}
public void beginBatchedUpdates() {
throwIfInMutationOperation();
Callback callback = this.mCallback;
if (callback instanceof BatchedCallback) {
return;
}
if (this.mBatchedCallback == null) {
this.mBatchedCallback = new BatchedCallback(callback);
}
this.mCallback = this.mBatchedCallback;
}
public void endBatchedUpdates() {
throwIfInMutationOperation();
Callback callback = this.mCallback;
if (callback instanceof BatchedCallback) {
((BatchedCallback) callback).dispatchLastEvent();
}
Callback callback2 = this.mCallback;
BatchedCallback batchedCallback = this.mBatchedCallback;
if (callback2 == batchedCallback) {
this.mCallback = batchedCallback.mWrappedCallback;
}
}
private int add(T t, boolean z) {
int findIndexOf = findIndexOf(t, this.mData, 0, this.mSize, 1);
if (findIndexOf == -1) {
findIndexOf = 0;
} else if (findIndexOf < this.mSize) {
T t2 = this.mData[findIndexOf];
if (this.mCallback.areItemsTheSame(t2, t)) {
if (this.mCallback.areContentsTheSame(t2, t)) {
this.mData[findIndexOf] = t;
return findIndexOf;
}
this.mData[findIndexOf] = t;
Callback callback = this.mCallback;
callback.onChanged(findIndexOf, 1, callback.getChangePayload(t2, t));
return findIndexOf;
}
}
addToData(findIndexOf, t);
if (z) {
this.mCallback.onInserted(findIndexOf, 1);
}
return findIndexOf;
}
public boolean remove(T t) {
throwIfInMutationOperation();
return remove(t, true);
}
public T removeItemAt(int i) {
throwIfInMutationOperation();
T t = get(i);
removeItemAtIndex(i, true);
return t;
}
private boolean remove(T t, boolean z) {
int findIndexOf = findIndexOf(t, this.mData, 0, this.mSize, 2);
if (findIndexOf == -1) {
return false;
}
removeItemAtIndex(findIndexOf, z);
return true;
}
private void removeItemAtIndex(int i, boolean z) {
T[] tArr = this.mData;
System.arraycopy(tArr, i + 1, tArr, i, (this.mSize - i) - 1);
int i2 = this.mSize - 1;
this.mSize = i2;
this.mData[i2] = null;
if (z) {
this.mCallback.onRemoved(i, 1);
}
}
public void updateItemAt(int i, T t) {
throwIfInMutationOperation();
T t2 = get(i);
boolean z = t2 == t || !this.mCallback.areContentsTheSame(t2, t);
if (t2 != t && this.mCallback.compare(t2, t) == 0) {
this.mData[i] = t;
if (z) {
Callback callback = this.mCallback;
callback.onChanged(i, 1, callback.getChangePayload(t2, t));
return;
}
return;
}
if (z) {
Callback callback2 = this.mCallback;
callback2.onChanged(i, 1, callback2.getChangePayload(t2, t));
}
removeItemAtIndex(i, false);
int add = add(t, false);
if (i != add) {
this.mCallback.onMoved(i, add);
}
}
public void recalculatePositionOfItemAt(int i) {
throwIfInMutationOperation();
T t = get(i);
removeItemAtIndex(i, false);
int add = add(t, false);
if (i != add) {
this.mCallback.onMoved(i, add);
}
}
public T get(int i) throws IndexOutOfBoundsException {
int i2;
if (i < this.mSize && i >= 0) {
T[] tArr = this.mOldData;
if (tArr != null && i >= (i2 = this.mNewDataStart)) {
return tArr[(i - i2) + this.mOldDataStart];
}
return this.mData[i];
}
throw new IndexOutOfBoundsException("Asked to get item at " + i + " but size is " + this.mSize);
}
public int indexOf(T t) {
if (this.mOldData != null) {
int findIndexOf = findIndexOf(t, this.mData, 0, this.mNewDataStart, 4);
if (findIndexOf != -1) {
return findIndexOf;
}
int findIndexOf2 = findIndexOf(t, this.mOldData, this.mOldDataStart, this.mOldDataSize, 4);
if (findIndexOf2 != -1) {
return (findIndexOf2 - this.mOldDataStart) + this.mNewDataStart;
}
return -1;
}
return findIndexOf(t, this.mData, 0, this.mSize, 4);
}
private int findIndexOf(T t, T[] tArr, int i, int i2, int i3) {
while (i < i2) {
int i4 = (i + i2) / 2;
T t2 = tArr[i4];
int compare = this.mCallback.compare(t2, t);
if (compare < 0) {
i = i4 + 1;
} else {
if (compare == 0) {
if (this.mCallback.areItemsTheSame(t2, t)) {
return i4;
}
int linearEqualitySearch = linearEqualitySearch(t, i4, i, i2);
return (i3 == 1 && linearEqualitySearch == -1) ? i4 : linearEqualitySearch;
}
i2 = i4;
}
}
if (i3 == 1) {
return i;
}
return -1;
}
private int linearEqualitySearch(T t, int i, int i2, int i3) {
T t2;
for (int i4 = i - 1; i4 >= i2; i4--) {
T t3 = this.mData[i4];
if (this.mCallback.compare(t3, t) != 0) {
break;
}
if (this.mCallback.areItemsTheSame(t3, t)) {
return i4;
}
}
do {
i++;
if (i >= i3) {
return -1;
}
t2 = this.mData[i];
if (this.mCallback.compare(t2, t) != 0) {
return -1;
}
} while (!this.mCallback.areItemsTheSame(t2, t));
return i;
}
private void addToData(int i, T t) {
int i2 = this.mSize;
if (i > i2) {
throw new IndexOutOfBoundsException("cannot add item to " + i + " because size is " + this.mSize);
}
T[] tArr = this.mData;
if (i2 == tArr.length) {
T[] tArr2 = (T[]) ((Object[]) Array.newInstance((Class<?>) this.mTClass, tArr.length + 10));
System.arraycopy(this.mData, 0, tArr2, 0, i);
tArr2[i] = t;
System.arraycopy(this.mData, i, tArr2, i + 1, this.mSize - i);
this.mData = tArr2;
} else {
System.arraycopy(tArr, i, tArr, i + 1, i2 - i);
this.mData[i] = t;
}
this.mSize++;
}
private T[] copyArray(T[] tArr) {
T[] tArr2 = (T[]) ((Object[]) Array.newInstance((Class<?>) this.mTClass, tArr.length));
System.arraycopy(tArr, 0, tArr2, 0, tArr.length);
return tArr2;
}
public void clear() {
throwIfInMutationOperation();
int i = this.mSize;
if (i == 0) {
return;
}
Arrays.fill(this.mData, 0, i, (Object) null);
this.mSize = 0;
this.mCallback.onRemoved(0, i);
}
public static abstract class Callback<T2> implements Comparator<T2>, ListUpdateCallback {
public abstract boolean areContentsTheSame(T2 t2, T2 t22);
public abstract boolean areItemsTheSame(T2 t2, T2 t22);
@Override // java.util.Comparator
public abstract int compare(T2 t2, T2 t22);
@Nullable
public Object getChangePayload(T2 t2, T2 t22) {
return null;
}
public abstract void onChanged(int i, int i2);
public void onChanged(int i, int i2, Object obj) {
onChanged(i, i2);
}
}
public static class BatchedCallback<T2> extends Callback<T2> {
private final BatchingListUpdateCallback mBatchingListUpdateCallback;
final Callback<T2> mWrappedCallback;
public BatchedCallback(Callback<T2> callback) {
this.mWrappedCallback = callback;
this.mBatchingListUpdateCallback = new BatchingListUpdateCallback(callback);
}
@Override // androidx.recyclerview.widget.SortedList.Callback, java.util.Comparator
public int compare(T2 t2, T2 t22) {
return this.mWrappedCallback.compare(t2, t22);
}
@Override // androidx.recyclerview.widget.ListUpdateCallback
public void onInserted(int i, int i2) {
this.mBatchingListUpdateCallback.onInserted(i, i2);
}
@Override // androidx.recyclerview.widget.ListUpdateCallback
public void onRemoved(int i, int i2) {
this.mBatchingListUpdateCallback.onRemoved(i, i2);
}
@Override // androidx.recyclerview.widget.ListUpdateCallback
public void onMoved(int i, int i2) {
this.mBatchingListUpdateCallback.onMoved(i, i2);
}
@Override // androidx.recyclerview.widget.SortedList.Callback
public void onChanged(int i, int i2) {
this.mBatchingListUpdateCallback.onChanged(i, i2, null);
}
@Override // androidx.recyclerview.widget.SortedList.Callback, androidx.recyclerview.widget.ListUpdateCallback
public void onChanged(int i, int i2, Object obj) {
this.mBatchingListUpdateCallback.onChanged(i, i2, obj);
}
@Override // androidx.recyclerview.widget.SortedList.Callback
public boolean areContentsTheSame(T2 t2, T2 t22) {
return this.mWrappedCallback.areContentsTheSame(t2, t22);
}
@Override // androidx.recyclerview.widget.SortedList.Callback
public boolean areItemsTheSame(T2 t2, T2 t22) {
return this.mWrappedCallback.areItemsTheSame(t2, t22);
}
@Override // androidx.recyclerview.widget.SortedList.Callback
@Nullable
public Object getChangePayload(T2 t2, T2 t22) {
return this.mWrappedCallback.getChangePayload(t2, t22);
}
public void dispatchLastEvent() {
this.mBatchingListUpdateCallback.dispatchLastEvent();
}
}
}

View File

@@ -0,0 +1,38 @@
package androidx.recyclerview.widget;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.SortedList;
/* loaded from: classes.dex */
public abstract class SortedListAdapterCallback<T2> extends SortedList.Callback<T2> {
final RecyclerView.Adapter mAdapter;
public SortedListAdapterCallback(RecyclerView.Adapter adapter) {
this.mAdapter = adapter;
}
@Override // androidx.recyclerview.widget.ListUpdateCallback
public void onInserted(int i, int i2) {
this.mAdapter.notifyItemRangeInserted(i, i2);
}
@Override // androidx.recyclerview.widget.ListUpdateCallback
public void onRemoved(int i, int i2) {
this.mAdapter.notifyItemRangeRemoved(i, i2);
}
@Override // androidx.recyclerview.widget.ListUpdateCallback
public void onMoved(int i, int i2) {
this.mAdapter.notifyItemMoved(i, i2);
}
@Override // androidx.recyclerview.widget.SortedList.Callback
public void onChanged(int i, int i2) {
this.mAdapter.notifyItemRangeChanged(i, i2);
}
@Override // androidx.recyclerview.widget.SortedList.Callback, androidx.recyclerview.widget.ListUpdateCallback
public void onChanged(int i, int i2, Object obj) {
this.mAdapter.notifyItemRangeChanged(i, i2, obj);
}
}

View File

@@ -0,0 +1,78 @@
package androidx.recyclerview.widget;
import androidx.annotation.NonNull;
import androidx.collection.LongSparseArray;
/* loaded from: classes.dex */
interface StableIdStorage {
public static class NoStableIdStorage implements StableIdStorage {
private final StableIdLookup mNoIdLookup = new StableIdLookup() { // from class: androidx.recyclerview.widget.StableIdStorage.NoStableIdStorage.1
@Override // androidx.recyclerview.widget.StableIdStorage.StableIdLookup
public long localToGlobal(long j) {
return -1L;
}
};
@Override // androidx.recyclerview.widget.StableIdStorage
@NonNull
public StableIdLookup createStableIdLookup() {
return this.mNoIdLookup;
}
}
public static class SharedPoolStableIdStorage implements StableIdStorage {
private final StableIdLookup mSameIdLookup = new StableIdLookup() { // from class: androidx.recyclerview.widget.StableIdStorage.SharedPoolStableIdStorage.1
@Override // androidx.recyclerview.widget.StableIdStorage.StableIdLookup
public long localToGlobal(long j) {
return j;
}
};
@Override // androidx.recyclerview.widget.StableIdStorage
@NonNull
public StableIdLookup createStableIdLookup() {
return this.mSameIdLookup;
}
}
public interface StableIdLookup {
long localToGlobal(long j);
}
@NonNull
StableIdLookup createStableIdLookup();
public static class IsolatedStableIdStorage implements StableIdStorage {
long mNextStableId = 0;
public long obtainId() {
long j = this.mNextStableId;
this.mNextStableId = 1 + j;
return j;
}
@Override // androidx.recyclerview.widget.StableIdStorage
@NonNull
public StableIdLookup createStableIdLookup() {
return new WrapperStableIdLookup();
}
public class WrapperStableIdLookup implements StableIdLookup {
private final LongSparseArray<Long> mLocalToGlobalLookup = new LongSparseArray<>();
public WrapperStableIdLookup() {
}
@Override // androidx.recyclerview.widget.StableIdStorage.StableIdLookup
public long localToGlobal(long j) {
Long l = this.mLocalToGlobalLookup.get(j);
if (l == null) {
l = Long.valueOf(IsolatedStableIdStorage.this.obtainId());
this.mLocalToGlobalLookup.put(j, l);
}
return l.longValue();
}
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,29 @@
package androidx.recyclerview.widget;
import androidx.recyclerview.widget.TileList;
/* loaded from: classes.dex */
interface ThreadUtil<T> {
public interface BackgroundCallback<T> {
void loadTile(int i, int i2);
void recycleTile(TileList.Tile<T> tile);
void refresh(int i);
void updateRange(int i, int i2, int i3, int i4, int i5);
}
public interface MainThreadCallback<T> {
void addTile(int i, TileList.Tile<T> tile);
void removeTile(int i, int i2);
void updateItemCount(int i, int i2);
}
BackgroundCallback<T> getBackgroundProxy(BackgroundCallback<T> backgroundCallback);
MainThreadCallback<T> getMainThreadProxy(MainThreadCallback<T> mainThreadCallback);
}

View File

@@ -0,0 +1,85 @@
package androidx.recyclerview.widget;
import android.util.SparseArray;
import java.lang.reflect.Array;
/* loaded from: classes.dex */
class TileList<T> {
Tile<T> mLastAccessedTile;
final int mTileSize;
private final SparseArray<Tile<T>> mTiles = new SparseArray<>(10);
public TileList(int i) {
this.mTileSize = i;
}
public T getItemAt(int i) {
Tile<T> tile = this.mLastAccessedTile;
if (tile == null || !tile.containsPosition(i)) {
int indexOfKey = this.mTiles.indexOfKey(i - (i % this.mTileSize));
if (indexOfKey < 0) {
return null;
}
this.mLastAccessedTile = this.mTiles.valueAt(indexOfKey);
}
return this.mLastAccessedTile.getByPosition(i);
}
public int size() {
return this.mTiles.size();
}
public void clear() {
this.mTiles.clear();
}
public Tile<T> getAtIndex(int i) {
if (i < 0 || i >= this.mTiles.size()) {
return null;
}
return this.mTiles.valueAt(i);
}
public Tile<T> addOrReplace(Tile<T> tile) {
int indexOfKey = this.mTiles.indexOfKey(tile.mStartPosition);
if (indexOfKey < 0) {
this.mTiles.put(tile.mStartPosition, tile);
return null;
}
Tile<T> valueAt = this.mTiles.valueAt(indexOfKey);
this.mTiles.setValueAt(indexOfKey, tile);
if (this.mLastAccessedTile == valueAt) {
this.mLastAccessedTile = tile;
}
return valueAt;
}
public Tile<T> removeAtPos(int i) {
Tile<T> tile = this.mTiles.get(i);
if (this.mLastAccessedTile == tile) {
this.mLastAccessedTile = null;
}
this.mTiles.delete(i);
return tile;
}
public static class Tile<T> {
public int mItemCount;
public final T[] mItems;
Tile<T> mNext;
public int mStartPosition;
public boolean containsPosition(int i) {
int i2 = this.mStartPosition;
return i2 <= i && i < i2 + this.mItemCount;
}
public Tile(Class<T> cls, int i) {
this.mItems = (T[]) ((Object[]) Array.newInstance((Class<?>) cls, i));
}
public T getByPosition(int i) {
return this.mItems[i - this.mStartPosition];
}
}
}

View File

@@ -0,0 +1,135 @@
package androidx.recyclerview.widget;
import android.view.View;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
/* loaded from: classes.dex */
class ViewBoundsCheck {
static final int CVE_PVE_POS = 12;
static final int CVE_PVS_POS = 8;
static final int CVS_PVE_POS = 4;
static final int CVS_PVS_POS = 0;
static final int EQ = 2;
static final int FLAG_CVE_EQ_PVE = 8192;
static final int FLAG_CVE_EQ_PVS = 512;
static final int FLAG_CVE_GT_PVE = 4096;
static final int FLAG_CVE_GT_PVS = 256;
static final int FLAG_CVE_LT_PVE = 16384;
static final int FLAG_CVE_LT_PVS = 1024;
static final int FLAG_CVS_EQ_PVE = 32;
static final int FLAG_CVS_EQ_PVS = 2;
static final int FLAG_CVS_GT_PVE = 16;
static final int FLAG_CVS_GT_PVS = 1;
static final int FLAG_CVS_LT_PVE = 64;
static final int FLAG_CVS_LT_PVS = 4;
static final int GT = 1;
static final int LT = 4;
static final int MASK = 7;
BoundFlags mBoundFlags = new BoundFlags();
final Callback mCallback;
public interface Callback {
View getChildAt(int i);
int getChildEnd(View view);
int getChildStart(View view);
int getParentEnd();
int getParentStart();
}
@Retention(RetentionPolicy.SOURCE)
public @interface ViewBounds {
}
public ViewBoundsCheck(Callback callback) {
this.mCallback = callback;
}
public static class BoundFlags {
int mBoundFlags = 0;
int mChildEnd;
int mChildStart;
int mRvEnd;
int mRvStart;
public void addFlags(int i) {
this.mBoundFlags = i | this.mBoundFlags;
}
public int compare(int i, int i2) {
if (i > i2) {
return 1;
}
return i == i2 ? 2 : 4;
}
public void resetFlags() {
this.mBoundFlags = 0;
}
public void setBounds(int i, int i2, int i3, int i4) {
this.mRvStart = i;
this.mRvEnd = i2;
this.mChildStart = i3;
this.mChildEnd = i4;
}
public boolean boundsMatch() {
int i = this.mBoundFlags;
if ((i & 7) != 0 && (i & compare(this.mChildStart, this.mRvStart)) == 0) {
return false;
}
int i2 = this.mBoundFlags;
if ((i2 & 112) != 0 && (i2 & (compare(this.mChildStart, this.mRvEnd) << 4)) == 0) {
return false;
}
int i3 = this.mBoundFlags;
if ((i3 & 1792) != 0 && (i3 & (compare(this.mChildEnd, this.mRvStart) << 8)) == 0) {
return false;
}
int i4 = this.mBoundFlags;
return (i4 & 28672) == 0 || (i4 & (compare(this.mChildEnd, this.mRvEnd) << 12)) != 0;
}
}
public View findOneViewWithinBoundFlags(int i, int i2, int i3, int i4) {
int parentStart = this.mCallback.getParentStart();
int parentEnd = this.mCallback.getParentEnd();
int i5 = i2 > i ? 1 : -1;
View view = null;
while (i != i2) {
View childAt = this.mCallback.getChildAt(i);
this.mBoundFlags.setBounds(parentStart, parentEnd, this.mCallback.getChildStart(childAt), this.mCallback.getChildEnd(childAt));
if (i3 != 0) {
this.mBoundFlags.resetFlags();
this.mBoundFlags.addFlags(i3);
if (this.mBoundFlags.boundsMatch()) {
return childAt;
}
}
if (i4 != 0) {
this.mBoundFlags.resetFlags();
this.mBoundFlags.addFlags(i4);
if (this.mBoundFlags.boundsMatch()) {
view = childAt;
}
}
i += i5;
}
return view;
}
public boolean isViewWithinBoundFlags(View view, int i) {
this.mBoundFlags.setBounds(this.mCallback.getParentStart(), this.mCallback.getParentEnd(), this.mCallback.getChildStart(view), this.mCallback.getChildEnd(view));
if (i == 0) {
return false;
}
this.mBoundFlags.resetFlags();
this.mBoundFlags.addFlags(i);
return this.mBoundFlags.boundsMatch();
}
}

View File

@@ -0,0 +1,227 @@
package androidx.recyclerview.widget;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import androidx.collection.LongSparseArray;
import androidx.collection.SimpleArrayMap;
import androidx.core.util.Pools;
import androidx.recyclerview.widget.RecyclerView;
/* loaded from: classes.dex */
class ViewInfoStore {
private static final boolean DEBUG = false;
@VisibleForTesting
final SimpleArrayMap<RecyclerView.ViewHolder, InfoRecord> mLayoutHolderMap = new SimpleArrayMap<>();
@VisibleForTesting
final LongSparseArray<RecyclerView.ViewHolder> mOldChangedHolders = new LongSparseArray<>();
public interface ProcessCallback {
void processAppeared(RecyclerView.ViewHolder viewHolder, @Nullable RecyclerView.ItemAnimator.ItemHolderInfo itemHolderInfo, RecyclerView.ItemAnimator.ItemHolderInfo itemHolderInfo2);
void processDisappeared(RecyclerView.ViewHolder viewHolder, @NonNull RecyclerView.ItemAnimator.ItemHolderInfo itemHolderInfo, @Nullable RecyclerView.ItemAnimator.ItemHolderInfo itemHolderInfo2);
void processPersistent(RecyclerView.ViewHolder viewHolder, @NonNull RecyclerView.ItemAnimator.ItemHolderInfo itemHolderInfo, @NonNull RecyclerView.ItemAnimator.ItemHolderInfo itemHolderInfo2);
void unused(RecyclerView.ViewHolder viewHolder);
}
public void clear() {
this.mLayoutHolderMap.clear();
this.mOldChangedHolders.clear();
}
public void addToPreLayout(RecyclerView.ViewHolder viewHolder, RecyclerView.ItemAnimator.ItemHolderInfo itemHolderInfo) {
InfoRecord infoRecord = this.mLayoutHolderMap.get(viewHolder);
if (infoRecord == null) {
infoRecord = InfoRecord.obtain();
this.mLayoutHolderMap.put(viewHolder, infoRecord);
}
infoRecord.preInfo = itemHolderInfo;
infoRecord.flags |= 4;
}
public boolean isDisappearing(RecyclerView.ViewHolder viewHolder) {
InfoRecord infoRecord = this.mLayoutHolderMap.get(viewHolder);
return (infoRecord == null || (infoRecord.flags & 1) == 0) ? false : true;
}
@Nullable
public RecyclerView.ItemAnimator.ItemHolderInfo popFromPreLayout(RecyclerView.ViewHolder viewHolder) {
return popFromLayoutStep(viewHolder, 4);
}
@Nullable
public RecyclerView.ItemAnimator.ItemHolderInfo popFromPostLayout(RecyclerView.ViewHolder viewHolder) {
return popFromLayoutStep(viewHolder, 8);
}
private RecyclerView.ItemAnimator.ItemHolderInfo popFromLayoutStep(RecyclerView.ViewHolder viewHolder, int i) {
InfoRecord valueAt;
RecyclerView.ItemAnimator.ItemHolderInfo itemHolderInfo;
int indexOfKey = this.mLayoutHolderMap.indexOfKey(viewHolder);
if (indexOfKey >= 0 && (valueAt = this.mLayoutHolderMap.valueAt(indexOfKey)) != null) {
int i2 = valueAt.flags;
if ((i2 & i) != 0) {
int i3 = (~i) & i2;
valueAt.flags = i3;
if (i == 4) {
itemHolderInfo = valueAt.preInfo;
} else if (i == 8) {
itemHolderInfo = valueAt.postInfo;
} else {
throw new IllegalArgumentException("Must provide flag PRE or POST");
}
if ((i3 & 12) == 0) {
this.mLayoutHolderMap.removeAt(indexOfKey);
InfoRecord.recycle(valueAt);
}
return itemHolderInfo;
}
}
return null;
}
public void addToOldChangeHolders(long j, RecyclerView.ViewHolder viewHolder) {
this.mOldChangedHolders.put(j, viewHolder);
}
public void addToAppearedInPreLayoutHolders(RecyclerView.ViewHolder viewHolder, RecyclerView.ItemAnimator.ItemHolderInfo itemHolderInfo) {
InfoRecord infoRecord = this.mLayoutHolderMap.get(viewHolder);
if (infoRecord == null) {
infoRecord = InfoRecord.obtain();
this.mLayoutHolderMap.put(viewHolder, infoRecord);
}
infoRecord.flags |= 2;
infoRecord.preInfo = itemHolderInfo;
}
public boolean isInPreLayout(RecyclerView.ViewHolder viewHolder) {
InfoRecord infoRecord = this.mLayoutHolderMap.get(viewHolder);
return (infoRecord == null || (infoRecord.flags & 4) == 0) ? false : true;
}
public RecyclerView.ViewHolder getFromOldChangeHolders(long j) {
return this.mOldChangedHolders.get(j);
}
public void addToPostLayout(RecyclerView.ViewHolder viewHolder, RecyclerView.ItemAnimator.ItemHolderInfo itemHolderInfo) {
InfoRecord infoRecord = this.mLayoutHolderMap.get(viewHolder);
if (infoRecord == null) {
infoRecord = InfoRecord.obtain();
this.mLayoutHolderMap.put(viewHolder, infoRecord);
}
infoRecord.postInfo = itemHolderInfo;
infoRecord.flags |= 8;
}
public void addToDisappearedInLayout(RecyclerView.ViewHolder viewHolder) {
InfoRecord infoRecord = this.mLayoutHolderMap.get(viewHolder);
if (infoRecord == null) {
infoRecord = InfoRecord.obtain();
this.mLayoutHolderMap.put(viewHolder, infoRecord);
}
infoRecord.flags |= 1;
}
public void removeFromDisappearedInLayout(RecyclerView.ViewHolder viewHolder) {
InfoRecord infoRecord = this.mLayoutHolderMap.get(viewHolder);
if (infoRecord == null) {
return;
}
infoRecord.flags &= -2;
}
public void process(ProcessCallback processCallback) {
for (int size = this.mLayoutHolderMap.size() - 1; size >= 0; size--) {
RecyclerView.ViewHolder keyAt = this.mLayoutHolderMap.keyAt(size);
InfoRecord removeAt = this.mLayoutHolderMap.removeAt(size);
int i = removeAt.flags;
if ((i & 3) == 3) {
processCallback.unused(keyAt);
} else if ((i & 1) != 0) {
RecyclerView.ItemAnimator.ItemHolderInfo itemHolderInfo = removeAt.preInfo;
if (itemHolderInfo == null) {
processCallback.unused(keyAt);
} else {
processCallback.processDisappeared(keyAt, itemHolderInfo, removeAt.postInfo);
}
} else if ((i & 14) == 14) {
processCallback.processAppeared(keyAt, removeAt.preInfo, removeAt.postInfo);
} else if ((i & 12) == 12) {
processCallback.processPersistent(keyAt, removeAt.preInfo, removeAt.postInfo);
} else if ((i & 4) != 0) {
processCallback.processDisappeared(keyAt, removeAt.preInfo, null);
} else if ((i & 8) != 0) {
processCallback.processAppeared(keyAt, removeAt.preInfo, removeAt.postInfo);
}
InfoRecord.recycle(removeAt);
}
}
public void removeViewHolder(RecyclerView.ViewHolder viewHolder) {
int size = this.mOldChangedHolders.size() - 1;
while (true) {
if (size < 0) {
break;
}
if (viewHolder == this.mOldChangedHolders.valueAt(size)) {
this.mOldChangedHolders.removeAt(size);
break;
}
size--;
}
InfoRecord remove = this.mLayoutHolderMap.remove(viewHolder);
if (remove != null) {
InfoRecord.recycle(remove);
}
}
public void onDetach() {
InfoRecord.drainCache();
}
public void onViewDetached(RecyclerView.ViewHolder viewHolder) {
removeFromDisappearedInLayout(viewHolder);
}
public static class InfoRecord {
static final int FLAG_APPEAR = 2;
static final int FLAG_APPEAR_AND_DISAPPEAR = 3;
static final int FLAG_APPEAR_PRE_AND_POST = 14;
static final int FLAG_DISAPPEARED = 1;
static final int FLAG_POST = 8;
static final int FLAG_PRE = 4;
static final int FLAG_PRE_AND_POST = 12;
static Pools.Pool<InfoRecord> sPool = new Pools.SimplePool(20);
int flags;
@Nullable
RecyclerView.ItemAnimator.ItemHolderInfo postInfo;
@Nullable
RecyclerView.ItemAnimator.ItemHolderInfo preInfo;
private InfoRecord() {
}
public static InfoRecord obtain() {
InfoRecord acquire = sPool.acquire();
return acquire == null ? new InfoRecord() : acquire;
}
public static void recycle(InfoRecord infoRecord) {
infoRecord.flags = 0;
infoRecord.preInfo = null;
infoRecord.postInfo = null;
sPool.release(infoRecord);
}
public static void drainCache() {
while (sPool.acquire() != null) {
}
}
}
}

View File

@@ -0,0 +1,157 @@
package androidx.recyclerview.widget;
import android.util.SparseArray;
import android.util.SparseIntArray;
import androidx.annotation.NonNull;
import java.util.ArrayList;
import java.util.List;
/* loaded from: classes.dex */
interface ViewTypeStorage {
public interface ViewTypeLookup {
void dispose();
int globalToLocal(int i);
int localToGlobal(int i);
}
@NonNull
ViewTypeLookup createViewTypeWrapper(@NonNull NestedAdapterWrapper nestedAdapterWrapper);
@NonNull
NestedAdapterWrapper getWrapperForGlobalType(int i);
public static class SharedIdRangeViewTypeStorage implements ViewTypeStorage {
SparseArray<List<NestedAdapterWrapper>> mGlobalTypeToWrapper = new SparseArray<>();
@Override // androidx.recyclerview.widget.ViewTypeStorage
@NonNull
public NestedAdapterWrapper getWrapperForGlobalType(int i) {
List<NestedAdapterWrapper> list = this.mGlobalTypeToWrapper.get(i);
if (list == null || list.isEmpty()) {
throw new IllegalArgumentException("Cannot find the wrapper for global view type " + i);
}
return list.get(0);
}
@Override // androidx.recyclerview.widget.ViewTypeStorage
@NonNull
public ViewTypeLookup createViewTypeWrapper(@NonNull NestedAdapterWrapper nestedAdapterWrapper) {
return new WrapperViewTypeLookup(nestedAdapterWrapper);
}
public void removeWrapper(@NonNull NestedAdapterWrapper nestedAdapterWrapper) {
for (int size = this.mGlobalTypeToWrapper.size() - 1; size >= 0; size--) {
List<NestedAdapterWrapper> valueAt = this.mGlobalTypeToWrapper.valueAt(size);
if (valueAt.remove(nestedAdapterWrapper) && valueAt.isEmpty()) {
this.mGlobalTypeToWrapper.removeAt(size);
}
}
}
public class WrapperViewTypeLookup implements ViewTypeLookup {
final NestedAdapterWrapper mWrapper;
@Override // androidx.recyclerview.widget.ViewTypeStorage.ViewTypeLookup
public int globalToLocal(int i) {
return i;
}
public WrapperViewTypeLookup(NestedAdapterWrapper nestedAdapterWrapper) {
this.mWrapper = nestedAdapterWrapper;
}
@Override // androidx.recyclerview.widget.ViewTypeStorage.ViewTypeLookup
public int localToGlobal(int i) {
List<NestedAdapterWrapper> list = SharedIdRangeViewTypeStorage.this.mGlobalTypeToWrapper.get(i);
if (list == null) {
list = new ArrayList<>();
SharedIdRangeViewTypeStorage.this.mGlobalTypeToWrapper.put(i, list);
}
if (!list.contains(this.mWrapper)) {
list.add(this.mWrapper);
}
return i;
}
@Override // androidx.recyclerview.widget.ViewTypeStorage.ViewTypeLookup
public void dispose() {
SharedIdRangeViewTypeStorage.this.removeWrapper(this.mWrapper);
}
}
}
public static class IsolatedViewTypeStorage implements ViewTypeStorage {
SparseArray<NestedAdapterWrapper> mGlobalTypeToWrapper = new SparseArray<>();
int mNextViewType = 0;
public int obtainViewType(NestedAdapterWrapper nestedAdapterWrapper) {
int i = this.mNextViewType;
this.mNextViewType = i + 1;
this.mGlobalTypeToWrapper.put(i, nestedAdapterWrapper);
return i;
}
@Override // androidx.recyclerview.widget.ViewTypeStorage
@NonNull
public NestedAdapterWrapper getWrapperForGlobalType(int i) {
NestedAdapterWrapper nestedAdapterWrapper = this.mGlobalTypeToWrapper.get(i);
if (nestedAdapterWrapper != null) {
return nestedAdapterWrapper;
}
throw new IllegalArgumentException("Cannot find the wrapper for global view type " + i);
}
@Override // androidx.recyclerview.widget.ViewTypeStorage
@NonNull
public ViewTypeLookup createViewTypeWrapper(@NonNull NestedAdapterWrapper nestedAdapterWrapper) {
return new WrapperViewTypeLookup(nestedAdapterWrapper);
}
public void removeWrapper(@NonNull NestedAdapterWrapper nestedAdapterWrapper) {
for (int size = this.mGlobalTypeToWrapper.size() - 1; size >= 0; size--) {
if (this.mGlobalTypeToWrapper.valueAt(size) == nestedAdapterWrapper) {
this.mGlobalTypeToWrapper.removeAt(size);
}
}
}
public class WrapperViewTypeLookup implements ViewTypeLookup {
final NestedAdapterWrapper mWrapper;
private SparseIntArray mLocalToGlobalMapping = new SparseIntArray(1);
private SparseIntArray mGlobalToLocalMapping = new SparseIntArray(1);
public WrapperViewTypeLookup(NestedAdapterWrapper nestedAdapterWrapper) {
this.mWrapper = nestedAdapterWrapper;
}
@Override // androidx.recyclerview.widget.ViewTypeStorage.ViewTypeLookup
public int localToGlobal(int i) {
int indexOfKey = this.mLocalToGlobalMapping.indexOfKey(i);
if (indexOfKey > -1) {
return this.mLocalToGlobalMapping.valueAt(indexOfKey);
}
int obtainViewType = IsolatedViewTypeStorage.this.obtainViewType(this.mWrapper);
this.mLocalToGlobalMapping.put(i, obtainViewType);
this.mGlobalToLocalMapping.put(obtainViewType, i);
return obtainViewType;
}
@Override // androidx.recyclerview.widget.ViewTypeStorage.ViewTypeLookup
public int globalToLocal(int i) {
int indexOfKey = this.mGlobalToLocalMapping.indexOfKey(i);
if (indexOfKey < 0) {
throw new IllegalStateException("requested global type " + i + " does not belong to the adapter:" + this.mWrapper.adapter);
}
return this.mGlobalToLocalMapping.valueAt(indexOfKey);
}
@Override // androidx.recyclerview.widget.ViewTypeStorage.ViewTypeLookup
public void dispose() {
IsolatedViewTypeStorage.this.removeWrapper(this.mWrapper);
}
}
}
}