487 lines
13 KiB
Smali
487 lines
13 KiB
Smali
.class public final Lcom/discord/utilities/recycler/DiffCreator;
|
|
.super Ljava/lang/Object;
|
|
.source "DiffCreator.kt"
|
|
|
|
|
|
# annotations
|
|
.annotation system Ldalvik/annotation/MemberClasses;
|
|
value = {
|
|
Lcom/discord/utilities/recycler/DiffCreator$Companion;
|
|
}
|
|
.end annotation
|
|
|
|
.annotation system Ldalvik/annotation/Signature;
|
|
value = {
|
|
"<T::",
|
|
"Ljava/util/List<",
|
|
"+",
|
|
"Lcom/discord/utilities/recycler/DiffKeyProvider;",
|
|
">;VH:",
|
|
"Landroidx/recyclerview/widget/RecyclerView$ViewHolder;",
|
|
">",
|
|
"Ljava/lang/Object;"
|
|
}
|
|
.end annotation
|
|
|
|
|
|
# static fields
|
|
.field public static final Companion:Lcom/discord/utilities/recycler/DiffCreator$Companion;
|
|
|
|
.field public static final EXPENSIVE_DIFF_THRESHOLD:I = 0xe1
|
|
|
|
|
|
# direct methods
|
|
.method public static constructor <clinit>()V
|
|
.locals 2
|
|
|
|
new-instance v0, Lcom/discord/utilities/recycler/DiffCreator$Companion;
|
|
|
|
const/4 v1, 0x0
|
|
|
|
invoke-direct {v0, v1}, Lcom/discord/utilities/recycler/DiffCreator$Companion;-><init>(Lkotlin/jvm/internal/DefaultConstructorMarker;)V
|
|
|
|
sput-object v0, Lcom/discord/utilities/recycler/DiffCreator;->Companion:Lcom/discord/utilities/recycler/DiffCreator$Companion;
|
|
|
|
return-void
|
|
.end method
|
|
|
|
.method public constructor <init>()V
|
|
.locals 0
|
|
|
|
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
|
|
|
|
return-void
|
|
.end method
|
|
|
|
.method public static final synthetic access$setItemsAndDispatchUpdate(Lcom/discord/utilities/recycler/DiffCreator;Landroidx/recyclerview/widget/RecyclerView$Adapter;Lkotlin/jvm/functions/Function1;Ljava/util/List;Landroidx/recyclerview/widget/DiffUtil$DiffResult;)V
|
|
.locals 0
|
|
|
|
invoke-direct {p0, p1, p2, p3, p4}, Lcom/discord/utilities/recycler/DiffCreator;->setItemsAndDispatchUpdate(Landroidx/recyclerview/widget/RecyclerView$Adapter;Lkotlin/jvm/functions/Function1;Ljava/util/List;Landroidx/recyclerview/widget/DiffUtil$DiffResult;)V
|
|
|
|
return-void
|
|
.end method
|
|
|
|
.method private final createDiffUtilCallback(Ljava/util/List;Ljava/util/List;)Lcom/discord/utilities/recycler/DiffCreator$createDiffUtilCallback$1;
|
|
.locals 1
|
|
.annotation system Ldalvik/annotation/Signature;
|
|
value = {
|
|
"(TT;TT;)",
|
|
"Lcom/discord/utilities/recycler/DiffCreator$createDiffUtilCallback$1;"
|
|
}
|
|
.end annotation
|
|
|
|
new-instance v0, Lcom/discord/utilities/recycler/DiffCreator$createDiffUtilCallback$1;
|
|
|
|
invoke-direct {v0, p1, p2}, Lcom/discord/utilities/recycler/DiffCreator$createDiffUtilCallback$1;-><init>(Ljava/util/List;Ljava/util/List;)V
|
|
|
|
return-object v0
|
|
.end method
|
|
|
|
.method private final isExpensiveDiff(Ljava/util/List;Ljava/util/List;)Z
|
|
.locals 10
|
|
.annotation system Ldalvik/annotation/Signature;
|
|
value = {
|
|
"(TT;TT;)Z"
|
|
}
|
|
.end annotation
|
|
|
|
invoke-interface {p2}, Ljava/util/List;->size()I
|
|
|
|
move-result v0
|
|
|
|
invoke-interface {p1}, Ljava/util/List;->size()I
|
|
|
|
move-result v1
|
|
|
|
sub-int/2addr v0, v1
|
|
|
|
invoke-static {v0}, Ljava/lang/Math;->abs(I)I
|
|
|
|
move-result v0
|
|
|
|
const/4 v1, 0x1
|
|
|
|
const/16 v2, 0xe1
|
|
|
|
if-le v0, v2, :cond_0
|
|
|
|
return v1
|
|
|
|
:cond_0
|
|
sget-object v3, Lcom/discord/utilities/collections/ShallowPartitionMap;->Companion:Lcom/discord/utilities/collections/ShallowPartitionMap$Companion;
|
|
|
|
invoke-interface {p1}, Ljava/util/List;->size()I
|
|
|
|
move-result v4
|
|
|
|
const/4 v5, 0x0
|
|
|
|
const/4 v6, 0x0
|
|
|
|
const/4 v7, 0x0
|
|
|
|
const/16 v8, 0xe
|
|
|
|
const/4 v9, 0x0
|
|
|
|
invoke-static/range {v3 .. v9}, Lcom/discord/utilities/collections/ShallowPartitionMap$Companion;->create$default(Lcom/discord/utilities/collections/ShallowPartitionMap$Companion;IIILkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lcom/discord/utilities/collections/ShallowPartitionMap;
|
|
|
|
move-result-object v0
|
|
|
|
new-instance v3, Ljava/util/ArrayList;
|
|
|
|
invoke-direct {v3}, Ljava/util/ArrayList;-><init>()V
|
|
|
|
invoke-interface {p1}, Ljava/util/List;->iterator()Ljava/util/Iterator;
|
|
|
|
move-result-object p1
|
|
|
|
:goto_0
|
|
invoke-interface {p1}, Ljava/util/Iterator;->hasNext()Z
|
|
|
|
move-result v4
|
|
|
|
if-eqz v4, :cond_1
|
|
|
|
invoke-interface {p1}, Ljava/util/Iterator;->next()Ljava/lang/Object;
|
|
|
|
move-result-object v4
|
|
|
|
check-cast v4, Lcom/discord/utilities/recycler/DiffKeyProvider;
|
|
|
|
invoke-interface {v4}, Lcom/discord/utilities/recycler/DiffKeyProvider;->getKey()Ljava/lang/String;
|
|
|
|
move-result-object v4
|
|
|
|
sget-object v5, Lkotlin/Unit;->a:Lkotlin/Unit;
|
|
|
|
invoke-interface {v0, v4, v5}, Ljava/util/Map;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
|
|
|
|
goto :goto_0
|
|
|
|
:cond_1
|
|
invoke-interface {p2}, Ljava/util/List;->iterator()Ljava/util/Iterator;
|
|
|
|
move-result-object p1
|
|
|
|
:goto_1
|
|
invoke-interface {p1}, Ljava/util/Iterator;->hasNext()Z
|
|
|
|
move-result p2
|
|
|
|
if-eqz p2, :cond_3
|
|
|
|
invoke-interface {p1}, Ljava/util/Iterator;->next()Ljava/lang/Object;
|
|
|
|
move-result-object p2
|
|
|
|
check-cast p2, Lcom/discord/utilities/recycler/DiffKeyProvider;
|
|
|
|
invoke-interface {p2}, Lcom/discord/utilities/recycler/DiffKeyProvider;->getKey()Ljava/lang/String;
|
|
|
|
move-result-object p2
|
|
|
|
invoke-interface {v0, p2}, Ljava/util/Map;->containsKey(Ljava/lang/Object;)Z
|
|
|
|
move-result v4
|
|
|
|
if-nez v4, :cond_2
|
|
|
|
invoke-interface {v3, p2}, Ljava/util/Collection;->add(Ljava/lang/Object;)Z
|
|
|
|
:cond_2
|
|
invoke-virtual {v0, p2}, Lcom/discord/utilities/collections/ShallowPartitionMap;->remove(Ljava/lang/Object;)Ljava/lang/Object;
|
|
|
|
goto :goto_1
|
|
|
|
:cond_3
|
|
invoke-virtual {v0}, Lcom/discord/utilities/collections/ShallowPartitionMap;->size()I
|
|
|
|
move-result p1
|
|
|
|
invoke-interface {v3}, Ljava/util/Collection;->size()I
|
|
|
|
move-result p2
|
|
|
|
add-int/2addr p2, p1
|
|
|
|
if-le p2, v2, :cond_4
|
|
|
|
goto :goto_2
|
|
|
|
:cond_4
|
|
const/4 v1, 0x0
|
|
|
|
:goto_2
|
|
return v1
|
|
.end method
|
|
|
|
.method private final setItemsAndDispatchUpdate(Landroidx/recyclerview/widget/RecyclerView$Adapter;Lkotlin/jvm/functions/Function1;Ljava/util/List;Landroidx/recyclerview/widget/DiffUtil$DiffResult;)V
|
|
.locals 0
|
|
.annotation system Ldalvik/annotation/Signature;
|
|
value = {
|
|
"(",
|
|
"Landroidx/recyclerview/widget/RecyclerView$Adapter<",
|
|
"TVH;>;",
|
|
"Lkotlin/jvm/functions/Function1<",
|
|
"-TT;",
|
|
"Lkotlin/Unit;",
|
|
">;TT;",
|
|
"Landroidx/recyclerview/widget/DiffUtil$DiffResult;",
|
|
")V"
|
|
}
|
|
.end annotation
|
|
|
|
invoke-interface {p2, p3}, Lkotlin/jvm/functions/Function1;->invoke(Ljava/lang/Object;)Ljava/lang/Object;
|
|
|
|
if-eqz p4, :cond_0
|
|
|
|
invoke-virtual {p4, p1}, Landroidx/recyclerview/widget/DiffUtil$DiffResult;->dispatchUpdatesTo(Landroidx/recyclerview/widget/RecyclerView$Adapter;)V
|
|
|
|
goto :goto_0
|
|
|
|
:cond_0
|
|
invoke-virtual {p1}, Landroidx/recyclerview/widget/RecyclerView$Adapter;->notifyDataSetChanged()V
|
|
|
|
:goto_0
|
|
return-void
|
|
.end method
|
|
|
|
|
|
# virtual methods
|
|
.method public final calculateDiffResult(Ljava/util/List;Ljava/util/List;)Landroidx/recyclerview/widget/DiffUtil$DiffResult;
|
|
.locals 2
|
|
.annotation system Ldalvik/annotation/Signature;
|
|
value = {
|
|
"(TT;TT;)",
|
|
"Landroidx/recyclerview/widget/DiffUtil$DiffResult;"
|
|
}
|
|
.end annotation
|
|
|
|
const/4 v0, 0x0
|
|
|
|
if-eqz p1, :cond_2
|
|
|
|
if-eqz p2, :cond_1
|
|
|
|
invoke-direct {p0, p1, p2}, Lcom/discord/utilities/recycler/DiffCreator;->isExpensiveDiff(Ljava/util/List;Ljava/util/List;)Z
|
|
|
|
move-result v1
|
|
|
|
if-eqz v1, :cond_0
|
|
|
|
return-object v0
|
|
|
|
:cond_0
|
|
invoke-direct {p0, p1, p2}, Lcom/discord/utilities/recycler/DiffCreator;->createDiffUtilCallback(Ljava/util/List;Ljava/util/List;)Lcom/discord/utilities/recycler/DiffCreator$createDiffUtilCallback$1;
|
|
|
|
move-result-object p1
|
|
|
|
const/4 p2, 0x1
|
|
|
|
invoke-static {p1, p2}, Landroidx/recyclerview/widget/DiffUtil;->calculateDiff(Landroidx/recyclerview/widget/DiffUtil$Callback;Z)Landroidx/recyclerview/widget/DiffUtil$DiffResult;
|
|
|
|
move-result-object p1
|
|
|
|
return-object p1
|
|
|
|
:cond_1
|
|
const-string p1, "newItems"
|
|
|
|
invoke-static {p1}, Lj0/n/c/h;->c(Ljava/lang/String;)V
|
|
|
|
throw v0
|
|
|
|
:cond_2
|
|
const-string p1, "oldItems"
|
|
|
|
invoke-static {p1}, Lj0/n/c/h;->c(Ljava/lang/String;)V
|
|
|
|
throw v0
|
|
.end method
|
|
|
|
.method public final dispatchDiffUpdates(Landroidx/recyclerview/widget/RecyclerView$Adapter;Lkotlin/jvm/functions/Function1;Ljava/util/List;Ljava/util/List;)V
|
|
.locals 1
|
|
.annotation system Ldalvik/annotation/Signature;
|
|
value = {
|
|
"(",
|
|
"Landroidx/recyclerview/widget/RecyclerView$Adapter<",
|
|
"TVH;>;",
|
|
"Lkotlin/jvm/functions/Function1<",
|
|
"-TT;",
|
|
"Lkotlin/Unit;",
|
|
">;TT;TT;)V"
|
|
}
|
|
.end annotation
|
|
|
|
const/4 v0, 0x0
|
|
|
|
if-eqz p1, :cond_3
|
|
|
|
if-eqz p2, :cond_2
|
|
|
|
if-eqz p3, :cond_1
|
|
|
|
if-eqz p4, :cond_0
|
|
|
|
invoke-virtual {p0, p3, p4}, Lcom/discord/utilities/recycler/DiffCreator;->calculateDiffResult(Ljava/util/List;Ljava/util/List;)Landroidx/recyclerview/widget/DiffUtil$DiffResult;
|
|
|
|
move-result-object p3
|
|
|
|
invoke-direct {p0, p1, p2, p4, p3}, Lcom/discord/utilities/recycler/DiffCreator;->setItemsAndDispatchUpdate(Landroidx/recyclerview/widget/RecyclerView$Adapter;Lkotlin/jvm/functions/Function1;Ljava/util/List;Landroidx/recyclerview/widget/DiffUtil$DiffResult;)V
|
|
|
|
return-void
|
|
|
|
:cond_0
|
|
const-string p1, "newItems"
|
|
|
|
invoke-static {p1}, Lj0/n/c/h;->c(Ljava/lang/String;)V
|
|
|
|
throw v0
|
|
|
|
:cond_1
|
|
const-string p1, "oldItems"
|
|
|
|
invoke-static {p1}, Lj0/n/c/h;->c(Ljava/lang/String;)V
|
|
|
|
throw v0
|
|
|
|
:cond_2
|
|
const-string p1, "setItems"
|
|
|
|
invoke-static {p1}, Lj0/n/c/h;->c(Ljava/lang/String;)V
|
|
|
|
throw v0
|
|
|
|
:cond_3
|
|
const-string p1, "adapter"
|
|
|
|
invoke-static {p1}, Lj0/n/c/h;->c(Ljava/lang/String;)V
|
|
|
|
throw v0
|
|
.end method
|
|
|
|
.method public final dispatchDiffUpdatesAsync(Landroidx/recyclerview/widget/RecyclerView$Adapter;Lkotlin/jvm/functions/Function1;Ljava/util/List;Ljava/util/List;Lcom/discord/app/AppComponent;)V
|
|
.locals 17
|
|
.annotation system Ldalvik/annotation/Signature;
|
|
value = {
|
|
"(",
|
|
"Landroidx/recyclerview/widget/RecyclerView$Adapter<",
|
|
"TVH;>;",
|
|
"Lkotlin/jvm/functions/Function1<",
|
|
"-TT;",
|
|
"Lkotlin/Unit;",
|
|
">;TT;TT;",
|
|
"Lcom/discord/app/AppComponent;",
|
|
")V"
|
|
}
|
|
.end annotation
|
|
|
|
move-object/from16 v0, p0
|
|
|
|
move-object/from16 v1, p1
|
|
|
|
move-object/from16 v2, p2
|
|
|
|
move-object/from16 v3, p3
|
|
|
|
move-object/from16 v4, p4
|
|
|
|
move-object/from16 v5, p5
|
|
|
|
const/4 v6, 0x0
|
|
|
|
if-eqz v1, :cond_4
|
|
|
|
if-eqz v2, :cond_3
|
|
|
|
if-eqz v3, :cond_2
|
|
|
|
if-eqz v4, :cond_1
|
|
|
|
if-eqz v5, :cond_0
|
|
|
|
new-instance v7, Lcom/discord/utilities/recycler/DiffCreator$dispatchDiffUpdatesAsync$1;
|
|
|
|
invoke-direct {v7, v0, v3, v4}, Lcom/discord/utilities/recycler/DiffCreator$dispatchDiffUpdatesAsync$1;-><init>(Lcom/discord/utilities/recycler/DiffCreator;Ljava/util/List;Ljava/util/List;)V
|
|
|
|
new-instance v3, Lr0/l/a/s;
|
|
|
|
invoke-direct {v3, v7}, Lr0/l/a/s;-><init>(Ljava/util/concurrent/Callable;)V
|
|
|
|
invoke-static {v3}, Lrx/Observable;->d0(Lrx/Observable$a;)Lrx/Observable;
|
|
|
|
move-result-object v3
|
|
|
|
const-string v7, "Observable.fromCallable \u2026oldItems, newItems)\n }"
|
|
|
|
invoke-static {v3, v7}, Lj0/n/c/h;->checkExpressionValueIsNotNull(Ljava/lang/Object;Ljava/lang/String;)V
|
|
|
|
invoke-static {v3}, Lcom/discord/utilities/rx/ObservableExtensionsKt;->computationBuffered(Lrx/Observable;)Lrx/Observable;
|
|
|
|
move-result-object v3
|
|
|
|
const/4 v7, 0x2
|
|
|
|
invoke-static {v3, v5, v6, v7, v6}, Lcom/discord/utilities/rx/ObservableExtensionsKt;->ui$default(Lrx/Observable;Lcom/discord/app/AppComponent;Lcom/discord/utilities/mg_recycler/MGRecyclerAdapterSimple;ILjava/lang/Object;)Lrx/Observable;
|
|
|
|
move-result-object v8
|
|
|
|
const-class v9, Lcom/discord/utilities/recycler/DiffCreator;
|
|
|
|
const/4 v10, 0x0
|
|
|
|
const/4 v11, 0x0
|
|
|
|
const/4 v12, 0x0
|
|
|
|
const/4 v13, 0x0
|
|
|
|
new-instance v14, Lcom/discord/utilities/recycler/DiffCreator$dispatchDiffUpdatesAsync$2;
|
|
|
|
invoke-direct {v14, v0, v1, v2, v4}, Lcom/discord/utilities/recycler/DiffCreator$dispatchDiffUpdatesAsync$2;-><init>(Lcom/discord/utilities/recycler/DiffCreator;Landroidx/recyclerview/widget/RecyclerView$Adapter;Lkotlin/jvm/functions/Function1;Ljava/util/List;)V
|
|
|
|
const/16 v15, 0x1e
|
|
|
|
const/16 v16, 0x0
|
|
|
|
invoke-static/range {v8 .. v16}, Lcom/discord/utilities/rx/ObservableExtensionsKt;->appSubscribe$default(Lrx/Observable;Ljava/lang/Class;Landroid/content/Context;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function0;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)V
|
|
|
|
return-void
|
|
|
|
:cond_0
|
|
const-string v1, "appComponent"
|
|
|
|
invoke-static {v1}, Lj0/n/c/h;->c(Ljava/lang/String;)V
|
|
|
|
throw v6
|
|
|
|
:cond_1
|
|
const-string v1, "newItems"
|
|
|
|
invoke-static {v1}, Lj0/n/c/h;->c(Ljava/lang/String;)V
|
|
|
|
throw v6
|
|
|
|
:cond_2
|
|
const-string v1, "oldItems"
|
|
|
|
invoke-static {v1}, Lj0/n/c/h;->c(Ljava/lang/String;)V
|
|
|
|
throw v6
|
|
|
|
:cond_3
|
|
const-string v1, "setItems"
|
|
|
|
invoke-static {v1}, Lj0/n/c/h;->c(Ljava/lang/String;)V
|
|
|
|
throw v6
|
|
|
|
:cond_4
|
|
const-string v1, "adapter"
|
|
|
|
invoke-static {v1}, Lj0/n/c/h;->c(Ljava/lang/String;)V
|
|
|
|
throw v6
|
|
.end method
|