160 lines
8.3 KiB
Java
160 lines
8.3 KiB
Java
package com.discord.widgets.chat.list.adapter;
|
|
|
|
import android.view.View;
|
|
import android.widget.LinearLayout;
|
|
import androidx.constraintlayout.widget.ConstraintLayout;
|
|
import androidx.fragment.app.FragmentManager;
|
|
import com.discord.api.botuikit.SelectItem;
|
|
import com.discord.databinding.WidgetChatListAdapterItemBotComponentRowBinding;
|
|
import com.discord.models.botuikit.MessageComponent;
|
|
import com.discord.models.message.Message;
|
|
import com.discord.restapi.RestAPIParams;
|
|
import com.discord.widgets.botuikit.ComponentProvider;
|
|
import com.discord.widgets.botuikit.views.ComponentActionListener;
|
|
import com.discord.widgets.botuikit.views.select.ComponentContext;
|
|
import com.discord.widgets.botuikit.views.select.SelectComponentBottomSheet;
|
|
import com.discord.widgets.chat.list.entries.BotUiComponentEntry;
|
|
import com.discord.widgets.chat.list.entries.ChatListEntry;
|
|
import d0.t.n;
|
|
import d0.t.o;
|
|
import d0.t.u;
|
|
import d0.z.d.m;
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
/* compiled from: WidgetChatListAdapterItemBotComponentRow.kt */
|
|
public final class WidgetChatListAdapterItemBotComponentRow extends WidgetChatListItem implements ComponentActionListener {
|
|
private final WidgetChatListAdapterItemBotComponentRowBinding binding;
|
|
public BotUiComponentEntry entry;
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public WidgetChatListAdapterItemBotComponentRow(WidgetChatListAdapter widgetChatListAdapter) {
|
|
super(2131558929, widgetChatListAdapter);
|
|
m.checkNotNullParameter(widgetChatListAdapter, "adapter");
|
|
View view = this.itemView;
|
|
int i = 2131362526;
|
|
LinearLayout linearLayout = (LinearLayout) view.findViewById(2131362526);
|
|
if (linearLayout != null) {
|
|
i = 2131362530;
|
|
View findViewById = view.findViewById(2131362530);
|
|
if (findViewById != null) {
|
|
i = 2131362532;
|
|
View findViewById2 = view.findViewById(2131362532);
|
|
if (findViewById2 != null) {
|
|
WidgetChatListAdapterItemBotComponentRowBinding widgetChatListAdapterItemBotComponentRowBinding = new WidgetChatListAdapterItemBotComponentRowBinding((ConstraintLayout) view, linearLayout, findViewById, findViewById2);
|
|
m.checkNotNullExpressionValue(widgetChatListAdapterItemBotComponentRowBinding, "WidgetChatListAdapterIte…RowBinding.bind(itemView)");
|
|
this.binding = widgetChatListAdapterItemBotComponentRowBinding;
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
throw new NullPointerException("Missing required view with ID: ".concat(view.getResources().getResourceName(i)));
|
|
}
|
|
|
|
public final BotUiComponentEntry getEntry() {
|
|
BotUiComponentEntry botUiComponentEntry = this.entry;
|
|
if (botUiComponentEntry == null) {
|
|
m.throwUninitializedPropertyAccessException("entry");
|
|
}
|
|
return botUiComponentEntry;
|
|
}
|
|
|
|
@Override // com.discord.widgets.botuikit.views.ComponentActionListener
|
|
public void onButtonComponentClick(int i, String str, String str2) {
|
|
m.checkNotNullParameter(str, "customId");
|
|
m.checkNotNullParameter(str2, "hash");
|
|
WidgetChatListAdapter widgetChatListAdapter = (WidgetChatListAdapter) this.adapter;
|
|
BotUiComponentEntry botUiComponentEntry = this.entry;
|
|
if (botUiComponentEntry == null) {
|
|
m.throwUninitializedPropertyAccessException("entry");
|
|
}
|
|
long applicationId = botUiComponentEntry.getApplicationId();
|
|
BotUiComponentEntry botUiComponentEntry2 = this.entry;
|
|
if (botUiComponentEntry2 == null) {
|
|
m.throwUninitializedPropertyAccessException("entry");
|
|
}
|
|
long id2 = botUiComponentEntry2.getMessage().getId();
|
|
BotUiComponentEntry botUiComponentEntry3 = this.entry;
|
|
if (botUiComponentEntry3 == null) {
|
|
m.throwUninitializedPropertyAccessException("entry");
|
|
}
|
|
widgetChatListAdapter.onBotUiComponentClicked(applicationId, id2, botUiComponentEntry3.getMessage().getFlags(), i, new RestAPIParams.ComponentInteractionData.ButtonComponentInteractionData(null, str, str2, 1, null));
|
|
}
|
|
|
|
@Override // com.discord.widgets.chat.list.adapter.WidgetChatListItem
|
|
public void onConfigure(int i, ChatListEntry chatListEntry) {
|
|
m.checkNotNullParameter(chatListEntry, "data");
|
|
super.onConfigure(i, chatListEntry);
|
|
BotUiComponentEntry botUiComponentEntry = (BotUiComponentEntry) chatListEntry;
|
|
this.entry = botUiComponentEntry;
|
|
if (botUiComponentEntry == null) {
|
|
m.throwUninitializedPropertyAccessException("entry");
|
|
}
|
|
Message message = botUiComponentEntry.getMessage();
|
|
View view = this.binding.f1726c;
|
|
m.checkNotNullExpressionValue(view, "binding.chatListAdapterItemGutterBg");
|
|
View view2 = this.binding.d;
|
|
m.checkNotNullExpressionValue(view2, "binding.chatListAdapterItemHighlightedBg");
|
|
configureCellHighlight(message, view2, view);
|
|
BotUiComponentEntry botUiComponentEntry2 = this.entry;
|
|
if (botUiComponentEntry2 == null) {
|
|
m.throwUninitializedPropertyAccessException("entry");
|
|
}
|
|
List<MessageComponent> messageComponents = botUiComponentEntry2.getMessageComponents();
|
|
ArrayList arrayList = new ArrayList(o.collectionSizeOrDefault(messageComponents, 10));
|
|
int i2 = 0;
|
|
for (Object obj : messageComponents) {
|
|
int i3 = i2 + 1;
|
|
if (i2 < 0) {
|
|
n.throwIndexOverflow();
|
|
}
|
|
ComponentProvider botUiComponentProvider = ((WidgetChatListAdapter) this.adapter).getBotUiComponentProvider();
|
|
LinearLayout linearLayout = this.binding.b;
|
|
m.checkNotNullExpressionValue(linearLayout, "binding.chatListAdapterItemComponentRoot");
|
|
arrayList.add(botUiComponentProvider.getConfiguredComponentView(this, (MessageComponent) obj, linearLayout, i2));
|
|
i2 = i3;
|
|
}
|
|
LinearLayout linearLayout2 = this.binding.b;
|
|
m.checkNotNullExpressionValue(linearLayout2, "binding.chatListAdapterItemComponentRoot");
|
|
WidgetChatListAdapterItemBotComponentRowKt.replaceViews(linearLayout2, u.filterNotNull(arrayList));
|
|
}
|
|
|
|
@Override // com.discord.widgets.botuikit.views.ComponentActionListener
|
|
public void onSelectComponentClick(int i, String str, String str2, String str3, List<SelectItem> list, List<SelectItem> list2, int i2, int i3) {
|
|
m.checkNotNullParameter(str, "customId");
|
|
m.checkNotNullParameter(str2, "hash");
|
|
m.checkNotNullParameter(list, "options");
|
|
m.checkNotNullParameter(list2, "selectedItems");
|
|
SelectComponentBottomSheet.Companion companion = SelectComponentBottomSheet.Companion;
|
|
FragmentManager fragmentManager = ((WidgetChatListAdapter) this.adapter).getFragmentManager();
|
|
BotUiComponentEntry botUiComponentEntry = this.entry;
|
|
if (botUiComponentEntry == null) {
|
|
m.throwUninitializedPropertyAccessException("entry");
|
|
}
|
|
Long guildId = botUiComponentEntry.getGuildId();
|
|
BotUiComponentEntry botUiComponentEntry2 = this.entry;
|
|
if (botUiComponentEntry2 == null) {
|
|
m.throwUninitializedPropertyAccessException("entry");
|
|
}
|
|
long id2 = botUiComponentEntry2.getMessage().getId();
|
|
BotUiComponentEntry botUiComponentEntry3 = this.entry;
|
|
if (botUiComponentEntry3 == null) {
|
|
m.throwUninitializedPropertyAccessException("entry");
|
|
}
|
|
long channelId = botUiComponentEntry3.getMessage().getChannelId();
|
|
BotUiComponentEntry botUiComponentEntry4 = this.entry;
|
|
if (botUiComponentEntry4 == null) {
|
|
m.throwUninitializedPropertyAccessException("entry");
|
|
}
|
|
Long flags = botUiComponentEntry4.getMessage().getFlags();
|
|
BotUiComponentEntry botUiComponentEntry5 = this.entry;
|
|
if (botUiComponentEntry5 == null) {
|
|
m.throwUninitializedPropertyAccessException("entry");
|
|
}
|
|
companion.show(fragmentManager, new ComponentContext(guildId, id2, channelId, flags, botUiComponentEntry5.getApplicationId()), i, str, str2, str3, i2, i3, list, list2);
|
|
}
|
|
|
|
public final void setEntry(BotUiComponentEntry botUiComponentEntry) {
|
|
m.checkNotNullParameter(botUiComponentEntry, "<set-?>");
|
|
this.entry = botUiComponentEntry;
|
|
}
|
|
}
|