225 lines
10 KiB
Java
225 lines
10 KiB
Java
package com.discord.widgets.guildscheduledevent;
|
|
|
|
import android.content.Context;
|
|
import c.d.b.a.a;
|
|
import com.discord.api.guildscheduledevent.GuildScheduledEvent;
|
|
import com.discord.app.AppViewModel;
|
|
import com.discord.stores.StoreGuildScheduledEvents;
|
|
import com.discord.stores.StoreStream;
|
|
import com.discord.utilities.rx.ObservableExtensionsKt;
|
|
import com.discord.widgets.guildscheduledevent.GuildScheduledEventListItem;
|
|
import d0.t.o;
|
|
import d0.z.d.k;
|
|
import d0.z.d.m;
|
|
import j0.l.a.i2;
|
|
import j0.l.a.r;
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
import java.util.Objects;
|
|
import java.util.concurrent.atomic.AtomicInteger;
|
|
import kotlin.Unit;
|
|
import kotlin.jvm.functions.Function0;
|
|
import kotlin.jvm.functions.Function1;
|
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
|
import rx.Observable;
|
|
/* compiled from: GuildScheduledEventListViewModel.kt */
|
|
public final class GuildScheduledEventListViewModel extends AppViewModel<ViewState> {
|
|
public static final Companion Companion = new Companion(null);
|
|
private final long guildId;
|
|
|
|
/* compiled from: GuildScheduledEventListViewModel.kt */
|
|
/* renamed from: com.discord.widgets.guildscheduledevent.GuildScheduledEventListViewModel$1 reason: invalid class name */
|
|
public static final /* synthetic */ class AnonymousClass1 extends k implements Function1<StoreState, Unit> {
|
|
public AnonymousClass1(GuildScheduledEventListViewModel guildScheduledEventListViewModel) {
|
|
super(1, guildScheduledEventListViewModel, GuildScheduledEventListViewModel.class, "handleStoreState", "handleStoreState(Lcom/discord/widgets/guildscheduledevent/GuildScheduledEventListViewModel$StoreState;)V", 0);
|
|
}
|
|
|
|
/* Return type fixed from 'java.lang.Object' to match base method */
|
|
/* JADX DEBUG: Method arguments types fixed to match base method, original types: [java.lang.Object] */
|
|
@Override // kotlin.jvm.functions.Function1
|
|
public /* bridge */ /* synthetic */ Unit invoke(StoreState storeState) {
|
|
invoke(storeState);
|
|
return Unit.a;
|
|
}
|
|
|
|
public final void invoke(StoreState storeState) {
|
|
m.checkNotNullParameter(storeState, "p1");
|
|
GuildScheduledEventListViewModel.access$handleStoreState((GuildScheduledEventListViewModel) this.receiver, storeState);
|
|
}
|
|
}
|
|
|
|
/* compiled from: GuildScheduledEventListViewModel.kt */
|
|
public static final class Companion {
|
|
private Companion() {
|
|
}
|
|
|
|
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
|
|
this();
|
|
}
|
|
|
|
public static final /* synthetic */ Observable access$observeStores(Companion companion, long j, StoreGuildScheduledEvents storeGuildScheduledEvents) {
|
|
return companion.observeStores(j, storeGuildScheduledEvents);
|
|
}
|
|
|
|
private final Observable<StoreState> observeStores(long j, StoreGuildScheduledEvents storeGuildScheduledEvents) {
|
|
AtomicInteger atomicInteger = new AtomicInteger(-1);
|
|
Observable<List<GuildScheduledEvent>> observeGuildScheduledEvents = storeGuildScheduledEvents.observeGuildScheduledEvents(j);
|
|
GuildScheduledEventListViewModel$Companion$observeStores$1 guildScheduledEventListViewModel$Companion$observeStores$1 = new GuildScheduledEventListViewModel$Companion$observeStores$1(atomicInteger);
|
|
Objects.requireNonNull(observeGuildScheduledEvents);
|
|
Observable<StoreState> F = Observable.h0(new r(observeGuildScheduledEvents.i, new i2(guildScheduledEventListViewModel$Companion$observeStores$1))).F(GuildScheduledEventListViewModel$Companion$observeStores$2.INSTANCE);
|
|
m.checkNotNullExpressionValue(F, "guildScheduledEventsStor… .map { StoreState(it) }");
|
|
return F;
|
|
}
|
|
}
|
|
|
|
/* compiled from: GuildScheduledEventListViewModel.kt */
|
|
public static final class StoreState {
|
|
private final List<GuildScheduledEvent> guildScheduledEvents;
|
|
|
|
public StoreState(List<GuildScheduledEvent> list) {
|
|
m.checkNotNullParameter(list, "guildScheduledEvents");
|
|
this.guildScheduledEvents = list;
|
|
}
|
|
|
|
/* JADX DEBUG: Multi-variable search result rejected for r0v0, resolved type: com.discord.widgets.guildscheduledevent.GuildScheduledEventListViewModel$StoreState */
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
public static /* synthetic */ StoreState copy$default(StoreState storeState, List list, int i, Object obj) {
|
|
if ((i & 1) != 0) {
|
|
list = storeState.guildScheduledEvents;
|
|
}
|
|
return storeState.copy(list);
|
|
}
|
|
|
|
public final List<GuildScheduledEvent> component1() {
|
|
return this.guildScheduledEvents;
|
|
}
|
|
|
|
public final StoreState copy(List<GuildScheduledEvent> list) {
|
|
m.checkNotNullParameter(list, "guildScheduledEvents");
|
|
return new StoreState(list);
|
|
}
|
|
|
|
public boolean equals(Object obj) {
|
|
if (this != obj) {
|
|
return (obj instanceof StoreState) && m.areEqual(this.guildScheduledEvents, ((StoreState) obj).guildScheduledEvents);
|
|
}
|
|
return true;
|
|
}
|
|
|
|
public final List<GuildScheduledEvent> getGuildScheduledEvents() {
|
|
return this.guildScheduledEvents;
|
|
}
|
|
|
|
public int hashCode() {
|
|
List<GuildScheduledEvent> list = this.guildScheduledEvents;
|
|
if (list != null) {
|
|
return list.hashCode();
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
public String toString() {
|
|
return a.E(a.L("StoreState(guildScheduledEvents="), this.guildScheduledEvents, ")");
|
|
}
|
|
}
|
|
|
|
/* compiled from: GuildScheduledEventListViewModel.kt */
|
|
public static abstract class ViewState {
|
|
|
|
/* compiled from: GuildScheduledEventListViewModel.kt */
|
|
public static final class Initial extends ViewState {
|
|
public static final Initial INSTANCE = new Initial();
|
|
|
|
private Initial() {
|
|
super(null);
|
|
}
|
|
}
|
|
|
|
/* compiled from: GuildScheduledEventListViewModel.kt */
|
|
public static final class Loaded extends ViewState {
|
|
private final List<GuildScheduledEventListItem.Event> guildScheduledEvents;
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public Loaded(List<GuildScheduledEventListItem.Event> list) {
|
|
super(null);
|
|
m.checkNotNullParameter(list, "guildScheduledEvents");
|
|
this.guildScheduledEvents = list;
|
|
}
|
|
|
|
/* JADX DEBUG: Multi-variable search result rejected for r0v0, resolved type: com.discord.widgets.guildscheduledevent.GuildScheduledEventListViewModel$ViewState$Loaded */
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
public static /* synthetic */ Loaded copy$default(Loaded loaded, List list, int i, Object obj) {
|
|
if ((i & 1) != 0) {
|
|
list = loaded.guildScheduledEvents;
|
|
}
|
|
return loaded.copy(list);
|
|
}
|
|
|
|
public final List<GuildScheduledEventListItem.Event> component1() {
|
|
return this.guildScheduledEvents;
|
|
}
|
|
|
|
public final Loaded copy(List<GuildScheduledEventListItem.Event> list) {
|
|
m.checkNotNullParameter(list, "guildScheduledEvents");
|
|
return new Loaded(list);
|
|
}
|
|
|
|
public boolean equals(Object obj) {
|
|
if (this != obj) {
|
|
return (obj instanceof Loaded) && m.areEqual(this.guildScheduledEvents, ((Loaded) obj).guildScheduledEvents);
|
|
}
|
|
return true;
|
|
}
|
|
|
|
public final List<GuildScheduledEventListItem.Event> getGuildScheduledEvents() {
|
|
return this.guildScheduledEvents;
|
|
}
|
|
|
|
public int hashCode() {
|
|
List<GuildScheduledEventListItem.Event> list = this.guildScheduledEvents;
|
|
if (list != null) {
|
|
return list.hashCode();
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
public String toString() {
|
|
return a.E(a.L("Loaded(guildScheduledEvents="), this.guildScheduledEvents, ")");
|
|
}
|
|
}
|
|
|
|
private ViewState() {
|
|
}
|
|
|
|
public /* synthetic */ ViewState(DefaultConstructorMarker defaultConstructorMarker) {
|
|
this();
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public GuildScheduledEventListViewModel(long j, Observable<StoreState> observable) {
|
|
super(ViewState.Initial.INSTANCE);
|
|
m.checkNotNullParameter(observable, "storeStateObservable");
|
|
this.guildId = j;
|
|
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.ui$default(ObservableExtensionsKt.computationLatest(observable), this, null, 2, null), GuildScheduledEventListViewModel.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new AnonymousClass1(this), 62, (Object) null);
|
|
}
|
|
|
|
/* JADX INFO: this call moved to the top of the method (can break code semantics) */
|
|
public /* synthetic */ GuildScheduledEventListViewModel(long j, Observable observable, int i, DefaultConstructorMarker defaultConstructorMarker) {
|
|
this(j, (i & 2) != 0 ? Companion.access$observeStores(Companion, j, StoreStream.Companion.getGuildScheduledEvents()) : observable);
|
|
}
|
|
|
|
public static final /* synthetic */ void access$handleStoreState(GuildScheduledEventListViewModel guildScheduledEventListViewModel, StoreState storeState) {
|
|
guildScheduledEventListViewModel.handleStoreState(storeState);
|
|
}
|
|
|
|
private final void handleStoreState(StoreState storeState) {
|
|
List<GuildScheduledEvent> guildScheduledEvents = storeState.getGuildScheduledEvents();
|
|
ArrayList arrayList = new ArrayList(o.collectionSizeOrDefault(guildScheduledEvents, 10));
|
|
for (GuildScheduledEvent guildScheduledEvent : guildScheduledEvents) {
|
|
arrayList.add(new GuildScheduledEventListItem.Event(guildScheduledEvent));
|
|
}
|
|
updateViewState(new ViewState.Loaded(arrayList));
|
|
}
|
|
}
|