forked from Juby210/discord-jadx
168 lines
9.1 KiB
Java
168 lines
9.1 KiB
Java
package com.discord.widgets.guilds.create;
|
|
|
|
import android.content.Context;
|
|
import android.content.Intent;
|
|
import android.widget.LinearLayout;
|
|
import android.widget.TextView;
|
|
import androidx.fragment.app.Fragment;
|
|
import b.a.d.j;
|
|
import b.d.b.a.a;
|
|
import com.discord.R;
|
|
import com.discord.api.channel.Channel;
|
|
import com.discord.api.guild.Guild;
|
|
import com.discord.api.role.GuildRole;
|
|
import com.discord.app.AppViewFlipper;
|
|
import com.discord.databinding.WidgetGuildCloneBinding;
|
|
import com.discord.models.domain.ModelAuditLogEntry;
|
|
import com.discord.models.domain.ModelGuildTemplate;
|
|
import com.discord.stores.StoreGuildTemplates;
|
|
import com.discord.stores.StoreStream;
|
|
import com.discord.utilities.color.ColorCompat;
|
|
import com.discord.utilities.color.ColorCompatKt;
|
|
import com.discord.utilities.viewbinding.FragmentViewBindingDelegate;
|
|
import com.discord.utilities.viewbinding.FragmentViewBindingDelegateKt;
|
|
import com.discord.widgets.guilds.create.GuildCreateCloneViews;
|
|
import com.discord.widgets.guilds.create.WidgetGuildCreate;
|
|
import com.discord.widgets.guilds.create.WidgetGuildCreateViewModel;
|
|
import com.discord.widgets.roles.RolesListView;
|
|
import d0.t.n;
|
|
import d0.t.u;
|
|
import d0.z.d.m;
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
|
import kotlin.reflect.KProperty;
|
|
/* compiled from: WidgetGuildClone.kt */
|
|
public final class WidgetGuildClone extends WidgetGuildCreate {
|
|
public static final /* synthetic */ KProperty[] $$delegatedProperties = {a.b0(WidgetGuildClone.class, "binding", "getBinding()Lcom/discord/databinding/WidgetGuildCloneBinding;", 0)};
|
|
public static final Companion Companion = new Companion(null);
|
|
private static final String INTENT_GUILD_TEMPLATE_CODE = "guild_template_code";
|
|
private static final int VIEW_INDEX_INVALID_TEMPLATE = 1;
|
|
private static final int VIEW_INDEX_LOADING_TEMPLATE = 0;
|
|
private static final int VIEW_INDEX_READY = 2;
|
|
private final FragmentViewBindingDelegate binding$delegate = FragmentViewBindingDelegateKt.viewBinding$default(this, WidgetGuildClone$binding$2.INSTANCE, null, 2, null);
|
|
|
|
/* compiled from: WidgetGuildClone.kt */
|
|
public static final class Companion {
|
|
private Companion() {
|
|
}
|
|
|
|
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
|
|
this();
|
|
}
|
|
|
|
public static /* synthetic */ void show$default(Companion companion, Context context, String str, String str2, int i, Object obj) {
|
|
if ((i & 2) != 0) {
|
|
str = null;
|
|
}
|
|
companion.show(context, str, str2);
|
|
}
|
|
|
|
public final void show(Context context, String str, String str2) {
|
|
m.checkNotNullParameter(context, "context");
|
|
m.checkNotNullParameter(str2, ModelAuditLogEntry.CHANGE_KEY_LOCATION);
|
|
Intent putExtra = new Intent().putExtra(WidgetGuildCreate.EXTRA_OPTIONS, new WidgetGuildCreate.Options(str2, null, false, null, false, 30, null));
|
|
m.checkNotNullExpressionValue(putExtra, "Intent().putExtra(EXTRA_OPTIONS, options)");
|
|
if (str != null) {
|
|
putExtra.putExtra(WidgetGuildClone.INTENT_GUILD_TEMPLATE_CODE, str);
|
|
}
|
|
j.d(context, WidgetGuildClone.class, putExtra);
|
|
}
|
|
}
|
|
|
|
public WidgetGuildClone() {
|
|
super(R.layout.widget_guild_clone);
|
|
}
|
|
|
|
private final WidgetGuildCloneBinding getBinding() {
|
|
return (WidgetGuildCloneBinding) this.binding$delegate.getValue((Fragment) this, $$delegatedProperties[0]);
|
|
}
|
|
|
|
@Override // com.discord.widgets.guilds.create.WidgetGuildCreate
|
|
public void configureUI(WidgetGuildCreateViewModel.ViewState viewState) {
|
|
List<Channel> list;
|
|
m.checkNotNullParameter(viewState, "viewState");
|
|
super.configureUI(viewState);
|
|
StoreStream.Companion.getGuildTemplates().clearDynamicLinkGuildTemplateCode();
|
|
int i = 0;
|
|
if (m.areEqual(viewState, WidgetGuildCreateViewModel.ViewState.Uninitialized.INSTANCE)) {
|
|
AppViewFlipper appViewFlipper = getBinding().c;
|
|
m.checkNotNullExpressionValue(appViewFlipper, "binding.guildCreateFlipper");
|
|
appViewFlipper.setDisplayedChild(0);
|
|
} else if (viewState instanceof WidgetGuildCreateViewModel.ViewState.Initialized) {
|
|
WidgetGuildCreateViewModel.ViewState.Initialized initialized = (WidgetGuildCreateViewModel.ViewState.Initialized) viewState;
|
|
StoreGuildTemplates.GuildTemplateState guildTemplate = initialized.getGuildTemplate();
|
|
if (m.areEqual(guildTemplate, StoreGuildTemplates.GuildTemplateState.None.INSTANCE) || m.areEqual(guildTemplate, StoreGuildTemplates.GuildTemplateState.Invalid.INSTANCE) || m.areEqual(guildTemplate, StoreGuildTemplates.GuildTemplateState.LoadFailed.INSTANCE)) {
|
|
AppViewFlipper appViewFlipper2 = getBinding().c;
|
|
m.checkNotNullExpressionValue(appViewFlipper2, "binding.guildCreateFlipper");
|
|
appViewFlipper2.setDisplayedChild(1);
|
|
} else if (m.areEqual(guildTemplate, StoreGuildTemplates.GuildTemplateState.Loading.INSTANCE)) {
|
|
AppViewFlipper appViewFlipper3 = getBinding().c;
|
|
m.checkNotNullExpressionValue(appViewFlipper3, "binding.guildCreateFlipper");
|
|
appViewFlipper3.setDisplayedChild(0);
|
|
} else if (guildTemplate instanceof StoreGuildTemplates.GuildTemplateState.Resolved) {
|
|
ModelGuildTemplate guildTemplate2 = ((StoreGuildTemplates.GuildTemplateState.Resolved) initialized.getGuildTemplate()).getGuildTemplate();
|
|
Guild serializedSourceGuild = guildTemplate2.getSerializedSourceGuild();
|
|
if (serializedSourceGuild == null) {
|
|
AppViewFlipper appViewFlipper4 = getBinding().c;
|
|
m.checkNotNullExpressionValue(appViewFlipper4, "binding.guildCreateFlipper");
|
|
appViewFlipper4.setDisplayedChild(1);
|
|
return;
|
|
}
|
|
AppViewFlipper appViewFlipper5 = getBinding().c;
|
|
m.checkNotNullExpressionValue(appViewFlipper5, "binding.guildCreateFlipper");
|
|
appViewFlipper5.setDisplayedChild(2);
|
|
TextView textView = getBinding().g;
|
|
m.checkNotNullExpressionValue(textView, "binding.guildTemplateName");
|
|
int themedColor = ColorCompat.getThemedColor(textView, (int) R.attr.colorHeaderSecondary);
|
|
TextView textView2 = getBinding().g;
|
|
m.checkNotNullExpressionValue(textView2, "binding.guildTemplateName");
|
|
ColorCompatKt.setDrawableColor(textView2, themedColor);
|
|
TextView textView3 = getBinding().g;
|
|
m.checkNotNullExpressionValue(textView3, "binding.guildTemplateName");
|
|
textView3.setText(guildTemplate2.getName());
|
|
GuildTemplateChannelsView guildTemplateChannelsView = getBinding().h;
|
|
List<Channel> g = serializedSourceGuild.g();
|
|
if (g == null || (list = u.sortedWith(g, new WidgetGuildClone$configureUI$$inlined$sortedBy$1())) == null) {
|
|
list = n.emptyList();
|
|
}
|
|
guildTemplateChannelsView.updateView(list);
|
|
List<GuildRole> G = serializedSourceGuild.G();
|
|
if (G == null) {
|
|
G = n.emptyList();
|
|
}
|
|
List sortedWith = u.sortedWith(G, new WidgetGuildClone$configureUI$$inlined$sortedBy$2());
|
|
ArrayList arrayList = new ArrayList();
|
|
for (Object obj : sortedWith) {
|
|
if (!m.areEqual(((GuildRole) obj).g(), "@everyone")) {
|
|
arrayList.add(obj);
|
|
}
|
|
}
|
|
LinearLayout linearLayout = getBinding().j;
|
|
m.checkNotNullExpressionValue(linearLayout, "binding.guildTemplatePreviewRolesLayout");
|
|
if (!(!arrayList.isEmpty())) {
|
|
i = 8;
|
|
}
|
|
linearLayout.setVisibility(i);
|
|
RolesListView rolesListView = getBinding().i;
|
|
RolesListView rolesListView2 = getBinding().i;
|
|
m.checkNotNullExpressionValue(rolesListView2, "binding.guildTemplatePreviewRoles");
|
|
rolesListView.updateView(arrayList, ColorCompat.getThemedColor(rolesListView2.getContext(), (int) R.attr.primary_300), serializedSourceGuild.r());
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override // com.discord.widgets.guilds.create.WidgetGuildCreate
|
|
public WidgetGuildCreateViewModel createViewModelFactory() {
|
|
return new WidgetGuildCreateViewModel(R.string.create_server_default_server_name_format, null, getMostRecentIntent().getStringExtra(INTENT_GUILD_TEMPLATE_CODE), false, getArgs().getAnalyticsLocation(), null, false, null, null, null, 962, null);
|
|
}
|
|
|
|
@Override // com.discord.widgets.guilds.create.WidgetGuildCreate
|
|
public GuildCreateCloneViews getViews() {
|
|
GuildCreateCloneViews.Companion companion = GuildCreateCloneViews.Companion;
|
|
WidgetGuildCloneBinding binding = getBinding();
|
|
m.checkNotNullExpressionValue(binding, "binding");
|
|
return companion.from(binding);
|
|
}
|
|
}
|