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

166 lines
9.0 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.appcompat.widget.AppCompatImageView;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.constraintlayout.widget.Guideline;
import c.d.b.a.a;
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.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) {
super(2131558969, widgetChatListAdapter);
m.checkNotNullParameter(widgetChatListAdapter, "adapter");
View view = this.itemView;
int i = 2131362566;
AppCompatImageView appCompatImageView = (AppCompatImageView) view.findViewById(2131362566);
if (appCompatImageView != null) {
i = 2131365288;
ImageView imageView = (ImageView) view.findViewById(2131365288);
if (imageView != null) {
i = 2131365289;
LinkifiedTextView linkifiedTextView = (LinkifiedTextView) view.findViewById(2131365289);
if (linkifiedTextView != null) {
i = 2131365290;
TextView textView = (TextView) view.findViewById(2131365290);
if (textView != null) {
i = 2131365471;
Guideline guideline = (Guideline) view.findViewById(2131365471);
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;
}
}
}
}
}
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 2131231679;
}
if ((type != null && type.intValue() == 4) || (type != null && type.intValue() == 5)) {
return 2131231677;
}
if (type != null && type.intValue() == 6) {
return 2131231491;
}
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 2131232057;
}
if (type == null || type.intValue() != 12) {
if (type == null || type.intValue() != 14) {
if (type != null && type.intValue() == 15) {
return 2131231521;
}
if (type != null && type.intValue() == 16) {
return 2131232089;
}
if (type != null && type.intValue() == 17) {
return 2131232089;
}
if (type != null && type.intValue() == 18) {
return 2131232019;
}
if (type != null) {
type.intValue();
}
}
return 2131232090;
}
}
}
return 2131231678;
}
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.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(), 2130968932);
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));
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.f() : 0, null, 4, null));
LinkifiedTextView linkifiedTextView3 = this.binding.d;
m.checkNotNullExpressionValue(linkifiedTextView3, "binding.systemText");
linkifiedTextView3.setText(systemMessage);
this.binding.f1753c.setImageResource(getIcon(component1));
AppCompatImageView appCompatImageView = this.binding.b;
m.checkNotNullExpressionValue(appCompatImageView, "binding.chatListAdapterItemThreadEmbedSpine");
int i2 = 0;
if (!(component1.hasThread() && !messageEntry.isThreadStarterMessage())) {
i2 = 8;
}
appCompatImageView.setVisibility(i2);
}
}