discord-jadx/app/src/main/java/com/discord/widgets/chat/list/adapter/WidgetChatListAdapterItemSy...

166 lines
9.0 KiB
Java
Raw Normal View History

2021-06-27 20:44:35 +00:00
package com.discord.widgets.chat.list.adapter;
import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
2021-07-19 11:38:20 +00:00
import androidx.appcompat.widget.AppCompatImageView;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.constraintlayout.widget.Guideline;
2021-06-27 20:44:35 +00:00
import c.d.b.a.a;
import com.discord.api.user.User;
2021-06-27 20:53:42 +00:00
import com.discord.api.utcdatetime.UtcDateTime;
2021-06-27 20:44:35 +00:00
import com.discord.databinding.WidgetChatListAdapterItemSystemBinding;
import com.discord.models.guild.Guild;
import com.discord.models.member.GuildMember;
2021-07-03 23:36:06 +00:00
import com.discord.models.message.Message;
2021-06-27 20:44:35 +00:00
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.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;
/* compiled from: WidgetChatListAdapterItemSystemMessage.kt */
public final class WidgetChatListAdapterItemSystemMessage extends WidgetChatListItem {
private final WidgetChatListAdapterItemSystemBinding binding;
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public WidgetChatListAdapterItemSystemMessage(WidgetChatListAdapter widgetChatListAdapter) {
2021-07-19 19:45:22 +00:00
super(2131558969, widgetChatListAdapter);
2021-06-27 20:44:35 +00:00
m.checkNotNullParameter(widgetChatListAdapter, "adapter");
View view = this.itemView;
2021-07-19 19:45:22 +00:00
int i = 2131362566;
AppCompatImageView appCompatImageView = (AppCompatImageView) view.findViewById(2131362566);
2021-07-19 11:38:20 +00:00
if (appCompatImageView != null) {
2021-07-20 00:17:12 +00:00
i = 2131365288;
ImageView imageView = (ImageView) view.findViewById(2131365288);
2021-07-19 11:38:20 +00:00
if (imageView != null) {
2021-07-20 00:17:12 +00:00
i = 2131365289;
LinkifiedTextView linkifiedTextView = (LinkifiedTextView) view.findViewById(2131365289);
2021-07-19 11:38:20 +00:00
if (linkifiedTextView != null) {
2021-07-20 00:17:12 +00:00
i = 2131365290;
TextView textView = (TextView) view.findViewById(2131365290);
2021-07-19 11:38:20 +00:00
if (textView != null) {
2021-07-20 00:17:12 +00:00
i = 2131365471;
Guideline guideline = (Guideline) view.findViewById(2131365471);
2021-07-19 11:38:20 +00:00
if (guideline != null) {
WidgetChatListAdapterItemSystemBinding widgetChatListAdapterItemSystemBinding = new WidgetChatListAdapterItemSystemBinding((ConstraintLayout) view, appCompatImageView, imageView, linkifiedTextView, textView, guideline);
m.checkNotNullExpressionValue(widgetChatListAdapterItemSystemBinding, "WidgetChatListAdapterIte…temBinding.bind(itemView)");
this.binding = widgetChatListAdapterItemSystemBinding;
return;
}
}
2021-06-27 20:44:35 +00:00
}
}
}
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;
}
2021-06-27 20:53:42 +00:00
private final int getIcon(Message message) {
2021-07-03 23:36:06 +00:00
Integer type = message.getType();
if (type == null || type.intValue() != 1) {
if (type != null && type.intValue() == 2) {
2021-07-19 19:45:22 +00:00
return 2131231679;
2021-06-27 20:53:42 +00:00
}
2021-07-03 23:36:06 +00:00
if ((type != null && type.intValue() == 4) || (type != null && type.intValue() == 5)) {
2021-07-19 19:45:22 +00:00
return 2131231677;
2021-06-27 20:53:42 +00:00
}
2021-07-03 23:36:06 +00:00
if (type != null && type.intValue() == 6) {
2021-07-19 19:45:22 +00:00
return 2131231491;
2021-06-27 20:53:42 +00:00
}
2021-07-03 23:36:06 +00:00
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)))) {
2021-07-19 19:45:22 +00:00
return 2131232057;
2021-06-27 20:53:42 +00:00
}
2021-07-03 23:36:06 +00:00
if (type == null || type.intValue() != 12) {
if (type == null || type.intValue() != 14) {
if (type != null && type.intValue() == 15) {
2021-07-19 19:45:22 +00:00
return 2131231521;
2021-06-27 20:53:42 +00:00
}
2021-07-03 23:36:06 +00:00
if (type != null && type.intValue() == 16) {
2021-07-19 19:45:22 +00:00
return 2131232089;
2021-06-27 20:53:42 +00:00
}
2021-07-03 23:36:06 +00:00
if (type != null && type.intValue() == 17) {
2021-07-19 19:45:22 +00:00
return 2131232089;
2021-06-27 20:53:42 +00:00
}
2021-07-03 23:36:06 +00:00
if (type != null && type.intValue() == 18) {
2021-07-19 19:45:22 +00:00
return 2131232019;
2021-06-27 20:53:42 +00:00
}
2021-07-03 23:36:06 +00:00
if (type != null) {
type.intValue();
2021-06-27 20:53:42 +00:00
}
}
2021-07-19 19:45:22 +00:00
return 2131232090;
2021-06-27 20:53:42 +00:00
}
}
2021-06-27 20:44:35 +00:00
}
2021-07-19 19:45:22 +00:00
return 2131231678;
2021-06-27 20:44:35 +00:00
}
2021-06-27 20:53:42 +00:00
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);
2021-06-27 20:44:35 +00:00
}
@Override // com.discord.widgets.chat.list.adapter.WidgetChatListItem
public void onConfigure(int i, ChatListEntry chatListEntry) {
2021-06-27 20:53:42 +00:00
User user;
2021-06-27 20:44:35 +00:00
m.checkNotNullParameter(chatListEntry, "data");
super.onConfigure(i, chatListEntry);
MessageEntry messageEntry = (MessageEntry) chatListEntry;
2021-06-27 20:53:42 +00:00
Message component1 = messageEntry.component1();
2021-06-27 20:44:35 +00:00
GuildMember component3 = messageEntry.component3();
GuildMember component4 = messageEntry.component4();
Map<Long, String> component6 = messageEntry.component6();
2021-07-03 23:36:06 +00:00
User author = component1.getAuthor();
String str = component6.get(author != null ? Long.valueOf(author.i()) : null);
2021-06-27 20:44:35 +00:00
Guild guild = ((WidgetChatListAdapter) this.adapter).getData().getGuild();
String name = guild != null ? guild.getName() : null;
2021-07-03 23:36:06 +00:00
List<User> mentions = component1.getMentions();
Long valueOf = (mentions == null || (user = (User) u.firstOrNull(mentions)) == null) ? null : Long.valueOf(user.i());
2021-06-27 20:44:35 +00:00
String str2 = valueOf != null ? component6.get(Long.valueOf(valueOf.longValue())) : null;
2021-07-19 11:38:20 +00:00
LinkifiedTextView linkifiedTextView = this.binding.d;
2021-06-27 20:44:35 +00:00
m.checkNotNullExpressionValue(linkifiedTextView, "binding.systemText");
int themedColor = ColorCompat.getThemedColor(linkifiedTextView.getContext(), 2130968932);
GuildMember.Companion companion = GuildMember.Companion;
int color = companion.getColor(component3, themedColor);
int color2 = companion.getColor(component4, themedColor);
2021-07-19 11:38:20 +00:00
LinkifiedTextView linkifiedTextView2 = this.binding.d;
2021-06-27 20:44:35 +00:00
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));
2021-07-19 11:38:20 +00:00
ConstraintLayout constraintLayout = this.binding.a;
m.checkNotNullExpressionValue(constraintLayout, "binding.root");
ViewExtensions.setOnLongClickListenerConsumeClick(constraintLayout, new WidgetChatListAdapterItemSystemMessage$onConfigure$2(this, component1));
TextView textView = this.binding.e;
2021-06-27 20:44:35 +00:00
m.checkNotNullExpressionValue(textView, "binding.systemTimestamp");
2021-07-19 19:45:22 +00:00
Context x2 = a.x(this.itemView, "itemView", "itemView.context");
2021-07-03 23:36:06 +00:00
UtcDateTime timestamp = component1.getTimestamp();
2021-07-19 19:45:22 +00:00
textView.setText(TimeUtils.toReadableTimeString$default(x2, timestamp != null ? timestamp.f() : 0, null, 4, null));
2021-07-19 11:38:20 +00:00
LinkifiedTextView linkifiedTextView3 = this.binding.d;
2021-06-27 20:44:35 +00:00
m.checkNotNullExpressionValue(linkifiedTextView3, "binding.systemText");
linkifiedTextView3.setText(systemMessage);
2021-07-19 19:45:22 +00:00
this.binding.f1753c.setImageResource(getIcon(component1));
2021-07-19 11:38:20 +00:00
AppCompatImageView appCompatImageView = this.binding.b;
m.checkNotNullExpressionValue(appCompatImageView, "binding.chatListAdapterItemThreadEmbedSpine");
int i2 = 0;
if (!(component1.hasThread() && !messageEntry.isThreadStarterMessage())) {
i2 = 8;
}
appCompatImageView.setVisibility(i2);
2021-06-27 20:44:35 +00:00
}
}