discord-jadx/app/src/main/java/com/discord/widgets/guildscheduledevent/PreviewGuildScheduledEventV...

240 lines
11 KiB
Java

package com.discord.widgets.guildscheduledevent;
import android.content.Context;
import c.d.b.a.a;
import com.airbnb.lottie.parser.AnimatableValueParser;
import com.discord.api.channel.Channel;
import com.discord.api.stageinstance.StageInstancePrivacyLevel;
import com.discord.app.AppViewModel;
import com.discord.restapi.RestAPIParams;
import com.discord.stores.StoreChannels;
import com.discord.stores.StoreStream;
import com.discord.utilities.rest.RestAPI;
import com.discord.utilities.rx.ObservableExtensionsKt;
import com.discord.widgets.stage.StageChannelAPI;
import d0.z.d.m;
import java.util.Objects;
import kotlin.Unit;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.internal.DefaultConstructorMarker;
/* compiled from: PreviewGuildScheduledEventViewModel.kt */
public final class PreviewGuildScheduledEventViewModel extends AppViewModel<ViewState> {
private final StoreChannels channelsStore;
private ViewState.Initialized currentViewState;
private final Long eventId;
private final GuildScheduledEventModel eventModel;
/* compiled from: PreviewGuildScheduledEventViewModel.kt */
public static abstract class ViewState {
/* compiled from: PreviewGuildScheduledEventViewModel.kt */
public static final class Initial extends ViewState {
public static final Initial INSTANCE = new Initial();
private Initial() {
super(null);
}
}
/* compiled from: PreviewGuildScheduledEventViewModel.kt */
public static final class Initialized extends ViewState {
private final Channel channel;
private final boolean eventAlreadyExists;
private final GuildScheduledEventModel eventModel;
private final boolean requestProcessing;
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public Initialized(boolean z2, boolean z3, Channel channel, GuildScheduledEventModel guildScheduledEventModel) {
super(null);
m.checkNotNullParameter(guildScheduledEventModel, "eventModel");
this.requestProcessing = z2;
this.eventAlreadyExists = z3;
this.channel = channel;
this.eventModel = guildScheduledEventModel;
}
public static /* synthetic */ Initialized copy$default(Initialized initialized, boolean z2, boolean z3, Channel channel, GuildScheduledEventModel guildScheduledEventModel, int i, Object obj) {
if ((i & 1) != 0) {
z2 = initialized.requestProcessing;
}
if ((i & 2) != 0) {
z3 = initialized.eventAlreadyExists;
}
if ((i & 4) != 0) {
channel = initialized.channel;
}
if ((i & 8) != 0) {
guildScheduledEventModel = initialized.eventModel;
}
return initialized.copy(z2, z3, channel, guildScheduledEventModel);
}
public final boolean component1() {
return this.requestProcessing;
}
public final boolean component2() {
return this.eventAlreadyExists;
}
public final Channel component3() {
return this.channel;
}
public final GuildScheduledEventModel component4() {
return this.eventModel;
}
public final Initialized copy(boolean z2, boolean z3, Channel channel, GuildScheduledEventModel guildScheduledEventModel) {
m.checkNotNullParameter(guildScheduledEventModel, "eventModel");
return new Initialized(z2, z3, channel, guildScheduledEventModel);
}
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof Initialized)) {
return false;
}
Initialized initialized = (Initialized) obj;
return this.requestProcessing == initialized.requestProcessing && this.eventAlreadyExists == initialized.eventAlreadyExists && m.areEqual(this.channel, initialized.channel) && m.areEqual(this.eventModel, initialized.eventModel);
}
public final Channel getChannel() {
return this.channel;
}
public final boolean getEventAlreadyExists() {
return this.eventAlreadyExists;
}
public final GuildScheduledEventModel getEventModel() {
return this.eventModel;
}
public final boolean getRequestProcessing() {
return this.requestProcessing;
}
public int hashCode() {
boolean z2 = this.requestProcessing;
int i = 1;
if (z2) {
z2 = true;
}
int i2 = z2 ? 1 : 0;
int i3 = z2 ? 1 : 0;
int i4 = z2 ? 1 : 0;
int i5 = i2 * 31;
boolean z3 = this.eventAlreadyExists;
if (!z3) {
i = z3 ? 1 : 0;
}
int i6 = (i5 + i) * 31;
Channel channel = this.channel;
int i7 = 0;
int hashCode = (i6 + (channel != null ? channel.hashCode() : 0)) * 31;
GuildScheduledEventModel guildScheduledEventModel = this.eventModel;
if (guildScheduledEventModel != null) {
i7 = guildScheduledEventModel.hashCode();
}
return hashCode + i7;
}
public String toString() {
StringBuilder L = a.L("Initialized(requestProcessing=");
L.append(this.requestProcessing);
L.append(", eventAlreadyExists=");
L.append(this.eventAlreadyExists);
L.append(", channel=");
L.append(this.channel);
L.append(", eventModel=");
L.append(this.eventModel);
L.append(")");
return L.toString();
}
}
/* compiled from: PreviewGuildScheduledEventViewModel.kt */
public static final class Invalid extends ViewState {
public static final Invalid INSTANCE = new Invalid();
private Invalid() {
super(null);
}
}
private ViewState() {
}
public /* synthetic */ ViewState(DefaultConstructorMarker defaultConstructorMarker) {
this();
}
}
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public PreviewGuildScheduledEventViewModel(GuildScheduledEventModel guildScheduledEventModel, Long l, StoreChannels storeChannels) {
super(ViewState.Initial.INSTANCE);
m.checkNotNullParameter(guildScheduledEventModel, "eventModel");
m.checkNotNullParameter(storeChannels, "channelsStore");
this.eventModel = guildScheduledEventModel;
this.eventId = l;
this.channelsStore = storeChannels;
boolean z2 = l != null;
Long channelId = guildScheduledEventModel.getChannelId();
ViewState.Initialized initialized = new ViewState.Initialized(false, z2, channelId != null ? storeChannels.getChannel(channelId.longValue()) : null, guildScheduledEventModel);
this.currentViewState = initialized;
updateViewState(initialized);
}
/* JADX INFO: this call moved to the top of the method (can break code semantics) */
public /* synthetic */ PreviewGuildScheduledEventViewModel(GuildScheduledEventModel guildScheduledEventModel, Long l, StoreChannels storeChannels, int i, DefaultConstructorMarker defaultConstructorMarker) {
this(guildScheduledEventModel, l, (i & 4) != 0 ? StoreStream.Companion.getChannels() : storeChannels);
}
public static final /* synthetic */ ViewState access$requireViewState(PreviewGuildScheduledEventViewModel previewGuildScheduledEventViewModel) {
return previewGuildScheduledEventViewModel.requireViewState();
}
public static final /* synthetic */ void access$updateViewState(PreviewGuildScheduledEventViewModel previewGuildScheduledEventViewModel, ViewState viewState) {
previewGuildScheduledEventViewModel.updateViewState(viewState);
}
public static /* synthetic */ void onBottomButtonClicked$default(PreviewGuildScheduledEventViewModel previewGuildScheduledEventViewModel, Context context, boolean z2, Function0 function0, int i, Object obj) {
if ((i & 2) != 0) {
z2 = false;
}
previewGuildScheduledEventViewModel.onBottomButtonClicked(context, z2, function0);
}
public final ViewState.Initialized getCurrentViewState() {
return this.currentViewState;
}
public final void onBottomButtonClicked(Context context, boolean z2, Function0<Unit> function0) {
Channel channel;
m.checkNotNullParameter(context, "context");
m.checkNotNullParameter(function0, "onRequestSuccess");
ViewState.Initialized initialized = this.currentViewState;
Objects.requireNonNull(initialized, "null cannot be cast to non-null type com.discord.widgets.guildscheduledevent.PreviewGuildScheduledEventViewModel.ViewState.Initialized");
if (!initialized.getRequestProcessing()) {
updateViewState(ViewState.Initialized.copy$default(initialized, true, false, null, null, 14, null));
if (!initialized.getEventAlreadyExists()) {
RestAPIParams.CreateGuildScheduledEventBody requestBody = this.eventModel.toRequestBody();
if (requestBody != null) {
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.ui$default(ObservableExtensionsKt.restSubscribeOn$default(RestAPI.Companion.getApi().createGuildScheduledEvent(this.eventModel.getGuildId(), requestBody), false, 1, null), this, null, 2, null), PreviewGuildScheduledEventViewModel.class, (Context) null, (Function1) null, new PreviewGuildScheduledEventViewModel$onBottomButtonClicked$3(this), (Function0) null, (Function0) null, new PreviewGuildScheduledEventViewModel$onBottomButtonClicked$4(this, function0), 54, (Object) null);
}
} else if (this.eventModel.getName() != null && this.eventId != null && this.eventModel.getChannelId() != null && (channel = this.channelsStore.getChannel(this.eventModel.getChannelId().longValue())) != null && AnimatableValueParser.x1(channel)) {
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.ui$default(ObservableExtensionsKt.restSubscribeOn$default(StageChannelAPI.INSTANCE.startStageInstance(this.eventModel.getChannelId().longValue(), this.eventModel.getName(), StageInstancePrivacyLevel.GUILD_ONLY, z2, String.valueOf(this.eventId.longValue())), false, 1, null), this, null, 2, null), PreviewGuildScheduledEventViewModel.class, context, (Function1) null, new PreviewGuildScheduledEventViewModel$onBottomButtonClicked$1(this), (Function0) null, (Function0) null, new PreviewGuildScheduledEventViewModel$onBottomButtonClicked$2(this, function0), 52, (Object) null);
}
}
}
public final void setCurrentViewState(ViewState.Initialized initialized) {
m.checkNotNullParameter(initialized, "<set-?>");
this.currentViewState = initialized;
}
}