172 lines
9.2 KiB
Java
172 lines
9.2 KiB
Java
package com.discord.widgets.nux;
|
|
|
|
import android.content.Context;
|
|
import android.content.Intent;
|
|
import android.view.View;
|
|
import android.widget.TextView;
|
|
import androidx.fragment.app.Fragment;
|
|
import androidx.fragment.app.FragmentManager;
|
|
import c.a.d.j;
|
|
import c.d.b.a.a;
|
|
import com.discord.R;
|
|
import com.discord.app.AppFragment;
|
|
import com.discord.databinding.WidgetNuxChannelPromptBinding;
|
|
import com.discord.models.guild.Guild;
|
|
import com.discord.stores.StoreStream;
|
|
import com.discord.utilities.error.Error;
|
|
import com.discord.utilities.icon.IconUtils;
|
|
import com.discord.utilities.images.MGImages;
|
|
import com.discord.utilities.rx.ObservableExtensionsKt;
|
|
import com.discord.utilities.view.extensions.ViewExtensions;
|
|
import com.discord.utilities.view.validators.ValidationManager;
|
|
import com.discord.utilities.viewbinding.FragmentViewBindingDelegate;
|
|
import com.discord.utilities.viewbinding.FragmentViewBindingDelegateKt;
|
|
import com.discord.widgets.guilds.invite.GuildInviteShareSheetFeatureFlag;
|
|
import com.discord.widgets.guilds.invite.WidgetGuildInviteShare;
|
|
import com.discord.widgets.guilds.invite.WidgetGuildInviteShareSheet;
|
|
import com.facebook.drawee.view.SimpleDraweeView;
|
|
import com.google.android.material.textfield.TextInputLayout;
|
|
import d0.g;
|
|
import d0.z.d.m;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import kotlin.Lazy;
|
|
import kotlin.jvm.functions.Function0;
|
|
import kotlin.jvm.functions.Function1;
|
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
|
import kotlin.reflect.KProperty;
|
|
/* compiled from: WidgetNuxChannelPrompt.kt */
|
|
public final class WidgetNuxChannelPrompt extends AppFragment {
|
|
public static final /* synthetic */ KProperty[] $$delegatedProperties = {a.W(WidgetNuxChannelPrompt.class, "binding", "getBinding()Lcom/discord/databinding/WidgetNuxChannelPromptBinding;", 0)};
|
|
public static final Companion Companion = new Companion(null);
|
|
private final FragmentViewBindingDelegate binding$delegate = FragmentViewBindingDelegateKt.viewBinding$default(this, WidgetNuxChannelPrompt$binding$2.INSTANCE, null, 2, null);
|
|
private final Lazy validationManager$delegate = g.lazy(new WidgetNuxChannelPrompt$validationManager$2(this));
|
|
|
|
/* compiled from: WidgetNuxChannelPrompt.kt */
|
|
public static final class Companion {
|
|
private Companion() {
|
|
}
|
|
|
|
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
|
|
this();
|
|
}
|
|
|
|
public final void launch(Context context, long j) {
|
|
m.checkNotNullParameter(context, "context");
|
|
Intent intent = new Intent();
|
|
intent.putExtra("com.discord.intent.extra.EXTRA_GUILD_ID", j);
|
|
j.d(context, WidgetNuxChannelPrompt.class, intent);
|
|
}
|
|
}
|
|
|
|
public WidgetNuxChannelPrompt() {
|
|
super(R.layout.widget_nux_channel_prompt);
|
|
}
|
|
|
|
public static final /* synthetic */ void access$finishActivity(WidgetNuxChannelPrompt widgetNuxChannelPrompt, long j) {
|
|
widgetNuxChannelPrompt.finishActivity(j);
|
|
}
|
|
|
|
public static final /* synthetic */ WidgetNuxChannelPromptBinding access$getBinding$p(WidgetNuxChannelPrompt widgetNuxChannelPrompt) {
|
|
return widgetNuxChannelPrompt.getBinding();
|
|
}
|
|
|
|
public static final /* synthetic */ void access$handleGuild(WidgetNuxChannelPrompt widgetNuxChannelPrompt, Guild guild) {
|
|
widgetNuxChannelPrompt.handleGuild(guild);
|
|
}
|
|
|
|
public static final /* synthetic */ void access$handleSubmit(WidgetNuxChannelPrompt widgetNuxChannelPrompt, long j) {
|
|
widgetNuxChannelPrompt.handleSubmit(j);
|
|
}
|
|
|
|
private final void finishActivity(long j) {
|
|
if (GuildInviteShareSheetFeatureFlag.Companion.getINSTANCE().isEnabled()) {
|
|
WidgetGuildInviteShareSheet.Companion.enqueueNoticeForHomeTab$default(WidgetGuildInviteShareSheet.Companion, null, j, GuildTemplateAnalytics.STEP_GUILD_CREATE, 1, null);
|
|
j.c(requireContext(), false, null, 6);
|
|
} else {
|
|
WidgetGuildInviteShare.Companion companion = WidgetGuildInviteShare.Companion;
|
|
Context requireContext = requireContext();
|
|
FragmentManager parentFragmentManager = getParentFragmentManager();
|
|
m.checkNotNullExpressionValue(parentFragmentManager, "parentFragmentManager");
|
|
WidgetGuildInviteShare.Companion.launch$default(companion, requireContext, parentFragmentManager, j, null, true, null, GuildTemplateAnalytics.STEP_GUILD_CREATE, 32, null);
|
|
}
|
|
requireActivity().finish();
|
|
}
|
|
|
|
private final WidgetNuxChannelPromptBinding getBinding() {
|
|
return (WidgetNuxChannelPromptBinding) this.binding$delegate.getValue((Fragment) this, $$delegatedProperties[0]);
|
|
}
|
|
|
|
private final ValidationManager getValidationManager() {
|
|
return (ValidationManager) this.validationManager$delegate.getValue();
|
|
}
|
|
|
|
private final void handleGuild(Guild guild) {
|
|
if (guild != null) {
|
|
String forGuild$default = IconUtils.getForGuild$default(Long.valueOf(guild.getId()), guild.getIcon(), null, true, Integer.valueOf(IconUtils.getMediaProxySize(getResources().getDimensionPixelSize(R.dimen.avatar_size_large))), 4, null);
|
|
if (forGuild$default != null) {
|
|
TextView textView = getBinding().d;
|
|
m.checkNotNullExpressionValue(textView, "binding.nufChannelPromptGuildIconName");
|
|
textView.setVisibility(8);
|
|
SimpleDraweeView simpleDraweeView = getBinding().f1886c;
|
|
m.checkNotNullExpressionValue(simpleDraweeView, "binding.nufChannelPromptGuildIcon");
|
|
IconUtils.setIcon$default(simpleDraweeView, forGuild$default, 0, (Function1) null, (MGImages.ChangeDetector) null, 28, (Object) null);
|
|
} else {
|
|
TextView textView2 = getBinding().d;
|
|
m.checkNotNullExpressionValue(textView2, "binding.nufChannelPromptGuildIconName");
|
|
textView2.setVisibility(0);
|
|
TextView textView3 = getBinding().d;
|
|
m.checkNotNullExpressionValue(textView3, "binding.nufChannelPromptGuildIconName");
|
|
textView3.setText(guild.getShortName());
|
|
SimpleDraweeView simpleDraweeView2 = getBinding().f1886c;
|
|
m.checkNotNullExpressionValue(simpleDraweeView2, "binding.nufChannelPromptGuildIcon");
|
|
IconUtils.setIcon$default(simpleDraweeView2, IconUtils.DEFAULT_ICON, 0, (Function1) null, (MGImages.ChangeDetector) null, 28, (Object) null);
|
|
}
|
|
TextView textView4 = getBinding().e;
|
|
m.checkNotNullExpressionValue(textView4, "binding.nufChannelPromptGuildName");
|
|
textView4.setText(guild.getName());
|
|
}
|
|
}
|
|
|
|
private final void handleSubmit(long j) {
|
|
getBinding().b.setIsLoading(true);
|
|
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.takeSingleUntilTimeout$default(StoreStream.Companion.getChannels().observeDefaultChannel(j), 0, false, 3, null), WidgetNuxChannelPrompt.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new WidgetNuxChannelPrompt$handleSubmit$1(this, j), 62, (Object) null);
|
|
}
|
|
|
|
public static final void launch(Context context, long j) {
|
|
Companion.launch(context, j);
|
|
}
|
|
|
|
public final void handleError(Error error) {
|
|
m.checkNotNullParameter(error, "error");
|
|
getBinding().b.setIsLoading(false);
|
|
Error.Response response = error.getResponse();
|
|
m.checkNotNullExpressionValue(response, "error.response");
|
|
if (response.getMessages().isEmpty()) {
|
|
error.setShowErrorToasts(true);
|
|
return;
|
|
}
|
|
ValidationManager validationManager = getValidationManager();
|
|
Error.Response response2 = error.getResponse();
|
|
m.checkNotNullExpressionValue(response2, "error.response");
|
|
Map<String, List<String>> messages = response2.getMessages();
|
|
m.checkNotNullExpressionValue(messages, "error.response.messages");
|
|
error.setShowErrorToasts(!validationManager.setErrors(messages).isEmpty());
|
|
}
|
|
|
|
@Override // com.discord.app.AppFragment
|
|
public void onViewBound(View view) {
|
|
m.checkNotNullParameter(view, "view");
|
|
super.onViewBound(view);
|
|
long longExtra = getMostRecentIntent().getLongExtra("com.discord.intent.extra.EXTRA_GUILD_ID", 0);
|
|
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.ui$default(StoreStream.Companion.getGuilds().observeGuild(longExtra), this, null, 2, null), WidgetNuxChannelPrompt.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new WidgetNuxChannelPrompt$onViewBound$1(this), 62, (Object) null);
|
|
getBinding().f.setOnClickListener(new WidgetNuxChannelPrompt$onViewBound$2(this, longExtra));
|
|
AppFragment.setOnBackPressed$default(this, new WidgetNuxChannelPrompt$onViewBound$3(this, longExtra), 0, 2, null);
|
|
getBinding().b.setIsLoading(false);
|
|
getBinding().b.setOnClickListener(new WidgetNuxChannelPrompt$onViewBound$4(this, longExtra));
|
|
TextInputLayout textInputLayout = getBinding().g;
|
|
m.checkNotNullExpressionValue(textInputLayout, "binding.nufChannelPromptTopicWrap");
|
|
ViewExtensions.setOnImeActionDone(textInputLayout, true, new WidgetNuxChannelPrompt$onViewBound$5(this));
|
|
}
|
|
}
|