ADD week 5

This commit is contained in:
2025-03-31 16:33:42 +02:00
parent 86f265f22d
commit bf645048e6
4927 changed files with 544053 additions and 0 deletions

View File

@ -0,0 +1,272 @@
package androidx.recyclerview;
/* loaded from: classes.dex */
public final class R {
public static final class attr {
public static final int alpha = 0x7f03002e;
public static final int fastScrollEnabled = 0x7f0301d3;
public static final int fastScrollHorizontalThumbDrawable = 0x7f0301d4;
public static final int fastScrollHorizontalTrackDrawable = 0x7f0301d5;
public static final int fastScrollVerticalThumbDrawable = 0x7f0301d6;
public static final int fastScrollVerticalTrackDrawable = 0x7f0301d7;
public static final int font = 0x7f0301fb;
public static final int fontProviderAuthority = 0x7f0301fd;
public static final int fontProviderCerts = 0x7f0301fe;
public static final int fontProviderFetchStrategy = 0x7f0301ff;
public static final int fontProviderFetchTimeout = 0x7f030200;
public static final int fontProviderPackage = 0x7f030201;
public static final int fontProviderQuery = 0x7f030202;
public static final int fontStyle = 0x7f030204;
public static final int fontVariationSettings = 0x7f030205;
public static final int fontWeight = 0x7f030206;
public static final int layoutManager = 0x7f03026d;
public static final int recyclerViewStyle = 0x7f030396;
public static final int reverseLayout = 0x7f03039c;
public static final int spanCount = 0x7f0303d4;
public static final int stackFromEnd = 0x7f0303df;
public static final int ttcIndex = 0x7f0304b6;
private attr() {
}
}
public static final class color {
public static final int notification_action_color_filter = 0x7f0502e9;
public static final int notification_icon_bg_color = 0x7f0502ea;
public static final int ripple_material_light = 0x7f0502f7;
public static final int secondary_text_default_material_light = 0x7f0502f9;
private color() {
}
}
public static final class dimen {
public static final int compat_button_inset_horizontal_material = 0x7f060058;
public static final int compat_button_inset_vertical_material = 0x7f060059;
public static final int compat_button_padding_horizontal_material = 0x7f06005a;
public static final int compat_button_padding_vertical_material = 0x7f06005b;
public static final int compat_control_corner_material = 0x7f06005c;
public static final int compat_notification_large_icon_max_height = 0x7f06005d;
public static final int compat_notification_large_icon_max_width = 0x7f06005e;
public static final int fastscroll_default_thickness = 0x7f060092;
public static final int fastscroll_margin = 0x7f060093;
public static final int fastscroll_minimum_range = 0x7f060094;
public static final int item_touch_helper_max_drag_scroll_per_frame = 0x7f06009c;
public static final int item_touch_helper_swipe_escape_max_velocity = 0x7f06009d;
public static final int item_touch_helper_swipe_escape_velocity = 0x7f06009e;
public static final int notification_action_icon_size = 0x7f060307;
public static final int notification_action_text_size = 0x7f060308;
public static final int notification_big_circle_margin = 0x7f060309;
public static final int notification_content_margin_start = 0x7f06030a;
public static final int notification_large_icon_height = 0x7f06030b;
public static final int notification_large_icon_width = 0x7f06030c;
public static final int notification_main_column_padding_top = 0x7f06030d;
public static final int notification_media_narrow_margin = 0x7f06030e;
public static final int notification_right_icon_size = 0x7f06030f;
public static final int notification_right_side_padding_top = 0x7f060310;
public static final int notification_small_icon_background_padding = 0x7f060311;
public static final int notification_small_icon_size_as_large = 0x7f060312;
public static final int notification_subtext_size = 0x7f060313;
public static final int notification_top_pad = 0x7f060314;
public static final int notification_top_pad_large_text = 0x7f060315;
private dimen() {
}
}
public static final class drawable {
public static final int notification_action_background = 0x7f0700d0;
public static final int notification_bg = 0x7f0700d1;
public static final int notification_bg_low = 0x7f0700d2;
public static final int notification_bg_low_normal = 0x7f0700d3;
public static final int notification_bg_low_pressed = 0x7f0700d4;
public static final int notification_bg_normal = 0x7f0700d5;
public static final int notification_bg_normal_pressed = 0x7f0700d6;
public static final int notification_icon_background = 0x7f0700d7;
public static final int notification_template_icon_bg = 0x7f0700d8;
public static final int notification_template_icon_low_bg = 0x7f0700d9;
public static final int notification_tile_bg = 0x7f0700da;
public static final int notify_panel_notification_icon_bg = 0x7f0700db;
private drawable() {
}
}
public static final class id {
public static final int accessibility_action_clickable_span = 0x7f08000f;
public static final int accessibility_custom_action_0 = 0x7f080010;
public static final int accessibility_custom_action_1 = 0x7f080011;
public static final int accessibility_custom_action_10 = 0x7f080012;
public static final int accessibility_custom_action_11 = 0x7f080013;
public static final int accessibility_custom_action_12 = 0x7f080014;
public static final int accessibility_custom_action_13 = 0x7f080015;
public static final int accessibility_custom_action_14 = 0x7f080016;
public static final int accessibility_custom_action_15 = 0x7f080017;
public static final int accessibility_custom_action_16 = 0x7f080018;
public static final int accessibility_custom_action_17 = 0x7f080019;
public static final int accessibility_custom_action_18 = 0x7f08001a;
public static final int accessibility_custom_action_19 = 0x7f08001b;
public static final int accessibility_custom_action_2 = 0x7f08001c;
public static final int accessibility_custom_action_20 = 0x7f08001d;
public static final int accessibility_custom_action_21 = 0x7f08001e;
public static final int accessibility_custom_action_22 = 0x7f08001f;
public static final int accessibility_custom_action_23 = 0x7f080020;
public static final int accessibility_custom_action_24 = 0x7f080021;
public static final int accessibility_custom_action_25 = 0x7f080022;
public static final int accessibility_custom_action_26 = 0x7f080023;
public static final int accessibility_custom_action_27 = 0x7f080024;
public static final int accessibility_custom_action_28 = 0x7f080025;
public static final int accessibility_custom_action_29 = 0x7f080026;
public static final int accessibility_custom_action_3 = 0x7f080027;
public static final int accessibility_custom_action_30 = 0x7f080028;
public static final int accessibility_custom_action_31 = 0x7f080029;
public static final int accessibility_custom_action_4 = 0x7f08002a;
public static final int accessibility_custom_action_5 = 0x7f08002b;
public static final int accessibility_custom_action_6 = 0x7f08002c;
public static final int accessibility_custom_action_7 = 0x7f08002d;
public static final int accessibility_custom_action_8 = 0x7f08002e;
public static final int accessibility_custom_action_9 = 0x7f08002f;
public static final int action_container = 0x7f08003a;
public static final int action_divider = 0x7f08003c;
public static final int action_image = 0x7f08003d;
public static final int action_text = 0x7f080043;
public static final int actions = 0x7f080044;
public static final int async = 0x7f080052;
public static final int blocking = 0x7f08005c;
public static final int chronometer = 0x7f080071;
public static final int dialog_button = 0x7f080095;
public static final int forever = 0x7f0800c2;
public static final int icon = 0x7f0800d4;
public static final int icon_group = 0x7f0800d5;
public static final int info = 0x7f0800dd;
public static final int italic = 0x7f0800e0;
public static final int item_touch_helper_previous_elevation = 0x7f0800e1;
public static final int line1 = 0x7f0800e9;
public static final int line3 = 0x7f0800ea;
public static final int normal = 0x7f080139;
public static final int notification_background = 0x7f08013b;
public static final int notification_main_column = 0x7f08013c;
public static final int notification_main_column_container = 0x7f08013d;
public static final int right_icon = 0x7f08016b;
public static final int right_side = 0x7f08016c;
public static final int tag_accessibility_actions = 0x7f0801ad;
public static final int tag_accessibility_clickable_spans = 0x7f0801ae;
public static final int tag_accessibility_heading = 0x7f0801af;
public static final int tag_accessibility_pane_title = 0x7f0801b0;
public static final int tag_screen_reader_focusable = 0x7f0801b4;
public static final int tag_transition_group = 0x7f0801b6;
public static final int tag_unhandled_key_event_manager = 0x7f0801b7;
public static final int tag_unhandled_key_listeners = 0x7f0801b8;
public static final int text = 0x7f0801ba;
public static final int text2 = 0x7f0801bb;
public static final int time = 0x7f0801ca;
public static final int title = 0x7f0801cb;
private id() {
}
}
public static final class integer {
public static final int status_bar_notification_info_maxnum = 0x7f090043;
private integer() {
}
}
public static final class layout {
public static final int custom_dialog = 0x7f0b001d;
public static final int notification_action = 0x7f0b0060;
public static final int notification_action_tombstone = 0x7f0b0061;
public static final int notification_template_custom_big = 0x7f0b0062;
public static final int notification_template_icon_group = 0x7f0b0063;
public static final int notification_template_part_chronometer = 0x7f0b0064;
public static final int notification_template_part_time = 0x7f0b0065;
private layout() {
}
}
public static final class string {
public static final int status_bar_notification_info_overflow = 0x7f0f00a8;
private string() {
}
}
public static final class style {
public static final int TextAppearance_Compat_Notification = 0x7f1001c3;
public static final int TextAppearance_Compat_Notification_Info = 0x7f1001c4;
public static final int TextAppearance_Compat_Notification_Line2 = 0x7f1001c5;
public static final int TextAppearance_Compat_Notification_Time = 0x7f1001c6;
public static final int TextAppearance_Compat_Notification_Title = 0x7f1001c7;
public static final int Widget_Compat_NotificationActionContainer = 0x7f10032d;
public static final int Widget_Compat_NotificationActionText = 0x7f10032e;
private style() {
}
}
public static final class styleable {
public static final int ColorStateListItem_alpha = 0x00000003;
public static final int ColorStateListItem_android_alpha = 0x00000001;
public static final int ColorStateListItem_android_color = 0x00000000;
public static final int ColorStateListItem_android_lStar = 0x00000002;
public static final int ColorStateListItem_lStar = 0x00000004;
public static final int FontFamilyFont_android_font = 0x00000000;
public static final int FontFamilyFont_android_fontStyle = 0x00000002;
public static final int FontFamilyFont_android_fontVariationSettings = 0x00000004;
public static final int FontFamilyFont_android_fontWeight = 0x00000001;
public static final int FontFamilyFont_android_ttcIndex = 0x00000003;
public static final int FontFamilyFont_font = 0x00000005;
public static final int FontFamilyFont_fontStyle = 0x00000006;
public static final int FontFamilyFont_fontVariationSettings = 0x00000007;
public static final int FontFamilyFont_fontWeight = 0x00000008;
public static final int FontFamilyFont_ttcIndex = 0x00000009;
public static final int FontFamily_fontProviderAuthority = 0x00000000;
public static final int FontFamily_fontProviderCerts = 0x00000001;
public static final int FontFamily_fontProviderFetchStrategy = 0x00000002;
public static final int FontFamily_fontProviderFetchTimeout = 0x00000003;
public static final int FontFamily_fontProviderPackage = 0x00000004;
public static final int FontFamily_fontProviderQuery = 0x00000005;
public static final int FontFamily_fontProviderSystemFontFamily = 0x00000006;
public static final int GradientColorItem_android_color = 0x00000000;
public static final int GradientColorItem_android_offset = 0x00000001;
public static final int GradientColor_android_centerColor = 0x00000007;
public static final int GradientColor_android_centerX = 0x00000003;
public static final int GradientColor_android_centerY = 0x00000004;
public static final int GradientColor_android_endColor = 0x00000001;
public static final int GradientColor_android_endX = 0x0000000a;
public static final int GradientColor_android_endY = 0x0000000b;
public static final int GradientColor_android_gradientRadius = 0x00000005;
public static final int GradientColor_android_startColor = 0x00000000;
public static final int GradientColor_android_startX = 0x00000008;
public static final int GradientColor_android_startY = 0x00000009;
public static final int GradientColor_android_tileMode = 0x00000006;
public static final int GradientColor_android_type = 0x00000002;
public static final int RecyclerView_android_clipToPadding = 0x00000001;
public static final int RecyclerView_android_descendantFocusability = 0x00000002;
public static final int RecyclerView_android_orientation = 0x00000000;
public static final int RecyclerView_fastScrollEnabled = 0x00000003;
public static final int RecyclerView_fastScrollHorizontalThumbDrawable = 0x00000004;
public static final int RecyclerView_fastScrollHorizontalTrackDrawable = 0x00000005;
public static final int RecyclerView_fastScrollVerticalThumbDrawable = 0x00000006;
public static final int RecyclerView_fastScrollVerticalTrackDrawable = 0x00000007;
public static final int RecyclerView_layoutManager = 0x00000008;
public static final int RecyclerView_reverseLayout = 0x00000009;
public static final int RecyclerView_spanCount = 0x0000000a;
public static final int RecyclerView_stackFromEnd = 0x0000000b;
public static final int[] ColorStateListItem = {android.R.attr.color, android.R.attr.alpha, android.R.attr.lStar, ch.mod_p.sre24.e5.R.attr.alpha, ch.mod_p.sre24.e5.R.attr.lStar};
public static final int[] FontFamily = {ch.mod_p.sre24.e5.R.attr.fontProviderAuthority, ch.mod_p.sre24.e5.R.attr.fontProviderCerts, ch.mod_p.sre24.e5.R.attr.fontProviderFetchStrategy, ch.mod_p.sre24.e5.R.attr.fontProviderFetchTimeout, ch.mod_p.sre24.e5.R.attr.fontProviderPackage, ch.mod_p.sre24.e5.R.attr.fontProviderQuery, ch.mod_p.sre24.e5.R.attr.fontProviderSystemFontFamily};
public static final int[] FontFamilyFont = {android.R.attr.font, android.R.attr.fontWeight, android.R.attr.fontStyle, android.R.attr.ttcIndex, android.R.attr.fontVariationSettings, ch.mod_p.sre24.e5.R.attr.font, ch.mod_p.sre24.e5.R.attr.fontStyle, ch.mod_p.sre24.e5.R.attr.fontVariationSettings, ch.mod_p.sre24.e5.R.attr.fontWeight, ch.mod_p.sre24.e5.R.attr.ttcIndex};
public static final 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 final int[] GradientColorItem = {android.R.attr.color, android.R.attr.offset};
public static final int[] RecyclerView = {android.R.attr.orientation, android.R.attr.clipToPadding, android.R.attr.descendantFocusability, ch.mod_p.sre24.e5.R.attr.fastScrollEnabled, ch.mod_p.sre24.e5.R.attr.fastScrollHorizontalThumbDrawable, ch.mod_p.sre24.e5.R.attr.fastScrollHorizontalTrackDrawable, ch.mod_p.sre24.e5.R.attr.fastScrollVerticalThumbDrawable, ch.mod_p.sre24.e5.R.attr.fastScrollVerticalTrackDrawable, ch.mod_p.sre24.e5.R.attr.layoutManager, ch.mod_p.sre24.e5.R.attr.reverseLayout, ch.mod_p.sre24.e5.R.attr.spanCount, ch.mod_p.sre24.e5.R.attr.stackFromEnd};
private styleable() {
}
}
private R() {
}
}

View File

@ -0,0 +1,590 @@
package androidx.recyclerview.widget;
import androidx.core.util.Pools;
import androidx.recyclerview.widget.OpReorderer;
import androidx.recyclerview.widget.RecyclerView;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/* loaded from: classes.dex */
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;
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);
}
boolean hasAnyUpdateTypes(int i) {
return (i & this.mExistingUpdateTypes) != 0;
}
AdapterHelper(Callback callback) {
this(callback, false);
}
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);
}
AdapterHelper addUpdateOp(UpdateOp... updateOpArr) {
Collections.addAll(this.mPendingUpdates, updateOpArr);
return this;
}
void reset() {
recycleUpdateOpsAndClearList(this.mPendingUpdates);
recycleUpdateOpsAndClearList(this.mPostponedList);
this.mExistingUpdateTypes = 0;
}
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();
}
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.positionStart + updateOp.itemCount;
int i3 = updateOp.positionStart;
char c2 = 65535;
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.positionStart + updateOp.itemCount;
char c = 65535;
int i3 = 0;
for (int i4 = updateOp.positionStart; i4 < i2; i4++) {
if (this.mCallback.findViewHolder(i4) != null || canFindInPreLayout(i4)) {
if (c == 0) {
dispatchAndUpdateViewHolders(obtainUpdateOp(4, i, i3, updateOp.payload));
i = i4;
i3 = 0;
}
c = 1;
} else {
if (c == 1) {
postponeAndUpdateViewHolders(obtainUpdateOp(4, i, i3, updateOp.payload));
i = i4;
i3 = 0;
}
c = 0;
}
i3++;
}
if (i3 != updateOp.itemCount) {
Object obj = updateOp.payload;
recycleUpdateOp(updateOp);
updateOp = obtainUpdateOp(4, i, i3, obj);
}
if (c == 0) {
dispatchAndUpdateViewHolders(updateOp);
} else {
postponeAndUpdateViewHolders(updateOp);
}
}
private void dispatchAndUpdateViewHolders(UpdateOp updateOp) {
int i;
if (updateOp.cmd == 1 || updateOp.cmd == 8) {
throw new IllegalArgumentException("should not dispatch add or move for pre layout");
}
int updatePositionWithPostponed = updatePositionWithPostponed(updateOp.positionStart, updateOp.cmd);
int i2 = updateOp.positionStart;
int i3 = updateOp.cmd;
if (i3 == 2) {
i = 0;
} else {
if (i3 != 4) {
throw new IllegalArgumentException("op should be remove or update." + updateOp);
}
i = 1;
}
int i4 = 1;
for (int i5 = 1; i5 < updateOp.itemCount; i5++) {
int updatePositionWithPostponed2 = updatePositionWithPostponed(updateOp.positionStart + (i * i5), updateOp.cmd);
int i6 = updateOp.cmd;
if (i6 == 2 ? updatePositionWithPostponed2 != updatePositionWithPostponed : !(i6 == 4 && updatePositionWithPostponed2 == updatePositionWithPostponed + 1)) {
UpdateOp obtainUpdateOp = obtainUpdateOp(updateOp.cmd, updatePositionWithPostponed, i4, updateOp.payload);
dispatchFirstPassAndUpdateViewHolders(obtainUpdateOp, i2);
recycleUpdateOp(obtainUpdateOp);
if (updateOp.cmd == 4) {
i2 += i4;
}
updatePositionWithPostponed = updatePositionWithPostponed2;
i4 = 1;
} else {
i4++;
}
}
Object obj = updateOp.payload;
recycleUpdateOp(updateOp);
if (i4 > 0) {
UpdateOp obtainUpdateOp2 = obtainUpdateOp(updateOp.cmd, updatePositionWithPostponed, i4, obj);
dispatchFirstPassAndUpdateViewHolders(obtainUpdateOp2, i2);
recycleUpdateOp(obtainUpdateOp2);
}
}
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);
if (updateOp.cmd == 8) {
if (updateOp.positionStart < updateOp.itemCount) {
i3 = updateOp.positionStart;
i4 = updateOp.itemCount;
} else {
i3 = updateOp.itemCount;
i4 = updateOp.positionStart;
}
if (i >= i3 && i <= i4) {
if (i3 == updateOp.positionStart) {
if (i2 == 1) {
updateOp.itemCount++;
} else if (i2 == 2) {
updateOp.itemCount--;
}
i++;
} else {
if (i2 == 1) {
updateOp.positionStart++;
} else if (i2 == 2) {
updateOp.positionStart--;
}
i--;
}
} else if (i < updateOp.positionStart) {
if (i2 == 1) {
updateOp.positionStart++;
updateOp.itemCount++;
} else if (i2 == 2) {
updateOp.positionStart--;
updateOp.itemCount--;
}
}
} else if (updateOp.positionStart <= i) {
if (updateOp.cmd == 1) {
i -= updateOp.itemCount;
} else if (updateOp.cmd == 2) {
i += updateOp.itemCount;
}
} else if (i2 == 1) {
updateOp.positionStart++;
} else if (i2 == 2) {
updateOp.positionStart--;
}
}
for (int size2 = this.mPostponedList.size() - 1; size2 >= 0; size2--) {
UpdateOp updateOp2 = this.mPostponedList.get(size2);
if (updateOp2.cmd == 8) {
if (updateOp2.itemCount == updateOp2.positionStart || updateOp2.itemCount < 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);
if (updateOp.cmd == 8) {
if (findPositionOffset(updateOp.itemCount, i2 + 1) == i) {
return true;
}
} else if (updateOp.cmd == 1) {
int i3 = updateOp.positionStart + updateOp.itemCount;
for (int i4 = updateOp.positionStart; i4 < i3; i4++) {
if (findPositionOffset(i4, i2 + 1) == i) {
return true;
}
}
} 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);
} else {
throw new IllegalArgumentException("Unknown update op type for " + updateOp);
}
}
boolean hasPendingUpdates() {
return this.mPendingUpdates.size() > 0;
}
int findPositionOffset(int i) {
return findPositionOffset(i, 0);
}
int findPositionOffset(int i, int i2) {
int size = this.mPostponedList.size();
while (i2 < size) {
UpdateOp updateOp = this.mPostponedList.get(i2);
if (updateOp.cmd == 8) {
if (updateOp.positionStart == i) {
i = updateOp.itemCount;
} else {
if (updateOp.positionStart < i) {
i--;
}
if (updateOp.itemCount <= i) {
i++;
}
}
} else if (updateOp.positionStart > i) {
continue;
} else if (updateOp.cmd == 2) {
if (i < updateOp.positionStart + updateOp.itemCount) {
return -1;
}
i -= updateOp.itemCount;
} else if (updateOp.cmd == 1) {
i += updateOp.itemCount;
}
i2++;
}
return i;
}
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;
}
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;
}
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;
}
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;
}
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) {
if (i3 == 8) {
if (updateOp.positionStart == i) {
i = updateOp.itemCount;
} else {
if (updateOp.positionStart < i) {
i--;
}
if (updateOp.itemCount <= i) {
i++;
}
}
}
} else if (updateOp.positionStart > i) {
continue;
} else {
if (updateOp.positionStart + updateOp.itemCount > i) {
return -1;
}
i -= updateOp.itemCount;
}
} else if (updateOp.positionStart <= i) {
i += updateOp.itemCount;
}
}
return i;
}
boolean hasUpdates() {
return (this.mPostponedList.isEmpty() || this.mPendingUpdates.isEmpty()) ? false : true;
}
static 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;
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;
}
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)) + "[" + cmdToString() + ",s:" + this.positionStart + "c:" + this.itemCount + ",p:" + this.payload + "]";
}
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null || getClass() != obj.getClass()) {
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);
}
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,32 @@
package androidx.recyclerview.widget;
import androidx.recyclerview.widget.RecyclerView;
/* loaded from: classes.dex */
public final class AdapterListUpdateCallback implements ListUpdateCallback {
private final RecyclerView.Adapter mAdapter;
public AdapterListUpdateCallback(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,64 @@
package androidx.recyclerview.widget;
import androidx.recyclerview.widget.DiffUtil;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
/* loaded from: classes.dex */
public final class AsyncDifferConfig<T> {
private final Executor mBackgroundThreadExecutor;
private final DiffUtil.ItemCallback<T> mDiffCallback;
private final Executor mMainThreadExecutor;
public Executor getBackgroundThreadExecutor() {
return this.mBackgroundThreadExecutor;
}
public DiffUtil.ItemCallback<T> getDiffCallback() {
return this.mDiffCallback;
}
public Executor getMainThreadExecutor() {
return this.mMainThreadExecutor;
}
AsyncDifferConfig(Executor executor, Executor executor2, 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;
private Executor mMainThreadExecutor;
public Builder<T> setBackgroundThreadExecutor(Executor executor) {
this.mBackgroundThreadExecutor = executor;
return this;
}
public Builder<T> setMainThreadExecutor(Executor executor) {
this.mMainThreadExecutor = executor;
return this;
}
public Builder(DiffUtil.ItemCallback<T> itemCallback) {
this.mDiffCallback = itemCallback;
}
public AsyncDifferConfig<T> build() {
if (this.mBackgroundThreadExecutor == null) {
synchronized (sExecutorLock) {
if (sDiffExecutor == null) {
sDiffExecutor = Executors.newFixedThreadPool(2);
}
}
this.mBackgroundThreadExecutor = sDiffExecutor;
}
return new AsyncDifferConfig<>(this.mMainThreadExecutor, this.mBackgroundThreadExecutor, this.mDiffCallback);
}
}
}

View File

@ -0,0 +1,179 @@
package androidx.recyclerview.widget;
import android.os.Handler;
import android.os.Looper;
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;
private List<T> mList;
private final List<ListListener<T>> mListeners;
Executor mMainThreadExecutor;
int mMaxScheduledGeneration;
private List<T> mReadOnlyList;
private final ListUpdateCallback mUpdateCallback;
public interface ListListener<T> {
void onCurrentListChanged(List<T> list, List<T> list2);
}
public List<T> getCurrentList() {
return this.mReadOnlyList;
}
private static class MainThreadExecutor implements Executor {
final Handler mHandler = new Handler(Looper.getMainLooper());
MainThreadExecutor() {
}
@Override // java.util.concurrent.Executor
public void execute(Runnable runnable) {
this.mHandler.post(runnable);
}
}
public AsyncListDiffer(RecyclerView.Adapter adapter, DiffUtil.ItemCallback<T> itemCallback) {
this(new AdapterListUpdateCallback(adapter), new AsyncDifferConfig.Builder(itemCallback).build());
}
public AsyncListDiffer(ListUpdateCallback listUpdateCallback, 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(List<T> list) {
submitList(list, null);
}
public void submitList(final List<T> list, 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
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() {
if (AsyncListDiffer.this.mMaxScheduledGeneration == i) {
AsyncListDiffer.this.latchList(list, calculateDiff, runnable);
}
}
});
}
});
}
void latchList(List<T> list, DiffUtil.DiffResult diffResult, 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(List<T> list, 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(ListListener<T> listListener) {
this.mListeners.add(listListener);
}
public void removeListListener(ListListener<T> listListener) {
this.mListeners.remove(listListener);
}
}

View File

@ -0,0 +1,336 @@
package androidx.recyclerview.widget;
import android.util.Log;
import android.util.SparseBooleanArray;
import android.util.SparseIntArray;
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> {
public abstract void fillData(T[] tArr, int i, int i2);
public int getMaxCachedTiles() {
return 10;
}
public void recycleData(T[] tArr, int i) {
}
public abstract int refreshData();
}
private boolean isRefreshPending() {
return this.mRequestedGeneration != this.mDisplayedGeneration;
}
public int getItemCount() {
return this.mItemCount;
}
void log(String str, Object... objArr) {
Log.d(TAG, "[MAIN] " + String.format(str, objArr));
}
public AsyncListUtil(Class<T> cls, int i, DataCallback<T> dataCallback, 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.this.mItemCount = i3;
AsyncListUtil.this.mViewCallback.onDataRefresh();
AsyncListUtil asyncListUtil = AsyncListUtil.this;
asyncListUtil.mDisplayedGeneration = asyncListUtil.mRequestedGeneration;
recycleAllTiles();
AsyncListUtil.this.mAllowScrollHints = false;
AsyncListUtil.this.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.this.mBackgroundProxy.recycleTile(AsyncListUtil.this.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();
this.mItemCount = AsyncListUtil.this.mDataCallback.refreshData();
AsyncListUtil.this.mMainThreadProxy.updateItemCount(this.mGeneration, this.mItemCount);
}
@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;
acquireTile.mItemCount = Math.min(AsyncListUtil.this.mTileSize, this.mItemCount - acquireTile.mStartPosition);
AsyncListUtil.this.mDataCallback.fillData(acquireTile.mItems, acquireTile.mStartPosition, acquireTile.mItemCount);
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;
}
return new TileList.Tile<>(AsyncListUtil.this.mTClass, AsyncListUtil.this.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) {
Log.d(AsyncListUtil.TAG, "[BKGR] " + 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);
}
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;
}
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;
public abstract void getItemRangeInto(int[] iArr);
public abstract void onDataRefresh();
public abstract void onItemLoaded(int i);
public void extendRangeInto(int[] iArr, 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,90 @@
package androidx.recyclerview.widget;
/* 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(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,342 @@
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();
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);
}
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;
}
void addView(View view, boolean z) {
addView(view, -1, z);
}
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;
}
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);
}
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);
}
View getChildAt(int i) {
return this.mCallback.getChildAt(getOffset(i));
}
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();
}
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;
}
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);
}
int getChildCount() {
return this.mCallback.getChildCount() - this.mHiddenViews.size();
}
int getUnfilteredChildCount() {
return this.mCallback.getChildCount();
}
View getUnfilteredChildAt(int i) {
return this.mCallback.getChildAt(i);
}
void detachViewFromParent(int i) {
int offset = getOffset(i);
this.mBucket.remove(offset);
this.mCallback.detachViewFromParent(offset);
}
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);
}
boolean isHidden(View view) {
return this.mHiddenViews.contains(view);
}
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);
}
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();
}
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;
}
static class Bucket {
static final int BITS_PER_WORD = 64;
static final long LAST_BIT = Long.MIN_VALUE;
long mData = 0;
Bucket mNext;
Bucket() {
}
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();
}
}
void clear(int i) {
if (i < 64) {
this.mData &= ~(1 << i);
return;
}
Bucket bucket = this.mNext;
if (bucket != null) {
bucket.clear(i - 64);
}
}
boolean get(int i) {
if (i < 64) {
return (this.mData & (1 << i)) != 0;
}
ensureNext();
return this.mNext.get(i - 64);
}
void reset() {
this.mData = 0L;
Bucket bucket = this.mNext;
if (bucket != null) {
bucket.reset();
}
}
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);
}
}
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;
}
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,565 @@
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.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<>();
private static class MoveInfo {
public int fromX;
public int fromY;
public RecyclerView.ViewHolder holder;
public int toX;
public int toY;
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;
}
}
private 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;
}
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;
}
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) viewHolder.itemView.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;
}
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;
}
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) {
if (changeInfo.oldHolder != null) {
endChangeAnimationIfNecessary(changeInfo, changeInfo.oldHolder);
}
if (changeInfo.newHolder != null) {
endChangeAnimationIfNecessary(changeInfo, changeInfo.newHolder);
}
}
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;
}
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();
}
}
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(RecyclerView.ViewHolder viewHolder, List<Object> list) {
return !list.isEmpty() || super.canReuseUpdatedViewHolder(viewHolder, list);
}
}

View File

@ -0,0 +1,438 @@
package androidx.recyclerview.widget;
import androidx.recyclerview.widget.RecyclerView;
import java.util.ArrayList;
import java.util.Arrays;
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<Snake> SNAKE_COMPARATOR = new Comparator<Snake>() { // from class: androidx.recyclerview.widget.DiffUtil.1
@Override // java.util.Comparator
public int compare(Snake snake, Snake snake2) {
int i = snake.x - snake2.x;
return i == 0 ? snake.y - snake2.y : i;
}
};
public static abstract class Callback {
public abstract boolean areContentsTheSame(int i, int i2);
public abstract boolean areItemsTheSame(int i, int i2);
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(T t, T t2);
public abstract boolean areItemsTheSame(T t, T t2);
public Object getChangePayload(T t, T t2) {
return null;
}
}
private DiffUtil() {
}
public static DiffResult calculateDiff(Callback callback) {
return calculateDiff(callback, true);
}
public static DiffResult calculateDiff(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 abs = oldListSize + newListSize + Math.abs(oldListSize - newListSize);
int i = abs * 2;
int[] iArr = new int[i];
int[] iArr2 = new int[i];
ArrayList arrayList3 = new ArrayList();
while (!arrayList2.isEmpty()) {
Range range = (Range) arrayList2.remove(arrayList2.size() - 1);
Snake diffPartial = diffPartial(callback, range.oldListStart, range.oldListEnd, range.newListStart, range.newListEnd, iArr, iArr2, abs);
if (diffPartial != null) {
if (diffPartial.size > 0) {
arrayList.add(diffPartial);
}
diffPartial.x += range.oldListStart;
diffPartial.y += range.newListStart;
Range range2 = arrayList3.isEmpty() ? new Range() : (Range) arrayList3.remove(arrayList3.size() - 1);
range2.oldListStart = range.oldListStart;
range2.newListStart = range.newListStart;
if (diffPartial.reverse) {
range2.oldListEnd = diffPartial.x;
range2.newListEnd = diffPartial.y;
} else if (diffPartial.removal) {
range2.oldListEnd = diffPartial.x - 1;
range2.newListEnd = diffPartial.y;
} else {
range2.oldListEnd = diffPartial.x;
range2.newListEnd = diffPartial.y - 1;
}
arrayList2.add(range2);
if (diffPartial.reverse) {
if (diffPartial.removal) {
range.oldListStart = diffPartial.x + diffPartial.size + 1;
range.newListStart = diffPartial.y + diffPartial.size;
} else {
range.oldListStart = diffPartial.x + diffPartial.size;
range.newListStart = diffPartial.y + diffPartial.size + 1;
}
} else {
range.oldListStart = diffPartial.x + diffPartial.size;
range.newListStart = diffPartial.y + diffPartial.size;
}
arrayList2.add(range);
} else {
arrayList3.add(range);
}
}
Collections.sort(arrayList, SNAKE_COMPARATOR);
return new DiffResult(callback, arrayList, iArr, iArr2, z);
}
/* JADX WARN: Code restructure failed: missing block: B:14:0x0042, code lost:
if (r24[r13 - 1] < r24[r13 + r5]) goto L20;
*/
/* JADX WARN: Code restructure failed: missing block: B:51:0x00b8, code lost:
if (r25[r12 - 1] < r25[r12 + 1]) goto L50;
*/
/* JADX WARN: Removed duplicated region for block: B:58:0x00e1 A[LOOP:4: B:54:0x00cd->B:58:0x00e1, LOOP_END] */
/* JADX WARN: Removed duplicated region for block: B:59:0x00ec A[EDGE_INSN: B:59:0x00ec->B:60:0x00ec BREAK A[LOOP:4: B:54:0x00cd->B:58:0x00e1], SYNTHETIC] */
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
private static androidx.recyclerview.widget.DiffUtil.Snake diffPartial(androidx.recyclerview.widget.DiffUtil.Callback r19, int r20, int r21, int r22, int r23, int[] r24, int[] r25, int r26) {
/*
Method dump skipped, instructions count: 305
To view this dump add '--comments-level debug' option
*/
throw new UnsupportedOperationException("Method not decompiled: androidx.recyclerview.widget.DiffUtil.diffPartial(androidx.recyclerview.widget.DiffUtil$Callback, int, int, int, int, int[], int[], int):androidx.recyclerview.widget.DiffUtil$Snake");
}
static class Snake {
boolean removal;
boolean reverse;
int size;
int x;
int y;
Snake() {
}
}
static class Range {
int newListEnd;
int newListStart;
int oldListEnd;
int 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_IGNORE = 16;
private static final int FLAG_MASK = 31;
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 = 5;
public static final int NO_POSITION = -1;
private final Callback mCallback;
private final boolean mDetectMoves;
private final int[] mNewItemStatuses;
private final int mNewListSize;
private final int[] mOldItemStatuses;
private final int mOldListSize;
private final List<Snake> mSnakes;
List<Snake> getSnakes() {
return this.mSnakes;
}
DiffResult(Callback callback, List<Snake> list, int[] iArr, int[] iArr2, boolean z) {
this.mSnakes = 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;
addRootSnake();
findMatchingItems();
}
private void addRootSnake() {
Snake snake = this.mSnakes.isEmpty() ? null : this.mSnakes.get(0);
if (snake != null && snake.x == 0 && snake.y == 0) {
return;
}
Snake snake2 = new Snake();
snake2.x = 0;
snake2.y = 0;
snake2.removal = false;
snake2.size = 0;
snake2.reverse = false;
this.mSnakes.add(0, snake2);
}
private void findMatchingItems() {
int i = this.mOldListSize;
int i2 = this.mNewListSize;
for (int size = this.mSnakes.size() - 1; size >= 0; size--) {
Snake snake = this.mSnakes.get(size);
int i3 = snake.x + snake.size;
int i4 = snake.y + snake.size;
if (this.mDetectMoves) {
while (i > i3) {
findAddition(i, i2, size);
i--;
}
while (i2 > i4) {
findRemoval(i, i2, size);
i2--;
}
}
for (int i5 = 0; i5 < snake.size; i5++) {
int i6 = snake.x + i5;
int i7 = snake.y + i5;
int i8 = this.mCallback.areContentsTheSame(i6, i7) ? 1 : 2;
this.mOldItemStatuses[i6] = (i7 << 5) | i8;
this.mNewItemStatuses[i7] = (i6 << 5) | i8;
}
i = snake.x;
i2 = snake.y;
}
}
private void findAddition(int i, int i2, int i3) {
if (this.mOldItemStatuses[i - 1] != 0) {
return;
}
findMatchingItem(i, i2, i3, false);
}
private void findRemoval(int i, int i2, int i3) {
if (this.mNewItemStatuses[i2 - 1] != 0) {
return;
}
findMatchingItem(i, i2, i3, true);
}
public int convertOldPositionToNew(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 & 31) == 0) {
return -1;
}
return i2 >> 5;
}
public int convertNewPositionToOld(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 & 31) == 0) {
return -1;
}
return i2 >> 5;
}
private boolean findMatchingItem(int i, int i2, int i3, boolean z) {
int i4;
int i5;
int i6;
if (z) {
i2--;
i5 = i;
i4 = i2;
} else {
i4 = i - 1;
i5 = i4;
}
while (i3 >= 0) {
Snake snake = this.mSnakes.get(i3);
int i7 = snake.x + snake.size;
int i8 = snake.y + snake.size;
if (z) {
for (int i9 = i5 - 1; i9 >= i7; i9--) {
if (this.mCallback.areItemsTheSame(i9, i4)) {
i6 = this.mCallback.areContentsTheSame(i9, i4) ? 8 : 4;
this.mNewItemStatuses[i4] = (i9 << 5) | 16;
this.mOldItemStatuses[i9] = (i4 << 5) | i6;
return true;
}
}
} else {
for (int i10 = i2 - 1; i10 >= i8; i10--) {
if (this.mCallback.areItemsTheSame(i4, i10)) {
i6 = this.mCallback.areContentsTheSame(i4, i10) ? 8 : 4;
int i11 = i - 1;
this.mOldItemStatuses[i11] = (i10 << 5) | 16;
this.mNewItemStatuses[i10] = (i11 << 5) | i6;
return true;
}
}
}
i5 = snake.x;
i2 = snake.y;
i3--;
}
return false;
}
public void dispatchUpdatesTo(RecyclerView.Adapter adapter) {
dispatchUpdatesTo(new AdapterListUpdateCallback(adapter));
}
public void dispatchUpdatesTo(ListUpdateCallback listUpdateCallback) {
BatchingListUpdateCallback batchingListUpdateCallback;
if (listUpdateCallback instanceof BatchingListUpdateCallback) {
batchingListUpdateCallback = (BatchingListUpdateCallback) listUpdateCallback;
} else {
batchingListUpdateCallback = new BatchingListUpdateCallback(listUpdateCallback);
}
ArrayList arrayList = new ArrayList();
int i = this.mOldListSize;
int i2 = this.mNewListSize;
for (int size = this.mSnakes.size() - 1; size >= 0; size--) {
Snake snake = this.mSnakes.get(size);
int i3 = snake.size;
int i4 = snake.x + i3;
int i5 = snake.y + i3;
if (i4 < i) {
dispatchRemovals(arrayList, batchingListUpdateCallback, i4, i - i4, i4);
}
if (i5 < i2) {
dispatchAdditions(arrayList, batchingListUpdateCallback, i4, i2 - i5, i5);
}
for (int i6 = i3 - 1; i6 >= 0; i6--) {
if ((this.mOldItemStatuses[snake.x + i6] & 31) == 2) {
batchingListUpdateCallback.onChanged(snake.x + i6, 1, this.mCallback.getChangePayload(snake.x + i6, snake.y + i6));
}
}
i = snake.x;
i2 = snake.y;
}
batchingListUpdateCallback.dispatchLastEvent();
}
private static PostponedUpdate removePostponedUpdate(List<PostponedUpdate> list, int i, boolean z) {
int size = list.size() - 1;
while (size >= 0) {
PostponedUpdate postponedUpdate = list.get(size);
if (postponedUpdate.posInOwnerList == i && postponedUpdate.removal == z) {
list.remove(size);
while (size < list.size()) {
list.get(size).currentPos += z ? 1 : -1;
size++;
}
return postponedUpdate;
}
size--;
}
return null;
}
private void dispatchAdditions(List<PostponedUpdate> list, ListUpdateCallback listUpdateCallback, int i, int i2, int i3) {
if (!this.mDetectMoves) {
listUpdateCallback.onInserted(i, i2);
return;
}
for (int i4 = i2 - 1; i4 >= 0; i4--) {
int i5 = i3 + i4;
int i6 = this.mNewItemStatuses[i5];
int i7 = i6 & 31;
if (i7 == 0) {
listUpdateCallback.onInserted(i, 1);
Iterator<PostponedUpdate> it = list.iterator();
while (it.hasNext()) {
it.next().currentPos++;
}
} else if (i7 == 4 || i7 == 8) {
int i8 = i6 >> 5;
listUpdateCallback.onMoved(removePostponedUpdate(list, i8, true).currentPos, i);
if (i7 == 4) {
listUpdateCallback.onChanged(i, 1, this.mCallback.getChangePayload(i8, i5));
}
} else if (i7 == 16) {
list.add(new PostponedUpdate(i5, i, false));
} else {
throw new IllegalStateException("unknown flag for pos " + i5 + " " + Long.toBinaryString(i7));
}
}
}
private void dispatchRemovals(List<PostponedUpdate> list, ListUpdateCallback listUpdateCallback, int i, int i2, int i3) {
if (!this.mDetectMoves) {
listUpdateCallback.onRemoved(i, i2);
return;
}
for (int i4 = i2 - 1; i4 >= 0; i4--) {
int i5 = i3 + i4;
int i6 = this.mOldItemStatuses[i5];
int i7 = i6 & 31;
if (i7 == 0) {
listUpdateCallback.onRemoved(i + i4, 1);
Iterator<PostponedUpdate> it = list.iterator();
while (it.hasNext()) {
it.next().currentPos--;
}
} else if (i7 == 4 || i7 == 8) {
int i8 = i6 >> 5;
PostponedUpdate removePostponedUpdate = removePostponedUpdate(list, i8, false);
listUpdateCallback.onMoved(i + i4, removePostponedUpdate.currentPos - 1);
if (i7 == 4) {
listUpdateCallback.onChanged(removePostponedUpdate.currentPos - 1, 1, this.mCallback.getChangePayload(i5, i8));
}
} else if (i7 == 16) {
list.add(new PostponedUpdate(i5, i + i4, true));
} else {
throw new IllegalStateException("unknown flag for pos " + i5 + " " + Long.toBinaryString(i7));
}
}
}
}
private 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;
}
}
}

View File

@ -0,0 +1,121 @@
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.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;
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(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,485 @@
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.core.view.ViewCompat;
import androidx.recyclerview.widget.RecyclerView;
/* 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;
float mHorizontalDragX;
int mHorizontalThumbCenterX;
private final StateListDrawable mHorizontalThumbDrawable;
private final int mHorizontalThumbHeight;
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;
float mVerticalDragY;
int mVerticalThumbCenterY;
final StateListDrawable mVerticalThumbDrawable;
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];
Drawable getHorizontalThumbDrawable() {
return this.mHorizontalThumbDrawable;
}
Drawable getHorizontalTrackDrawable() {
return this.mHorizontalTrackDrawable;
}
Drawable getVerticalThumbDrawable() {
return this.mVerticalThumbDrawable;
}
Drawable getVerticalTrackDrawable() {
return this.mVerticalTrackDrawable;
}
public boolean isDragging() {
return this.mState == 2;
}
boolean isVisible() {
return this.mState == 1;
}
@Override // androidx.recyclerview.widget.RecyclerView.OnItemTouchListener
public void onRequestDisallowInterceptTouchEvent(boolean z) {
}
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(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();
}
void requestRedraw() {
this.mRecyclerView.invalidate();
}
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(HIDE_DELAY_AFTER_DRAGGING_MS);
} else if (i == 1) {
resetHideDelay(HIDE_DELAY_AFTER_VISIBLE_MS);
}
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();
}
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);
}
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(RecyclerView recyclerView, 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(RecyclerView recyclerView, 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;
}
boolean isPointInsideVerticalThumb(float f, float f2) {
if (!isLayoutRTL() ? f >= this.mRecyclerViewWidth - this.mVerticalThumbWidth : f <= this.mVerticalThumbWidth / 2) {
int i = this.mVerticalThumbCenterY;
int i2 = this.mVerticalThumbHeight;
if (f2 >= i - (i2 / 2) && f2 <= i + (i2 / 2)) {
return true;
}
}
return false;
}
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;
}
private class AnimatorListener extends AnimatorListenerAdapter {
private boolean mCanceled = false;
@Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
public void onAnimationCancel(Animator animator) {
this.mCanceled = true;
}
AnimatorListener() {
}
@Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
public void onAnimationEnd(Animator animator) {
if (this.mCanceled) {
this.mCanceled = false;
} else if (((Float) FastScroller.this.mShowHideAnimator.getAnimatedValue()).floatValue() == 0.0f) {
FastScroller.this.mAnimationState = 0;
FastScroller.this.setState(0);
} else {
FastScroller.this.mAnimationState = 2;
FastScroller.this.requestRedraw();
}
}
}
private class AnimatorUpdater implements ValueAnimator.AnimatorUpdateListener {
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,300 @@
package androidx.recyclerview.widget;
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) {
if ((task.view == null) != (task2.view == null)) {
return task.view == null ? 1 : -1;
}
if (task.immediate != task2.immediate) {
return task.immediate ? -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<>();
GapWorker() {
}
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;
}
Task() {
}
}
static class LayoutPrefetchRegistryImpl implements RecyclerView.LayoutManager.LayoutPrefetchRegistry {
int mCount;
int[] mPrefetchArray;
int mPrefetchDx;
int mPrefetchDy;
void setPrefetchVector(int i, int i2) {
this.mPrefetchDx = i;
this.mPrefetchDy = i2;
}
LayoutPrefetchRegistryImpl() {
}
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);
}
if (this.mCount > layoutManager.mPrefetchMaxCountObserved) {
layoutManager.mPrefetchMaxCountObserved = this.mCount;
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++;
}
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;
}
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);
}
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 i6 = layoutPrefetchRegistryImpl.mPrefetchArray[i5 + 1];
task.immediate = i6 <= abs;
task.viewVelocity = abs;
task.distanceToItem = i6;
task.view = recyclerView2;
task.position = layoutPrefetchRegistryImpl.mPrefetchArray[i5];
i3++;
}
}
}
Collections.sort(this.mTasks, sTaskComparator);
}
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);
}
}
return tryGetViewHolderForPositionByDeadline;
} finally {
recyclerView.onExitLayoutOrScroll(false);
}
}
private void prefetchInnerRecyclerViewWithDeadline(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();
}
}
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);
}
}
} finally {
this.mPostTimeNs = 0L;
TraceCompat.endSection();
}
}
}

View File

@ -0,0 +1,874 @@
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;
}
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(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 = chooseSize(i2, rect.height() + paddingTop, getMinimumHeight());
int[] iArr = this.mCachedBorders;
chooseSize = chooseSize(i, iArr[iArr.length - 1] + paddingLeft, getMinimumWidth());
} else {
chooseSize = chooseSize(i, rect.width() + paddingLeft, getMinimumWidth());
int[] iArr2 = this.mCachedBorders;
chooseSize2 = chooseSize(i2, iArr2[iArr2.length - 1] + paddingTop, getMinimumHeight());
}
setMeasuredDimension(chooseSize, chooseSize2);
}
private void calculateItemBorders(int i) {
this.mCachedBorders = calculateItemBorders(this.mCachedBorders, this.mSpanCount, i);
}
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;
}
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
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 && anchorInfo.mPosition > 0) {
anchorInfo.mPosition--;
spanIndex = getSpanIndex(recycler, state, anchorInfo.mPosition);
}
return;
}
int itemCount = state.getItemCount() - 1;
int i2 = anchorInfo.mPosition;
while (i2 < itemCount) {
int i3 = i2 + 1;
int spanIndex2 = getSpanIndex(recycler, state, i3);
if (spanIndex2 <= spanIndex) {
break;
}
i2 = i3;
spanIndex = spanIndex2;
}
anchorInfo.mPosition = i2;
}
@Override // androidx.recyclerview.widget.LinearLayoutManager
View findReferenceChild(RecyclerView.Recycler recycler, RecyclerView.State state, int i, int i2, int i3) {
ensureLayoutState();
int startAfterPadding = this.mOrientationHelper.getStartAfterPadding();
int endAfterPadding = this.mOrientationHelper.getEndAfterPadding();
int i4 = i2 > i ? 1 : -1;
View view = null;
View view2 = null;
while (i != i2) {
View childAt = getChildAt(i);
int position = getPosition(childAt);
if (position >= 0 && position < i3 && 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;
}
}
}
i += i4;
}
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
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:0x009c, code lost:
r21.mFinished = true;
*/
/* JADX WARN: Code restructure failed: missing block: B:31:0x009e, 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
*/
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: 554
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 + layoutParams.topMargin + layoutParams.bottomMargin;
int i5 = rect.left + rect.right + layoutParams.leftMargin + layoutParams.rightMargin;
int spaceForSpanRange = getSpaceForSpanRange(layoutParams.mSpanIndex, layoutParams.mSpanSize);
if (this.mOrientation == 1) {
i3 = getChildMeasureSpec(spaceForSpanRange, i, i5, layoutParams.width, false);
i2 = getChildMeasureSpec(this.mOrientationHelper.getTotalSpace(), getHeightMode(), i4, layoutParams.height, true);
} else {
int childMeasureSpec = getChildMeasureSpec(spaceForSpanRange, i, i4, layoutParams.height, false);
int childMeasureSpec2 = getChildMeasureSpec(this.mOrientationHelper.getTotalSpace(), getWidthMode(), i5, 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) {
i3 = i;
i2 = 0;
i4 = 1;
} else {
i2 = i - 1;
i3 = -1;
i4 = -1;
}
while (i2 != i3) {
View view = this.mSet[i2];
LayoutParams layoutParams = (LayoutParams) view.getLayoutParams();
layoutParams.mSpanSize = getSpanSize(recycler, state, getPosition(view));
layoutParams.mSpanIndex = i5;
i5 += layoutParams.mSpanSize;
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();
}
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;
}
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 = 0
r3 = 0
L22:
if (r2 >= r6) goto L33
int r4 = r5.getSpanSize(r2)
int r3 = r3 + r4
if (r3 != r7) goto L2d
r3 = 0
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");
}
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);
}
/* JADX WARN: Removed duplicated region for block: B:11:0x002d */
/* JADX WARN: Removed duplicated region for block: B:23:0x0043 */
/* JADX WARN: Removed duplicated region for block: B:26:? A[RETURN, SYNTHETIC] */
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
public int getSpanGroupIndex(int r7, int r8) {
/*
r6 = this;
boolean r0 = r6.mCacheSpanGroupIndices
r1 = 0
if (r0 == 0) goto L24
android.util.SparseIntArray r0 = r6.mSpanGroupIndexCache
int r0 = findFirstKeyLessThan(r0, r7)
r2 = -1
if (r0 == r2) goto L24
android.util.SparseIntArray r2 = r6.mSpanGroupIndexCache
int r2 = r2.get(r0)
int r3 = r0 + 1
int r4 = r6.getCachedSpanIndex(r0, r8)
int r0 = r6.getSpanSize(r0)
int r4 = r4 + r0
if (r4 != r8) goto L27
int r2 = r2 + 1
goto L26
L24:
r2 = 0
r3 = 0
L26:
r4 = 0
L27:
int r0 = r6.getSpanSize(r7)
L2b:
if (r3 >= r7) goto L40
int r5 = r6.getSpanSize(r3)
int r4 = r4 + r5
if (r4 != r8) goto L38
int r2 = r2 + 1
r4 = 0
goto L3d
L38:
if (r4 <= r8) goto L3d
int r2 = r2 + 1
r4 = r5
L3d:
int r3 = r3 + 1
goto L2b
L40:
int r4 = r4 + r0
if (r4 <= r8) goto L45
int r2 = r2 + 1
L45:
return r2
*/
throw new UnsupportedOperationException("Method not decompiled: androidx.recyclerview.widget.GridLayoutManager.SpanSizeLookup.getSpanGroupIndex(int, int):int");
}
}
/* JADX WARN: Code restructure failed: missing block: B:63:0x00d2, code lost:
if (r13 == (r2 > r15)) goto L45;
*/
/* JADX WARN: Code restructure failed: missing block: B:76:0x00f2, code lost:
if (r13 == (r2 > r10)) goto L68;
*/
/* JADX WARN: Removed duplicated region for block: B:50:0x00fa */
/* JADX WARN: Removed duplicated region for block: B:52: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 r23, int r24, androidx.recyclerview.widget.RecyclerView.Recycler r25, androidx.recyclerview.widget.RecyclerView.State r26) {
/*
Method dump skipped, instructions count: 326
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 boolean supportsPredictiveItemAnimations() {
return this.mPendingSavedState == null && !this.mPendingSpanCountChange;
}
@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,59 @@
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) {
}
ItemTouchUIUtilImpl() {
}
@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,40 @@
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;
LayoutState() {
}
boolean hasMore(RecyclerView.State state) {
int i = this.mCurrentPosition;
return i >= 0 && i < state.getItemCount();
}
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,164 @@
package androidx.recyclerview.widget;
import android.content.Context;
import android.graphics.PointF;
import android.util.DisplayMetrics;
import android.view.View;
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
protected void onStart() {
}
@Override // androidx.recyclerview.widget.RecyclerView.SmoothScroller
protected 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
protected 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
protected 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);
}
}
protected 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;
}
protected int calculateTimeForDeceleration(int i) {
return (int) Math.ceil(calculateTimeForScrolling(i) / 0.3356d);
}
protected int calculateTimeForScrolling(int i) {
return (int) Math.ceil(Math.abs(i) * getSpeedPerPixel());
}
protected int getHorizontalSnapPreference() {
PointF pointF = this.mTargetVector;
if (pointF == null || pointF.x == 0.0f) {
return 0;
}
return this.mTargetVector.x > 0.0f ? 1 : -1;
}
protected int getVerticalSnapPreference() {
PointF pointF = this.mTargetVector;
if (pointF == null || pointF.y == 0.0f) {
return 0;
}
return this.mTargetVector.y > 0.0f ? 1 : -1;
}
protected 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(TARGET_SEEK_SCROLL_DISTANCE_PX) * 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) - layoutParams.topMargin, layoutManager.getDecoratedBottom(view) + 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) - layoutParams.leftMargin, layoutManager.getDecoratedRight(view) + layoutParams.rightMargin, layoutManager.getPaddingLeft(), layoutManager.getWidth() - layoutManager.getPaddingRight(), i);
}
}

View File

@ -0,0 +1,160 @@
package androidx.recyclerview.widget;
import android.graphics.PointF;
import android.view.View;
import androidx.recyclerview.widget.RecyclerView;
/* loaded from: classes.dex */
public class LinearSnapHelper extends SnapHelper {
private static final float INVALID_DISTANCE = 1.0f;
private OrientationHelper mHorizontalHelper;
private OrientationHelper mVerticalHelper;
@Override // androidx.recyclerview.widget.SnapHelper
public int[] calculateDistanceToFinalSnap(RecyclerView.LayoutManager layoutManager, View view) {
int[] iArr = new int[2];
if (layoutManager.canScrollHorizontally()) {
iArr[0] = distanceToCenter(layoutManager, view, getHorizontalHelper(layoutManager));
} else {
iArr[0] = 0;
}
if (layoutManager.canScrollVertically()) {
iArr[1] = distanceToCenter(layoutManager, 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(RecyclerView.LayoutManager layoutManager, 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);
}
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 1.0f;
}
View view = null;
View view2 = null;
int i = Integer.MAX_VALUE;
int i2 = Integer.MIN_VALUE;
for (int i3 = 0; i3 < childCount; i3++) {
View childAt = layoutManager.getChildAt(i3);
int position = layoutManager.getPosition(childAt);
if (position != -1) {
if (position < i) {
view = childAt;
i = position;
}
if (position > i2) {
view2 = childAt;
i2 = position;
}
}
}
if (view == null || view2 == null) {
return 1.0f;
}
int max = Math.max(orientationHelper.getDecoratedEnd(view), orientationHelper.getDecoratedEnd(view2)) - Math.min(orientationHelper.getDecoratedStart(view), orientationHelper.getDecoratedStart(view2));
if (max == 0) {
return 1.0f;
}
return (max * 1.0f) / ((i2 - i) + 1);
}
private OrientationHelper getVerticalHelper(RecyclerView.LayoutManager layoutManager) {
OrientationHelper orientationHelper = this.mVerticalHelper;
if (orientationHelper == null || orientationHelper.mLayoutManager != layoutManager) {
this.mVerticalHelper = OrientationHelper.createVerticalHelper(layoutManager);
}
return this.mVerticalHelper;
}
private OrientationHelper getHorizontalHelper(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,64 @@
package androidx.recyclerview.widget;
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(List<T> list, List<T> list2) {
}
protected ListAdapter(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(List<T> list, 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);
}
protected ListAdapter(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(List<T> list, 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(List<T> list) {
this.mDiffer.submitList(list);
}
public void submitList(List<T> list, Runnable runnable) {
this.mDiffer.submitList(list, runnable);
}
protected T getItem(int i) {
return this.mDiffer.getCurrentList().get(i);
}
@Override // androidx.recyclerview.widget.RecyclerView.Adapter
public int getItemCount() {
return this.mDiffer.getCurrentList().size();
}
public List<T> getCurrentList() {
return this.mDiffer.getCurrentList();
}
}

View File

@ -0,0 +1,12 @@
package androidx.recyclerview.widget;
/* loaded from: classes.dex */
public interface ListUpdateCallback {
void onChanged(int i, int i2, 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,281 @@
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> {
MessageThreadUtil() {
}
/* renamed from: androidx.recyclerview.widget.MessageThreadUtil$1, reason: invalid class name */
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();
}
}
};
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 */
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;
}
}
}
};
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);
}
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;
SyncQueueItem() {
}
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) {
SyncQueueItem syncQueueItem = sPool;
if (syncQueueItem != null) {
this.next = syncQueueItem;
}
sPool = this;
}
}
static SyncQueueItem obtainMessage(int i, int i2, int i3, int i4, int i5, int i6, Object obj) {
SyncQueueItem syncQueueItem;
synchronized (sPoolLock) {
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;
}
return syncQueueItem;
}
static SyncQueueItem obtainMessage(int i, int i2, int i3) {
return obtainMessage(i, i2, i3, 0, 0, 0, null);
}
static SyncQueueItem obtainMessage(int i, int i2, Object obj) {
return obtainMessage(i, i2, 0, 0, 0, 0, obj);
}
}
static class MessageQueue {
private SyncQueueItem mRoot;
MessageQueue() {
}
synchronized SyncQueueItem next() {
SyncQueueItem syncQueueItem = this.mRoot;
if (syncQueueItem == null) {
return null;
}
this.mRoot = syncQueueItem.next;
return syncQueueItem;
}
synchronized void sendMessageAtFrontOfQueue(SyncQueueItem syncQueueItem) {
syncQueueItem.next = this.mRoot;
this.mRoot = syncQueueItem;
}
synchronized void sendMessage(SyncQueueItem syncQueueItem) {
SyncQueueItem syncQueueItem2 = this.mRoot;
if (syncQueueItem2 == null) {
this.mRoot = syncQueueItem;
return;
}
while (syncQueueItem2.next != null) {
syncQueueItem2 = syncQueueItem2.next;
}
syncQueueItem2.next = syncQueueItem;
}
synchronized void removeMessages(int i) {
while (true) {
SyncQueueItem syncQueueItem = this.mRoot;
if (syncQueueItem == null || syncQueueItem.what != i) {
break;
}
SyncQueueItem syncQueueItem2 = this.mRoot;
this.mRoot = syncQueueItem2.next;
syncQueueItem2.recycle();
}
SyncQueueItem syncQueueItem3 = this.mRoot;
if (syncQueueItem3 != null) {
SyncQueueItem syncQueueItem4 = syncQueueItem3.next;
while (syncQueueItem4 != null) {
SyncQueueItem syncQueueItem5 = syncQueueItem4.next;
if (syncQueueItem4.what == i) {
syncQueueItem3.next = syncQueueItem5;
syncQueueItem4.recycle();
} else {
syncQueueItem3 = syncQueueItem4;
}
syncQueueItem4 = syncQueueItem5;
}
}
}
}
}

View File

@ -0,0 +1,247 @@
package androidx.recyclerview.widget;
import androidx.recyclerview.widget.AdapterHelper;
import java.util.List;
/* loaded from: classes.dex */
class OpReorderer {
final Callback mCallback;
interface Callback {
AdapterHelper.UpdateOp obtainUpdateOp(int i, int i2, int i3, Object obj);
void recycleUpdateOp(AdapterHelper.UpdateOp updateOp);
}
OpReorderer(Callback callback) {
this.mCallback = callback;
}
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);
}
}
void swapMoveRemove(List<AdapterHelper.UpdateOp> list, int i, AdapterHelper.UpdateOp updateOp, int i2, AdapterHelper.UpdateOp updateOp2) {
boolean z;
boolean z2 = false;
if (updateOp.positionStart < updateOp.itemCount) {
if (updateOp2.positionStart == updateOp.positionStart && updateOp2.itemCount == updateOp.itemCount - updateOp.positionStart) {
z = false;
z2 = true;
} else {
z = false;
}
} else if (updateOp2.positionStart == updateOp.itemCount + 1 && updateOp2.itemCount == updateOp.positionStart - updateOp.itemCount) {
z = true;
z2 = true;
} else {
z = true;
}
if (updateOp.itemCount < updateOp2.positionStart) {
updateOp2.positionStart--;
} else if (updateOp.itemCount < updateOp2.positionStart + updateOp2.itemCount) {
updateOp2.itemCount--;
updateOp.cmd = 2;
updateOp.itemCount = 1;
if (updateOp2.itemCount == 0) {
list.remove(i2);
this.mCallback.recycleUpdateOp(updateOp2);
return;
}
return;
}
AdapterHelper.UpdateOp updateOp3 = null;
if (updateOp.positionStart <= updateOp2.positionStart) {
updateOp2.positionStart++;
} else if (updateOp.positionStart < updateOp2.positionStart + updateOp2.itemCount) {
updateOp3 = this.mCallback.obtainUpdateOp(2, updateOp.positionStart + 1, (updateOp2.positionStart + updateOp2.itemCount) - updateOp.positionStart, 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) {
if (updateOp.positionStart > updateOp3.positionStart) {
updateOp.positionStart -= updateOp3.itemCount;
}
if (updateOp.itemCount > updateOp3.positionStart) {
updateOp.itemCount -= updateOp3.itemCount;
}
}
if (updateOp.positionStart > updateOp2.positionStart) {
updateOp.positionStart -= updateOp2.itemCount;
}
if (updateOp.itemCount > updateOp2.positionStart) {
updateOp.itemCount -= updateOp2.itemCount;
}
} else {
if (updateOp3 != null) {
if (updateOp.positionStart >= updateOp3.positionStart) {
updateOp.positionStart -= updateOp3.itemCount;
}
if (updateOp.itemCount >= updateOp3.positionStart) {
updateOp.itemCount -= updateOp3.itemCount;
}
}
if (updateOp.positionStart >= updateOp2.positionStart) {
updateOp.positionStart -= updateOp2.itemCount;
}
if (updateOp.itemCount >= updateOp2.positionStart) {
updateOp.itemCount -= 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 < updateOp2.positionStart ? -1 : 0;
if (updateOp.positionStart < updateOp2.positionStart) {
i3++;
}
if (updateOp2.positionStart <= updateOp.positionStart) {
updateOp.positionStart += updateOp2.itemCount;
}
if (updateOp2.positionStart <= updateOp.itemCount) {
updateOp.itemCount += updateOp2.itemCount;
}
updateOp2.positionStart += i3;
list.set(i, updateOp2);
list.set(i2, updateOp);
}
/* JADX WARN: Removed duplicated region for block: B:10:0x005d */
/* JADX WARN: Removed duplicated region for block: B:12:0x006b */
/* JADX WARN: Removed duplicated region for block: B:14:0x0070 */
/* JADX WARN: Removed duplicated region for block: B:17:? A[RETURN, SYNTHETIC] */
/* JADX WARN: Removed duplicated region for block: B:18:0x0061 */
/* JADX WARN: Removed duplicated region for block: B:19:0x0035 */
/* JADX WARN: Removed duplicated region for block: B:7:0x002f */
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
void swapMoveUpdate(java.util.List<androidx.recyclerview.widget.AdapterHelper.UpdateOp> r8, int r9, androidx.recyclerview.widget.AdapterHelper.UpdateOp r10, int r11, androidx.recyclerview.widget.AdapterHelper.UpdateOp r12) {
/*
r7 = this;
int r0 = r10.itemCount
int r1 = r12.positionStart
r2 = 4
r3 = 1
r4 = 0
if (r0 >= r1) goto Lf
int r0 = r12.positionStart
int r0 = r0 - r3
r12.positionStart = r0
goto L28
Lf:
int r0 = r10.itemCount
int r1 = r12.positionStart
int r5 = r12.itemCount
int r1 = r1 + r5
if (r0 >= r1) goto L28
int r0 = r12.itemCount
int r0 = r0 - r3
r12.itemCount = r0
androidx.recyclerview.widget.OpReorderer$Callback r0 = r7.mCallback
int r1 = r10.positionStart
java.lang.Object r5 = r12.payload
androidx.recyclerview.widget.AdapterHelper$UpdateOp r0 = r0.obtainUpdateOp(r2, r1, r3, r5)
goto L29
L28:
r0 = r4
L29:
int r1 = r10.positionStart
int r5 = r12.positionStart
if (r1 > r5) goto L35
int r1 = r12.positionStart
int r1 = r1 + r3
r12.positionStart = r1
goto L56
L35:
int r1 = r10.positionStart
int r5 = r12.positionStart
int r6 = r12.itemCount
int r5 = r5 + r6
if (r1 >= r5) goto L56
int r1 = r12.positionStart
int r4 = r12.itemCount
int r1 = r1 + r4
int r4 = r10.positionStart
int r1 = r1 - r4
androidx.recyclerview.widget.OpReorderer$Callback r4 = r7.mCallback
int r5 = r10.positionStart
int r5 = r5 + r3
java.lang.Object r3 = r12.payload
androidx.recyclerview.widget.AdapterHelper$UpdateOp r4 = r4.obtainUpdateOp(r2, r5, r1, r3)
int r2 = r12.itemCount
int r2 = r2 - r1
r12.itemCount = r2
L56:
r8.set(r11, r10)
int r10 = r12.itemCount
if (r10 <= 0) goto L61
r8.set(r9, r12)
goto L69
L61:
r8.remove(r9)
androidx.recyclerview.widget.OpReorderer$Callback r10 = r7.mCallback
r10.recycleUpdateOp(r12)
L69:
if (r0 == 0) goto L6e
r8.add(r9, r0)
L6e:
if (r4 == 0) goto L73
r8.add(r9, r4)
L73:
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,242 @@
package androidx.recyclerview.widget;
import android.graphics.Rect;
import android.view.View;
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) + layoutParams.leftMargin + layoutParams.rightMargin;
}
@Override // androidx.recyclerview.widget.OrientationHelper
public int getDecoratedMeasurementInOther(View view) {
RecyclerView.LayoutParams layoutParams = (RecyclerView.LayoutParams) view.getLayoutParams();
return this.mLayoutManager.getDecoratedMeasuredHeight(view) + layoutParams.topMargin + layoutParams.bottomMargin;
}
@Override // androidx.recyclerview.widget.OrientationHelper
public int getDecoratedEnd(View view) {
return this.mLayoutManager.getDecoratedRight(view) + ((RecyclerView.LayoutParams) view.getLayoutParams()).rightMargin;
}
@Override // androidx.recyclerview.widget.OrientationHelper
public int getDecoratedStart(View view) {
return this.mLayoutManager.getDecoratedLeft(view) - ((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) + layoutParams.topMargin + layoutParams.bottomMargin;
}
@Override // androidx.recyclerview.widget.OrientationHelper
public int getDecoratedMeasurementInOther(View view) {
RecyclerView.LayoutParams layoutParams = (RecyclerView.LayoutParams) view.getLayoutParams();
return this.mLayoutManager.getDecoratedMeasuredWidth(view) + layoutParams.leftMargin + layoutParams.rightMargin;
}
@Override // androidx.recyclerview.widget.OrientationHelper
public int getDecoratedEnd(View view) {
return this.mLayoutManager.getDecoratedBottom(view) + ((RecyclerView.LayoutParams) view.getLayoutParams()).bottomMargin;
}
@Override // androidx.recyclerview.widget.OrientationHelper
public int getDecoratedStart(View view) {
return this.mLayoutManager.getDecoratedTop(view) - ((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,179 @@
package androidx.recyclerview.widget;
import android.graphics.PointF;
import android.util.DisplayMetrics;
import android.view.View;
import androidx.recyclerview.widget.RecyclerView;
/* loaded from: classes.dex */
public class PagerSnapHelper extends SnapHelper {
private static final int MAX_SCROLL_ON_FLING_DURATION = 100;
private OrientationHelper mHorizontalHelper;
private OrientationHelper mVerticalHelper;
@Override // androidx.recyclerview.widget.SnapHelper
public int[] calculateDistanceToFinalSnap(RecyclerView.LayoutManager layoutManager, View view) {
int[] iArr = new int[2];
if (layoutManager.canScrollHorizontally()) {
iArr[0] = distanceToCenter(layoutManager, view, getHorizontalHelper(layoutManager));
} else {
iArr[0] = 0;
}
if (layoutManager.canScrollVertically()) {
iArr[1] = distanceToCenter(layoutManager, view, getVerticalHelper(layoutManager));
} else {
iArr[1] = 0;
}
return iArr;
}
@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;
}
@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;
View view2 = null;
int i3 = Integer.MIN_VALUE;
int i4 = Integer.MAX_VALUE;
for (int i5 = 0; i5 < childCount; i5++) {
View childAt = layoutManager.getChildAt(i5);
if (childAt != null) {
int distanceToCenter = distanceToCenter(layoutManager, childAt, orientationHelper);
if (distanceToCenter <= 0 && distanceToCenter > i3) {
view2 = childAt;
i3 = distanceToCenter;
}
if (distanceToCenter >= 0 && distanceToCenter < i4) {
view = childAt;
i4 = 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
protected LinearSmoothScroller createSnapScroller(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
protected 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
protected float calculateSpeedPerPixel(DisplayMetrics displayMetrics) {
return 100.0f / displayMetrics.densityDpi;
}
@Override // androidx.recyclerview.widget.LinearSmoothScroller
protected int calculateTimeForScrolling(int i) {
return Math.min(100, super.calculateTimeForScrolling(i));
}
};
}
return null;
}
private int distanceToCenter(RecyclerView.LayoutManager layoutManager, View view, OrientationHelper orientationHelper) {
return (orientationHelper.getDecoratedStart(view) + (orientationHelper.getDecoratedMeasurement(view) / 2)) - (orientationHelper.getStartAfterPadding() + (orientationHelper.getTotalSpace() / 2));
}
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 OrientationHelper getOrientationHelper(RecyclerView.LayoutManager layoutManager) {
if (layoutManager.canScrollVertically()) {
return getVerticalHelper(layoutManager);
}
if (layoutManager.canScrollHorizontally()) {
return getHorizontalHelper(layoutManager);
}
return null;
}
private OrientationHelper getVerticalHelper(RecyclerView.LayoutManager layoutManager) {
OrientationHelper orientationHelper = this.mVerticalHelper;
if (orientationHelper == null || orientationHelper.mLayoutManager != layoutManager) {
this.mVerticalHelper = OrientationHelper.createVerticalHelper(layoutManager);
}
return this.mVerticalHelper;
}
private OrientationHelper getHorizontalHelper(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,188 @@
package androidx.recyclerview.widget;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.view.accessibility.AccessibilityEvent;
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;
public AccessibilityDelegateCompat getItemDelegate() {
return this.mItemDelegate;
}
public RecyclerViewAccessibilityDelegate(RecyclerView recyclerView) {
this.mRecyclerView = recyclerView;
AccessibilityDelegateCompat itemDelegate = getItemDelegate();
if (itemDelegate != null && (itemDelegate instanceof ItemDelegate)) {
this.mItemDelegate = (ItemDelegate) itemDelegate;
} else {
this.mItemDelegate = new ItemDelegate(this);
}
}
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(RecyclerViewAccessibilityDelegate recyclerViewAccessibilityDelegate) {
this.mRecyclerViewDelegate = recyclerViewAccessibilityDelegate;
}
void saveOriginalDelegate(View view) {
AccessibilityDelegateCompat accessibilityDelegate = ViewCompat.getAccessibilityDelegate(view);
if (accessibilityDelegate == null || accessibilityDelegate == this) {
return;
}
this.mOriginalItemDelegates.put(view, accessibilityDelegate);
}
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(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(View view, 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(View view, 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(View view, 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(View view, 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(ViewGroup viewGroup, View view, 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
public AccessibilityNodeProviderCompat getAccessibilityNodeProvider(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 {
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)));
}
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));
}
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,140 @@
package androidx.recyclerview.widget;
import android.view.View;
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(RecyclerView.ViewHolder viewHolder) {
return !this.mSupportsChangeAnimations || viewHolder.isInvalid();
}
@Override // androidx.recyclerview.widget.RecyclerView.ItemAnimator
public boolean animateDisappearance(RecyclerView.ViewHolder viewHolder, RecyclerView.ItemAnimator.ItemHolderInfo itemHolderInfo, 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(RecyclerView.ViewHolder viewHolder, RecyclerView.ItemAnimator.ItemHolderInfo itemHolderInfo, RecyclerView.ItemAnimator.ItemHolderInfo itemHolderInfo2) {
if (itemHolderInfo != null && (itemHolderInfo.left != itemHolderInfo2.left || itemHolderInfo.top != itemHolderInfo2.top)) {
return animateMove(viewHolder, itemHolderInfo.left, itemHolderInfo.top, itemHolderInfo2.left, itemHolderInfo2.top);
}
return animateAdd(viewHolder);
}
@Override // androidx.recyclerview.widget.RecyclerView.ItemAnimator
public boolean animatePersistence(RecyclerView.ViewHolder viewHolder, RecyclerView.ItemAnimator.ItemHolderInfo itemHolderInfo, RecyclerView.ItemAnimator.ItemHolderInfo itemHolderInfo2) {
if (itemHolderInfo.left != itemHolderInfo2.left || itemHolderInfo.top != itemHolderInfo2.top) {
return animateMove(viewHolder, itemHolderInfo.left, itemHolderInfo.top, itemHolderInfo2.left, itemHolderInfo2.top);
}
dispatchMoveFinished(viewHolder);
return false;
}
@Override // androidx.recyclerview.widget.RecyclerView.ItemAnimator
public boolean animateChange(RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder viewHolder2, RecyclerView.ItemAnimator.ItemHolderInfo itemHolderInfo, 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,142 @@
package androidx.recyclerview.widget;
import android.util.DisplayMetrics;
import android.view.View;
import android.view.animation.DecelerateInterpolator;
import android.widget.Scroller;
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();
}
}
};
public abstract int[] calculateDistanceToFinalSnap(RecyclerView.LayoutManager layoutManager, View view);
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(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(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;
}
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]);
}
protected RecyclerView.SmoothScroller createScroller(RecyclerView.LayoutManager layoutManager) {
return createSnapScroller(layoutManager);
}
@Deprecated
protected LinearSmoothScroller createSnapScroller(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
protected void onTargetFound(View view, RecyclerView.State state, RecyclerView.SmoothScroller.Action action) {
if (SnapHelper.this.mRecyclerView == null) {
return;
}
SnapHelper snapHelper = SnapHelper.this;
int[] calculateDistanceToFinalSnap = snapHelper.calculateDistanceToFinalSnap(snapHelper.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
protected float calculateSpeedPerPixel(DisplayMetrics displayMetrics) {
return SnapHelper.MILLISECONDS_PER_INCH / displayMetrics.densityDpi;
}
};
}
return null;
}
}

View File

@ -0,0 +1,592 @@
package androidx.recyclerview.widget;
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(Class<T> cls, Callback<T> callback) {
this(cls, callback, 10);
}
public SortedList(Class<T> cls, 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(T[] tArr, boolean z) {
throwIfInMutationOperation();
if (tArr.length == 0) {
return;
}
if (z) {
addAllInternal(tArr);
} else {
addAllInternal(copyArray(tArr));
}
}
public void addAll(T... tArr) {
addAll(tArr, false);
}
/* JADX WARN: Multi-variable type inference failed */
public void addAll(Collection<T> collection) {
addAll(collection.toArray((Object[]) Array.newInstance((Class<?>) this.mTClass, collection.size())), true);
}
public void replaceAll(T[] tArr, boolean z) {
throwIfInMutationOperation();
if (z) {
replaceAllInternal(tArr);
} else {
replaceAllInternal(copyArray(tArr));
}
}
public void replaceAll(T... tArr) {
replaceAll(tArr, false);
}
/* JADX WARN: Multi-variable type inference failed */
public void replaceAll(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(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(T[] tArr) {
if (tArr.length == 0) {
return 0;
}
Arrays.sort(tArr, this.mCallback);
int i = 1;
int i2 = 0;
for (int i3 = 1; i3 < tArr.length; i3++) {
T t = tArr[i3];
if (this.mCallback.compare(tArr[i2], t) == 0) {
int findSameItem = findSameItem(t, tArr, i2, i);
if (findSameItem != -1) {
tArr[findSameItem] = t;
} else {
if (i != i3) {
tArr[i] = t;
}
i++;
}
} else {
if (i != i3) {
tArr[i] = t;
}
i2 = i;
i++;
}
}
return i;
}
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) {
throw new IndexOutOfBoundsException("Asked to get item at " + i + " but size is " + this.mSize);
}
T[] tArr = this.mOldData;
if (tArr != null && i >= (i2 = this.mNewDataStart)) {
return tArr[(i - i2) + this.mOldDataStart];
}
return this.mData[i];
}
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);
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
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);
}
}

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,82 @@
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) {
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;
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));
}
T getByPosition(int i) {
return this.mItems[i - this.mStartPosition];
}
}
}

View File

@ -0,0 +1,138 @@
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;
interface Callback {
View getChildAt(int i);
int getChildEnd(View view);
int getChildStart(View view);
int getParentEnd();
int getParentStart();
}
@Retention(RetentionPolicy.SOURCE)
public @interface ViewBounds {
}
ViewBoundsCheck(Callback callback) {
this.mCallback = callback;
}
static class BoundFlags {
int mBoundFlags = 0;
int mChildEnd;
int mChildStart;
int mRvEnd;
int mRvStart;
void addFlags(int i) {
this.mBoundFlags = i | this.mBoundFlags;
}
int compare(int i, int i2) {
if (i > i2) {
return 1;
}
return i == i2 ? 2 : 4;
}
void resetFlags() {
this.mBoundFlags = 0;
}
void setBounds(int i, int i2, int i3, int i4) {
this.mRvStart = i;
this.mRvEnd = i2;
this.mChildStart = i3;
this.mChildEnd = i4;
}
BoundFlags() {
}
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;
}
}
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;
}
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,213 @@
package androidx.recyclerview.widget;
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;
final SimpleArrayMap<RecyclerView.ViewHolder, InfoRecord> mLayoutHolderMap = new SimpleArrayMap<>();
final LongSparseArray<RecyclerView.ViewHolder> mOldChangedHolders = new LongSparseArray<>();
interface ProcessCallback {
void processAppeared(RecyclerView.ViewHolder viewHolder, RecyclerView.ItemAnimator.ItemHolderInfo itemHolderInfo, RecyclerView.ItemAnimator.ItemHolderInfo itemHolderInfo2);
void processDisappeared(RecyclerView.ViewHolder viewHolder, RecyclerView.ItemAnimator.ItemHolderInfo itemHolderInfo, RecyclerView.ItemAnimator.ItemHolderInfo itemHolderInfo2);
void processPersistent(RecyclerView.ViewHolder viewHolder, RecyclerView.ItemAnimator.ItemHolderInfo itemHolderInfo, RecyclerView.ItemAnimator.ItemHolderInfo itemHolderInfo2);
void unused(RecyclerView.ViewHolder viewHolder);
}
ViewInfoStore() {
}
void clear() {
this.mLayoutHolderMap.clear();
this.mOldChangedHolders.clear();
}
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;
}
boolean isDisappearing(RecyclerView.ViewHolder viewHolder) {
InfoRecord infoRecord = this.mLayoutHolderMap.get(viewHolder);
return (infoRecord == null || (infoRecord.flags & 1) == 0) ? false : true;
}
RecyclerView.ItemAnimator.ItemHolderInfo popFromPreLayout(RecyclerView.ViewHolder viewHolder) {
return popFromLayoutStep(viewHolder, 4);
}
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 || (valueAt.flags & i) == 0) {
return null;
}
valueAt.flags &= ~i;
if (i == 4) {
itemHolderInfo = valueAt.preInfo;
} else if (i == 8) {
itemHolderInfo = valueAt.postInfo;
} else {
throw new IllegalArgumentException("Must provide flag PRE or POST");
}
if ((valueAt.flags & 12) == 0) {
this.mLayoutHolderMap.removeAt(indexOfKey);
InfoRecord.recycle(valueAt);
}
return itemHolderInfo;
}
void addToOldChangeHolders(long j, RecyclerView.ViewHolder viewHolder) {
this.mOldChangedHolders.put(j, viewHolder);
}
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;
}
boolean isInPreLayout(RecyclerView.ViewHolder viewHolder) {
InfoRecord infoRecord = this.mLayoutHolderMap.get(viewHolder);
return (infoRecord == null || (infoRecord.flags & 4) == 0) ? false : true;
}
RecyclerView.ViewHolder getFromOldChangeHolders(long j) {
return this.mOldChangedHolders.get(j);
}
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;
}
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;
}
void removeFromDisappearedInLayout(RecyclerView.ViewHolder viewHolder) {
InfoRecord infoRecord = this.mLayoutHolderMap.get(viewHolder);
if (infoRecord == null) {
return;
}
infoRecord.flags &= -2;
}
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);
if ((removeAt.flags & 3) == 3) {
processCallback.unused(keyAt);
} else if ((removeAt.flags & 1) != 0) {
if (removeAt.preInfo == null) {
processCallback.unused(keyAt);
} else {
processCallback.processDisappeared(keyAt, removeAt.preInfo, removeAt.postInfo);
}
} else if ((removeAt.flags & 14) == 14) {
processCallback.processAppeared(keyAt, removeAt.preInfo, removeAt.postInfo);
} else if ((removeAt.flags & 12) == 12) {
processCallback.processPersistent(keyAt, removeAt.preInfo, removeAt.postInfo);
} else if ((removeAt.flags & 4) != 0) {
processCallback.processDisappeared(keyAt, removeAt.preInfo, null);
} else if ((removeAt.flags & 8) != 0) {
processCallback.processAppeared(keyAt, removeAt.preInfo, removeAt.postInfo);
} else {
int i = removeAt.flags;
}
InfoRecord.recycle(removeAt);
}
}
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);
}
}
void onDetach() {
InfoRecord.drainCache();
}
public void onViewDetached(RecyclerView.ViewHolder viewHolder) {
removeFromDisappearedInLayout(viewHolder);
}
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;
RecyclerView.ItemAnimator.ItemHolderInfo postInfo;
RecyclerView.ItemAnimator.ItemHolderInfo preInfo;
private InfoRecord() {
}
static InfoRecord obtain() {
InfoRecord acquire = sPool.acquire();
return acquire == null ? new InfoRecord() : acquire;
}
static void recycle(InfoRecord infoRecord) {
infoRecord.flags = 0;
infoRecord.preInfo = null;
infoRecord.postInfo = null;
sPool.release(infoRecord);
}
static void drainCache() {
while (sPool.acquire() != null) {
}
}
}
}