244 lines
14 KiB
Java
244 lines
14 KiB
Java
package com.discord.widgets.guildscheduledevent;
|
|
|
|
import android.content.Context;
|
|
import android.content.Intent;
|
|
import android.os.Bundle;
|
|
import android.view.View;
|
|
import android.widget.TextView;
|
|
import androidx.activity.result.ActivityResultLauncher;
|
|
import androidx.constraintlayout.widget.ConstraintLayout;
|
|
import androidx.fragment.app.Fragment;
|
|
import androidx.fragment.app.FragmentManager;
|
|
import androidx.fragment.app.FragmentViewModelLazyKt;
|
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
|
import androidx.recyclerview.widget.RecyclerView;
|
|
import c.a.d.f0;
|
|
import c.a.d.h0;
|
|
import c.d.b.a.a;
|
|
import com.airbnb.lottie.parser.AnimatableValueParser;
|
|
import com.discord.R;
|
|
import com.discord.api.channel.Channel;
|
|
import com.discord.api.guildscheduledevent.GuildScheduledEventStatus;
|
|
import com.discord.app.AppBottomSheet;
|
|
import com.discord.app.AppTransitionActivity;
|
|
import com.discord.databinding.WidgetGuildScheduledEventListBottomSheetBinding;
|
|
import com.discord.utilities.intent.IntentUtilsKt;
|
|
import com.discord.utilities.recycler.SpaceBetweenItemDecoration;
|
|
import com.discord.utilities.resources.StringResourceUtilsKt;
|
|
import com.discord.utilities.rx.ObservableExtensionsKt;
|
|
import com.discord.utilities.viewbinding.FragmentViewBindingDelegate;
|
|
import com.discord.utilities.viewbinding.FragmentViewBindingDelegateKt;
|
|
import com.discord.widgets.guildscheduledevent.GuildScheduledEventListItem;
|
|
import com.discord.widgets.guildscheduledevent.GuildScheduledEventListViewModel;
|
|
import com.discord.widgets.guildscheduledevent.WidgetPreviewGuildScheduledEvent;
|
|
import com.discord.widgets.stage.StageChannelJoinHelper;
|
|
import com.discord.widgets.stage.start.StageEventsGuildsFeatureFlag;
|
|
import com.discord.widgets.voice.fullscreen.WidgetCallFullscreen;
|
|
import d0.g;
|
|
import d0.z.d.a0;
|
|
import d0.z.d.m;
|
|
import java.util.Objects;
|
|
import kotlin.Lazy;
|
|
import kotlin.jvm.functions.Function0;
|
|
import kotlin.jvm.functions.Function1;
|
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
|
import kotlin.reflect.KProperty;
|
|
/* compiled from: WidgetGuildScheduledEventListBottomSheet.kt */
|
|
public final class WidgetGuildScheduledEventListBottomSheet extends AppBottomSheet {
|
|
public static final /* synthetic */ KProperty[] $$delegatedProperties = {a.a0(WidgetGuildScheduledEventListBottomSheet.class, "binding", "getBinding()Lcom/discord/databinding/WidgetGuildScheduledEventListBottomSheetBinding;", 0)};
|
|
public static final Companion Companion = new Companion(null);
|
|
private GuildScheduledEventListAdapter adapter;
|
|
private final FragmentViewBindingDelegate binding$delegate = FragmentViewBindingDelegateKt.viewBinding$default(this, WidgetGuildScheduledEventListBottomSheet$binding$2.INSTANCE, null, 2, null);
|
|
private final Lazy channelId$delegate = g.lazy(new WidgetGuildScheduledEventListBottomSheet$channelId$2(this));
|
|
private final Lazy guildId$delegate = g.lazy(new WidgetGuildScheduledEventListBottomSheet$guildId$2(this));
|
|
private final ActivityResultLauncher<Intent> previewLauncher;
|
|
private final Lazy viewModel$delegate;
|
|
|
|
/* compiled from: WidgetGuildScheduledEventListBottomSheet.kt */
|
|
public static final class Companion {
|
|
private Companion() {
|
|
}
|
|
|
|
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
|
|
this();
|
|
}
|
|
|
|
public static /* synthetic */ void show$default(Companion companion, FragmentManager fragmentManager, long j, Long l, int i, Object obj) {
|
|
if ((i & 4) != 0) {
|
|
l = null;
|
|
}
|
|
companion.show(fragmentManager, j, l);
|
|
}
|
|
|
|
public final void show(FragmentManager fragmentManager, long j, Long l) {
|
|
m.checkNotNullParameter(fragmentManager, "fragmentManager");
|
|
if (StageEventsGuildsFeatureFlag.Companion.getINSTANCE().canGuildAccessStageEvents(j)) {
|
|
WidgetGuildScheduledEventListBottomSheet widgetGuildScheduledEventListBottomSheet = new WidgetGuildScheduledEventListBottomSheet();
|
|
Bundle I = a.I("com.discord.intent.extra.EXTRA_GUILD_ID", j);
|
|
if (l != null) {
|
|
I.putLong("com.discord.intent.extra.EXTRA_CHANNEL_ID", l.longValue());
|
|
}
|
|
widgetGuildScheduledEventListBottomSheet.setArguments(I);
|
|
widgetGuildScheduledEventListBottomSheet.show(fragmentManager, WidgetGuildScheduledEventListBottomSheet.class.getName());
|
|
}
|
|
}
|
|
}
|
|
|
|
public WidgetGuildScheduledEventListBottomSheet() {
|
|
super(false, 1, null);
|
|
WidgetGuildScheduledEventListBottomSheet$viewModel$2 widgetGuildScheduledEventListBottomSheet$viewModel$2 = new WidgetGuildScheduledEventListBottomSheet$viewModel$2(this);
|
|
f0 f0Var = new f0(this);
|
|
this.viewModel$delegate = FragmentViewModelLazyKt.createViewModelLazy(this, a0.getOrCreateKotlinClass(GuildScheduledEventListViewModel.class), new WidgetGuildScheduledEventListBottomSheet$appViewModels$$inlined$viewModels$1(f0Var), new h0(widgetGuildScheduledEventListBottomSheet$viewModel$2));
|
|
this.previewLauncher = WidgetPreviewGuildScheduledEvent.Companion.registerForResult$default(WidgetPreviewGuildScheduledEvent.Companion, this, new WidgetGuildScheduledEventListBottomSheet$previewLauncher$1(this), null, 4, null);
|
|
}
|
|
|
|
public static final /* synthetic */ void access$configureUi(WidgetGuildScheduledEventListBottomSheet widgetGuildScheduledEventListBottomSheet, GuildScheduledEventListViewModel.ViewState viewState) {
|
|
widgetGuildScheduledEventListBottomSheet.configureUi(viewState);
|
|
}
|
|
|
|
public static final /* synthetic */ Long access$getChannelId$p(WidgetGuildScheduledEventListBottomSheet widgetGuildScheduledEventListBottomSheet) {
|
|
return widgetGuildScheduledEventListBottomSheet.getChannelId();
|
|
}
|
|
|
|
public static final /* synthetic */ long access$getGuildId$p(WidgetGuildScheduledEventListBottomSheet widgetGuildScheduledEventListBottomSheet) {
|
|
return widgetGuildScheduledEventListBottomSheet.getGuildId();
|
|
}
|
|
|
|
public static final /* synthetic */ void access$onEventStartClicked(WidgetGuildScheduledEventListBottomSheet widgetGuildScheduledEventListBottomSheet, GuildScheduledEventListItem.Event event) {
|
|
widgetGuildScheduledEventListBottomSheet.onEventStartClicked(event);
|
|
}
|
|
|
|
public static final /* synthetic */ void access$onPreviewEventResult(WidgetGuildScheduledEventListBottomSheet widgetGuildScheduledEventListBottomSheet, Intent intent) {
|
|
widgetGuildScheduledEventListBottomSheet.onPreviewEventResult(intent);
|
|
}
|
|
|
|
public static final /* synthetic */ void access$onRsvpClicked(WidgetGuildScheduledEventListBottomSheet widgetGuildScheduledEventListBottomSheet, GuildScheduledEventListItem.Event event) {
|
|
widgetGuildScheduledEventListBottomSheet.onRsvpClicked(event);
|
|
}
|
|
|
|
private final void configureUi(GuildScheduledEventListViewModel.ViewState viewState) {
|
|
if (!(viewState instanceof GuildScheduledEventListViewModel.ViewState.Loaded)) {
|
|
viewState = null;
|
|
}
|
|
GuildScheduledEventListViewModel.ViewState.Loaded loaded = (GuildScheduledEventListViewModel.ViewState.Loaded) viewState;
|
|
if (loaded != null) {
|
|
TextView textView = getBinding().e;
|
|
m.checkNotNullExpressionValue(textView, "binding.guildScheduledEventListToolbarTitle");
|
|
Context requireContext = requireContext();
|
|
m.checkNotNullExpressionValue(requireContext, "requireContext()");
|
|
int i = 0;
|
|
textView.setText(StringResourceUtilsKt.getI18nPluralString(requireContext, R.plurals.guild_events_plural_number, loaded.getGuildScheduledEvents().size(), Integer.valueOf(loaded.getGuildScheduledEvents().size())));
|
|
GuildScheduledEventListAdapter guildScheduledEventListAdapter = this.adapter;
|
|
if (guildScheduledEventListAdapter == null) {
|
|
m.throwUninitializedPropertyAccessException("adapter");
|
|
}
|
|
guildScheduledEventListAdapter.setData(loaded.getGuildScheduledEvents());
|
|
TextView textView2 = getBinding().b;
|
|
m.checkNotNullExpressionValue(textView2, "binding.createEventButton");
|
|
textView2.setVisibility(loaded.getCanCreateEvents() ? 0 : 8);
|
|
ConstraintLayout constraintLayout = getBinding().f1874c;
|
|
m.checkNotNullExpressionValue(constraintLayout, "binding.guildScheduledEventListEmptyState");
|
|
if (!loaded.getGuildScheduledEvents().isEmpty()) {
|
|
i = 8;
|
|
}
|
|
constraintLayout.setVisibility(i);
|
|
}
|
|
}
|
|
|
|
private final WidgetGuildScheduledEventListBottomSheetBinding getBinding() {
|
|
return (WidgetGuildScheduledEventListBottomSheetBinding) this.binding$delegate.getValue((Fragment) this, $$delegatedProperties[0]);
|
|
}
|
|
|
|
private final Long getChannelId() {
|
|
return (Long) this.channelId$delegate.getValue();
|
|
}
|
|
|
|
private final long getGuildId() {
|
|
return ((Number) this.guildId$delegate.getValue()).longValue();
|
|
}
|
|
|
|
private final GuildScheduledEventListViewModel getViewModel() {
|
|
return (GuildScheduledEventListViewModel) this.viewModel$delegate.getValue();
|
|
}
|
|
|
|
private final void onEventStartClicked(GuildScheduledEventListItem.Event event) {
|
|
if (event.getCanStartEvent()) {
|
|
WidgetPreviewGuildScheduledEvent.Companion companion = WidgetPreviewGuildScheduledEvent.Companion;
|
|
Context requireContext = requireContext();
|
|
m.checkNotNullExpressionValue(requireContext, "requireContext()");
|
|
companion.launch(requireContext, GuildScheduledEventModelKt.toModel(event.getEvent()), Long.valueOf(event.getEvent().g()), this.previewLauncher);
|
|
}
|
|
}
|
|
|
|
private final void onPreviewEventResult(Intent intent) {
|
|
Long longExtraOrNull;
|
|
if (intent != null && (longExtraOrNull = IntentUtilsKt.getLongExtraOrNull(intent, "com.discord.intent.extra.EXTRA_CHANNEL_ID")) != null) {
|
|
long longValue = longExtraOrNull.longValue();
|
|
WidgetCallFullscreen.Companion companion = WidgetCallFullscreen.Companion;
|
|
Context requireContext = requireContext();
|
|
m.checkNotNullExpressionValue(requireContext, "requireContext()");
|
|
WidgetCallFullscreen.Companion.launch$default(companion, requireContext, longValue, true, null, AppTransitionActivity.Transition.TYPE_SLIDE_VERTICAL_WITH_FADE, 8, null);
|
|
dismiss();
|
|
}
|
|
}
|
|
|
|
private final void onRsvpClicked(GuildScheduledEventListItem.Event event) {
|
|
if (event.getEvent().k() == GuildScheduledEventStatus.ACTIVE) {
|
|
Channel channel = event.getChannel();
|
|
if (channel != null && AnimatableValueParser.x1(channel)) {
|
|
StageChannelJoinHelper stageChannelJoinHelper = StageChannelJoinHelper.INSTANCE;
|
|
Context requireContext = requireContext();
|
|
m.checkNotNullExpressionValue(requireContext, "requireContext()");
|
|
FragmentManager parentFragmentManager = getParentFragmentManager();
|
|
m.checkNotNullExpressionValue(parentFragmentManager, "parentFragmentManager");
|
|
StageChannelJoinHelper.connectToStage$default(stageChannelJoinHelper, requireContext, parentFragmentManager, channel.h(), false, false, null, null, null, null, new WidgetGuildScheduledEventListBottomSheet$onRsvpClicked$$inlined$let$lambda$1(this), 504, null);
|
|
return;
|
|
}
|
|
return;
|
|
}
|
|
if (!event.isRsvped()) {
|
|
c.a.d.m.g(getContext(), R.string.guild_event_interested_notification, 0, null, 12);
|
|
}
|
|
getViewModel().toggleRsvp(event.getEvent());
|
|
}
|
|
|
|
@Override // com.discord.app.AppBottomSheet
|
|
public int getContentViewResId() {
|
|
return R.layout.widget_guild_scheduled_event_list_bottom_sheet;
|
|
}
|
|
|
|
@Override // com.discord.app.AppBottomSheet, androidx.fragment.app.Fragment
|
|
public void onResume() {
|
|
super.onResume();
|
|
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.bindToComponentLifecycle$default(getViewModel().observeViewState(), this, null, 2, null), WidgetGuildScheduledEventListBottomSheet.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new WidgetGuildScheduledEventListBottomSheet$onResume$1(this), 62, (Object) null);
|
|
}
|
|
|
|
@Override // com.discord.app.AppBottomSheet, androidx.fragment.app.Fragment
|
|
public void onViewCreated(View view, Bundle bundle) {
|
|
m.checkNotNullParameter(view, "view");
|
|
super.onViewCreated(view, bundle);
|
|
RecyclerView recyclerView = getBinding().d;
|
|
m.checkNotNullExpressionValue(recyclerView, "binding.guildScheduledEventListRecyclerView");
|
|
this.adapter = new GuildScheduledEventListAdapter(recyclerView, new WidgetGuildScheduledEventListBottomSheet$onViewCreated$1(this), new WidgetGuildScheduledEventListBottomSheet$onViewCreated$2(this));
|
|
RecyclerView recyclerView2 = getBinding().d;
|
|
GuildScheduledEventListAdapter guildScheduledEventListAdapter = this.adapter;
|
|
if (guildScheduledEventListAdapter == null) {
|
|
m.throwUninitializedPropertyAccessException("adapter");
|
|
}
|
|
recyclerView2.setAdapter(guildScheduledEventListAdapter);
|
|
recyclerView2.setLayoutManager(new LinearLayoutManager(recyclerView2.getContext()));
|
|
Context context = recyclerView2.getContext();
|
|
m.checkNotNullExpressionValue(context, "context");
|
|
RecyclerView.LayoutManager layoutManager = recyclerView2.getLayoutManager();
|
|
Objects.requireNonNull(layoutManager, "null cannot be cast to non-null type androidx.recyclerview.widget.LinearLayoutManager");
|
|
int orientation = ((LinearLayoutManager) layoutManager).getOrientation();
|
|
GuildScheduledEventListAdapter guildScheduledEventListAdapter2 = this.adapter;
|
|
if (guildScheduledEventListAdapter2 == null) {
|
|
m.throwUninitializedPropertyAccessException("adapter");
|
|
}
|
|
recyclerView2.addItemDecoration(new SpaceBetweenItemDecoration(context, orientation, guildScheduledEventListAdapter2, 0, 0, 24, null));
|
|
recyclerView2.setItemAnimator(null);
|
|
getBinding().b.setOnClickListener(new WidgetGuildScheduledEventListBottomSheet$onViewCreated$4(this));
|
|
}
|
|
}
|