package com.discord.widgets.guildscheduledevent; import android.content.Context; import android.content.Intent; import android.text.Editable; import android.view.View; import android.widget.TextView; import androidx.activity.result.ActivityResultLauncher; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentViewModelLazyKt; import c.a.d.f0; import c.a.d.h0; import c.a.d.j; import c.a.k.b; import c.d.b.a.a; import c0.g; import c0.z.d.a0; import c0.z.d.m; import com.discord.R; import com.discord.api.channel.Channel; import com.discord.api.guildscheduledevent.GuildScheduledEventEntityType; import com.discord.app.AppFragment; import com.discord.databinding.WidgetGuildScheduledEventLocationSelectBinding; import com.discord.utilities.rx.ObservableExtensionsKt; import com.discord.utilities.view.extensions.ViewExtensions; import com.discord.utilities.viewbinding.FragmentViewBindingDelegate; import com.discord.utilities.viewbinding.FragmentViewBindingDelegateKt; import com.discord.views.CheckedSetting; import com.discord.widgets.channels.WidgetChannelSelector; import com.discord.widgets.guildscheduledevent.WidgetGuildScheduledEventLocationSelectViewModel; import com.discord.widgets.guildscheduledevent.WidgetGuildScheduledEventSettings; import com.google.android.material.button.MaterialButton; import com.google.android.material.textfield.TextInputEditText; import com.google.android.material.textfield.TextInputLayout; import java.util.Set; import kotlin.Lazy; import kotlin.jvm.functions.Function0; import kotlin.jvm.functions.Function1; import kotlin.jvm.internal.DefaultConstructorMarker; import kotlin.reflect.KProperty; /* compiled from: WidgetGuildScheduledEventLocationSelect.kt */ public final class WidgetGuildScheduledEventLocationSelect extends AppFragment { public static final /* synthetic */ KProperty[] $$delegatedProperties = {a.Z(WidgetGuildScheduledEventLocationSelect.class, "binding", "getBinding()Lcom/discord/databinding/WidgetGuildScheduledEventLocationSelectBinding;", 0)}; public static final Companion Companion = new Companion(null); private static final String GUILD_SCHEDULED_EVENT_LOCATION_SELECT_REQUEST_KEY = "GUILD_SCHEDULED_EVENT_LOCATION_SELECT_REQUEST_KEY"; private final FragmentViewBindingDelegate binding$delegate = FragmentViewBindingDelegateKt.viewBinding$default(this, WidgetGuildScheduledEventLocationSelect$binding$2.INSTANCE, null, 2, null); private WidgetGuildScheduledEventLocationSelectViewModel.ViewState.Valid currentViewState; private final Lazy existingGuildScheduledEventId$delegate = g.lazy(new WidgetGuildScheduledEventLocationSelect$existingGuildScheduledEventId$2(this)); private final Lazy guildId$delegate = g.lazy(new WidgetGuildScheduledEventLocationSelect$guildId$2(this)); private final ActivityResultLauncher nextStepLauncher; private final Lazy viewModel$delegate; /* compiled from: WidgetGuildScheduledEventLocationSelect.kt */ public static final class Companion { private Companion() { } public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) { this(); } public static /* synthetic */ void launch$default(Companion companion, Context context, long j, Long l, int i, Object obj) { if ((i & 4) != 0) { l = null; } companion.launch(context, j, l); } public final void launch(Context context, long j, Long l) { m.checkNotNullParameter(context, "context"); Intent intent = new Intent(); intent.putExtra("com.discord.intent.extra.EXTRA_GUILD_ID", j); if (l != null) { intent.putExtra("com.discord.intent.extra.EXTRA_CHANNEL_ID", l.longValue()); } j.d(context, WidgetGuildScheduledEventLocationSelect.class, intent); } public final void launchForEdit(Context context, long j, long j2) { m.checkNotNullParameter(context, "context"); Intent intent = new Intent(); intent.putExtra("com.discord.intent.extra.EXTRA_GUILD_ID", j); intent.putExtra("com.discord.intent.extra.EXTRA_GUILD_SCHEDULED_EVENT_ID", j2); j.d(context, WidgetGuildScheduledEventLocationSelect.class, intent); } } public final /* synthetic */ class WhenMappings { public static final /* synthetic */ int[] $EnumSwitchMapping$0; public static final /* synthetic */ int[] $EnumSwitchMapping$1; public static final /* synthetic */ int[] $EnumSwitchMapping$2; static { GuildScheduledEventEntityType.values(); int[] iArr = new int[5]; $EnumSwitchMapping$0 = iArr; GuildScheduledEventEntityType guildScheduledEventEntityType = GuildScheduledEventEntityType.VOICE; iArr[guildScheduledEventEntityType.ordinal()] = 1; GuildScheduledEventEntityType guildScheduledEventEntityType2 = GuildScheduledEventEntityType.STAGE_INSTANCE; iArr[guildScheduledEventEntityType2.ordinal()] = 2; GuildScheduledEventEntityType.values(); int[] iArr2 = new int[5]; $EnumSwitchMapping$1 = iArr2; iArr2[guildScheduledEventEntityType2.ordinal()] = 1; iArr2[guildScheduledEventEntityType.ordinal()] = 2; GuildScheduledEventEntityType guildScheduledEventEntityType3 = GuildScheduledEventEntityType.EXTERNAL; iArr2[guildScheduledEventEntityType3.ordinal()] = 3; GuildScheduledEventEntityType.values(); int[] iArr3 = new int[5]; $EnumSwitchMapping$2 = iArr3; iArr3[guildScheduledEventEntityType2.ordinal()] = 1; iArr3[guildScheduledEventEntityType.ordinal()] = 2; iArr3[guildScheduledEventEntityType3.ordinal()] = 3; } } public WidgetGuildScheduledEventLocationSelect() { super(R.layout.widget_guild_scheduled_event_location_select); WidgetGuildScheduledEventLocationSelect$viewModel$2 widgetGuildScheduledEventLocationSelect$viewModel$2 = new WidgetGuildScheduledEventLocationSelect$viewModel$2(this); f0 f0Var = new f0(this); this.viewModel$delegate = FragmentViewModelLazyKt.createViewModelLazy(this, a0.getOrCreateKotlinClass(WidgetGuildScheduledEventLocationSelectViewModel.class), new WidgetGuildScheduledEventLocationSelect$appViewModels$$inlined$viewModels$1(f0Var), new h0(widgetGuildScheduledEventLocationSelect$viewModel$2)); this.nextStepLauncher = WidgetGuildScheduledEventSettings.Companion.registerForResult(this, new WidgetGuildScheduledEventLocationSelect$nextStepLauncher$1(this), new WidgetGuildScheduledEventLocationSelect$nextStepLauncher$2(this)); } public static final /* synthetic */ void access$configureUI(WidgetGuildScheduledEventLocationSelect widgetGuildScheduledEventLocationSelect, WidgetGuildScheduledEventLocationSelectViewModel.ViewState viewState) { widgetGuildScheduledEventLocationSelect.configureUI(viewState); } public static final /* synthetic */ WidgetGuildScheduledEventLocationSelectViewModel.ViewState.Valid access$getCurrentViewState$p(WidgetGuildScheduledEventLocationSelect widgetGuildScheduledEventLocationSelect) { return widgetGuildScheduledEventLocationSelect.currentViewState; } public static final /* synthetic */ Long access$getExistingGuildScheduledEventId$p(WidgetGuildScheduledEventLocationSelect widgetGuildScheduledEventLocationSelect) { return widgetGuildScheduledEventLocationSelect.getExistingGuildScheduledEventId(); } public static final /* synthetic */ long access$getGuildId$p(WidgetGuildScheduledEventLocationSelect widgetGuildScheduledEventLocationSelect) { return widgetGuildScheduledEventLocationSelect.getGuildId(); } public static final /* synthetic */ WidgetGuildScheduledEventLocationSelectViewModel access$getViewModel$p(WidgetGuildScheduledEventLocationSelect widgetGuildScheduledEventLocationSelect) { return widgetGuildScheduledEventLocationSelect.getViewModel(); } public static final /* synthetic */ void access$navigateNext(WidgetGuildScheduledEventLocationSelect widgetGuildScheduledEventLocationSelect) { widgetGuildScheduledEventLocationSelect.navigateNext(); } public static final /* synthetic */ void access$setCurrentViewState$p(WidgetGuildScheduledEventLocationSelect widgetGuildScheduledEventLocationSelect, WidgetGuildScheduledEventLocationSelectViewModel.ViewState.Valid valid) { widgetGuildScheduledEventLocationSelect.currentViewState = valid; } private final void configureLocationOption(WidgetGuildScheduledEventLocationSelectViewModel.ViewState.Valid valid, CheckedSetting checkedSetting, GuildScheduledEventEntityType guildScheduledEventEntityType, CharSequence charSequence) { checkedSetting.setChecked(valid.getSelectedLocationOption() == guildScheduledEventEntityType); if (charSequence != null) { checkedSetting.c(charSequence); } else { checkedSetting.e(new WidgetGuildScheduledEventLocationSelect$configureLocationOption$1(this, guildScheduledEventEntityType)); } } private final void configureUI(WidgetGuildScheduledEventLocationSelectViewModel.ViewState viewState) { if (viewState instanceof WidgetGuildScheduledEventLocationSelectViewModel.ViewState.Valid) { WidgetGuildScheduledEventLocationSelectViewModel.ViewState.Valid valid = (WidgetGuildScheduledEventLocationSelectViewModel.ViewState.Valid) viewState; this.currentViewState = valid; CheckedSetting checkedSetting = getBinding().j; m.checkNotNullExpressionValue(checkedSetting, "binding.stageChannelOption"); configureLocationOption(valid, checkedSetting, GuildScheduledEventEntityType.STAGE_INSTANCE, getDisabledMessageForChannelOption(valid.getAvailableStageChannelIds(), valid.getCanChangeChannel())); CheckedSetting checkedSetting2 = getBinding().m; m.checkNotNullExpressionValue(checkedSetting2, "binding.voiceChannelOption"); configureLocationOption(valid, checkedSetting2, GuildScheduledEventEntityType.VOICE, getDisabledMessageForChannelOption(valid.getAvailableVoiceChannelIds(), valid.getCanChangeChannel())); CheckedSetting checkedSetting3 = getBinding().g; m.checkNotNullExpressionValue(checkedSetting3, "binding.externalOption"); configureLocationOption(valid, checkedSetting3, GuildScheduledEventEntityType.EXTERNAL, getDisabledMessageForExternalOption(valid.getCanCreateExternalEvent(), valid.getCanChangeChannel())); boolean z2 = (valid.getAvailableStageChannelIds().isEmpty() ^ true) || valid.getShowStageOptionIfUnavailable(); CheckedSetting checkedSetting4 = getBinding().j; m.checkNotNullExpressionValue(checkedSetting4, "binding.stageChannelOption"); checkedSetting4.setVisibility(z2 ? 0 : 8); View view = getBinding().l; m.checkNotNullExpressionValue(view, "binding.voiceChannelDivider"); view.setVisibility(z2 ? 0 : 8); int ordinal = valid.getSelectedLocationOption().ordinal(); if (ordinal == 1 || ordinal == 2) { TextView textView = getBinding().h; m.checkNotNullExpressionValue(textView, "binding.locationHeader"); ViewExtensions.setTextAndVisibilityBy(textView, getString(R.string.guild_event_location_voice_field_label)); TextInputLayout textInputLayout = getBinding().f2281c; m.checkNotNullExpressionValue(textInputLayout, "binding.channelLocationLayout"); textInputLayout.setVisibility(0); TextInputLayout textInputLayout2 = getBinding().f; m.checkNotNullExpressionValue(textInputLayout2, "binding.externalLocationLayout"); textInputLayout2.setVisibility(8); } else if (ordinal != 3) { TextView textView2 = getBinding().h; m.checkNotNullExpressionValue(textView2, "binding.locationHeader"); textView2.setVisibility(8); TextInputLayout textInputLayout3 = getBinding().f2281c; m.checkNotNullExpressionValue(textInputLayout3, "binding.channelLocationLayout"); textInputLayout3.setVisibility(8); TextInputLayout textInputLayout4 = getBinding().f; m.checkNotNullExpressionValue(textInputLayout4, "binding.externalLocationLayout"); textInputLayout4.setVisibility(8); } else { TextView textView3 = getBinding().h; m.checkNotNullExpressionValue(textView3, "binding.locationHeader"); ViewExtensions.setTextAndVisibilityBy(textView3, getString(R.string.guild_event_location_elsewhere_field_label)); TextInputLayout textInputLayout5 = getBinding().f2281c; m.checkNotNullExpressionValue(textInputLayout5, "binding.channelLocationLayout"); textInputLayout5.setVisibility(8); TextInputLayout textInputLayout6 = getBinding().f; m.checkNotNullExpressionValue(textInputLayout6, "binding.externalLocationLayout"); textInputLayout6.setVisibility(0); } TextInputEditText textInputEditText = getBinding().b; String str = null; ViewExtensions.setEnabledAndAlpha$default(textInputEditText, valid.getCanChangeChannel(), 0.0f, 2, null); Editable text = textInputEditText.getText(); String obj = text != null ? text.toString() : null; Channel selectedChannel = valid.getSelectedChannel(); if (!m.areEqual(obj, selectedChannel != null ? selectedChannel.m() : null)) { Channel selectedChannel2 = valid.getSelectedChannel(); textInputEditText.setText(selectedChannel2 != null ? selectedChannel2.m() : null); } TextInputEditText textInputEditText2 = getBinding().e; Editable text2 = textInputEditText2.getText(); if (text2 != null) { str = text2.toString(); } if (!m.areEqual(str, valid.getExternalLocation())) { textInputEditText2.setText(valid.getExternalLocation()); } MaterialButton materialButton = getBinding().i; m.checkNotNullExpressionValue(materialButton, "binding.nextButton"); materialButton.setEnabled(isNextEnabled(valid)); } } private final WidgetGuildScheduledEventLocationSelectBinding getBinding() { return (WidgetGuildScheduledEventLocationSelectBinding) this.binding$delegate.getValue((Fragment) this, $$delegatedProperties[0]); } private final CharSequence getDisabledMessageForChannelOption(Set set, boolean z2) { if (!z2) { return getString(R.string.guild_event_location_disabled_cannot_edit); } if (set.isEmpty()) { return getString(R.string.guild_event_location_disabled_no_available_channel); } return null; } private final CharSequence getDisabledMessageForExternalOption(boolean z2, boolean z3) { if (!z3) { return getString(R.string.guild_event_location_disabled_cannot_edit); } if (!z2) { return getString(R.string.guild_event_location_disabled_external_no_permission); } return null; } private final Long getExistingGuildScheduledEventId() { return (Long) this.existingGuildScheduledEventId$delegate.getValue(); } private final long getGuildId() { return ((Number) this.guildId$delegate.getValue()).longValue(); } private final WidgetGuildScheduledEventLocationSelectViewModel getViewModel() { return (WidgetGuildScheduledEventLocationSelectViewModel) this.viewModel$delegate.getValue(); } private final boolean isNextEnabled(WidgetGuildScheduledEventLocationSelectViewModel.ViewState.Valid valid) { int ordinal = valid.getSelectedLocationOption().ordinal(); if (ordinal == 1 || ordinal == 2) { if (valid.getSelectedChannel() == null) { return false; } } else if (ordinal != 3 || valid.getExternalLocation().length() <= 0) { return false; } return true; } private final void navigateNext() { WidgetGuildScheduledEventLocationSelectViewModel.ViewState.Valid valid = this.currentViewState; if (valid != null) { WidgetGuildScheduledEventSettings.Companion companion = WidgetGuildScheduledEventSettings.Companion; Context requireContext = requireContext(); ActivityResultLauncher activityResultLauncher = this.nextStepLauncher; long guildId = getGuildId(); GuildScheduledEventEntityType selectedLocationOption = valid.getSelectedLocationOption(); Channel selectedChannel = valid.getSelectedChannel(); companion.launch(requireContext, activityResultLauncher, guildId, selectedLocationOption, selectedChannel != null ? Long.valueOf(selectedChannel.h()) : null, valid.getExternalLocation(), getExistingGuildScheduledEventId()); } } @Override // com.discord.app.AppFragment, androidx.fragment.app.Fragment public void onResume() { super.onResume(); ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.bindToComponentLifecycle$default(getViewModel().observeViewState(), this, null, 2, null), WidgetGuildScheduledEventLocationSelect.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new WidgetGuildScheduledEventLocationSelect$onResume$1(this), 62, (Object) null); } @Override // com.discord.app.AppFragment public void onViewBound(View view) { m.checkNotNullParameter(view, "view"); super.onViewBound(view); TextView textView = getBinding().k; m.checkNotNullExpressionValue(textView, "binding.stepText"); b.n(textView, R.string.guild_event_step_label, new Object[]{1, 3}, null, 4); getBinding().d.setOnClickListener(new WidgetGuildScheduledEventLocationSelect$onViewBound$1(this)); TextInputEditText textInputEditText = getBinding().e; m.checkNotNullExpressionValue(textInputEditText, "binding.externalLocationInput"); textInputEditText.addTextChangedListener(new WidgetGuildScheduledEventLocationSelect$onViewBound$$inlined$addTextChangedListener$1(this)); getBinding().b.setOnClickListener(new WidgetGuildScheduledEventLocationSelect$onViewBound$3(this)); WidgetChannelSelector.Companion.registerForResult(this, GUILD_SCHEDULED_EVENT_LOCATION_SELECT_REQUEST_KEY, false, new WidgetGuildScheduledEventLocationSelect$onViewBound$4(this)); TextInputLayout textInputLayout = getBinding().f; m.checkNotNullExpressionValue(textInputLayout, "binding.externalLocationLayout"); ViewExtensions.setOnImeActionDone$default(textInputLayout, false, new WidgetGuildScheduledEventLocationSelect$onViewBound$5(this), 1, null); getBinding().i.setOnClickListener(new WidgetGuildScheduledEventLocationSelect$onViewBound$6(this)); } }