166 lines
8.8 KiB
Java
166 lines
8.8 KiB
Java
package com.discord.widgets.chat.list.adapter;
|
|
|
|
import android.content.Context;
|
|
import android.text.method.LinkMovementMethod;
|
|
import android.view.View;
|
|
import android.widget.FrameLayout;
|
|
import android.widget.ImageView;
|
|
import android.widget.TextView;
|
|
import androidx.cardview.widget.CardView;
|
|
import androidx.constraintlayout.widget.ConstraintLayout;
|
|
import androidx.constraintlayout.widget.Guideline;
|
|
import c.a.k.b;
|
|
import c.d.b.a.a;
|
|
import com.discord.api.user.User;
|
|
import com.discord.api.utcdatetime.UtcDateTime;
|
|
import com.discord.databinding.WidgetChatListAdapterItemApplicationCommandBinding;
|
|
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.widgets.chat.list.entries.ChatListEntry;
|
|
import com.discord.widgets.chat.list.entries.MessageEntry;
|
|
import d0.g0.t;
|
|
import d0.z.d.m;
|
|
import java.util.Map;
|
|
import java.util.regex.Matcher;
|
|
import java.util.regex.Pattern;
|
|
/* compiled from: WidgetChatListAdapterItemApplicationCommand.kt */
|
|
public final class WidgetChatListAdapterItemApplicationCommand extends WidgetChatListItem {
|
|
private final WidgetChatListAdapterItemApplicationCommandBinding binding;
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public WidgetChatListAdapterItemApplicationCommand(WidgetChatListAdapter widgetChatListAdapter) {
|
|
super(2131558934, widgetChatListAdapter);
|
|
m.checkNotNullParameter(widgetChatListAdapter, "adapter");
|
|
View view = this.itemView;
|
|
int i = 2131362551;
|
|
ImageView imageView = (ImageView) view.findViewById(2131362551);
|
|
if (imageView != null) {
|
|
i = 2131362552;
|
|
TextView textView = (TextView) view.findViewById(2131362552);
|
|
if (textView != null) {
|
|
i = 2131362553;
|
|
CardView cardView = (CardView) view.findViewById(2131362553);
|
|
if (cardView != null) {
|
|
i = 2131362556;
|
|
FrameLayout frameLayout = (FrameLayout) view.findViewById(2131362556);
|
|
if (frameLayout != null) {
|
|
i = 2131362560;
|
|
ConstraintLayout constraintLayout = (ConstraintLayout) view.findViewById(2131362560);
|
|
if (constraintLayout != null) {
|
|
i = 2131362562;
|
|
TextView textView2 = (TextView) view.findViewById(2131362562);
|
|
if (textView2 != null) {
|
|
i = 2131362565;
|
|
TextView textView3 = (TextView) view.findViewById(2131362565);
|
|
if (textView3 != null) {
|
|
i = 2131365472;
|
|
Guideline guideline = (Guideline) view.findViewById(2131365472);
|
|
if (guideline != null) {
|
|
WidgetChatListAdapterItemApplicationCommandBinding widgetChatListAdapterItemApplicationCommandBinding = new WidgetChatListAdapterItemApplicationCommandBinding((ConstraintLayout) view, imageView, textView, cardView, frameLayout, constraintLayout, textView2, textView3, guideline);
|
|
m.checkNotNullExpressionValue(widgetChatListAdapterItemApplicationCommandBinding, "WidgetChatListAdapterIte…andBinding.bind(itemView)");
|
|
this.binding = widgetChatListAdapterItemApplicationCommandBinding;
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
throw new NullPointerException("Missing required view with ID: ".concat(view.getResources().getResourceName(i)));
|
|
}
|
|
|
|
public static final /* synthetic */ WidgetChatListAdapter access$getAdapter$p(WidgetChatListAdapterItemApplicationCommand widgetChatListAdapterItemApplicationCommand) {
|
|
return (WidgetChatListAdapter) widgetChatListAdapterItemApplicationCommand.adapter;
|
|
}
|
|
|
|
public static final /* synthetic */ WidgetChatListAdapterItemApplicationCommandBinding access$getBinding$p(WidgetChatListAdapterItemApplicationCommand widgetChatListAdapterItemApplicationCommand) {
|
|
return widgetChatListAdapterItemApplicationCommand.binding;
|
|
}
|
|
|
|
private final int getAuthorTextColor(GuildMember guildMember) {
|
|
View view = this.itemView;
|
|
m.checkNotNullExpressionValue(view, "itemView");
|
|
return GuildMember.Companion.getColor(guildMember, ColorCompat.getThemedColor(view.getContext(), 2130968932));
|
|
}
|
|
|
|
/* JADX WARNING: Code restructure failed: missing block: B:9:0x0048, code lost:
|
|
if (r5 != null) goto L_0x004e;
|
|
*/
|
|
@Override // com.discord.widgets.chat.list.adapter.WidgetChatListItem
|
|
public void onConfigure(int i, ChatListEntry chatListEntry) {
|
|
String str;
|
|
String str2;
|
|
m.checkNotNullParameter(chatListEntry, "data");
|
|
super.onConfigure(i, chatListEntry);
|
|
MessageEntry messageEntry = (MessageEntry) chatListEntry;
|
|
Message message = messageEntry.getMessage();
|
|
GuildMember author = messageEntry.getAuthor();
|
|
Map<Long, String> nickOrUsernames = messageEntry.getNickOrUsernames();
|
|
int authorTextColor = getAuthorTextColor(author);
|
|
WidgetChatListAdapterItemApplicationCommand$onConfigure$1 widgetChatListAdapterItemApplicationCommand$onConfigure$1 = WidgetChatListAdapterItemApplicationCommand$onConfigure$1.INSTANCE;
|
|
Pattern compile = Pattern.compile("^<(/[^:]+):([0-9]*)>(.*)");
|
|
String content = message.getContent();
|
|
String str3 = "";
|
|
if (content == null) {
|
|
content = str3;
|
|
}
|
|
Matcher matcher = compile.matcher(content);
|
|
if (matcher.matches()) {
|
|
str = matcher.group(1);
|
|
if (str == null) {
|
|
str = str3;
|
|
}
|
|
str2 = matcher.group(3);
|
|
} else {
|
|
str = "/";
|
|
}
|
|
str2 = str3;
|
|
User author2 = message.getAuthor();
|
|
String str4 = nickOrUsernames.get(author2 != null ? Long.valueOf(author2.i()) : null);
|
|
if (str4 != null) {
|
|
str3 = str4;
|
|
}
|
|
View view = this.itemView;
|
|
m.checkNotNullExpressionValue(view, "itemView");
|
|
int themedColor = ColorCompat.getThemedColor(view, 2130969007);
|
|
TextView textView = this.binding.e;
|
|
m.checkNotNullExpressionValue(textView, "binding.chatListAdapterItemTextName");
|
|
CharSequence c2 = b.c(textView, 2131893951, new Object[]{str3, str}, new WidgetChatListAdapterItemApplicationCommand$onConfigure$content$1(this, authorTextColor, message, themedColor));
|
|
TextView textView2 = this.binding.e;
|
|
m.checkNotNullExpressionValue(textView2, "binding.chatListAdapterItemTextName");
|
|
textView2.setMovementMethod(LinkMovementMethod.getInstance());
|
|
TextView textView3 = this.binding.e;
|
|
m.checkNotNullExpressionValue(textView3, "binding.chatListAdapterItemTextName");
|
|
textView3.setText(c2);
|
|
TextView textView4 = this.binding.b;
|
|
m.checkNotNullExpressionValue(textView4, "binding.chatListAdapterItemTextCommand");
|
|
textView4.setMaxLines(1);
|
|
this.binding.b.setOnClickListener(new WidgetChatListAdapterItemApplicationCommand$onConfigure$2(this));
|
|
boolean z2 = !t.isBlank(str2);
|
|
CardView cardView = this.binding.f1732c;
|
|
m.checkNotNullExpressionValue(cardView, "binding.chatListAdapterItemTextDecorator");
|
|
int i2 = 8;
|
|
cardView.setVisibility(z2 ? 0 : 8);
|
|
FrameLayout frameLayout = this.binding.d;
|
|
m.checkNotNullExpressionValue(frameLayout, "binding.chatListAdapterI…extDecoratorReplyLinkIcon");
|
|
if (z2) {
|
|
i2 = 0;
|
|
}
|
|
frameLayout.setVisibility(i2);
|
|
TextView textView5 = this.binding.b;
|
|
m.checkNotNullExpressionValue(textView5, "binding.chatListAdapterItemTextCommand");
|
|
textView5.setText(b.g(a.x(this.itemView, "itemView", "itemView.context"), 2131887433, new Object[]{str, str2}, null, 4));
|
|
TextView textView6 = this.binding.b;
|
|
m.checkNotNullExpressionValue(textView6, "binding.chatListAdapterItemTextCommand");
|
|
widgetChatListAdapterItemApplicationCommand$onConfigure$1.invoke(textView6);
|
|
TextView textView7 = this.binding.f;
|
|
m.checkNotNullExpressionValue(textView7, "binding.chatListAdapterItemTextTimestamp");
|
|
Context x2 = a.x(this.itemView, "itemView", "itemView.context");
|
|
UtcDateTime timestamp = message.getTimestamp();
|
|
textView7.setText(TimeUtils.toReadableTimeString$default(x2, timestamp != null ? timestamp.f() : 0, null, 4, null));
|
|
}
|
|
}
|