197 lines
11 KiB
Java
197 lines
11 KiB
Java
package com.discord.widgets.chat.list.adapter;
|
|
|
|
import android.content.Context;
|
|
import android.view.View;
|
|
import android.widget.ImageView;
|
|
import android.widget.LinearLayout;
|
|
import android.widget.TextView;
|
|
import androidx.appcompat.widget.AppCompatImageView;
|
|
import androidx.constraintlayout.widget.ConstraintLayout;
|
|
import androidx.constraintlayout.widget.Guideline;
|
|
import b.d.b.a.a;
|
|
import com.discord.R;
|
|
import com.discord.api.user.User;
|
|
import com.discord.api.utcdatetime.UtcDateTime;
|
|
import com.discord.databinding.WidgetChatListAdapterItemSystemBinding;
|
|
import com.discord.models.guild.Guild;
|
|
import com.discord.models.member.GuildMember;
|
|
import com.discord.models.message.Message;
|
|
import com.discord.stores.StoreStream;
|
|
import com.discord.utilities.color.ColorCompat;
|
|
import com.discord.utilities.time.TimeUtils;
|
|
import com.discord.utilities.view.extensions.ViewExtensions;
|
|
import com.discord.utilities.view.text.LinkifiedTextView;
|
|
import com.discord.views.sticker.StickerView;
|
|
import com.discord.widgets.chat.list.entries.ChatListEntry;
|
|
import com.discord.widgets.chat.list.entries.MessageEntry;
|
|
import d0.t.u;
|
|
import d0.z.d.m;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import rx.Subscription;
|
|
/* compiled from: WidgetChatListAdapterItemSystemMessage.kt */
|
|
public final class WidgetChatListAdapterItemSystemMessage extends WidgetChatListItem {
|
|
private final WidgetChatListAdapterItemSystemBinding binding;
|
|
private Subscription subscription;
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public WidgetChatListAdapterItemSystemMessage(WidgetChatListAdapter widgetChatListAdapter) {
|
|
super(R.layout.widget_chat_list_adapter_item_system, widgetChatListAdapter);
|
|
m.checkNotNullParameter(widgetChatListAdapter, "adapter");
|
|
View view = this.itemView;
|
|
int i = R.id.chat_list_adapter_item_thread_embed_spine;
|
|
AppCompatImageView appCompatImageView = (AppCompatImageView) view.findViewById(R.id.chat_list_adapter_item_thread_embed_spine);
|
|
if (appCompatImageView != null) {
|
|
i = R.id.system_icon;
|
|
ImageView imageView = (ImageView) view.findViewById(R.id.system_icon);
|
|
if (imageView != null) {
|
|
i = R.id.system_text;
|
|
LinkifiedTextView linkifiedTextView = (LinkifiedTextView) view.findViewById(R.id.system_text);
|
|
if (linkifiedTextView != null) {
|
|
i = R.id.system_timestamp;
|
|
TextView textView = (TextView) view.findViewById(R.id.system_timestamp);
|
|
if (textView != null) {
|
|
i = R.id.system_welcome_cta_button;
|
|
LinearLayout linearLayout = (LinearLayout) view.findViewById(R.id.system_welcome_cta_button);
|
|
if (linearLayout != null) {
|
|
i = R.id.system_welcome_cta_button_sticker;
|
|
StickerView stickerView = (StickerView) view.findViewById(R.id.system_welcome_cta_button_sticker);
|
|
if (stickerView != null) {
|
|
i = R.id.uikit_chat_guideline;
|
|
Guideline guideline = (Guideline) view.findViewById(R.id.uikit_chat_guideline);
|
|
if (guideline != null) {
|
|
WidgetChatListAdapterItemSystemBinding widgetChatListAdapterItemSystemBinding = new WidgetChatListAdapterItemSystemBinding((ConstraintLayout) view, appCompatImageView, imageView, linkifiedTextView, textView, linearLayout, stickerView, guideline);
|
|
m.checkNotNullExpressionValue(widgetChatListAdapterItemSystemBinding, "WidgetChatListAdapterIte…temBinding.bind(itemView)");
|
|
this.binding = widgetChatListAdapterItemSystemBinding;
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
throw new NullPointerException("Missing required view with ID: ".concat(view.getResources().getResourceName(i)));
|
|
}
|
|
|
|
public static final /* synthetic */ WidgetChatListAdapter access$getAdapter$p(WidgetChatListAdapterItemSystemMessage widgetChatListAdapterItemSystemMessage) {
|
|
return (WidgetChatListAdapter) widgetChatListAdapterItemSystemMessage.adapter;
|
|
}
|
|
|
|
public static final /* synthetic */ WidgetChatListAdapterItemSystemBinding access$getBinding$p(WidgetChatListAdapterItemSystemMessage widgetChatListAdapterItemSystemMessage) {
|
|
return widgetChatListAdapterItemSystemMessage.binding;
|
|
}
|
|
|
|
private final int getIcon(Message message) {
|
|
Integer type = message.getType();
|
|
if (type == null || type.intValue() != 1) {
|
|
if (type != null && type.intValue() == 2) {
|
|
return R.drawable.ic_group_leave;
|
|
}
|
|
if ((type != null && type.intValue() == 4) || (type != null && type.intValue() == 5)) {
|
|
return R.drawable.ic_group_edit;
|
|
}
|
|
if (type != null && type.intValue() == 6) {
|
|
return R.drawable.ic_channel_pinned_message;
|
|
}
|
|
if (type == null || type.intValue() != 7) {
|
|
if ((type != null && type.intValue() == 8) || ((type != null && type.intValue() == 9) || ((type != null && type.intValue() == 10) || (type != null && type.intValue() == 11)))) {
|
|
return R.drawable.ic_user_premium_guild_subscription;
|
|
}
|
|
if (type == null || type.intValue() != 12) {
|
|
if (type == null || type.intValue() != 14) {
|
|
if (type != null && type.intValue() == 15) {
|
|
return R.drawable.ic_check_green_24dp;
|
|
}
|
|
if (type != null && type.intValue() == 16) {
|
|
return R.drawable.ic_warning_circle_24dp;
|
|
}
|
|
if (type != null && type.intValue() == 17) {
|
|
return R.drawable.ic_warning_circle_24dp;
|
|
}
|
|
if (type != null && type.intValue() == 18) {
|
|
return R.drawable.ic_thread;
|
|
}
|
|
if (type != null) {
|
|
type.intValue();
|
|
}
|
|
}
|
|
return R.drawable.ic_x_red_24dp;
|
|
}
|
|
}
|
|
}
|
|
return R.drawable.ic_group_join;
|
|
}
|
|
|
|
private final CharSequence getSystemMessage(Message message, Context context, String str, int i, Long l, String str2, int i2, String str3) {
|
|
return new WidgetChatListAdapterItemSystemMessage$getSystemMessage$1(message, str, str2, new WidgetChatListAdapterItemSystemMessage$getSystemMessage$usernameRenderContext$1(i, i2), l, context, str3, new WidgetChatListAdapterItemSystemMessage$getSystemMessage$actorRenderContext$1(i)).invoke(context);
|
|
}
|
|
|
|
@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) {
|
|
User user;
|
|
m.checkNotNullParameter(chatListEntry, "data");
|
|
super.onConfigure(i, chatListEntry);
|
|
MessageEntry messageEntry = (MessageEntry) chatListEntry;
|
|
Message component1 = messageEntry.component1();
|
|
GuildMember component3 = messageEntry.component3();
|
|
GuildMember component4 = messageEntry.component4();
|
|
Map<Long, String> component6 = messageEntry.component6();
|
|
User author = component1.getAuthor();
|
|
String str = component6.get(author != null ? Long.valueOf(author.i()) : null);
|
|
Guild guild = ((WidgetChatListAdapter) this.adapter).getData().getGuild();
|
|
String name = guild != null ? guild.getName() : null;
|
|
List<User> mentions = component1.getMentions();
|
|
Long valueOf = (mentions == null || (user = (User) u.firstOrNull(mentions)) == null) ? null : Long.valueOf(user.i());
|
|
String str2 = valueOf != null ? component6.get(Long.valueOf(valueOf.longValue())) : null;
|
|
LinkifiedTextView linkifiedTextView = this.binding.d;
|
|
m.checkNotNullExpressionValue(linkifiedTextView, "binding.systemText");
|
|
int themedColor = ColorCompat.getThemedColor(linkifiedTextView.getContext(), (int) R.attr.colorHeaderPrimary);
|
|
GuildMember.Companion companion = GuildMember.Companion;
|
|
int color = companion.getColor(component3, themedColor);
|
|
int color2 = companion.getColor(component4, themedColor);
|
|
LinkifiedTextView linkifiedTextView2 = this.binding.d;
|
|
m.checkNotNullExpressionValue(linkifiedTextView2, "binding.systemText");
|
|
Context context = linkifiedTextView2.getContext();
|
|
m.checkNotNullExpressionValue(context, "binding.systemText.context");
|
|
CharSequence systemMessage = getSystemMessage(component1, context, str, color, valueOf, str2, color2, name);
|
|
this.binding.a.setOnClickListener(new WidgetChatListAdapterItemSystemMessage$onConfigure$1(this, component1, StoreStream.Companion.getExperiments()));
|
|
ConstraintLayout constraintLayout = this.binding.a;
|
|
m.checkNotNullExpressionValue(constraintLayout, "binding.root");
|
|
ViewExtensions.setOnLongClickListenerConsumeClick(constraintLayout, new WidgetChatListAdapterItemSystemMessage$onConfigure$2(this, component1));
|
|
TextView textView = this.binding.e;
|
|
m.checkNotNullExpressionValue(textView, "binding.systemTimestamp");
|
|
Context x2 = a.x(this.itemView, "itemView", "itemView.context");
|
|
UtcDateTime timestamp = component1.getTimestamp();
|
|
textView.setText(TimeUtils.toReadableTimeString$default(x2, timestamp != null ? timestamp.g() : 0, null, 4, null));
|
|
LinkifiedTextView linkifiedTextView3 = this.binding.d;
|
|
m.checkNotNullExpressionValue(linkifiedTextView3, "binding.systemText");
|
|
linkifiedTextView3.setText(systemMessage);
|
|
this.binding.c.setImageResource(getIcon(component1));
|
|
AppCompatImageView appCompatImageView = this.binding.f2311b;
|
|
m.checkNotNullExpressionValue(appCompatImageView, "binding.chatListAdapterItemThreadEmbedSpine");
|
|
boolean z2 = true;
|
|
int i2 = 0;
|
|
appCompatImageView.setVisibility(component1.hasThread() && !messageEntry.isThreadStarterMessage() ? 0 : 8);
|
|
LinearLayout linearLayout = this.binding.f;
|
|
m.checkNotNullExpressionValue(linearLayout, "binding.systemWelcomeCtaButton");
|
|
if (messageEntry.getWelcomeData() == null) {
|
|
z2 = false;
|
|
}
|
|
if (!z2) {
|
|
i2 = 8;
|
|
}
|
|
linearLayout.setVisibility(i2);
|
|
if (messageEntry.getWelcomeData() != null) {
|
|
StickerView.e(this.binding.g, messageEntry.getWelcomeData().getSticker(), null, 2);
|
|
this.binding.g.b();
|
|
this.binding.f.setOnClickListener(new WidgetChatListAdapterItemSystemMessage$onConfigure$3(this, component1, chatListEntry));
|
|
}
|
|
}
|
|
}
|