416 lines
13 KiB
Smali
416 lines
13 KiB
Smali
.class public final Lcom/discord/widgets/settings/billing/SettingsBillingViewModel;
|
|
.super Lf/a/b/l0;
|
|
.source "SettingsBillingViewModel.kt"
|
|
|
|
|
|
# annotations
|
|
.annotation system Ldalvik/annotation/MemberClasses;
|
|
value = {
|
|
Lcom/discord/widgets/settings/billing/SettingsBillingViewModel$ViewState;,
|
|
Lcom/discord/widgets/settings/billing/SettingsBillingViewModel$StoreState;,
|
|
Lcom/discord/widgets/settings/billing/SettingsBillingViewModel$Factory;
|
|
}
|
|
.end annotation
|
|
|
|
.annotation system Ldalvik/annotation/Signature;
|
|
value = {
|
|
"Lf/a/b/l0<",
|
|
"Lcom/discord/widgets/settings/billing/SettingsBillingViewModel$ViewState;",
|
|
">;"
|
|
}
|
|
.end annotation
|
|
|
|
|
|
# instance fields
|
|
.field public final storePaymentSources:Lcom/discord/stores/StorePaymentSources;
|
|
|
|
.field public final storeSubscriptions:Lcom/discord/stores/StoreSubscriptions;
|
|
|
|
|
|
# direct methods
|
|
.method public constructor <init>(Lcom/discord/stores/StorePaymentSources;Lcom/discord/stores/StoreSubscriptions;Lrx/Observable;)V
|
|
.locals 9
|
|
.annotation system Ldalvik/annotation/Signature;
|
|
value = {
|
|
"(",
|
|
"Lcom/discord/stores/StorePaymentSources;",
|
|
"Lcom/discord/stores/StoreSubscriptions;",
|
|
"Lrx/Observable<",
|
|
"Lcom/discord/widgets/settings/billing/SettingsBillingViewModel$StoreState;",
|
|
">;)V"
|
|
}
|
|
.end annotation
|
|
|
|
const-string v0, "storePaymentSources"
|
|
|
|
invoke-static {p1, v0}, Ly/n/c/j;->checkNotNullParameter(Ljava/lang/Object;Ljava/lang/String;)V
|
|
|
|
const-string v0, "storeSubscriptions"
|
|
|
|
invoke-static {p2, v0}, Ly/n/c/j;->checkNotNullParameter(Ljava/lang/Object;Ljava/lang/String;)V
|
|
|
|
const-string v0, "storeObservable"
|
|
|
|
invoke-static {p3, v0}, Ly/n/c/j;->checkNotNullParameter(Ljava/lang/Object;Ljava/lang/String;)V
|
|
|
|
sget-object v0, Lcom/discord/widgets/settings/billing/SettingsBillingViewModel$ViewState$Loading;->INSTANCE:Lcom/discord/widgets/settings/billing/SettingsBillingViewModel$ViewState$Loading;
|
|
|
|
invoke-direct {p0, v0}, Lf/a/b/l0;-><init>(Ljava/lang/Object;)V
|
|
|
|
iput-object p1, p0, Lcom/discord/widgets/settings/billing/SettingsBillingViewModel;->storePaymentSources:Lcom/discord/stores/StorePaymentSources;
|
|
|
|
iput-object p2, p0, Lcom/discord/widgets/settings/billing/SettingsBillingViewModel;->storeSubscriptions:Lcom/discord/stores/StoreSubscriptions;
|
|
|
|
invoke-direct {p0}, Lcom/discord/widgets/settings/billing/SettingsBillingViewModel;->fetchData()V
|
|
|
|
invoke-static {p3}, Lcom/discord/utilities/rx/ObservableExtensionsKt;->computationLatest(Lrx/Observable;)Lrx/Observable;
|
|
|
|
move-result-object p1
|
|
|
|
const/4 p2, 0x0
|
|
|
|
const/4 p3, 0x2
|
|
|
|
invoke-static {p1, p0, p2, p3, p2}, 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 v0
|
|
|
|
const-class v1, Lcom/discord/widgets/settings/billing/SettingsBillingViewModel;
|
|
|
|
new-instance v6, Lcom/discord/widgets/settings/billing/SettingsBillingViewModel$1;
|
|
|
|
invoke-direct {v6, p0}, Lcom/discord/widgets/settings/billing/SettingsBillingViewModel$1;-><init>(Lcom/discord/widgets/settings/billing/SettingsBillingViewModel;)V
|
|
|
|
const/4 v2, 0x0
|
|
|
|
const/4 v3, 0x0
|
|
|
|
const/4 v4, 0x0
|
|
|
|
const/4 v5, 0x0
|
|
|
|
const/16 v7, 0x1e
|
|
|
|
const/4 v8, 0x0
|
|
|
|
invoke-static/range {v0 .. v8}, 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
|
|
.end method
|
|
|
|
.method public static final synthetic access$handleStoreState(Lcom/discord/widgets/settings/billing/SettingsBillingViewModel;Lcom/discord/widgets/settings/billing/SettingsBillingViewModel$StoreState;)V
|
|
.locals 0
|
|
|
|
invoke-direct {p0, p1}, Lcom/discord/widgets/settings/billing/SettingsBillingViewModel;->handleStoreState(Lcom/discord/widgets/settings/billing/SettingsBillingViewModel$StoreState;)V
|
|
|
|
return-void
|
|
.end method
|
|
|
|
.method private final fetchData()V
|
|
.locals 1
|
|
|
|
iget-object v0, p0, Lcom/discord/widgets/settings/billing/SettingsBillingViewModel;->storePaymentSources:Lcom/discord/stores/StorePaymentSources;
|
|
|
|
invoke-virtual {v0}, Lcom/discord/stores/StorePaymentSources;->fetchPaymentSources()V
|
|
|
|
iget-object v0, p0, Lcom/discord/widgets/settings/billing/SettingsBillingViewModel;->storeSubscriptions:Lcom/discord/stores/StoreSubscriptions;
|
|
|
|
invoke-virtual {v0}, Lcom/discord/stores/StoreSubscriptions;->fetchSubscriptions()V
|
|
|
|
return-void
|
|
.end method
|
|
|
|
.method private final generateListItems(Ljava/util/List;Lcom/discord/models/domain/ModelSubscription;)Ljava/util/List;
|
|
.locals 8
|
|
.annotation system Ldalvik/annotation/Signature;
|
|
value = {
|
|
"(",
|
|
"Ljava/util/List<",
|
|
"+",
|
|
"Lcom/discord/models/domain/ModelPaymentSource;",
|
|
">;",
|
|
"Lcom/discord/models/domain/ModelSubscription;",
|
|
")",
|
|
"Ljava/util/List<",
|
|
"Lcom/discord/widgets/settings/billing/PaymentSourceAdapter$Item;",
|
|
">;"
|
|
}
|
|
.end annotation
|
|
|
|
new-instance v0, Ljava/util/ArrayList;
|
|
|
|
invoke-direct {v0}, Ljava/util/ArrayList;-><init>()V
|
|
|
|
invoke-interface {p1}, Ljava/util/Collection;->isEmpty()Z
|
|
|
|
move-result v1
|
|
|
|
const/4 v2, 0x1
|
|
|
|
xor-int/2addr v1, v2
|
|
|
|
if-eqz v1, :cond_8
|
|
|
|
invoke-interface {p1}, Ljava/lang/Iterable;->iterator()Ljava/util/Iterator;
|
|
|
|
move-result-object p1
|
|
|
|
const/4 v1, 0x0
|
|
|
|
const/4 v3, 0x0
|
|
|
|
:goto_0
|
|
invoke-interface {p1}, Ljava/util/Iterator;->hasNext()Z
|
|
|
|
move-result v4
|
|
|
|
if-eqz v4, :cond_7
|
|
|
|
invoke-interface {p1}, Ljava/util/Iterator;->next()Ljava/lang/Object;
|
|
|
|
move-result-object v4
|
|
|
|
add-int/lit8 v5, v3, 0x1
|
|
|
|
const/4 v6, 0x0
|
|
|
|
if-ltz v3, :cond_6
|
|
|
|
check-cast v4, Lcom/discord/models/domain/ModelPaymentSource;
|
|
|
|
if-eqz v3, :cond_1
|
|
|
|
if-eq v3, v2, :cond_0
|
|
|
|
move-object v3, v6
|
|
|
|
goto :goto_1
|
|
|
|
:cond_0
|
|
sget-object v3, Lcom/discord/widgets/settings/billing/PaymentSourceAdapter$PaymentSourceHeader$Type;->OTHER:Lcom/discord/widgets/settings/billing/PaymentSourceAdapter$PaymentSourceHeader$Type;
|
|
|
|
goto :goto_1
|
|
|
|
:cond_1
|
|
sget-object v3, Lcom/discord/widgets/settings/billing/PaymentSourceAdapter$PaymentSourceHeader$Type;->DEFAULT:Lcom/discord/widgets/settings/billing/PaymentSourceAdapter$PaymentSourceHeader$Type;
|
|
|
|
:goto_1
|
|
if-eqz v3, :cond_2
|
|
|
|
new-instance v7, Lcom/discord/widgets/settings/billing/PaymentSourceAdapter$PaymentSourceHeader;
|
|
|
|
invoke-direct {v7, v3}, Lcom/discord/widgets/settings/billing/PaymentSourceAdapter$PaymentSourceHeader;-><init>(Lcom/discord/widgets/settings/billing/PaymentSourceAdapter$PaymentSourceHeader$Type;)V
|
|
|
|
goto :goto_2
|
|
|
|
:cond_2
|
|
move-object v7, v6
|
|
|
|
:goto_2
|
|
if-eqz v7, :cond_3
|
|
|
|
invoke-virtual {v0, v7}, Ljava/util/ArrayList;->add(Ljava/lang/Object;)Z
|
|
|
|
:cond_3
|
|
new-instance v3, Lcom/discord/widgets/settings/billing/PaymentSourceAdapter$PaymentSourceItem;
|
|
|
|
invoke-virtual {v4}, Lcom/discord/models/domain/ModelPaymentSource;->getId()Ljava/lang/String;
|
|
|
|
move-result-object v7
|
|
|
|
if-eqz p2, :cond_4
|
|
|
|
invoke-virtual {p2}, Lcom/discord/models/domain/ModelSubscription;->getPaymentSourceId()Ljava/lang/String;
|
|
|
|
move-result-object v6
|
|
|
|
:cond_4
|
|
invoke-static {v7, v6}, Ly/n/c/j;->areEqual(Ljava/lang/Object;Ljava/lang/Object;)Z
|
|
|
|
move-result v6
|
|
|
|
if-eqz v6, :cond_5
|
|
|
|
invoke-virtual {p2}, Lcom/discord/models/domain/ModelSubscription;->getStatus()Lcom/discord/models/domain/ModelSubscription$Status;
|
|
|
|
move-result-object v6
|
|
|
|
invoke-virtual {v6}, Lcom/discord/models/domain/ModelSubscription$Status;->isCanceled()Z
|
|
|
|
move-result v6
|
|
|
|
if-nez v6, :cond_5
|
|
|
|
const/4 v6, 0x1
|
|
|
|
goto :goto_3
|
|
|
|
:cond_5
|
|
const/4 v6, 0x0
|
|
|
|
:goto_3
|
|
invoke-direct {v3, v4, v6}, Lcom/discord/widgets/settings/billing/PaymentSourceAdapter$PaymentSourceItem;-><init>(Lcom/discord/models/domain/ModelPaymentSource;Z)V
|
|
|
|
invoke-virtual {v0, v3}, Ljava/util/ArrayList;->add(Ljava/lang/Object;)Z
|
|
|
|
move v3, v5
|
|
|
|
goto :goto_0
|
|
|
|
:cond_6
|
|
invoke-static {}, Lf/h/a/f/f/n/f;->throwIndexOverflow()V
|
|
|
|
throw v6
|
|
|
|
:cond_7
|
|
new-instance p1, Lcom/discord/widgets/settings/billing/PaymentSourceAdapter$PaymentSourceAddItem;
|
|
|
|
invoke-direct {p1}, Lcom/discord/widgets/settings/billing/PaymentSourceAdapter$PaymentSourceAddItem;-><init>()V
|
|
|
|
invoke-virtual {v0, p1}, Ljava/util/ArrayList;->add(Ljava/lang/Object;)Z
|
|
|
|
:cond_8
|
|
return-object v0
|
|
.end method
|
|
|
|
.method private final handleStoreState(Lcom/discord/widgets/settings/billing/SettingsBillingViewModel$StoreState;)V
|
|
.locals 4
|
|
|
|
invoke-virtual {p1}, Lcom/discord/widgets/settings/billing/SettingsBillingViewModel$StoreState;->getPaymentSourceState()Lcom/discord/stores/StorePaymentSources$PaymentSourcesState;
|
|
|
|
move-result-object v0
|
|
|
|
invoke-virtual {p1}, Lcom/discord/widgets/settings/billing/SettingsBillingViewModel$StoreState;->getSubscriptionsState()Lcom/discord/stores/StoreSubscriptions$SubscriptionsState;
|
|
|
|
move-result-object p1
|
|
|
|
instance-of v1, v0, Lcom/discord/stores/StorePaymentSources$PaymentSourcesState$Loaded;
|
|
|
|
if-eqz v1, :cond_3
|
|
|
|
instance-of v1, p1, Lcom/discord/stores/StoreSubscriptions$SubscriptionsState$Loaded;
|
|
|
|
if-eqz v1, :cond_3
|
|
|
|
check-cast p1, Lcom/discord/stores/StoreSubscriptions$SubscriptionsState$Loaded;
|
|
|
|
invoke-virtual {p1}, Lcom/discord/stores/StoreSubscriptions$SubscriptionsState$Loaded;->getSubscriptions()Ljava/util/List;
|
|
|
|
move-result-object p1
|
|
|
|
invoke-interface {p1}, Ljava/lang/Iterable;->iterator()Ljava/util/Iterator;
|
|
|
|
move-result-object p1
|
|
|
|
:cond_0
|
|
invoke-interface {p1}, Ljava/util/Iterator;->hasNext()Z
|
|
|
|
move-result v1
|
|
|
|
if-eqz v1, :cond_2
|
|
|
|
invoke-interface {p1}, Ljava/util/Iterator;->next()Ljava/lang/Object;
|
|
|
|
move-result-object v1
|
|
|
|
move-object v2, v1
|
|
|
|
check-cast v2, Lcom/discord/models/domain/ModelSubscription;
|
|
|
|
invoke-virtual {v2}, Lcom/discord/models/domain/ModelSubscription;->getType()Lcom/discord/models/domain/ModelSubscription$Type;
|
|
|
|
move-result-object v2
|
|
|
|
sget-object v3, Lcom/discord/models/domain/ModelSubscription$Type;->PREMIUM:Lcom/discord/models/domain/ModelSubscription$Type;
|
|
|
|
if-ne v2, v3, :cond_1
|
|
|
|
const/4 v2, 0x1
|
|
|
|
goto :goto_0
|
|
|
|
:cond_1
|
|
const/4 v2, 0x0
|
|
|
|
:goto_0
|
|
if-eqz v2, :cond_0
|
|
|
|
goto :goto_1
|
|
|
|
:cond_2
|
|
const/4 v1, 0x0
|
|
|
|
:goto_1
|
|
check-cast v1, Lcom/discord/models/domain/ModelSubscription;
|
|
|
|
check-cast v0, Lcom/discord/stores/StorePaymentSources$PaymentSourcesState$Loaded;
|
|
|
|
invoke-virtual {v0}, Lcom/discord/stores/StorePaymentSources$PaymentSourcesState$Loaded;->getPaymentSources()Ljava/util/List;
|
|
|
|
move-result-object p1
|
|
|
|
invoke-direct {p0, p1, v1}, Lcom/discord/widgets/settings/billing/SettingsBillingViewModel;->generateListItems(Ljava/util/List;Lcom/discord/models/domain/ModelSubscription;)Ljava/util/List;
|
|
|
|
move-result-object p1
|
|
|
|
new-instance v0, Lcom/discord/widgets/settings/billing/SettingsBillingViewModel$ViewState$Loaded;
|
|
|
|
invoke-direct {v0, p1}, Lcom/discord/widgets/settings/billing/SettingsBillingViewModel$ViewState$Loaded;-><init>(Ljava/util/List;)V
|
|
|
|
invoke-virtual {p0, v0}, Lf/a/b/l0;->updateViewState(Ljava/lang/Object;)V
|
|
|
|
return-void
|
|
|
|
:cond_3
|
|
instance-of v0, v0, Lcom/discord/stores/StorePaymentSources$PaymentSourcesState$Failure;
|
|
|
|
if-nez v0, :cond_5
|
|
|
|
instance-of p1, p1, Lcom/discord/stores/StoreSubscriptions$SubscriptionsState$Failure;
|
|
|
|
if-eqz p1, :cond_4
|
|
|
|
goto :goto_2
|
|
|
|
:cond_4
|
|
sget-object p1, Lcom/discord/widgets/settings/billing/SettingsBillingViewModel$ViewState$Loading;->INSTANCE:Lcom/discord/widgets/settings/billing/SettingsBillingViewModel$ViewState$Loading;
|
|
|
|
invoke-virtual {p0, p1}, Lf/a/b/l0;->updateViewState(Ljava/lang/Object;)V
|
|
|
|
return-void
|
|
|
|
:cond_5
|
|
:goto_2
|
|
sget-object p1, Lcom/discord/widgets/settings/billing/SettingsBillingViewModel$ViewState$Failure;->INSTANCE:Lcom/discord/widgets/settings/billing/SettingsBillingViewModel$ViewState$Failure;
|
|
|
|
invoke-virtual {p0, p1}, Lf/a/b/l0;->updateViewState(Ljava/lang/Object;)V
|
|
|
|
return-void
|
|
.end method
|
|
|
|
|
|
# virtual methods
|
|
.method public final getStorePaymentSources()Lcom/discord/stores/StorePaymentSources;
|
|
.locals 1
|
|
|
|
iget-object v0, p0, Lcom/discord/widgets/settings/billing/SettingsBillingViewModel;->storePaymentSources:Lcom/discord/stores/StorePaymentSources;
|
|
|
|
return-object v0
|
|
.end method
|
|
|
|
.method public final getStoreSubscriptions()Lcom/discord/stores/StoreSubscriptions;
|
|
.locals 1
|
|
|
|
iget-object v0, p0, Lcom/discord/widgets/settings/billing/SettingsBillingViewModel;->storeSubscriptions:Lcom/discord/stores/StoreSubscriptions;
|
|
|
|
return-object v0
|
|
.end method
|
|
|
|
.method public final onRetryClicked()V
|
|
.locals 0
|
|
|
|
invoke-direct {p0}, Lcom/discord/widgets/settings/billing/SettingsBillingViewModel;->fetchData()V
|
|
|
|
return-void
|
|
.end method
|