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

337 lines
21 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.ImageView;
import android.widget.ProgressBar;
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.a.k.b;
import c.d.b.a.a;
import com.discord.R;
import com.discord.api.channel.Channel;
import com.discord.app.AppBottomSheet;
import com.discord.databinding.WidgetGuildScheduledEventDetailsBottomSheetBinding;
import com.discord.models.guild.UserGuildMember;
import com.discord.stores.StoreNotices;
import com.discord.stores.StoreStream;
import com.discord.utilities.extensions.SimpleDraweeViewExtensionsKt;
import com.discord.utilities.font.FontUtils;
import com.discord.utilities.icon.IconUtils;
import com.discord.utilities.images.MGImages;
import com.discord.utilities.resources.StringResourceUtilsKt;
import com.discord.utilities.rx.ObservableExtensionsKt;
import com.discord.utilities.view.extensions.ViewExtensions;
import com.discord.utilities.view.text.LinkifiedTextView;
import com.discord.utilities.viewbinding.FragmentViewBindingDelegate;
import com.discord.utilities.viewbinding.FragmentViewBindingDelegateKt;
import com.discord.views.segmentedcontrol.CardSegment;
import com.discord.views.segmentedcontrol.SegmentedControlContainer;
import com.discord.widgets.guildscheduledevent.GuildScheduledEventDetailsViewModel;
import com.discord.widgets.guildscheduledevent.GuildScheduledEventLocationInfo;
import com.discord.widgets.home.WidgetHome;
import com.facebook.drawee.view.SimpleDraweeView;
import d0.g;
import d0.t.m;
import d0.z.d.a0;
import kotlin.Lazy;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.reflect.KProperty;
/* compiled from: WidgetGuildScheduledEventDetailsBottomSheet.kt */
public final class WidgetGuildScheduledEventDetailsBottomSheet extends AppBottomSheet {
public static final /* synthetic */ KProperty[] $$delegatedProperties = {a.b0(WidgetGuildScheduledEventDetailsBottomSheet.class, "binding", "getBinding()Lcom/discord/databinding/WidgetGuildScheduledEventDetailsBottomSheetBinding;", 0)};
public static final Companion Companion = new Companion(null);
private GuildScheduledEventRsvpUserListAdapter adapter;
private final FragmentViewBindingDelegate binding$delegate = FragmentViewBindingDelegateKt.viewBinding$default(this, WidgetGuildScheduledEventDetailsBottomSheet$binding$2.INSTANCE, null, 2, null);
private final Lazy descriptionParser$delegate = g.lazy(new WidgetGuildScheduledEventDetailsBottomSheet$descriptionParser$2(this));
private final Lazy guildScheduledEventId$delegate = g.lazy(new WidgetGuildScheduledEventDetailsBottomSheet$guildScheduledEventId$2(this));
private final Lazy locationParser$delegate = g.lazy(WidgetGuildScheduledEventDetailsBottomSheet$locationParser$2.INSTANCE);
private final ActivityResultLauncher<Intent> previewLauncher;
private final Lazy viewModel$delegate;
/* compiled from: WidgetGuildScheduledEventDetailsBottomSheet.kt */
public static final class Companion {
private Companion() {
}
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
this();
}
public final void enqueue(long j) {
StoreNotices notices = StoreStream.Companion.getNotices();
String s2 = a.s("EVENTDETAILS-", j);
notices.requestToShow(new StoreNotices.Notice(s2, null, 0, 0, false, m.listOf(a0.getOrCreateKotlinClass(WidgetHome.class)), 0, false, 0, new WidgetGuildScheduledEventDetailsBottomSheet$Companion$enqueue$guildScheduledEventDetailsNotice$1(j, notices, s2), FontUtils.MAX_FONT_SCALING, null));
}
public final void handleInvalidEvent(Context context) {
d0.z.d.m.checkNotNullParameter(context, "context");
c.a.d.m.g(context, R.string.inaccessible_channel_link_title, 0, null, 12);
}
public final void show(FragmentManager fragmentManager, long j) {
d0.z.d.m.checkNotNullParameter(fragmentManager, "fragmentManager");
WidgetGuildScheduledEventDetailsBottomSheet widgetGuildScheduledEventDetailsBottomSheet = new WidgetGuildScheduledEventDetailsBottomSheet();
Bundle bundle = new Bundle();
bundle.putLong("com.discord.intent.extra.EXTRA_GUILD_SCHEDULED_EVENT_ID", j);
widgetGuildScheduledEventDetailsBottomSheet.setArguments(bundle);
widgetGuildScheduledEventDetailsBottomSheet.show(fragmentManager, WidgetGuildScheduledEventDetailsBottomSheet.class.getName());
}
}
public final /* synthetic */ class WhenMappings {
public static final /* synthetic */ int[] $EnumSwitchMapping$0;
static {
EventDetailsRsvpUsersFetchState.values();
int[] iArr = new int[4];
$EnumSwitchMapping$0 = iArr;
iArr[EventDetailsRsvpUsersFetchState.LOADING.ordinal()] = 1;
iArr[EventDetailsRsvpUsersFetchState.EMPTY.ordinal()] = 2;
iArr[EventDetailsRsvpUsersFetchState.ERROR.ordinal()] = 3;
iArr[EventDetailsRsvpUsersFetchState.SUCCESS.ordinal()] = 4;
}
}
public WidgetGuildScheduledEventDetailsBottomSheet() {
super(false, 1, null);
WidgetGuildScheduledEventDetailsBottomSheet$viewModel$2 widgetGuildScheduledEventDetailsBottomSheet$viewModel$2 = new WidgetGuildScheduledEventDetailsBottomSheet$viewModel$2(this);
f0 f0Var = new f0(this);
this.viewModel$delegate = FragmentViewModelLazyKt.createViewModelLazy(this, a0.getOrCreateKotlinClass(GuildScheduledEventDetailsViewModel.class), new WidgetGuildScheduledEventDetailsBottomSheet$appViewModels$$inlined$viewModels$1(f0Var), new h0(widgetGuildScheduledEventDetailsBottomSheet$viewModel$2));
this.previewLauncher = WidgetPreviewGuildScheduledEvent.Companion.createJoinOnStartActivityRegistration(this, new WidgetGuildScheduledEventDetailsBottomSheet$previewLauncher$1(this));
}
public static final /* synthetic */ void access$configureUi(WidgetGuildScheduledEventDetailsBottomSheet widgetGuildScheduledEventDetailsBottomSheet, GuildScheduledEventDetailsViewModel.ViewState viewState) {
widgetGuildScheduledEventDetailsBottomSheet.configureUi(viewState);
}
public static final /* synthetic */ long access$getGuildScheduledEventId$p(WidgetGuildScheduledEventDetailsBottomSheet widgetGuildScheduledEventDetailsBottomSheet) {
return widgetGuildScheduledEventDetailsBottomSheet.getGuildScheduledEventId();
}
public static final /* synthetic */ ActivityResultLauncher access$getPreviewLauncher$p(WidgetGuildScheduledEventDetailsBottomSheet widgetGuildScheduledEventDetailsBottomSheet) {
return widgetGuildScheduledEventDetailsBottomSheet.previewLauncher;
}
public static final /* synthetic */ GuildScheduledEventDetailsViewModel access$getViewModel$p(WidgetGuildScheduledEventDetailsBottomSheet widgetGuildScheduledEventDetailsBottomSheet) {
return widgetGuildScheduledEventDetailsBottomSheet.getViewModel();
}
private final void configureForRsvpUsersFetchState(EventDetailsRsvpUsersFetchState eventDetailsRsvpUsersFetchState) {
ProgressBar progressBar = getBinding().f1912s;
d0.z.d.m.checkNotNullExpressionValue(progressBar, "binding.loadingIndicator");
progressBar.setVisibility(8);
ConstraintLayout constraintLayout = getBinding().n;
d0.z.d.m.checkNotNullExpressionValue(constraintLayout, "binding.guildScheduledEventEmptyOrErrorContainer");
constraintLayout.setVisibility(8);
RecyclerView recyclerView = getBinding().r;
d0.z.d.m.checkNotNullExpressionValue(recyclerView, "binding.guildScheduledEventRsvpListRecyclerView");
recyclerView.setVisibility(8);
int ordinal = eventDetailsRsvpUsersFetchState.ordinal();
if (ordinal == 0) {
ProgressBar progressBar2 = getBinding().f1912s;
d0.z.d.m.checkNotNullExpressionValue(progressBar2, "binding.loadingIndicator");
progressBar2.setVisibility(0);
} else if (ordinal == 1) {
ConstraintLayout constraintLayout2 = getBinding().n;
d0.z.d.m.checkNotNullExpressionValue(constraintLayout2, "binding.guildScheduledEventEmptyOrErrorContainer");
constraintLayout2.setVisibility(0);
TextView textView = getBinding().o;
d0.z.d.m.checkNotNullExpressionValue(textView, "binding.guildScheduledEventEmptyOrErrorTitle");
b.n(textView, R.string.guild_event_details_user_list_fetch_error, new Object[0], null, 4);
} else if (ordinal == 2) {
ConstraintLayout constraintLayout3 = getBinding().n;
d0.z.d.m.checkNotNullExpressionValue(constraintLayout3, "binding.guildScheduledEventEmptyOrErrorContainer");
constraintLayout3.setVisibility(0);
TextView textView2 = getBinding().o;
d0.z.d.m.checkNotNullExpressionValue(textView2, "binding.guildScheduledEventEmptyOrErrorTitle");
b.n(textView2, R.string.guild_event_details_user_list_empty_title, new Object[0], null, 4);
} else if (ordinal == 3) {
RecyclerView recyclerView2 = getBinding().r;
d0.z.d.m.checkNotNullExpressionValue(recyclerView2, "binding.guildScheduledEventRsvpListRecyclerView");
recyclerView2.setVisibility(0);
}
}
private final void configureForSection(EventDetailsSection eventDetailsSection, EventDetailsRsvpUsersFetchState eventDetailsRsvpUsersFetchState) {
EventDetailsSection eventDetailsSection2 = EventDetailsSection.RSVP_LIST;
if (eventDetailsSection == eventDetailsSection2) {
configureForRsvpUsersFetchState(eventDetailsRsvpUsersFetchState);
}
ConstraintLayout constraintLayout = getBinding().p;
d0.z.d.m.checkNotNullExpressionValue(constraintLayout, "binding.guildScheduledEventInfoContainer");
boolean z2 = true;
int i = 0;
constraintLayout.setVisibility(eventDetailsSection == EventDetailsSection.EVENT_INFO ? 0 : 8);
ConstraintLayout constraintLayout2 = getBinding().q;
d0.z.d.m.checkNotNullExpressionValue(constraintLayout2, "binding.guildScheduledEventRsvpListContainer");
if (eventDetailsSection != eventDetailsSection2) {
z2 = false;
}
if (!z2) {
i = 8;
}
constraintLayout2.setVisibility(i);
}
private final void configureSegmentControl(int i) {
SegmentedControlContainer.b(getBinding().t, 0, 1);
getBinding().t.setOnSegmentSelectedChangeListener(new WidgetGuildScheduledEventDetailsBottomSheet$configureSegmentControl$1(this));
getBinding().t.setSelectedIndex(i);
CardSegment cardSegment = getBinding().u;
Context requireContext = requireContext();
d0.z.d.m.checkNotNullExpressionValue(requireContext, "requireContext()");
cardSegment.setText(b.h(requireContext, R.string.guild_event_details_info_tab_title, new Object[0], null, 4));
CardSegment cardSegment2 = getBinding().v;
Context requireContext2 = requireContext();
d0.z.d.m.checkNotNullExpressionValue(requireContext2, "requireContext()");
cardSegment2.setText(b.h(requireContext2, R.string.indicate_rsvp, new Object[0], null, 4));
}
private final void configureUi(GuildScheduledEventDetailsViewModel.ViewState viewState) {
CharSequence charSequence;
if (!(viewState instanceof GuildScheduledEventDetailsViewModel.ViewState.Initialized)) {
dismiss();
return;
}
GuildScheduledEventDetailsViewModel.ViewState.Initialized initialized = (GuildScheduledEventDetailsViewModel.ViewState.Initialized) viewState;
configureSegmentControl(initialized.getSegmentedControlIndex());
configureForSection(initialized.getSection(), initialized.getRsvpUsersFetchState());
getBinding().g.configure(initialized.getGuildScheduledEvent(), false);
TextView textView = getBinding().m;
d0.z.d.m.checkNotNullExpressionValue(textView, "binding.guildScheduledEventDetailsTitleText");
textView.setText(initialized.getGuildScheduledEvent().i());
SimpleDraweeView simpleDraweeView = getBinding().i;
d0.z.d.m.checkNotNullExpressionValue(simpleDraweeView, "binding.guildScheduledEventDetailsGuildIcon");
IconUtils.setIcon$default((ImageView) simpleDraweeView, initialized.getGuild(), 0, (MGImages.ChangeDetector) null, false, 28, (Object) null);
TextView textView2 = getBinding().j;
d0.z.d.m.checkNotNullExpressionValue(textView2, "binding.guildScheduledEventDetailsGuildName");
textView2.setText(initialized.getGuild().getName());
getBinding().f1911c.setImageResource(initialized.getLocationInfo().getLocationIcon());
LinkifiedTextView linkifiedTextView = getBinding().d;
d0.z.d.m.checkNotNullExpressionValue(linkifiedTextView, "binding.guildScheduledEventDetailsChannelName");
GuildScheduledEventExternalLocationParser locationParser = getLocationParser();
Context requireContext = requireContext();
d0.z.d.m.checkNotNullExpressionValue(requireContext, "requireContext()");
linkifiedTextView.setText(locationParser.getTextFromLocation(requireContext, initialized.getLocationInfo()));
ImageView imageView = getBinding().l;
d0.z.d.m.checkNotNullExpressionValue(imageView, "binding.guildScheduledEventDetailsRsvpIcon");
imageView.setVisibility(initialized.getGuildScheduledEvent().m() != null ? 0 : 8);
TextView textView3 = getBinding().k;
d0.z.d.m.checkNotNullExpressionValue(textView3, "binding.guildScheduledEventDetailsRsvpCount");
Integer m = initialized.getGuildScheduledEvent().m();
Channel channel = null;
if (m != null) {
int intValue = m.intValue();
Context requireContext2 = requireContext();
d0.z.d.m.checkNotNullExpressionValue(requireContext2, "requireContext()");
Context requireContext3 = requireContext();
d0.z.d.m.checkNotNullExpressionValue(requireContext3, "requireContext()");
charSequence = b.h(requireContext2, R.string.guild_event_interested_count, new Object[]{StringResourceUtilsKt.getI18nPluralString(requireContext3, R.plurals.guild_event_interested_count_count, intValue, Integer.valueOf(intValue))}, null, 4);
} else {
charSequence = null;
}
ViewExtensions.setTextAndVisibilityBy(textView3, charSequence);
UserGuildMember creator = initialized.getCreator();
if (creator != null) {
TextView textView4 = getBinding().e;
d0.z.d.m.checkNotNullExpressionValue(textView4, "binding.guildScheduledEventDetailsCreatedBy");
textView4.setVisibility(0);
SimpleDraweeView simpleDraweeView2 = getBinding().f;
d0.z.d.m.checkNotNullExpressionValue(simpleDraweeView2, "binding.guildScheduledEventDetailsCreatorAvatar");
simpleDraweeView2.setVisibility(0);
TextView textView5 = getBinding().e;
d0.z.d.m.checkNotNullExpressionValue(textView5, "binding.guildScheduledEventDetailsCreatedBy");
b.m(textView5, R.string.guild_event_created_by_hook, new Object[]{creator.getNickOrUserName()}, new WidgetGuildScheduledEventDetailsBottomSheet$configureUi$2(this, creator));
SimpleDraweeView simpleDraweeView3 = getBinding().f;
d0.z.d.m.checkNotNullExpressionValue(simpleDraweeView3, "binding.guildScheduledEventDetailsCreatorAvatar");
SimpleDraweeViewExtensionsKt.configureCreator(simpleDraweeView3, creator);
} else {
TextView textView6 = getBinding().e;
d0.z.d.m.checkNotNullExpressionValue(textView6, "binding.guildScheduledEventDetailsCreatedBy");
textView6.setVisibility(8);
SimpleDraweeView simpleDraweeView4 = getBinding().f;
d0.z.d.m.checkNotNullExpressionValue(simpleDraweeView4, "binding.guildScheduledEventDetailsCreatorAvatar");
simpleDraweeView4.setVisibility(8);
}
getDescriptionParser().configureDescription(initialized.getGuildScheduledEvent().d(), initialized.getGuildScheduledEvent().g());
GuildScheduledEventBottomButtonView guildScheduledEventBottomButtonView = getBinding().b;
d0.z.d.m.checkNotNullExpressionValue(guildScheduledEventBottomButtonView, "binding.guildScheduledEventDetailsButtonView");
guildScheduledEventBottomButtonView.setVisibility(0);
GuildScheduledEventLocationInfo locationInfo = initialized.getLocationInfo();
if (!(locationInfo instanceof GuildScheduledEventLocationInfo.ChannelLocation)) {
locationInfo = null;
}
GuildScheduledEventLocationInfo.ChannelLocation channelLocation = (GuildScheduledEventLocationInfo.ChannelLocation) locationInfo;
if (channelLocation != null) {
channel = channelLocation.getChannel();
}
getBinding().b.configureForDetails(initialized.getGuildScheduledEvent(), initialized.isRsvped(), initialized.isConnected(), initialized.getCanStartEvent(), initialized.getCanConnect(), initialized.isDeveloperMode(), new WidgetGuildScheduledEventDetailsBottomSheet$configureUi$3(this, viewState), new WidgetGuildScheduledEventDetailsBottomSheet$configureUi$4(this), new WidgetGuildScheduledEventDetailsBottomSheet$configureUi$5(this), new WidgetGuildScheduledEventDetailsBottomSheet$configureUi$6(this, viewState), new WidgetGuildScheduledEventDetailsBottomSheet$configureUi$7(this, channel), new WidgetGuildScheduledEventDetailsBottomSheet$configureUi$8(this));
getBinding().j.setOnClickListener(new WidgetGuildScheduledEventDetailsBottomSheet$configureUi$9(this));
GuildScheduledEventRsvpUserListAdapter guildScheduledEventRsvpUserListAdapter = this.adapter;
if (guildScheduledEventRsvpUserListAdapter == null) {
d0.z.d.m.throwUninitializedPropertyAccessException("adapter");
}
guildScheduledEventRsvpUserListAdapter.setData(initialized.getRsvpUsers());
}
private final long getGuildScheduledEventId() {
return ((Number) this.guildScheduledEventId$delegate.getValue()).longValue();
}
private final GuildScheduledEventExternalLocationParser getLocationParser() {
return (GuildScheduledEventExternalLocationParser) this.locationParser$delegate.getValue();
}
private final GuildScheduledEventDetailsViewModel getViewModel() {
return (GuildScheduledEventDetailsViewModel) this.viewModel$delegate.getValue();
}
public final WidgetGuildScheduledEventDetailsBottomSheetBinding getBinding() {
return (WidgetGuildScheduledEventDetailsBottomSheetBinding) this.binding$delegate.getValue((Fragment) this, $$delegatedProperties[0]);
}
@Override // com.discord.app.AppBottomSheet
public int getContentViewResId() {
return R.layout.widget_guild_scheduled_event_details_bottom_sheet;
}
public final GuildScheduledEventDescriptionParser getDescriptionParser() {
return (GuildScheduledEventDescriptionParser) this.descriptionParser$delegate.getValue();
}
@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), WidgetGuildScheduledEventDetailsBottomSheet.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new WidgetGuildScheduledEventDetailsBottomSheet$onResume$1(this), 62, (Object) null);
}
@Override // com.discord.app.AppBottomSheet, androidx.fragment.app.Fragment
public void onViewCreated(View view, Bundle bundle) {
d0.z.d.m.checkNotNullParameter(view, "view");
super.onViewCreated(view, bundle);
RecyclerView recyclerView = getBinding().r;
d0.z.d.m.checkNotNullExpressionValue(recyclerView, "binding.guildScheduledEventRsvpListRecyclerView");
this.adapter = new GuildScheduledEventRsvpUserListAdapter(recyclerView, new WidgetGuildScheduledEventDetailsBottomSheet$onViewCreated$1(this));
RecyclerView recyclerView2 = getBinding().r;
GuildScheduledEventRsvpUserListAdapter guildScheduledEventRsvpUserListAdapter = this.adapter;
if (guildScheduledEventRsvpUserListAdapter == null) {
d0.z.d.m.throwUninitializedPropertyAccessException("adapter");
}
recyclerView2.setAdapter(guildScheduledEventRsvpUserListAdapter);
recyclerView2.setLayoutManager(new LinearLayoutManager(recyclerView2.getContext()));
}
}