302 lines
19 KiB
Java
302 lines
19 KiB
Java
package com.discord.widgets.stage;
|
|
|
|
import android.content.Context;
|
|
import androidx.annotation.MainThread;
|
|
import androidx.fragment.app.FragmentManager;
|
|
import c.a.d.o;
|
|
import c.q.a.k.a;
|
|
import com.discord.api.channel.Channel;
|
|
import com.discord.stores.StoreChannels;
|
|
import com.discord.stores.StoreGuilds;
|
|
import com.discord.stores.StoreLurking;
|
|
import com.discord.stores.StoreStream;
|
|
import com.discord.stores.StoreUserRelationships;
|
|
import com.discord.stores.StoreVoiceChannelSelected;
|
|
import com.discord.stores.StoreVoiceStates;
|
|
import com.discord.utilities.rx.RxCoroutineUtilsKt;
|
|
import com.discord.utilities.voice.VoiceChannelJoinability;
|
|
import com.discord.utilities.voice.VoiceChannelJoinabilityUtils;
|
|
import d0.l;
|
|
import d0.w.g.b;
|
|
import d0.w.g.c;
|
|
import d0.w.h.a.g;
|
|
import d0.z.d.m;
|
|
import java.util.Set;
|
|
import kotlin.Unit;
|
|
import kotlin.coroutines.Continuation;
|
|
import kotlin.jvm.functions.Function0;
|
|
import kotlinx.coroutines.CoroutineScope;
|
|
import kotlinx.coroutines.Job;
|
|
import rx.Observable;
|
|
import s.a.k;
|
|
/* compiled from: StageChannelJoinHelper.kt */
|
|
public final class StageChannelJoinHelper {
|
|
public static final StageChannelJoinHelper INSTANCE = new StageChannelJoinHelper();
|
|
private static Job lurkJob;
|
|
|
|
public final /* synthetic */ class WhenMappings {
|
|
public static final /* synthetic */ int[] $EnumSwitchMapping$0;
|
|
|
|
static {
|
|
VoiceChannelJoinability.values();
|
|
int[] iArr = new int[5];
|
|
$EnumSwitchMapping$0 = iArr;
|
|
iArr[VoiceChannelJoinability.GUILD_VIDEO_AT_CAPACITY.ordinal()] = 1;
|
|
iArr[VoiceChannelJoinability.PERMISSIONS_MISSING.ordinal()] = 2;
|
|
iArr[VoiceChannelJoinability.CHANNEL_FULL.ordinal()] = 3;
|
|
iArr[VoiceChannelJoinability.CHANNEL_DOES_NOT_EXIST.ordinal()] = 4;
|
|
iArr[VoiceChannelJoinability.CAN_JOIN.ordinal()] = 5;
|
|
}
|
|
}
|
|
|
|
private StageChannelJoinHelper() {
|
|
}
|
|
|
|
public static /* synthetic */ void connectToStage$default(StageChannelJoinHelper stageChannelJoinHelper, Context context, FragmentManager fragmentManager, long j, boolean z2, boolean z3, StoreVoiceChannelSelected storeVoiceChannelSelected, StoreChannels storeChannels, StoreVoiceStates storeVoiceStates, StoreUserRelationships storeUserRelationships, Function0 function0, int i, Object obj) {
|
|
stageChannelJoinHelper.connectToStage(context, fragmentManager, j, (i & 8) != 0 ? false : z2, (i & 16) != 0 ? true : z3, (i & 32) != 0 ? StoreStream.Companion.getVoiceChannelSelected() : storeVoiceChannelSelected, (i & 64) != 0 ? StoreStream.Companion.getChannels() : storeChannels, (i & 128) != 0 ? StoreStream.Companion.getVoiceStates() : storeVoiceStates, (i & 256) != 0 ? StoreStream.Companion.getUserRelationships() : storeUserRelationships, (i & 512) != 0 ? StageChannelJoinHelper$connectToStage$1.INSTANCE : function0);
|
|
}
|
|
|
|
public static /* synthetic */ void lurkAndJoinStage$default(StageChannelJoinHelper stageChannelJoinHelper, Context context, FragmentManager fragmentManager, CoroutineScope coroutineScope, long j, long j2, boolean z2, StoreGuilds storeGuilds, StoreLurking storeLurking, StoreVoiceChannelSelected storeVoiceChannelSelected, int i, Object obj) {
|
|
stageChannelJoinHelper.lurkAndJoinStage(context, fragmentManager, coroutineScope, j, j2, (i & 32) != 0 ? false : z2, (i & 64) != 0 ? StoreStream.Companion.getGuilds() : storeGuilds, (i & 128) != 0 ? StoreStream.Companion.getLurking() : storeLurking, (i & 256) != 0 ? StoreStream.Companion.getVoiceChannelSelected() : storeVoiceChannelSelected);
|
|
}
|
|
|
|
public static /* synthetic */ Object lurkAndJoinStageAsync$default(StageChannelJoinHelper stageChannelJoinHelper, Context context, FragmentManager fragmentManager, long j, long j2, boolean z2, StoreGuilds storeGuilds, StoreLurking storeLurking, StoreVoiceChannelSelected storeVoiceChannelSelected, Continuation continuation, int i, Object obj) {
|
|
return stageChannelJoinHelper.lurkAndJoinStageAsync(context, fragmentManager, j, j2, (i & 16) != 0 ? false : z2, (i & 32) != 0 ? StoreStream.Companion.getGuilds() : storeGuilds, (i & 64) != 0 ? StoreStream.Companion.getLurking() : storeLurking, (i & 128) != 0 ? StoreStream.Companion.getVoiceChannelSelected() : storeVoiceChannelSelected, continuation);
|
|
}
|
|
|
|
@MainThread
|
|
public final void connectToStage(Context context, FragmentManager fragmentManager, long j, boolean z2, boolean z3, StoreVoiceChannelSelected storeVoiceChannelSelected, StoreChannels storeChannels, StoreVoiceStates storeVoiceStates, StoreUserRelationships storeUserRelationships, Function0<Unit> function0) {
|
|
m.checkNotNullParameter(context, "context");
|
|
m.checkNotNullParameter(fragmentManager, "fragmentManager");
|
|
m.checkNotNullParameter(storeVoiceChannelSelected, "voiceChannelSelectedStore");
|
|
m.checkNotNullParameter(storeChannels, "channelsStore");
|
|
m.checkNotNullParameter(storeVoiceStates, "voiceStatesStore");
|
|
m.checkNotNullParameter(storeUserRelationships, "userRelationshipsStore");
|
|
m.checkNotNullParameter(function0, "onCompleted");
|
|
verifyStageJoinability(context, fragmentManager, j, new StageChannelJoinHelper$connectToStage$2(storeChannels, j, storeVoiceStates, storeUserRelationships, z2, storeVoiceChannelSelected, fragmentManager, z3, context, function0));
|
|
}
|
|
|
|
@MainThread
|
|
public final void lurkAndJoinStage(Context context, FragmentManager fragmentManager, CoroutineScope coroutineScope, long j, long j2, boolean z2, StoreGuilds storeGuilds, StoreLurking storeLurking, StoreVoiceChannelSelected storeVoiceChannelSelected) {
|
|
m.checkNotNullParameter(context, "context");
|
|
m.checkNotNullParameter(fragmentManager, "fragmentManager");
|
|
m.checkNotNullParameter(storeGuilds, "guildsStore");
|
|
m.checkNotNullParameter(storeLurking, "lurkingStore");
|
|
m.checkNotNullParameter(storeVoiceChannelSelected, "selectedVoiceChannelStore");
|
|
Job job = lurkJob;
|
|
Job job2 = null;
|
|
if (job != null) {
|
|
a.k(job, null, 1, null);
|
|
}
|
|
if (coroutineScope != null) {
|
|
job2 = a.G(coroutineScope, null, null, new StageChannelJoinHelper$lurkAndJoinStage$1(context, fragmentManager, j, j2, z2, storeGuilds, storeLurking, storeVoiceChannelSelected, null), 3, null);
|
|
}
|
|
lurkJob = job2;
|
|
}
|
|
|
|
/* JADX WARNING: Removed duplicated region for block: B:16:0x00a8 */
|
|
/* JADX WARNING: Removed duplicated region for block: B:24:0x011e */
|
|
/* JADX WARNING: Removed duplicated region for block: B:30:0x0184 A[RETURN] */
|
|
/* JADX WARNING: Removed duplicated region for block: B:31:0x0185 */
|
|
/* JADX WARNING: Removed duplicated region for block: B:34:0x01af */
|
|
/* JADX WARNING: Removed duplicated region for block: B:8:0x0029 */
|
|
public final Object lurkAndJoinStageAsync(Context context, FragmentManager fragmentManager, long j, long j2, boolean z2, StoreGuilds storeGuilds, StoreLurking storeLurking, StoreVoiceChannelSelected storeVoiceChannelSelected, Continuation<? super Boolean> continuation) {
|
|
StageChannelJoinHelper$lurkAndJoinStageAsync$1 stageChannelJoinHelper$lurkAndJoinStageAsync$1;
|
|
int i;
|
|
boolean z3;
|
|
long j3;
|
|
FragmentManager fragmentManager2;
|
|
Context context2;
|
|
StageChannelJoinHelper stageChannelJoinHelper;
|
|
StoreLurking storeLurking2;
|
|
long j4;
|
|
Context context3;
|
|
FragmentManager fragmentManager3;
|
|
StoreLurking storeLurking3;
|
|
long j5;
|
|
long j6;
|
|
StoreVoiceChannelSelected storeVoiceChannelSelected2;
|
|
StageChannelJoinHelper stageChannelJoinHelper2;
|
|
boolean z4;
|
|
Observable<Channel> y2;
|
|
StageChannelJoinHelper stageChannelJoinHelper3;
|
|
Object obj;
|
|
StoreVoiceChannelSelected storeVoiceChannelSelected3;
|
|
Context context4;
|
|
StoreLurking storeLurking4;
|
|
StoreGuilds storeGuilds2;
|
|
FragmentManager fragmentManager4;
|
|
boolean z5;
|
|
if (continuation instanceof StageChannelJoinHelper$lurkAndJoinStageAsync$1) {
|
|
stageChannelJoinHelper$lurkAndJoinStageAsync$1 = (StageChannelJoinHelper$lurkAndJoinStageAsync$1) continuation;
|
|
int i2 = stageChannelJoinHelper$lurkAndJoinStageAsync$1.label;
|
|
if ((i2 & Integer.MIN_VALUE) != 0) {
|
|
stageChannelJoinHelper$lurkAndJoinStageAsync$1.label = i2 - Integer.MIN_VALUE;
|
|
Object obj2 = stageChannelJoinHelper$lurkAndJoinStageAsync$1.result;
|
|
Object coroutine_suspended = c.getCOROUTINE_SUSPENDED();
|
|
i = stageChannelJoinHelper$lurkAndJoinStageAsync$1.label;
|
|
if (i != 0) {
|
|
l.throwOnFailure(obj2);
|
|
storeVoiceChannelSelected.clear();
|
|
stageChannelJoinHelper$lurkAndJoinStageAsync$1.L$0 = this;
|
|
stageChannelJoinHelper$lurkAndJoinStageAsync$1.L$1 = context;
|
|
fragmentManager4 = fragmentManager;
|
|
stageChannelJoinHelper$lurkAndJoinStageAsync$1.L$2 = fragmentManager4;
|
|
storeGuilds2 = storeGuilds;
|
|
stageChannelJoinHelper$lurkAndJoinStageAsync$1.L$3 = storeGuilds2;
|
|
storeLurking4 = storeLurking;
|
|
stageChannelJoinHelper$lurkAndJoinStageAsync$1.L$4 = storeLurking4;
|
|
stageChannelJoinHelper$lurkAndJoinStageAsync$1.L$5 = storeVoiceChannelSelected;
|
|
stageChannelJoinHelper$lurkAndJoinStageAsync$1.J$0 = j;
|
|
stageChannelJoinHelper$lurkAndJoinStageAsync$1.J$1 = j2;
|
|
stageChannelJoinHelper$lurkAndJoinStageAsync$1.Z$0 = z2;
|
|
stageChannelJoinHelper$lurkAndJoinStageAsync$1.label = 1;
|
|
k kVar = new k(b.intercepted(stageChannelJoinHelper$lurkAndJoinStageAsync$1), 1);
|
|
kVar.A();
|
|
storeLurking.startLurking(j, d0.w.h.a.b.boxLong(j2), false, new StageChannelJoinHelper$lurkAndJoinStageAsync$2$1(kVar), new StageChannelJoinHelper$lurkAndJoinStageAsync$2$2(kVar));
|
|
Object u = kVar.u();
|
|
if (u == c.getCOROUTINE_SUSPENDED()) {
|
|
g.probeCoroutineSuspended(stageChannelJoinHelper$lurkAndJoinStageAsync$1);
|
|
}
|
|
if (u == coroutine_suspended) {
|
|
return coroutine_suspended;
|
|
}
|
|
j5 = j;
|
|
j6 = j2;
|
|
stageChannelJoinHelper3 = this;
|
|
obj = u;
|
|
storeVoiceChannelSelected3 = storeVoiceChannelSelected;
|
|
context4 = context;
|
|
z5 = z2;
|
|
} else if (i == 1) {
|
|
boolean z6 = stageChannelJoinHelper$lurkAndJoinStageAsync$1.Z$0;
|
|
j6 = stageChannelJoinHelper$lurkAndJoinStageAsync$1.J$1;
|
|
j5 = stageChannelJoinHelper$lurkAndJoinStageAsync$1.J$0;
|
|
StoreGuilds storeGuilds3 = (StoreGuilds) stageChannelJoinHelper$lurkAndJoinStageAsync$1.L$3;
|
|
context4 = (Context) stageChannelJoinHelper$lurkAndJoinStageAsync$1.L$1;
|
|
l.throwOnFailure(obj2);
|
|
storeVoiceChannelSelected3 = (StoreVoiceChannelSelected) stageChannelJoinHelper$lurkAndJoinStageAsync$1.L$5;
|
|
storeLurking4 = (StoreLurking) stageChannelJoinHelper$lurkAndJoinStageAsync$1.L$4;
|
|
obj = obj2;
|
|
z5 = z6;
|
|
fragmentManager4 = (FragmentManager) stageChannelJoinHelper$lurkAndJoinStageAsync$1.L$2;
|
|
stageChannelJoinHelper3 = (StageChannelJoinHelper) stageChannelJoinHelper$lurkAndJoinStageAsync$1.L$0;
|
|
storeGuilds2 = storeGuilds3;
|
|
} else if (i == 2) {
|
|
z4 = stageChannelJoinHelper$lurkAndJoinStageAsync$1.Z$0;
|
|
j6 = stageChannelJoinHelper$lurkAndJoinStageAsync$1.J$1;
|
|
j5 = stageChannelJoinHelper$lurkAndJoinStageAsync$1.J$0;
|
|
storeVoiceChannelSelected2 = (StoreVoiceChannelSelected) stageChannelJoinHelper$lurkAndJoinStageAsync$1.L$4;
|
|
storeLurking3 = (StoreLurking) stageChannelJoinHelper$lurkAndJoinStageAsync$1.L$3;
|
|
fragmentManager3 = (FragmentManager) stageChannelJoinHelper$lurkAndJoinStageAsync$1.L$2;
|
|
context3 = (Context) stageChannelJoinHelper$lurkAndJoinStageAsync$1.L$1;
|
|
stageChannelJoinHelper2 = (StageChannelJoinHelper) stageChannelJoinHelper$lurkAndJoinStageAsync$1.L$0;
|
|
l.throwOnFailure(obj2);
|
|
y2 = storeVoiceChannelSelected2.observeSelectedChannel().x(StageChannelJoinHelper$lurkAndJoinStageAsync$4.INSTANCE).y();
|
|
m.checkNotNullExpressionValue(y2, "selectedVoiceChannelStor…= null }\n .first()");
|
|
stageChannelJoinHelper$lurkAndJoinStageAsync$1.L$0 = stageChannelJoinHelper2;
|
|
stageChannelJoinHelper$lurkAndJoinStageAsync$1.L$1 = context3;
|
|
stageChannelJoinHelper$lurkAndJoinStageAsync$1.L$2 = fragmentManager3;
|
|
stageChannelJoinHelper$lurkAndJoinStageAsync$1.L$3 = storeLurking3;
|
|
stageChannelJoinHelper$lurkAndJoinStageAsync$1.L$4 = null;
|
|
stageChannelJoinHelper$lurkAndJoinStageAsync$1.J$0 = j5;
|
|
stageChannelJoinHelper$lurkAndJoinStageAsync$1.J$1 = j6;
|
|
stageChannelJoinHelper$lurkAndJoinStageAsync$1.Z$0 = z4;
|
|
stageChannelJoinHelper$lurkAndJoinStageAsync$1.label = 3;
|
|
if (RxCoroutineUtilsKt.awaitSingle(y2, stageChannelJoinHelper$lurkAndJoinStageAsync$1) != coroutine_suspended) {
|
|
return coroutine_suspended;
|
|
}
|
|
z3 = z4;
|
|
stageChannelJoinHelper = stageChannelJoinHelper2;
|
|
j3 = j6;
|
|
j4 = j5;
|
|
storeLurking2 = storeLurking3;
|
|
fragmentManager2 = fragmentManager3;
|
|
context2 = context3;
|
|
connectToStage$default(stageChannelJoinHelper, context2, fragmentManager2, j3, false, z3, null, null, null, null, new StageChannelJoinHelper$lurkAndJoinStageAsync$5(storeLurking2, j4), 488, null);
|
|
return d0.w.h.a.b.boxBoolean(true);
|
|
} else if (i == 3) {
|
|
boolean z7 = stageChannelJoinHelper$lurkAndJoinStageAsync$1.Z$0;
|
|
long j7 = stageChannelJoinHelper$lurkAndJoinStageAsync$1.J$1;
|
|
j4 = stageChannelJoinHelper$lurkAndJoinStageAsync$1.J$0;
|
|
storeLurking2 = (StoreLurking) stageChannelJoinHelper$lurkAndJoinStageAsync$1.L$3;
|
|
l.throwOnFailure(obj2);
|
|
stageChannelJoinHelper = (StageChannelJoinHelper) stageChannelJoinHelper$lurkAndJoinStageAsync$1.L$0;
|
|
z3 = z7;
|
|
j3 = j7;
|
|
fragmentManager2 = (FragmentManager) stageChannelJoinHelper$lurkAndJoinStageAsync$1.L$2;
|
|
context2 = (Context) stageChannelJoinHelper$lurkAndJoinStageAsync$1.L$1;
|
|
connectToStage$default(stageChannelJoinHelper, context2, fragmentManager2, j3, false, z3, null, null, null, null, new StageChannelJoinHelper$lurkAndJoinStageAsync$5(storeLurking2, j4), 488, null);
|
|
return d0.w.h.a.b.boxBoolean(true);
|
|
} else {
|
|
throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
|
|
}
|
|
if (((Unit) obj) != null) {
|
|
return d0.w.h.a.b.boxBoolean(false);
|
|
}
|
|
Observable<Set<Long>> y3 = storeGuilds2.observeGuildIds().x(new StageChannelJoinHelper$lurkAndJoinStageAsync$3(j5)).y();
|
|
m.checkNotNullExpressionValue(y3, "guildsStore\n .obs…in ids }\n .first()");
|
|
stageChannelJoinHelper$lurkAndJoinStageAsync$1.L$0 = stageChannelJoinHelper3;
|
|
stageChannelJoinHelper$lurkAndJoinStageAsync$1.L$1 = context4;
|
|
stageChannelJoinHelper$lurkAndJoinStageAsync$1.L$2 = fragmentManager4;
|
|
stageChannelJoinHelper$lurkAndJoinStageAsync$1.L$3 = storeLurking4;
|
|
stageChannelJoinHelper$lurkAndJoinStageAsync$1.L$4 = storeVoiceChannelSelected3;
|
|
stageChannelJoinHelper$lurkAndJoinStageAsync$1.L$5 = null;
|
|
stageChannelJoinHelper$lurkAndJoinStageAsync$1.J$0 = j5;
|
|
stageChannelJoinHelper$lurkAndJoinStageAsync$1.J$1 = j6;
|
|
stageChannelJoinHelper$lurkAndJoinStageAsync$1.Z$0 = z5;
|
|
stageChannelJoinHelper$lurkAndJoinStageAsync$1.label = 2;
|
|
if (RxCoroutineUtilsKt.awaitSingle(y3, stageChannelJoinHelper$lurkAndJoinStageAsync$1) == coroutine_suspended) {
|
|
return coroutine_suspended;
|
|
}
|
|
storeLurking3 = storeLurking4;
|
|
context3 = context4;
|
|
storeVoiceChannelSelected2 = storeVoiceChannelSelected3;
|
|
stageChannelJoinHelper2 = stageChannelJoinHelper3;
|
|
fragmentManager3 = fragmentManager4;
|
|
z4 = z5;
|
|
y2 = storeVoiceChannelSelected2.observeSelectedChannel().x(StageChannelJoinHelper$lurkAndJoinStageAsync$4.INSTANCE).y();
|
|
m.checkNotNullExpressionValue(y2, "selectedVoiceChannelStor…= null }\n .first()");
|
|
stageChannelJoinHelper$lurkAndJoinStageAsync$1.L$0 = stageChannelJoinHelper2;
|
|
stageChannelJoinHelper$lurkAndJoinStageAsync$1.L$1 = context3;
|
|
stageChannelJoinHelper$lurkAndJoinStageAsync$1.L$2 = fragmentManager3;
|
|
stageChannelJoinHelper$lurkAndJoinStageAsync$1.L$3 = storeLurking3;
|
|
stageChannelJoinHelper$lurkAndJoinStageAsync$1.L$4 = null;
|
|
stageChannelJoinHelper$lurkAndJoinStageAsync$1.J$0 = j5;
|
|
stageChannelJoinHelper$lurkAndJoinStageAsync$1.J$1 = j6;
|
|
stageChannelJoinHelper$lurkAndJoinStageAsync$1.Z$0 = z4;
|
|
stageChannelJoinHelper$lurkAndJoinStageAsync$1.label = 3;
|
|
if (RxCoroutineUtilsKt.awaitSingle(y2, stageChannelJoinHelper$lurkAndJoinStageAsync$1) != coroutine_suspended) {
|
|
}
|
|
}
|
|
}
|
|
stageChannelJoinHelper$lurkAndJoinStageAsync$1 = new StageChannelJoinHelper$lurkAndJoinStageAsync$1(this, continuation);
|
|
Object obj2 = stageChannelJoinHelper$lurkAndJoinStageAsync$1.result;
|
|
Object coroutine_suspended = c.getCOROUTINE_SUSPENDED();
|
|
i = stageChannelJoinHelper$lurkAndJoinStageAsync$1.label;
|
|
if (i != 0) {
|
|
}
|
|
if (((Unit) obj) != null) {
|
|
}
|
|
}
|
|
|
|
@MainThread
|
|
public final void verifyStageJoinability(Context context, FragmentManager fragmentManager, long j, Function0<Unit> function0) {
|
|
m.checkNotNullParameter(context, "context");
|
|
m.checkNotNullParameter(fragmentManager, "fragmentManager");
|
|
m.checkNotNullParameter(function0, "onJoinVerified");
|
|
int ordinal = VoiceChannelJoinabilityUtils.INSTANCE.getJoinability(j).ordinal();
|
|
if (ordinal == 0) {
|
|
function0.mo1invoke();
|
|
} else if (ordinal == 1) {
|
|
o.g(context, 2131887275, 0, null, 12);
|
|
} else if (ordinal == 2) {
|
|
c.a.a.l.j.a(fragmentManager);
|
|
} else if (ordinal == 3) {
|
|
o.g(context, 2131894269, 0, null, 12);
|
|
} else if (ordinal == 4) {
|
|
o.g(context, 2131889950, 0, null, 12);
|
|
}
|
|
}
|
|
}
|