257 lines
12 KiB
Java
257 lines
12 KiB
Java
package com.discord.widgets.chat.list.adapter;
|
|
|
|
import android.content.Context;
|
|
import android.view.View;
|
|
import android.widget.ImageView;
|
|
import android.widget.TextView;
|
|
import androidx.constraintlayout.widget.ConstraintLayout;
|
|
import c.d.b.a.a;
|
|
import com.discord.databinding.WidgetChatListAdapterItemGuildTemplateBinding;
|
|
import com.discord.models.domain.ModelGuildTemplate;
|
|
import com.discord.stores.StoreStream;
|
|
import com.discord.utilities.resources.StringResourceUtilsKt;
|
|
import com.discord.utilities.rx.ObservableExtensionsKt;
|
|
import com.discord.utilities.view.extensions.ViewExtensions;
|
|
import com.discord.widgets.chat.list.entries.ChatListEntry;
|
|
import com.discord.widgets.chat.list.entries.GuildTemplateEntry;
|
|
import com.discord.widgets.guilds.create.WidgetGuildClone;
|
|
import com.google.android.material.button.MaterialButton;
|
|
import d0.z.d.m;
|
|
import kotlin.NoWhenBranchMatchedException;
|
|
import kotlin.jvm.functions.Function0;
|
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
|
import rx.Observable;
|
|
import rx.Subscription;
|
|
/* compiled from: WidgetChatListAdapterItemGuildTemplate.kt */
|
|
public final class WidgetChatListAdapterItemGuildTemplate extends WidgetChatListItem {
|
|
private final WidgetChatListAdapterItemGuildTemplateBinding binding;
|
|
private GuildTemplateEntry item;
|
|
private Subscription subscription;
|
|
|
|
/* compiled from: WidgetChatListAdapterItemGuildTemplate.kt */
|
|
public static abstract class Model {
|
|
|
|
/* compiled from: WidgetChatListAdapterItemGuildTemplate.kt */
|
|
public static final class Invalid extends Model {
|
|
public static final Invalid INSTANCE = new Invalid();
|
|
|
|
private Invalid() {
|
|
super(null);
|
|
}
|
|
}
|
|
|
|
/* compiled from: WidgetChatListAdapterItemGuildTemplate.kt */
|
|
public static final class Loading extends Model {
|
|
public static final Loading INSTANCE = new Loading();
|
|
|
|
private Loading() {
|
|
super(null);
|
|
}
|
|
}
|
|
|
|
/* compiled from: WidgetChatListAdapterItemGuildTemplate.kt */
|
|
public static final class Resolved extends Model {
|
|
private final ModelGuildTemplate guildTemplate;
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public Resolved(ModelGuildTemplate modelGuildTemplate) {
|
|
super(null);
|
|
m.checkNotNullParameter(modelGuildTemplate, "guildTemplate");
|
|
this.guildTemplate = modelGuildTemplate;
|
|
}
|
|
|
|
public static /* synthetic */ Resolved copy$default(Resolved resolved, ModelGuildTemplate modelGuildTemplate, int i, Object obj) {
|
|
if ((i & 1) != 0) {
|
|
modelGuildTemplate = resolved.guildTemplate;
|
|
}
|
|
return resolved.copy(modelGuildTemplate);
|
|
}
|
|
|
|
public final ModelGuildTemplate component1() {
|
|
return this.guildTemplate;
|
|
}
|
|
|
|
public final Resolved copy(ModelGuildTemplate modelGuildTemplate) {
|
|
m.checkNotNullParameter(modelGuildTemplate, "guildTemplate");
|
|
return new Resolved(modelGuildTemplate);
|
|
}
|
|
|
|
public boolean equals(Object obj) {
|
|
if (this != obj) {
|
|
return (obj instanceof Resolved) && m.areEqual(this.guildTemplate, ((Resolved) obj).guildTemplate);
|
|
}
|
|
return true;
|
|
}
|
|
|
|
public final ModelGuildTemplate getGuildTemplate() {
|
|
return this.guildTemplate;
|
|
}
|
|
|
|
public int hashCode() {
|
|
ModelGuildTemplate modelGuildTemplate = this.guildTemplate;
|
|
if (modelGuildTemplate != null) {
|
|
return modelGuildTemplate.hashCode();
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
public String toString() {
|
|
StringBuilder K = a.K("Resolved(guildTemplate=");
|
|
K.append(this.guildTemplate);
|
|
K.append(")");
|
|
return K.toString();
|
|
}
|
|
}
|
|
|
|
private Model() {
|
|
}
|
|
|
|
public /* synthetic */ Model(DefaultConstructorMarker defaultConstructorMarker) {
|
|
this();
|
|
}
|
|
}
|
|
|
|
/* compiled from: WidgetChatListAdapterItemGuildTemplate.kt */
|
|
public static final class ModelProvider {
|
|
public static final ModelProvider INSTANCE = new ModelProvider();
|
|
|
|
private ModelProvider() {
|
|
}
|
|
|
|
public final Observable<Model> get(GuildTemplateEntry guildTemplateEntry) {
|
|
m.checkNotNullParameter(guildTemplateEntry, "item");
|
|
Observable<R> Y = StoreStream.Companion.getGuildTemplates().observeGuildTemplate(guildTemplateEntry.getGuildTemplateCode()).u(new WidgetChatListAdapterItemGuildTemplate$ModelProvider$get$1(guildTemplateEntry)).Y(WidgetChatListAdapterItemGuildTemplate$ModelProvider$get$2.INSTANCE);
|
|
m.checkNotNullExpressionValue(Y, "StoreStream\n .get…tes\n }\n }");
|
|
return Y;
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public WidgetChatListAdapterItemGuildTemplate(WidgetChatListAdapter widgetChatListAdapter) {
|
|
super(2131558948, widgetChatListAdapter);
|
|
m.checkNotNullParameter(widgetChatListAdapter, "adapter");
|
|
View view = this.itemView;
|
|
int i = 2131363763;
|
|
TextView textView = (TextView) view.findViewById(2131363763);
|
|
if (textView != null) {
|
|
i = 2131363764;
|
|
ImageView imageView = (ImageView) view.findViewById(2131363764);
|
|
if (imageView != null) {
|
|
i = 2131363765;
|
|
MaterialButton materialButton = (MaterialButton) view.findViewById(2131363765);
|
|
if (materialButton != null) {
|
|
i = 2131363766;
|
|
TextView textView2 = (TextView) view.findViewById(2131363766);
|
|
if (textView2 != null) {
|
|
i = 2131363767;
|
|
TextView textView3 = (TextView) view.findViewById(2131363767);
|
|
if (textView3 != null) {
|
|
ConstraintLayout constraintLayout = (ConstraintLayout) view;
|
|
WidgetChatListAdapterItemGuildTemplateBinding widgetChatListAdapterItemGuildTemplateBinding = new WidgetChatListAdapterItemGuildTemplateBinding(constraintLayout, textView, imageView, materialButton, textView2, textView3, constraintLayout);
|
|
m.checkNotNullExpressionValue(widgetChatListAdapterItemGuildTemplateBinding, "WidgetChatListAdapterIte…ateBinding.bind(itemView)");
|
|
this.binding = widgetChatListAdapterItemGuildTemplateBinding;
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
throw new NullPointerException("Missing required view with ID: ".concat(view.getResources().getResourceName(i)));
|
|
}
|
|
|
|
public static final /* synthetic */ void access$configureInvalidUI(WidgetChatListAdapterItemGuildTemplate widgetChatListAdapterItemGuildTemplate) {
|
|
widgetChatListAdapterItemGuildTemplate.configureInvalidUI();
|
|
}
|
|
|
|
public static final /* synthetic */ void access$configureUI(WidgetChatListAdapterItemGuildTemplate widgetChatListAdapterItemGuildTemplate, Model model) {
|
|
widgetChatListAdapterItemGuildTemplate.configureUI(model);
|
|
}
|
|
|
|
public static final /* synthetic */ Subscription access$getSubscription$p(WidgetChatListAdapterItemGuildTemplate widgetChatListAdapterItemGuildTemplate) {
|
|
return widgetChatListAdapterItemGuildTemplate.subscription;
|
|
}
|
|
|
|
public static final /* synthetic */ void access$openGuildTemplate(WidgetChatListAdapterItemGuildTemplate widgetChatListAdapterItemGuildTemplate, Context context, ModelGuildTemplate modelGuildTemplate) {
|
|
widgetChatListAdapterItemGuildTemplate.openGuildTemplate(context, modelGuildTemplate);
|
|
}
|
|
|
|
public static final /* synthetic */ void access$setSubscription$p(WidgetChatListAdapterItemGuildTemplate widgetChatListAdapterItemGuildTemplate, Subscription subscription) {
|
|
widgetChatListAdapterItemGuildTemplate.subscription = subscription;
|
|
}
|
|
|
|
private final void configureInvalidUI() {
|
|
this.binding.f1742c.setText(2131890079);
|
|
this.binding.d.setText(2131890078);
|
|
TextView textView = this.binding.d;
|
|
m.checkNotNullExpressionValue(textView, "binding.itemGuildTemplateSubtext");
|
|
textView.setVisibility(0);
|
|
MaterialButton materialButton = this.binding.b;
|
|
m.checkNotNullExpressionValue(materialButton, "binding.itemGuildTemplateJoinButton");
|
|
materialButton.setVisibility(8);
|
|
}
|
|
|
|
private final void configureLoadingUI() {
|
|
this.binding.f1742c.setText(2131890162);
|
|
TextView textView = this.binding.d;
|
|
m.checkNotNullExpressionValue(textView, "binding.itemGuildTemplateSubtext");
|
|
textView.setVisibility(8);
|
|
MaterialButton materialButton = this.binding.b;
|
|
m.checkNotNullExpressionValue(materialButton, "binding.itemGuildTemplateJoinButton");
|
|
materialButton.setVisibility(8);
|
|
}
|
|
|
|
private final void configureResolvedUI(Model.Resolved resolved) {
|
|
ModelGuildTemplate component1 = resolved.component1();
|
|
TextView textView = this.binding.f1742c;
|
|
m.checkNotNullExpressionValue(textView, "binding.itemGuildTemplateName");
|
|
textView.setText(component1.getName());
|
|
TextView textView2 = this.binding.d;
|
|
m.checkNotNullExpressionValue(textView2, "binding.itemGuildTemplateSubtext");
|
|
TextView textView3 = this.binding.d;
|
|
m.checkNotNullExpressionValue(textView3, "binding.itemGuildTemplateSubtext");
|
|
Context context = textView3.getContext();
|
|
m.checkNotNullExpressionValue(context, "binding.itemGuildTemplateSubtext.context");
|
|
ViewExtensions.setTextAndVisibilityBy(textView2, StringResourceUtilsKt.getI18nPluralString(context, 2131755185, component1.getUsageCount(), Integer.valueOf(component1.getUsageCount())));
|
|
MaterialButton materialButton = this.binding.b;
|
|
m.checkNotNullExpressionValue(materialButton, "binding.itemGuildTemplateJoinButton");
|
|
materialButton.setVisibility(0);
|
|
this.binding.b.setOnClickListener(new WidgetChatListAdapterItemGuildTemplate$configureResolvedUI$1(this, component1));
|
|
}
|
|
|
|
private final void configureUI(Model model) {
|
|
if (model instanceof Model.Loading) {
|
|
configureLoadingUI();
|
|
} else if (model instanceof Model.Resolved) {
|
|
configureResolvedUI((Model.Resolved) model);
|
|
} else if (model instanceof Model.Invalid) {
|
|
configureInvalidUI();
|
|
} else {
|
|
throw new NoWhenBranchMatchedException();
|
|
}
|
|
}
|
|
|
|
private final void openGuildTemplate(Context context, ModelGuildTemplate modelGuildTemplate) {
|
|
WidgetGuildClone.Companion.show(context, modelGuildTemplate.getCode(), "Guild Template Embed");
|
|
}
|
|
|
|
@Override // com.discord.utilities.mg_recycler.MGRecyclerViewHolder
|
|
public Subscription getSubscription() {
|
|
return this.subscription;
|
|
}
|
|
|
|
@Override // com.discord.widgets.chat.list.adapter.WidgetChatListItem
|
|
public void onConfigure(int i, ChatListEntry chatListEntry) {
|
|
m.checkNotNullParameter(chatListEntry, "data");
|
|
super.onConfigure(i, chatListEntry);
|
|
GuildTemplateEntry guildTemplateEntry = (GuildTemplateEntry) chatListEntry;
|
|
this.item = guildTemplateEntry;
|
|
ModelProvider modelProvider = ModelProvider.INSTANCE;
|
|
if (guildTemplateEntry == null) {
|
|
m.throwUninitializedPropertyAccessException("item");
|
|
}
|
|
Observable ui = ObservableExtensionsKt.ui(modelProvider.get(guildTemplateEntry));
|
|
WidgetChatListAdapterItemGuildTemplate$onConfigure$1 widgetChatListAdapterItemGuildTemplate$onConfigure$1 = new WidgetChatListAdapterItemGuildTemplate$onConfigure$1(this);
|
|
ObservableExtensionsKt.appSubscribe$default(ui, WidgetChatListAdapterItemGuildTemplate.class, (Context) null, new WidgetChatListAdapterItemGuildTemplate$onConfigure$3(this), new WidgetChatListAdapterItemGuildTemplate$onConfigure$2(this), (Function0) null, (Function0) null, widgetChatListAdapterItemGuildTemplate$onConfigure$1, 50, (Object) null);
|
|
}
|
|
}
|