forked from Juby210/discord-jadx
349 lines
18 KiB
Java
349 lines
18 KiB
Java
package com.discord.widgets.guildscheduledevent;
|
|
|
|
import android.content.Context;
|
|
import android.content.Intent;
|
|
import android.view.View;
|
|
import android.view.ViewGroup;
|
|
import android.widget.ImageView;
|
|
import android.widget.TextView;
|
|
import androidx.activity.result.ActivityResultLauncher;
|
|
import androidx.activity.result.contract.ActivityResultContracts;
|
|
import androidx.core.content.ContextCompat;
|
|
import androidx.fragment.app.Fragment;
|
|
import androidx.fragment.app.FragmentActivity;
|
|
import androidx.fragment.app.FragmentViewModelLazyKt;
|
|
import c.a.d.f0;
|
|
import c.a.d.h0;
|
|
import c.a.d.j;
|
|
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.app.AppFragment;
|
|
import com.discord.app.AppTransitionActivity;
|
|
import com.discord.databinding.WidgetPreviewGuildScheduledEventBinding;
|
|
import com.discord.utilities.dimen.DimenUtils;
|
|
import com.discord.utilities.rx.ObservableExtensionsKt;
|
|
import com.discord.utilities.viewbinding.FragmentViewBindingDelegate;
|
|
import com.discord.utilities.viewbinding.FragmentViewBindingDelegateKt;
|
|
import com.discord.views.CheckedSetting;
|
|
import com.discord.widgets.guildscheduledevent.GuildScheduledEventLocationInfo;
|
|
import com.discord.widgets.guildscheduledevent.PreviewGuildScheduledEventViewModel;
|
|
import com.google.android.material.button.MaterialButton;
|
|
import java.io.Serializable;
|
|
import java.util.Objects;
|
|
import kotlin.Lazy;
|
|
import kotlin.NoWhenBranchMatchedException;
|
|
import kotlin.Unit;
|
|
import kotlin.jvm.functions.Function0;
|
|
import kotlin.jvm.functions.Function1;
|
|
import kotlin.jvm.functions.Function3;
|
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
|
import kotlin.reflect.KProperty;
|
|
import z.a.a.b;
|
|
/* compiled from: WidgetPreviewGuildScheduledEvent.kt */
|
|
public final class WidgetPreviewGuildScheduledEvent extends AppFragment {
|
|
public static final /* synthetic */ KProperty[] $$delegatedProperties = {a.Z(WidgetPreviewGuildScheduledEvent.class, "binding", "getBinding()Lcom/discord/databinding/WidgetPreviewGuildScheduledEventBinding;", 0)};
|
|
public static final Companion Companion = new Companion(null);
|
|
public static final String EXTRA_EVENT_CREATED = "INTENT_EXTRA_EVENT_CREATED";
|
|
private static final String EXTRA_EVENT_MODEL = "INTENT_EXTRA_EVENT_MODEL";
|
|
private static final String EXTRA_EXISTING_EVENT_DATA = "INTENT_EXTRA_EXISTING_EVENT_DATA";
|
|
private static final int RESULT_QUIT = 2;
|
|
private final FragmentViewBindingDelegate binding$delegate = FragmentViewBindingDelegateKt.viewBinding$default(this, WidgetPreviewGuildScheduledEvent$binding$2.INSTANCE, null, 2, null);
|
|
private final Lazy eventModel$delegate = g.lazy(new WidgetPreviewGuildScheduledEvent$eventModel$2(this));
|
|
private final Lazy viewModel$delegate;
|
|
|
|
/* compiled from: WidgetPreviewGuildScheduledEvent.kt */
|
|
public static final class Companion {
|
|
|
|
/* compiled from: WidgetPreviewGuildScheduledEvent.kt */
|
|
public enum Action {
|
|
EDIT_EVENT,
|
|
START_EVENT
|
|
}
|
|
|
|
/* compiled from: WidgetPreviewGuildScheduledEvent.kt */
|
|
public static final class ExistingEventData implements Serializable {
|
|
private final Action action;
|
|
private final long guildScheduledEventId;
|
|
|
|
public ExistingEventData(long j, Action action) {
|
|
m.checkNotNullParameter(action, "action");
|
|
this.guildScheduledEventId = j;
|
|
this.action = action;
|
|
}
|
|
|
|
public static /* synthetic */ ExistingEventData copy$default(ExistingEventData existingEventData, long j, Action action, int i, Object obj) {
|
|
if ((i & 1) != 0) {
|
|
j = existingEventData.guildScheduledEventId;
|
|
}
|
|
if ((i & 2) != 0) {
|
|
action = existingEventData.action;
|
|
}
|
|
return existingEventData.copy(j, action);
|
|
}
|
|
|
|
public final long component1() {
|
|
return this.guildScheduledEventId;
|
|
}
|
|
|
|
public final Action component2() {
|
|
return this.action;
|
|
}
|
|
|
|
public final ExistingEventData copy(long j, Action action) {
|
|
m.checkNotNullParameter(action, "action");
|
|
return new ExistingEventData(j, action);
|
|
}
|
|
|
|
@Override // java.lang.Object
|
|
public boolean equals(Object obj) {
|
|
if (this == obj) {
|
|
return true;
|
|
}
|
|
if (!(obj instanceof ExistingEventData)) {
|
|
return false;
|
|
}
|
|
ExistingEventData existingEventData = (ExistingEventData) obj;
|
|
return this.guildScheduledEventId == existingEventData.guildScheduledEventId && m.areEqual(this.action, existingEventData.action);
|
|
}
|
|
|
|
public final Action getAction() {
|
|
return this.action;
|
|
}
|
|
|
|
public final long getGuildScheduledEventId() {
|
|
return this.guildScheduledEventId;
|
|
}
|
|
|
|
@Override // java.lang.Object
|
|
public int hashCode() {
|
|
int a = b.a(this.guildScheduledEventId) * 31;
|
|
Action action = this.action;
|
|
return a + (action != null ? action.hashCode() : 0);
|
|
}
|
|
|
|
@Override // java.lang.Object
|
|
public String toString() {
|
|
StringBuilder O = a.O("ExistingEventData(guildScheduledEventId=");
|
|
O.append(this.guildScheduledEventId);
|
|
O.append(", action=");
|
|
O.append(this.action);
|
|
O.append(")");
|
|
return O.toString();
|
|
}
|
|
}
|
|
|
|
private Companion() {
|
|
}
|
|
|
|
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
|
|
this();
|
|
}
|
|
|
|
public static /* synthetic */ void launch$default(Companion companion, Context context, GuildScheduledEventModel guildScheduledEventModel, ExistingEventData existingEventData, ActivityResultLauncher activityResultLauncher, boolean z2, int i, Object obj) {
|
|
companion.launch(context, guildScheduledEventModel, (i & 4) != 0 ? null : existingEventData, (i & 8) != 0 ? null : activityResultLauncher, (i & 16) != 0 ? false : z2);
|
|
}
|
|
|
|
/* JADX DEBUG: Multi-variable search result rejected for r0v0, resolved type: com.discord.widgets.guildscheduledevent.WidgetPreviewGuildScheduledEvent$Companion */
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
public static /* synthetic */ ActivityResultLauncher registerForResult$default(Companion companion, Fragment fragment, Function3 function3, Function0 function0, int i, Object obj) {
|
|
if ((i & 4) != 0) {
|
|
function0 = null;
|
|
}
|
|
return companion.registerForResult(fragment, function3, function0);
|
|
}
|
|
|
|
public final ActivityResultLauncher<Intent> createJoinOnStartActivityRegistration(Fragment fragment, Function0<Unit> function0) {
|
|
m.checkNotNullParameter(fragment, "fragment");
|
|
m.checkNotNullParameter(function0, "onEventStarted");
|
|
ActivityResultLauncher<Intent> registerForActivityResult = fragment.registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), new WidgetPreviewGuildScheduledEvent$Companion$createJoinOnStartActivityRegistration$1(fragment, function0));
|
|
m.checkNotNullExpressionValue(registerForActivityResult, "fragment.registerForActi…entStarted)\n }\n }");
|
|
return registerForActivityResult;
|
|
}
|
|
|
|
public final void launch(Context context, GuildScheduledEventModel guildScheduledEventModel, ExistingEventData existingEventData, ActivityResultLauncher<Intent> activityResultLauncher, boolean z2) {
|
|
m.checkNotNullParameter(context, "context");
|
|
m.checkNotNullParameter(guildScheduledEventModel, "eventModel");
|
|
Intent intent = new Intent();
|
|
intent.putExtra(WidgetPreviewGuildScheduledEvent.EXTRA_EVENT_MODEL, guildScheduledEventModel);
|
|
if (existingEventData != null) {
|
|
intent.putExtra(WidgetPreviewGuildScheduledEvent.EXTRA_EXISTING_EVENT_DATA, existingEventData);
|
|
}
|
|
if (z2) {
|
|
intent.putExtra("transition", AppTransitionActivity.Transition.TYPE_SLIDE_HORIZONTAL);
|
|
}
|
|
if (activityResultLauncher != null) {
|
|
j.g.f(context, activityResultLauncher, WidgetPreviewGuildScheduledEvent.class, intent);
|
|
} else {
|
|
j.d(context, WidgetPreviewGuildScheduledEvent.class, intent);
|
|
}
|
|
}
|
|
|
|
public final ActivityResultLauncher<Intent> registerForResult(Fragment fragment, Function3<? super Long, ? super Long, ? super Boolean, Unit> function3, Function0<Unit> function0) {
|
|
m.checkNotNullParameter(fragment, "fragment");
|
|
m.checkNotNullParameter(function3, "onEventCreated");
|
|
ActivityResultLauncher<Intent> registerForActivityResult = fragment.registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), new WidgetPreviewGuildScheduledEvent$Companion$registerForResult$1(function3, function0));
|
|
m.checkNotNullExpressionValue(registerForActivityResult, "fragment.registerForActi… }\n }\n }");
|
|
return registerForActivityResult;
|
|
}
|
|
}
|
|
|
|
public final /* synthetic */ class WhenMappings {
|
|
public static final /* synthetic */ int[] $EnumSwitchMapping$0;
|
|
|
|
static {
|
|
Companion.Action.values();
|
|
int[] iArr = new int[2];
|
|
$EnumSwitchMapping$0 = iArr;
|
|
iArr[Companion.Action.START_EVENT.ordinal()] = 1;
|
|
iArr[Companion.Action.EDIT_EVENT.ordinal()] = 2;
|
|
}
|
|
}
|
|
|
|
public WidgetPreviewGuildScheduledEvent() {
|
|
super(R.layout.widget_preview_guild_scheduled_event);
|
|
WidgetPreviewGuildScheduledEvent$viewModel$2 widgetPreviewGuildScheduledEvent$viewModel$2 = new WidgetPreviewGuildScheduledEvent$viewModel$2(this);
|
|
f0 f0Var = new f0(this);
|
|
this.viewModel$delegate = FragmentViewModelLazyKt.createViewModelLazy(this, a0.getOrCreateKotlinClass(PreviewGuildScheduledEventViewModel.class), new WidgetPreviewGuildScheduledEvent$appViewModels$$inlined$viewModels$1(f0Var), new h0(widgetPreviewGuildScheduledEvent$viewModel$2));
|
|
}
|
|
|
|
public static final /* synthetic */ void access$configureUi(WidgetPreviewGuildScheduledEvent widgetPreviewGuildScheduledEvent, PreviewGuildScheduledEventViewModel.ViewState viewState) {
|
|
widgetPreviewGuildScheduledEvent.configureUi(viewState);
|
|
}
|
|
|
|
public static final /* synthetic */ WidgetPreviewGuildScheduledEventBinding access$getBinding$p(WidgetPreviewGuildScheduledEvent widgetPreviewGuildScheduledEvent) {
|
|
return widgetPreviewGuildScheduledEvent.getBinding();
|
|
}
|
|
|
|
public static final /* synthetic */ GuildScheduledEventModel access$getEventModel$p(WidgetPreviewGuildScheduledEvent widgetPreviewGuildScheduledEvent) {
|
|
return widgetPreviewGuildScheduledEvent.getEventModel();
|
|
}
|
|
|
|
public static final /* synthetic */ PreviewGuildScheduledEventViewModel access$getViewModel$p(WidgetPreviewGuildScheduledEvent widgetPreviewGuildScheduledEvent) {
|
|
return widgetPreviewGuildScheduledEvent.getViewModel();
|
|
}
|
|
|
|
private final void configureTextForCreation(PreviewGuildScheduledEventViewModel.ViewState.Initialized initialized) {
|
|
TextView textView = getBinding().f;
|
|
m.checkNotNullExpressionValue(textView, "binding.confirmGuildScheduledEventSubtitle");
|
|
textView.setVisibility(8);
|
|
TextView textView2 = getBinding().g;
|
|
ViewGroup.LayoutParams layoutParams = textView2.getLayoutParams();
|
|
Objects.requireNonNull(layoutParams, "null cannot be cast to non-null type android.view.ViewGroup.MarginLayoutParams");
|
|
ViewGroup.MarginLayoutParams marginLayoutParams = (ViewGroup.MarginLayoutParams) layoutParams;
|
|
marginLayoutParams.setMargins(DimenUtils.dpToPixels(16), DimenUtils.dpToPixels(24), DimenUtils.dpToPixels(16), 0);
|
|
textView2.setLayoutParams(marginLayoutParams);
|
|
textView2.setText(c.a.k.b.j(textView2, R.string.guild_event_preview_title, new Object[0], null, 4));
|
|
TextView textView3 = getBinding().h;
|
|
m.checkNotNullExpressionValue(textView3, "binding.createEventSubtitle");
|
|
textView3.setVisibility(0);
|
|
GuildScheduledEventLocationInfo locationInfo = initialized.getLocationInfo();
|
|
if (locationInfo instanceof GuildScheduledEventLocationInfo.ChannelLocation) {
|
|
String locationName = initialized.getLocationInfo().getLocationName();
|
|
TextView textView4 = getBinding().h;
|
|
m.checkNotNullExpressionValue(textView4, "binding.createEventSubtitle");
|
|
c.a.k.b.m(textView4, R.string.guild_event_preview_body, new Object[0], new WidgetPreviewGuildScheduledEvent$configureTextForCreation$2(this, locationName, initialized));
|
|
} else if (locationInfo instanceof GuildScheduledEventLocationInfo.ExternalLocation) {
|
|
TextView textView5 = getBinding().h;
|
|
m.checkNotNullExpressionValue(textView5, "binding.createEventSubtitle");
|
|
textView5.setText(getString(R.string.guild_event_preview_external_event_body));
|
|
}
|
|
}
|
|
|
|
private final void configureTextForStart(PreviewGuildScheduledEventViewModel.ViewState.Initialized initialized) {
|
|
TextView textView = getBinding().f;
|
|
textView.setVisibility(0);
|
|
textView.setText(getString(R.string.start_event_confirmation_no_hook));
|
|
getBinding().g.setText(initialized.getEventModel().getName());
|
|
TextView textView2 = getBinding().h;
|
|
m.checkNotNullExpressionValue(textView2, "binding.createEventSubtitle");
|
|
textView2.setVisibility(8);
|
|
}
|
|
|
|
private final void configureUi(PreviewGuildScheduledEventViewModel.ViewState viewState) {
|
|
int i;
|
|
if (viewState instanceof PreviewGuildScheduledEventViewModel.ViewState.Invalid) {
|
|
FragmentActivity activity = getActivity();
|
|
if (activity != null) {
|
|
activity.finish();
|
|
}
|
|
} else if (viewState instanceof PreviewGuildScheduledEventViewModel.ViewState.Initialized) {
|
|
PreviewGuildScheduledEventViewModel.ViewState.Initialized initialized = (PreviewGuildScheduledEventViewModel.ViewState.Initialized) viewState;
|
|
GuildScheduledEventLocationInfo locationInfo = initialized.getLocationInfo();
|
|
if (!(locationInfo instanceof GuildScheduledEventLocationInfo.ChannelLocation)) {
|
|
locationInfo = null;
|
|
}
|
|
GuildScheduledEventLocationInfo.ChannelLocation channelLocation = (GuildScheduledEventLocationInfo.ChannelLocation) locationInfo;
|
|
getBinding().e.configureAsPreview(initialized.getEventModel(), channelLocation != null ? channelLocation.getChannel() : null);
|
|
MaterialButton materialButton = getBinding().i;
|
|
materialButton.setEnabled(!initialized.getRequestProcessing());
|
|
materialButton.setBackgroundTintList(ContextCompat.getColorStateList(materialButton.getContext(), initialized.isStartingEvent() ? R.color.uikit_btn_bg_color_selector_green : R.color.uikit_btn_bg_color_selector_brand));
|
|
Context context = materialButton.getContext();
|
|
m.checkNotNullExpressionValue(context, "context");
|
|
Companion.Action existingEventAction = initialized.getExistingEventAction();
|
|
if (existingEventAction == null) {
|
|
i = R.string.schedule_event;
|
|
} else {
|
|
int ordinal = existingEventAction.ordinal();
|
|
if (ordinal == 0) {
|
|
i = R.string.edit_event;
|
|
} else if (ordinal == 1) {
|
|
i = R.string.start_event;
|
|
} else {
|
|
throw new NoWhenBranchMatchedException();
|
|
}
|
|
}
|
|
int i2 = 0;
|
|
materialButton.setText(c.a.k.b.h(context, i, new Object[0], null, 4));
|
|
ImageView imageView = getBinding().b;
|
|
m.checkNotNullExpressionValue(imageView, "binding.backButton");
|
|
imageView.setVisibility(initialized.isStartingEvent() ^ true ? 0 : 8);
|
|
TextView textView = getBinding().j;
|
|
m.checkNotNullExpressionValue(textView, "binding.stepText");
|
|
textView.setVisibility(initialized.isStartingEvent() ^ true ? 0 : 8);
|
|
if (initialized.isStartingEvent()) {
|
|
configureTextForStart(initialized);
|
|
} else {
|
|
configureTextForCreation(initialized);
|
|
}
|
|
CheckedSetting checkedSetting = getBinding().d;
|
|
m.checkNotNullExpressionValue(checkedSetting, "binding.confirmGuildScheduledEventNotify");
|
|
if (!initialized.getCanNotifyEveryone()) {
|
|
i2 = 8;
|
|
}
|
|
checkedSetting.setVisibility(i2);
|
|
}
|
|
}
|
|
|
|
private final WidgetPreviewGuildScheduledEventBinding getBinding() {
|
|
return (WidgetPreviewGuildScheduledEventBinding) this.binding$delegate.getValue((Fragment) this, $$delegatedProperties[0]);
|
|
}
|
|
|
|
private final GuildScheduledEventModel getEventModel() {
|
|
return (GuildScheduledEventModel) this.eventModel$delegate.getValue();
|
|
}
|
|
|
|
private final PreviewGuildScheduledEventViewModel getViewModel() {
|
|
return (PreviewGuildScheduledEventViewModel) this.viewModel$delegate.getValue();
|
|
}
|
|
|
|
@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), WidgetPreviewGuildScheduledEvent.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new WidgetPreviewGuildScheduledEvent$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().j;
|
|
m.checkNotNullExpressionValue(textView, "binding.stepText");
|
|
c.a.k.b.n(textView, R.string.guild_event_step_label, new Object[]{3, 3}, null, 4);
|
|
getBinding().b.setOnClickListener(new WidgetPreviewGuildScheduledEvent$onViewBound$1(this));
|
|
getBinding().f2332c.setOnClickListener(new WidgetPreviewGuildScheduledEvent$onViewBound$2(this));
|
|
getBinding().i.setOnClickListener(new WidgetPreviewGuildScheduledEvent$onViewBound$3(this));
|
|
}
|
|
}
|