108 lines
5.1 KiB
Java
108 lines
5.1 KiB
Java
package com.discord.utilities.guildscheduledevent;
|
|
|
|
import android.content.Context;
|
|
import android.text.format.DateUtils;
|
|
import c.a.k.b;
|
|
import com.discord.R;
|
|
import com.discord.api.guildscheduledevent.GuildScheduledEvent;
|
|
import com.discord.api.guildscheduledevent.GuildScheduledEventStatus;
|
|
import com.discord.utilities.time.ClockFactory;
|
|
import com.discord.utilities.time.TimeUtils;
|
|
import d0.z.d.m;
|
|
import java.text.SimpleDateFormat;
|
|
import java.util.Collection;
|
|
import java.util.Iterator;
|
|
import java.util.Locale;
|
|
/* compiled from: GuildScheduledEventUtilities.kt */
|
|
public final class GuildScheduledEventUtilitiesKt {
|
|
|
|
public final /* synthetic */ class WhenMappings {
|
|
public static final /* synthetic */ int[] $EnumSwitchMapping$0;
|
|
public static final /* synthetic */ int[] $EnumSwitchMapping$1;
|
|
|
|
static {
|
|
GuildScheduledEventTiming.values();
|
|
int[] iArr = new int[7];
|
|
$EnumSwitchMapping$0 = iArr;
|
|
iArr[GuildScheduledEventTiming.LIVE.ordinal()] = 1;
|
|
GuildScheduledEventTiming.values();
|
|
int[] iArr2 = new int[7];
|
|
$EnumSwitchMapping$1 = iArr2;
|
|
iArr2[GuildScheduledEventTiming.EXPIRED.ordinal()] = 1;
|
|
iArr2[GuildScheduledEventTiming.NOW.ordinal()] = 2;
|
|
iArr2[GuildScheduledEventTiming.SOON.ordinal()] = 3;
|
|
iArr2[GuildScheduledEventTiming.TODAY.ordinal()] = 4;
|
|
iArr2[GuildScheduledEventTiming.TOMORROW.ordinal()] = 5;
|
|
}
|
|
}
|
|
|
|
public static final CharSequence getEventStartingTimeString(long j, Context context) {
|
|
m.checkNotNullParameter(context, "context");
|
|
int ordinal = getEventTiming(j).ordinal();
|
|
if (ordinal == 1 || ordinal == 2) {
|
|
return b.h(context, R.string.guild_event_date_at_time, new Object[]{DateUtils.getRelativeTimeSpanString(j, ClockFactory.get().currentTimeMillis(), 86400000), new SimpleDateFormat("h:mm a", Locale.getDefault()).format(Long.valueOf(j))}, null, 4);
|
|
}
|
|
if (ordinal == 3) {
|
|
return b.h(context, R.string.starting_in_minutes, new Object[]{Integer.valueOf(minutesRelativeToTime(j))}, null, 4);
|
|
}
|
|
if (ordinal == 4 || ordinal == 6) {
|
|
return b.h(context, R.string.starting_soon, new Object[0], null, 4);
|
|
}
|
|
String format = new SimpleDateFormat("EEE, MMM d · h:mm a", Locale.getDefault()).format(Long.valueOf(j));
|
|
m.checkNotNullExpressionValue(format, "SimpleDateFormat(\"EEE, M…lt())\n .format(this)");
|
|
return format;
|
|
}
|
|
|
|
public static final CharSequence getEventStartingTimeString(GuildScheduledEvent guildScheduledEvent, Context context) {
|
|
m.checkNotNullParameter(guildScheduledEvent, "$this$getEventStartingTimeString");
|
|
m.checkNotNullParameter(context, "context");
|
|
return getEventTiming(guildScheduledEvent).ordinal() != 5 ? getEventStartingTimeString(guildScheduledEvent.j().g(), context) : b.h(context, R.string.stage_channel_live_now, new Object[0], null, 4);
|
|
}
|
|
|
|
public static final GuildScheduledEventTiming getEventTiming(long j) {
|
|
int minutesRelativeToTime = minutesRelativeToTime(j);
|
|
return minutesRelativeToTime <= -60 ? GuildScheduledEventTiming.EXPIRED : minutesRelativeToTime <= 0 ? GuildScheduledEventTiming.NOW : minutesRelativeToTime <= 30 ? GuildScheduledEventTiming.SOON : DateUtils.isToday(j) ? GuildScheduledEventTiming.TODAY : DateUtils.isToday(j - 86400000) ? GuildScheduledEventTiming.TOMORROW : GuildScheduledEventTiming.LATER;
|
|
}
|
|
|
|
public static final GuildScheduledEventTiming getEventTiming(GuildScheduledEvent guildScheduledEvent) {
|
|
m.checkNotNullParameter(guildScheduledEvent, "$this$getEventTiming");
|
|
return guildScheduledEvent.k() == GuildScheduledEventStatus.ACTIVE ? GuildScheduledEventTiming.LIVE : getEventTiming(guildScheduledEvent.j().g());
|
|
}
|
|
|
|
public static final GuildScheduledEvent getLiveEvent(Collection<GuildScheduledEvent> collection) {
|
|
Object obj;
|
|
boolean z2;
|
|
m.checkNotNullParameter(collection, "$this$getLiveEvent");
|
|
Iterator<T> it = collection.iterator();
|
|
while (true) {
|
|
if (!it.hasNext()) {
|
|
obj = null;
|
|
break;
|
|
}
|
|
obj = it.next();
|
|
if (getEventTiming((GuildScheduledEvent) obj) == GuildScheduledEventTiming.LIVE) {
|
|
z2 = true;
|
|
continue;
|
|
} else {
|
|
z2 = false;
|
|
continue;
|
|
}
|
|
if (z2) {
|
|
break;
|
|
}
|
|
}
|
|
return (GuildScheduledEvent) obj;
|
|
}
|
|
|
|
public static final boolean hasLiveEvent(Collection<GuildScheduledEvent> collection) {
|
|
m.checkNotNullParameter(collection, "$this$hasLiveEvent");
|
|
return getLiveEvent(collection) != null;
|
|
}
|
|
|
|
public static final int minutesRelativeToTime(long j) {
|
|
TimeUtils timeUtils = TimeUtils.INSTANCE;
|
|
int minutesFromMillis = timeUtils.getMinutesFromMillis(j - ClockFactory.get().currentTimeMillis());
|
|
return minutesFromMillis != 0 ? minutesFromMillis : timeUtils.getMinutesFromMillis(ClockFactory.get().currentTimeMillis() - j) * -1;
|
|
}
|
|
}
|