122 lines
6.2 KiB
Java
122 lines
6.2 KiB
Java
package com.discord.utilities;
|
|
|
|
import android.content.Context;
|
|
import androidx.annotation.MainThread;
|
|
import com.discord.R;
|
|
import com.discord.api.channel.Channel;
|
|
import com.discord.api.channel.ChannelUtils;
|
|
import com.discord.rtcconnection.KrispOveruseDetector;
|
|
import com.discord.stores.StoreChannels;
|
|
import com.discord.stores.StoreMediaEngine;
|
|
import com.discord.stores.StoreStageChannels;
|
|
import com.discord.stores.StoreUserGuildSettings;
|
|
import com.discord.stores.StoreVoiceChannelSelected;
|
|
import com.discord.utilities.rx.ObservableExtensionsKt;
|
|
import com.discord.widgets.stage.StageRoles;
|
|
import d0.z.d.m;
|
|
import kotlin.NoWhenBranchMatchedException;
|
|
import kotlin.Unit;
|
|
import kotlin.jvm.functions.Function0;
|
|
import kotlin.jvm.functions.Function1;
|
|
/* compiled from: StoreUIEventHandler.kt */
|
|
public final class StoreUIEventHandler {
|
|
private final StoreChannels channelsStore;
|
|
private final Context context;
|
|
private final StoreMediaEngine mediaEngineStore;
|
|
private final StoreStageChannels stageChannelsStore;
|
|
private final StoreUserGuildSettings storeUserGuildSettings;
|
|
private final StoreVoiceChannelSelected voiceChannelSelectedStore;
|
|
|
|
public final /* synthetic */ class WhenMappings {
|
|
public static final /* synthetic */ int[] $EnumSwitchMapping$0;
|
|
public static final /* synthetic */ int[] $EnumSwitchMapping$1;
|
|
|
|
static {
|
|
KrispOveruseDetector.Status.values();
|
|
int[] iArr = new int[3];
|
|
$EnumSwitchMapping$0 = iArr;
|
|
iArr[KrispOveruseDetector.Status.CPU_OVERUSE.ordinal()] = 1;
|
|
iArr[KrispOveruseDetector.Status.VAD_CPU_OVERUSE.ordinal()] = 2;
|
|
iArr[KrispOveruseDetector.Status.FAILED.ordinal()] = 3;
|
|
StoreUserGuildSettings.SettingsUpdateType.values();
|
|
int[] iArr2 = new int[4];
|
|
$EnumSwitchMapping$1 = iArr2;
|
|
iArr2[StoreUserGuildSettings.SettingsUpdateType.GUILD.ordinal()] = 1;
|
|
iArr2[StoreUserGuildSettings.SettingsUpdateType.CHANNEL.ordinal()] = 2;
|
|
iArr2[StoreUserGuildSettings.SettingsUpdateType.THREAD.ordinal()] = 3;
|
|
iArr2[StoreUserGuildSettings.SettingsUpdateType.CATEGORY.ordinal()] = 4;
|
|
}
|
|
}
|
|
|
|
public StoreUIEventHandler(Context context, StoreMediaEngine storeMediaEngine, StoreChannels storeChannels, StoreVoiceChannelSelected storeVoiceChannelSelected, StoreStageChannels storeStageChannels, StoreUserGuildSettings storeUserGuildSettings) {
|
|
m.checkNotNullParameter(context, "context");
|
|
m.checkNotNullParameter(storeMediaEngine, "mediaEngineStore");
|
|
m.checkNotNullParameter(storeChannels, "channelsStore");
|
|
m.checkNotNullParameter(storeVoiceChannelSelected, "voiceChannelSelectedStore");
|
|
m.checkNotNullParameter(storeStageChannels, "stageChannelsStore");
|
|
m.checkNotNullParameter(storeUserGuildSettings, "storeUserGuildSettings");
|
|
this.context = context;
|
|
this.mediaEngineStore = storeMediaEngine;
|
|
this.channelsStore = storeChannels;
|
|
this.voiceChannelSelectedStore = storeVoiceChannelSelected;
|
|
this.stageChannelsStore = storeStageChannels;
|
|
this.storeUserGuildSettings = storeUserGuildSettings;
|
|
subscribeToStoreEvents();
|
|
}
|
|
|
|
public static final /* synthetic */ void access$handleKrispStatusEvent(StoreUIEventHandler storeUIEventHandler, KrispOveruseDetector.Status status) {
|
|
storeUIEventHandler.handleKrispStatusEvent(status);
|
|
}
|
|
|
|
public static final /* synthetic */ void access$handleUserGuildSettingsEvent(StoreUIEventHandler storeUIEventHandler, StoreUserGuildSettings.Event event) {
|
|
storeUIEventHandler.handleUserGuildSettingsEvent(event);
|
|
}
|
|
|
|
@MainThread
|
|
private final void handleKrispStatusEvent(KrispOveruseDetector.Status status) {
|
|
int i;
|
|
Channel channel;
|
|
StageRoles r0;
|
|
if (status != KrispOveruseDetector.Status.FAILED || (channel = this.channelsStore.getChannel(this.voiceChannelSelectedStore.getSelectedVoiceChannelId())) == null || !ChannelUtils.z(channel) || (r0 = this.stageChannelsStore.m10getMyRolesvisDeB4(channel.h())) == null || !StageRoles.m24isAudienceimpl(r0.m29unboximpl())) {
|
|
int ordinal = status.ordinal();
|
|
if (ordinal == 0) {
|
|
i = R.string.mobile_noise_cancellation_cpu_overuse;
|
|
} else if (ordinal == 1) {
|
|
i = R.string.mobile_noise_cancellation_failed;
|
|
} else if (ordinal == 2) {
|
|
i = R.string.mobile_advanced_voice_activity_cpu_overuse;
|
|
} else {
|
|
throw new NoWhenBranchMatchedException();
|
|
}
|
|
b.a.d.m.g(this.context, i, 0, null, 12);
|
|
}
|
|
}
|
|
|
|
@MainThread
|
|
private final void handleUserGuildSettingsEvent(StoreUserGuildSettings.Event event) {
|
|
int i;
|
|
if (event instanceof StoreUserGuildSettings.Event.SettingsUpdated) {
|
|
int ordinal = ((StoreUserGuildSettings.Event.SettingsUpdated) event).getType().ordinal();
|
|
if (ordinal == 0) {
|
|
i = R.string.server_settings_updated;
|
|
} else if (ordinal == 1) {
|
|
i = R.string.channel_settings_have_been_updated;
|
|
} else if (ordinal == 2) {
|
|
i = R.string.thread_settings_updated;
|
|
} else if (ordinal == 3) {
|
|
i = R.string.category_settings_have_been_updated;
|
|
} else {
|
|
throw new NoWhenBranchMatchedException();
|
|
}
|
|
b.a.d.m.g(this.context, i, 0, null, 12);
|
|
KotlinExtensionsKt.getExhaustive(Unit.a);
|
|
return;
|
|
}
|
|
throw new NoWhenBranchMatchedException();
|
|
}
|
|
|
|
private final void subscribeToStoreEvents() {
|
|
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.ui(this.mediaEngineStore.onKrispStatusEvent()), StoreUIEventHandler.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new StoreUIEventHandler$subscribeToStoreEvents$1(this), 62, (Object) null);
|
|
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.ui(this.storeUserGuildSettings.observeEvents()), StoreUIEventHandler.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new StoreUIEventHandler$subscribeToStoreEvents$2(this), 62, (Object) null);
|
|
}
|
|
}
|