261 lines
12 KiB
Java
261 lines
12 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.t.u;
|
|
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.Map;
|
|
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;
|
|
private final StoreGuildScheduledEvents guildScheduledEventsStore;
|
|
|
|
/* 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 observeGuildScheduledEvents$default = StoreGuildScheduledEvents.observeGuildScheduledEvents$default(storeGuildScheduledEvents, j, false, 2, null);
|
|
GuildScheduledEventListViewModel$Companion$observeStores$1 guildScheduledEventListViewModel$Companion$observeStores$1 = new GuildScheduledEventListViewModel$Companion$observeStores$1(atomicInteger);
|
|
Objects.requireNonNull(observeGuildScheduledEvents$default);
|
|
Observable<StoreState> j2 = Observable.j(Observable.h0(new r(observeGuildScheduledEvents$default.i, new i2(guildScheduledEventListViewModel$Companion$observeStores$1))), storeGuildScheduledEvents.observeUserGuildScheduledEvents(), GuildScheduledEventListViewModel$Companion$observeStores$2.INSTANCE);
|
|
m.checkNotNullExpressionValue(j2, "Observable.combineLatest…dScheduledEvents)\n }");
|
|
return j2;
|
|
}
|
|
}
|
|
|
|
/* compiled from: GuildScheduledEventListViewModel.kt */
|
|
public static final class StoreState {
|
|
private final List<GuildScheduledEvent> guildScheduledEvents;
|
|
private final Map<Long, GuildScheduledEvent> userGuildScheduledEvents;
|
|
|
|
public StoreState(List<GuildScheduledEvent> list, Map<Long, GuildScheduledEvent> map) {
|
|
m.checkNotNullParameter(list, "guildScheduledEvents");
|
|
m.checkNotNullParameter(map, "userGuildScheduledEvents");
|
|
this.guildScheduledEvents = list;
|
|
this.userGuildScheduledEvents = map;
|
|
}
|
|
|
|
/* 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, Map map, int i, Object obj) {
|
|
if ((i & 1) != 0) {
|
|
list = storeState.guildScheduledEvents;
|
|
}
|
|
if ((i & 2) != 0) {
|
|
map = storeState.userGuildScheduledEvents;
|
|
}
|
|
return storeState.copy(list, map);
|
|
}
|
|
|
|
public final List<GuildScheduledEvent> component1() {
|
|
return this.guildScheduledEvents;
|
|
}
|
|
|
|
public final Map<Long, GuildScheduledEvent> component2() {
|
|
return this.userGuildScheduledEvents;
|
|
}
|
|
|
|
public final StoreState copy(List<GuildScheduledEvent> list, Map<Long, GuildScheduledEvent> map) {
|
|
m.checkNotNullParameter(list, "guildScheduledEvents");
|
|
m.checkNotNullParameter(map, "userGuildScheduledEvents");
|
|
return new StoreState(list, map);
|
|
}
|
|
|
|
public boolean equals(Object obj) {
|
|
if (this == obj) {
|
|
return true;
|
|
}
|
|
if (!(obj instanceof StoreState)) {
|
|
return false;
|
|
}
|
|
StoreState storeState = (StoreState) obj;
|
|
return m.areEqual(this.guildScheduledEvents, storeState.guildScheduledEvents) && m.areEqual(this.userGuildScheduledEvents, storeState.userGuildScheduledEvents);
|
|
}
|
|
|
|
public final List<GuildScheduledEvent> getGuildScheduledEvents() {
|
|
return this.guildScheduledEvents;
|
|
}
|
|
|
|
public final Map<Long, GuildScheduledEvent> getUserGuildScheduledEvents() {
|
|
return this.userGuildScheduledEvents;
|
|
}
|
|
|
|
public int hashCode() {
|
|
List<GuildScheduledEvent> list = this.guildScheduledEvents;
|
|
int i = 0;
|
|
int hashCode = (list != null ? list.hashCode() : 0) * 31;
|
|
Map<Long, GuildScheduledEvent> map = this.userGuildScheduledEvents;
|
|
if (map != null) {
|
|
i = map.hashCode();
|
|
}
|
|
return hashCode + i;
|
|
}
|
|
|
|
public String toString() {
|
|
StringBuilder K = a.K("StoreState(guildScheduledEvents=");
|
|
K.append(this.guildScheduledEvents);
|
|
K.append(", userGuildScheduledEvents=");
|
|
return a.E(K, this.userGuildScheduledEvents, ")");
|
|
}
|
|
}
|
|
|
|
/* 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.D(a.K("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, StoreGuildScheduledEvents storeGuildScheduledEvents, Observable<StoreState> observable) {
|
|
super(ViewState.Initial.INSTANCE);
|
|
m.checkNotNullParameter(storeGuildScheduledEvents, "guildScheduledEventsStore");
|
|
m.checkNotNullParameter(observable, "storeStateObservable");
|
|
this.guildId = j;
|
|
this.guildScheduledEventsStore = storeGuildScheduledEvents;
|
|
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 WARNING: Illegal instructions before constructor call */
|
|
public /* synthetic */ GuildScheduledEventListViewModel(long j, StoreGuildScheduledEvents storeGuildScheduledEvents, Observable observable, int i, DefaultConstructorMarker defaultConstructorMarker) {
|
|
this(j, storeGuildScheduledEvents, (i & 4) != 0 ? Companion.access$observeStores(Companion, j, storeGuildScheduledEvents) : observable);
|
|
storeGuildScheduledEvents = (i & 2) != 0 ? StoreStream.Companion.getGuildScheduledEvents() : storeGuildScheduledEvents;
|
|
}
|
|
|
|
public static final /* synthetic */ void access$handleStoreState(GuildScheduledEventListViewModel guildScheduledEventListViewModel, StoreState storeState) {
|
|
guildScheduledEventListViewModel.handleStoreState(storeState);
|
|
}
|
|
|
|
private final void handleStoreState(StoreState storeState) {
|
|
List<GuildScheduledEvent> sortedWith = u.sortedWith(storeState.getGuildScheduledEvents(), new GuildScheduledEventListViewModel$handleStoreState$$inlined$sortedBy$1());
|
|
ArrayList arrayList = new ArrayList(o.collectionSizeOrDefault(sortedWith, 10));
|
|
for (GuildScheduledEvent guildScheduledEvent : sortedWith) {
|
|
arrayList.add(new GuildScheduledEventListItem.Event(guildScheduledEvent, storeState.getUserGuildScheduledEvents().keySet().contains(Long.valueOf(guildScheduledEvent.d()))));
|
|
}
|
|
updateViewState(new ViewState.Loaded(arrayList));
|
|
}
|
|
|
|
public final void toggleRsvp(GuildScheduledEvent guildScheduledEvent) {
|
|
m.checkNotNullParameter(guildScheduledEvent, "guildScheduledEvent");
|
|
this.guildScheduledEventsStore.toggleRsvpGuildScheduledEvent(guildScheduledEvent);
|
|
}
|
|
}
|