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

903 lines
40 KiB
Java

package com.discord.widgets.chat.list.adapter;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.TransitionDrawable;
import android.net.Uri;
import android.view.GestureDetector;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import androidx.appcompat.widget.ActivityChooserModel;
import androidx.core.app.NotificationCompat;
import androidx.fragment.app.FragmentManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import c.i.a.f.e.o.f;
import com.discord.R;
import com.discord.api.activity.Activity;
import com.discord.api.application.Application;
import com.discord.api.channel.Channel;
import com.discord.api.guildscheduledevent.GuildScheduledEvent;
import com.discord.api.message.activity.MessageActivityType;
import com.discord.api.message.reaction.MessageReaction;
import com.discord.api.sticker.BaseSticker;
import com.discord.api.sticker.Sticker;
import com.discord.app.AppFragment;
import com.discord.app.AppPermissionsRequests;
import com.discord.models.guild.Guild;
import com.discord.models.message.Message;
import com.discord.restapi.RestAPIParams;
import com.discord.stores.StoreChat;
import com.discord.utilities.mg_recycler.MGRecyclerAdapterSimple;
import com.discord.utilities.mg_recycler.MGRecyclerViewHolder;
import com.discord.utilities.time.Clock;
import com.discord.utilities.time.ClockFactory;
import com.discord.utilities.views.ViewCoroutineScopeKt;
import com.discord.widgets.botuikit.ComponentProvider;
import com.discord.widgets.chat.input.AppFlexInputViewModel;
import com.discord.widgets.chat.list.FragmentLifecycleListener;
import com.discord.widgets.chat.list.adapter.WidgetChatListAdapterItemCallMessage;
import com.discord.widgets.chat.list.entries.ChatListEntry;
import com.discord.widgets.chat.list.entries.MessageEntry;
import com.discord.widgets.chat.list.entries.NewMessagesEntry;
import com.discord.widgets.chat.list.model.WidgetChatListModel;
import d0.t.h0;
import d0.t.n;
import d0.t.n0;
import d0.z.d.m;
import java.lang.ref.WeakReference;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import kotlin.Unit;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlinx.coroutines.CoroutineScope;
import rx.functions.Action0;
/* compiled from: WidgetChatListAdapter.kt */
public final class WidgetChatListAdapter extends MGRecyclerAdapterSimple<ChatListEntry> {
public static final Companion Companion = new Companion(null);
private static final int NEW_MESSAGES_MAX_SCROLLBACK_COUNT = 30;
private static final int NEW_MESSAGES_MIN_SCROLLBACK_COUNT = 10;
private final AppPermissionsRequests appPermissionsRequests;
private final ComponentProvider botUiComponentProvider;
private final Clock clock;
private Data data;
private final EventHandler eventHandler;
private final AppFlexInputViewModel flexInputViewModel;
private FragmentManager fragmentManager;
private final HandlerOfScrolls handlerOfScrolls;
private final HandlerOfTouches handlerOfTouches;
private final HandlerOfUpdates handlerOfUpdates;
private boolean isTouchedSinceLastJump;
private boolean mentionMeMessageLevelHighlighting;
private ScrollToWithHighlight scrollToWithHighlight;
/* compiled from: WidgetChatListAdapter.kt */
public static final class Companion {
private Companion() {
}
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
this();
}
public static final /* synthetic */ int access$findBestNewMessagesPosition(Companion companion, int i) {
return companion.findBestNewMessagesPosition(i);
}
private final int findBestNewMessagesPosition(int i) {
if (-1 <= i && 10 > i) {
return -1;
}
if (10 <= i && 30 > i) {
return i;
}
return 30;
}
}
/* compiled from: WidgetChatListAdapter.kt */
public interface Data {
long getChannelId();
Map<Long, String> getChannelNames();
Guild getGuild();
long getGuildId();
List<ChatListEntry> getList();
Set<Long> getMyRoleIds();
long getNewMessagesMarkerMessageId();
long getOldestMessageId();
long getUserId();
boolean isSpoilerClickAllowed();
}
/* compiled from: WidgetChatListAdapter.kt */
public static final class EmptyData implements Data {
private final long channelId;
private final Map<Long, String> channelNames = h0.emptyMap();
private final Guild guild;
private final long guildId;
private final boolean isSpoilerClickAllowed;
private final List<ChatListEntry> list = n.emptyList();
private final Set<Long> myRoleIds = n0.emptySet();
private final long newMessagesMarkerMessageId;
private final long oldestMessageId;
private final long userId;
@Override // com.discord.widgets.chat.list.adapter.WidgetChatListAdapter.Data
public long getChannelId() {
return this.channelId;
}
@Override // com.discord.widgets.chat.list.adapter.WidgetChatListAdapter.Data
public Map<Long, String> getChannelNames() {
return this.channelNames;
}
@Override // com.discord.widgets.chat.list.adapter.WidgetChatListAdapter.Data
public Guild getGuild() {
return this.guild;
}
@Override // com.discord.widgets.chat.list.adapter.WidgetChatListAdapter.Data
public long getGuildId() {
return this.guildId;
}
@Override // com.discord.widgets.chat.list.adapter.WidgetChatListAdapter.Data
public List<ChatListEntry> getList() {
return this.list;
}
@Override // com.discord.widgets.chat.list.adapter.WidgetChatListAdapter.Data
public Set<Long> getMyRoleIds() {
return this.myRoleIds;
}
@Override // com.discord.widgets.chat.list.adapter.WidgetChatListAdapter.Data
public long getNewMessagesMarkerMessageId() {
return this.newMessagesMarkerMessageId;
}
@Override // com.discord.widgets.chat.list.adapter.WidgetChatListAdapter.Data
public long getOldestMessageId() {
return this.oldestMessageId;
}
@Override // com.discord.widgets.chat.list.adapter.WidgetChatListAdapter.Data
public long getUserId() {
return this.userId;
}
@Override // com.discord.widgets.chat.list.adapter.WidgetChatListAdapter.Data
public boolean isSpoilerClickAllowed() {
return this.isSpoilerClickAllowed;
}
}
/* compiled from: WidgetChatListAdapter.kt */
public interface EventHandler {
/* compiled from: WidgetChatListAdapter.kt */
public static final class DefaultImpls {
public static void onBotUiComponentClicked(EventHandler eventHandler, long j, Long l, long j2, long j3, Long l2, int i, RestAPIParams.ComponentInteractionData componentInteractionData) {
m.checkNotNullParameter(componentInteractionData, "componentSendData");
}
public static void onCallMessageClicked(EventHandler eventHandler, long j, WidgetChatListAdapterItemCallMessage.CallStatus callStatus) {
m.checkNotNullParameter(callStatus, "callStatus");
}
public static void onCommandClicked(EventHandler eventHandler, long j, Long l, long j2, long j3, long j4, long j5, String str) {
}
public static void onDismissClicked(EventHandler eventHandler, Message message) {
m.checkNotNullParameter(message, "message");
}
public static void onInteractionStateUpdated(EventHandler eventHandler, StoreChat.InteractionState interactionState) {
m.checkNotNullParameter(interactionState, "interactionState");
}
public static void onListClicked(EventHandler eventHandler) {
}
public static void onMessageAuthorAvatarClicked(EventHandler eventHandler, Message message, long j) {
m.checkNotNullParameter(message, "message");
}
public static void onMessageAuthorLongClicked(EventHandler eventHandler, Message message, Long l) {
m.checkNotNullParameter(message, "message");
}
public static void onMessageAuthorNameClicked(EventHandler eventHandler, Message message, long j) {
m.checkNotNullParameter(message, "message");
}
public static void onMessageBlockedGroupClicked(EventHandler eventHandler, Message message) {
m.checkNotNullParameter(message, "message");
}
public static void onMessageClicked(EventHandler eventHandler, Message message, boolean z2) {
m.checkNotNullParameter(message, "message");
}
public static void onMessageLongClicked(EventHandler eventHandler, Message message, CharSequence charSequence, boolean z2) {
m.checkNotNullParameter(message, "message");
m.checkNotNullParameter(charSequence, "formattedMessage");
}
public static void onOldestMessageId(EventHandler eventHandler, long j, long j2) {
}
public static void onOpenPinsClicked(EventHandler eventHandler, Message message) {
m.checkNotNullParameter(message, "message");
}
public static void onQuickAddReactionClicked(EventHandler eventHandler, long j, long j2, long j3, long j4) {
}
public static boolean onQuickDownloadClicked(EventHandler eventHandler, Uri uri, String str) {
m.checkNotNullParameter(uri, NotificationCompat.MessagingStyle.Message.KEY_DATA_URI);
m.checkNotNullParameter(str, "fileName");
return false;
}
public static void onReactionClicked(EventHandler eventHandler, long j, long j2, long j3, long j4, MessageReaction messageReaction, boolean z2) {
m.checkNotNullParameter(messageReaction, "reaction");
}
public static void onReactionLongClicked(EventHandler eventHandler, long j, long j2, long j3, MessageReaction messageReaction) {
m.checkNotNullParameter(messageReaction, "reaction");
}
public static void onSendGreetMessageClicked(EventHandler eventHandler, long j, int i, Sticker sticker) {
m.checkNotNullParameter(sticker, "sticker");
}
public static void onShareButtonClick(EventHandler eventHandler, GuildScheduledEvent guildScheduledEvent, WeakReference<Context> weakReference, WeakReference<AppFragment> weakReference2) {
m.checkNotNullParameter(guildScheduledEvent, "guildEvent");
m.checkNotNullParameter(weakReference, "weakContext");
m.checkNotNullParameter(weakReference2, "weakFragment");
}
public static void onStickerClicked(EventHandler eventHandler, Message message, BaseSticker baseSticker) {
m.checkNotNullParameter(message, "message");
m.checkNotNullParameter(baseSticker, "sticker");
}
public static void onThreadClicked(EventHandler eventHandler, Channel channel) {
m.checkNotNullParameter(channel, "channel");
}
public static void onThreadLongClicked(EventHandler eventHandler, Channel channel) {
m.checkNotNullParameter(channel, "channel");
}
public static void onUrlLongClicked(EventHandler eventHandler, String str) {
m.checkNotNullParameter(str, "url");
}
public static void onUserActivityAction(EventHandler eventHandler, long j, long j2, long j3, MessageActivityType messageActivityType, Activity activity, Application application) {
m.checkNotNullParameter(messageActivityType, "messageActivityType");
m.checkNotNullParameter(activity, ActivityChooserModel.ATTRIBUTE_ACTIVITY);
m.checkNotNullParameter(application, "application");
}
public static void onUserMentionClicked(EventHandler eventHandler, long j, long j2, long j3) {
}
public static void onWelcomeCtaClicked(EventHandler eventHandler, Message message, Channel channel, BaseSticker baseSticker) {
m.checkNotNullParameter(message, "message");
m.checkNotNullParameter(channel, "channel");
m.checkNotNullParameter(baseSticker, "sticker");
}
}
void onBotUiComponentClicked(long j, Long l, long j2, long j3, Long l2, int i, RestAPIParams.ComponentInteractionData componentInteractionData);
void onCallMessageClicked(long j, WidgetChatListAdapterItemCallMessage.CallStatus callStatus);
void onCommandClicked(long j, Long l, long j2, long j3, long j4, long j5, String str);
void onDismissClicked(Message message);
void onInteractionStateUpdated(StoreChat.InteractionState interactionState);
void onListClicked();
void onMessageAuthorAvatarClicked(Message message, long j);
void onMessageAuthorLongClicked(Message message, Long l);
void onMessageAuthorNameClicked(Message message, long j);
void onMessageBlockedGroupClicked(Message message);
void onMessageClicked(Message message, boolean z2);
void onMessageLongClicked(Message message, CharSequence charSequence, boolean z2);
void onOldestMessageId(long j, long j2);
void onOpenPinsClicked(Message message);
void onQuickAddReactionClicked(long j, long j2, long j3, long j4);
boolean onQuickDownloadClicked(Uri uri, String str);
void onReactionClicked(long j, long j2, long j3, long j4, MessageReaction messageReaction, boolean z2);
void onReactionLongClicked(long j, long j2, long j3, MessageReaction messageReaction);
void onSendGreetMessageClicked(long j, int i, Sticker sticker);
void onShareButtonClick(GuildScheduledEvent guildScheduledEvent, WeakReference<Context> weakReference, WeakReference<AppFragment> weakReference2);
void onStickerClicked(Message message, BaseSticker baseSticker);
void onThreadClicked(Channel channel);
void onThreadLongClicked(Channel channel);
void onUrlLongClicked(String str);
void onUserActivityAction(long j, long j2, long j3, MessageActivityType messageActivityType, Activity activity, Application application);
void onUserMentionClicked(long j, long j2, long j3);
void onWelcomeCtaClicked(Message message, Channel channel, BaseSticker baseSticker);
}
/* compiled from: WidgetChatListAdapter.kt */
public final class HandlerOfScrolls extends RecyclerView.OnScrollListener {
private long channelId;
private int scrollState;
public HandlerOfScrolls() {
}
@Override // androidx.recyclerview.widget.RecyclerView.OnScrollListener
public void onScrollStateChanged(RecyclerView recyclerView, int i) {
m.checkNotNullParameter(recyclerView, "recyclerView");
super.onScrollStateChanged(recyclerView, i);
if (this.scrollState != i || WidgetChatListAdapter.this.getData().getChannelId() != this.channelId) {
this.scrollState = i;
this.channelId = WidgetChatListAdapter.this.getData().getChannelId();
WidgetChatListAdapter.access$publishInteractionState(WidgetChatListAdapter.this);
}
}
}
/* compiled from: WidgetChatListAdapter.kt */
public final class HandlerOfTouches implements View.OnTouchListener {
private final GestureDetector tapGestureDetector;
public HandlerOfTouches() {
this.tapGestureDetector = new GestureDetector(WidgetChatListAdapter.this.getContext(), new WidgetChatListAdapter$HandlerOfTouches$tapGestureDetector$1(this));
}
@Override // android.view.View.OnTouchListener
public boolean onTouch(View view, MotionEvent motionEvent) {
boolean z2 = motionEvent != null && motionEvent.getAction() == 2;
if (!WidgetChatListAdapter.access$isTouchedSinceLastJump$p(WidgetChatListAdapter.this) && z2) {
WidgetChatListAdapter.access$setTouchedSinceLastJump$p(WidgetChatListAdapter.this, true);
WidgetChatListAdapter.access$publishInteractionState(WidgetChatListAdapter.this);
}
return this.tapGestureDetector.onTouchEvent(motionEvent);
}
}
/* compiled from: WidgetChatListAdapter.kt */
public final class HandlerOfUpdates implements Runnable {
private long channelId;
private long oldestMessageId;
public HandlerOfUpdates() {
}
@Override // java.lang.Runnable
public void run() {
if (this.channelId != WidgetChatListAdapter.this.getData().getChannelId()) {
this.channelId = WidgetChatListAdapter.this.getData().getChannelId();
WidgetChatListAdapter.this.scrollToMessageId(0, WidgetChatListAdapter$HandlerOfUpdates$run$1.INSTANCE);
WidgetChatListAdapter.access$setTouchedSinceLastJump$p(WidgetChatListAdapter.this, false);
}
if (this.oldestMessageId != WidgetChatListAdapter.this.getData().getOldestMessageId()) {
this.oldestMessageId = WidgetChatListAdapter.this.getData().getOldestMessageId();
WidgetChatListAdapter.this.getEventHandler().onOldestMessageId(this.channelId, this.oldestMessageId);
}
WidgetChatListAdapter.access$publishInteractionState(WidgetChatListAdapter.this);
}
}
/* compiled from: WidgetChatListAdapter.kt */
public static final class ScrollToWithHighlight implements Runnable {
private final WidgetChatListAdapter adapter;
private int attempts;
private final long messageId;
private final Function0<Unit> onCompleted;
public ScrollToWithHighlight(WidgetChatListAdapter widgetChatListAdapter, long j, Function0<Unit> function0) {
m.checkNotNullParameter(widgetChatListAdapter, "adapter");
m.checkNotNullParameter(function0, "onCompleted");
this.adapter = widgetChatListAdapter;
this.messageId = j;
this.onCompleted = function0;
widgetChatListAdapter.getRecycler().post(this);
}
private final void animateHighlight(View view) {
view.setBackgroundResource(R.drawable.drawable_bg_highlight);
Drawable background = view.getBackground();
Objects.requireNonNull(background, "null cannot be cast to non-null type android.graphics.drawable.TransitionDrawable");
TransitionDrawable transitionDrawable = (TransitionDrawable) background;
transitionDrawable.startTransition(500);
CoroutineScope coroutineScope = ViewCoroutineScopeKt.getCoroutineScope(view);
if (coroutineScope != null) {
f.x0(coroutineScope, null, null, new WidgetChatListAdapter$ScrollToWithHighlight$animateHighlight$1(transitionDrawable, null), 3, null);
}
}
private final int getNewMessageEntryIndex(List<? extends ChatListEntry> list) {
boolean z2;
long j = this.messageId;
boolean z3 = j == 0;
if (j == 1) {
return 0;
}
Integer num = null;
if (j == 0) {
Long valueOf = Long.valueOf(this.adapter.getData().getNewMessagesMarkerMessageId());
if (!(valueOf.longValue() > 0)) {
valueOf = null;
}
if (valueOf == null) {
return 0;
}
j = valueOf.longValue();
}
int i = -1;
if (j <= 0) {
return -1;
}
Iterator<? extends ChatListEntry> it = list.iterator();
int i2 = 0;
while (true) {
if (!it.hasNext()) {
break;
}
ChatListEntry chatListEntry = (ChatListEntry) it.next();
if ((chatListEntry instanceof MessageEntry) && ((MessageEntry) chatListEntry).getMessage().getId() <= j) {
i = i2;
break;
}
i2++;
}
if (i < 0 && z3) {
i = Companion.access$findBestNewMessagesPosition(WidgetChatListAdapter.Companion, n.getLastIndex(list));
}
Iterator<Integer> it2 = d0.d0.f.downTo(i, 0).iterator();
while (true) {
if (!it2.hasNext()) {
break;
}
Integer next = it2.next();
ChatListEntry chatListEntry2 = (ChatListEntry) list.get(next.intValue());
if (!(chatListEntry2 instanceof NewMessagesEntry) || ((NewMessagesEntry) chatListEntry2).getMessageId() != j) {
z2 = false;
continue;
} else {
z2 = true;
continue;
}
if (z2) {
num = next;
break;
}
}
Integer num2 = num;
return num2 != null ? num2.intValue() : i;
}
private final void scheduleRetry() {
int i = this.attempts;
if (i < 20) {
this.attempts = i + 1;
CoroutineScope coroutineScope = ViewCoroutineScopeKt.getCoroutineScope(this.adapter.getRecycler());
if (coroutineScope != null) {
f.x0(coroutineScope, null, null, new WidgetChatListAdapter$ScrollToWithHighlight$scheduleRetry$1(this, null), 3, null);
return;
}
return;
}
this.onCompleted.mo1invoke();
}
public final void cancel() {
this.adapter.getRecycler().removeCallbacks(this);
}
public final WidgetChatListAdapter getAdapter() {
return this.adapter;
}
public final long getMessageId() {
return this.messageId;
}
public final Function0<Unit> getOnCompleted() {
return this.onCompleted;
}
@Override // java.lang.Runnable
public void run() {
Data data = this.adapter.getData();
View view = null;
if (!(data instanceof WidgetChatListModel)) {
data = null;
}
WidgetChatListModel widgetChatListModel = (WidgetChatListModel) data;
if (widgetChatListModel == null || !widgetChatListModel.isLoadingMessages()) {
int newMessageEntryIndex = getNewMessageEntryIndex(this.adapter.getData().getList());
if (newMessageEntryIndex < 0) {
scheduleRetry();
return;
}
int height = (int) (((float) this.adapter.getRecycler().getHeight()) / 2.0f);
LinearLayoutManager layoutManager = this.adapter.getLayoutManager();
if (layoutManager != null) {
layoutManager.scrollToPositionWithOffset(newMessageEntryIndex, height);
view = layoutManager.findViewByPosition(newMessageEntryIndex);
}
if (view != null) {
if (!(newMessageEntryIndex < this.adapter.getData().getList().size() && (this.adapter.getData().getList().get(newMessageEntryIndex) instanceof NewMessagesEntry))) {
animateHighlight(view);
}
this.onCompleted.mo1invoke();
return;
}
scheduleRetry();
return;
}
scheduleRetry();
}
}
public WidgetChatListAdapter(RecyclerView recyclerView, AppPermissionsRequests appPermissionsRequests, FragmentManager fragmentManager, EventHandler eventHandler) {
this(recyclerView, appPermissionsRequests, fragmentManager, eventHandler, null, null, 48, null);
}
public WidgetChatListAdapter(RecyclerView recyclerView, AppPermissionsRequests appPermissionsRequests, FragmentManager fragmentManager, EventHandler eventHandler, AppFlexInputViewModel appFlexInputViewModel) {
this(recyclerView, appPermissionsRequests, fragmentManager, eventHandler, appFlexInputViewModel, null, 32, null);
}
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public WidgetChatListAdapter(RecyclerView recyclerView, AppPermissionsRequests appPermissionsRequests, FragmentManager fragmentManager, EventHandler eventHandler, AppFlexInputViewModel appFlexInputViewModel, Clock clock) {
super(recyclerView, false, 2, null);
m.checkNotNullParameter(recyclerView, "recycler");
m.checkNotNullParameter(appPermissionsRequests, "appPermissionsRequests");
m.checkNotNullParameter(fragmentManager, "fragmentManager");
m.checkNotNullParameter(eventHandler, "eventHandler");
m.checkNotNullParameter(clock, "clock");
this.appPermissionsRequests = appPermissionsRequests;
this.fragmentManager = fragmentManager;
this.eventHandler = eventHandler;
this.flexInputViewModel = appFlexInputViewModel;
this.clock = clock;
Context context = recyclerView.getContext();
m.checkNotNullExpressionValue(context, "recycler.context");
this.botUiComponentProvider = new ComponentProvider(context);
this.data = new EmptyData();
this.mentionMeMessageLevelHighlighting = true;
this.handlerOfTouches = new HandlerOfTouches();
this.handlerOfScrolls = new HandlerOfScrolls();
this.handlerOfUpdates = new HandlerOfUpdates();
}
/* JADX INFO: this call moved to the top of the method (can break code semantics) */
public /* synthetic */ WidgetChatListAdapter(RecyclerView recyclerView, AppPermissionsRequests appPermissionsRequests, FragmentManager fragmentManager, EventHandler eventHandler, AppFlexInputViewModel appFlexInputViewModel, Clock clock, int i, DefaultConstructorMarker defaultConstructorMarker) {
this(recyclerView, appPermissionsRequests, fragmentManager, eventHandler, (i & 16) != 0 ? null : appFlexInputViewModel, (i & 32) != 0 ? ClockFactory.get() : clock);
}
public static final /* synthetic */ HandlerOfScrolls access$getHandlerOfScrolls$p(WidgetChatListAdapter widgetChatListAdapter) {
return widgetChatListAdapter.handlerOfScrolls;
}
public static final /* synthetic */ HandlerOfTouches access$getHandlerOfTouches$p(WidgetChatListAdapter widgetChatListAdapter) {
return widgetChatListAdapter.handlerOfTouches;
}
public static final /* synthetic */ HandlerOfUpdates access$getHandlerOfUpdates$p(WidgetChatListAdapter widgetChatListAdapter) {
return widgetChatListAdapter.handlerOfUpdates;
}
public static final /* synthetic */ ScrollToWithHighlight access$getScrollToWithHighlight$p(WidgetChatListAdapter widgetChatListAdapter) {
return widgetChatListAdapter.scrollToWithHighlight;
}
public static final /* synthetic */ boolean access$isTouchedSinceLastJump$p(WidgetChatListAdapter widgetChatListAdapter) {
return widgetChatListAdapter.isTouchedSinceLastJump;
}
public static final /* synthetic */ void access$publishInteractionState(WidgetChatListAdapter widgetChatListAdapter) {
widgetChatListAdapter.publishInteractionState();
}
public static final /* synthetic */ void access$setScrollToWithHighlight$p(WidgetChatListAdapter widgetChatListAdapter, ScrollToWithHighlight scrollToWithHighlight) {
widgetChatListAdapter.scrollToWithHighlight = scrollToWithHighlight;
}
public static final /* synthetic */ void access$setTouchedSinceLastJump$p(WidgetChatListAdapter widgetChatListAdapter, boolean z2) {
widgetChatListAdapter.isTouchedSinceLastJump = z2;
}
private final void publishInteractionState() {
Data data = this.data;
if (!(data instanceof WidgetChatListModel)) {
data = null;
}
WidgetChatListModel widgetChatListModel = (WidgetChatListModel) data;
this.eventHandler.onInteractionStateUpdated(new StoreChat.InteractionState(this.data.getChannelId(), widgetChatListModel != null ? widgetChatListModel.getNewestKnownMessageId() : 0, this.isTouchedSinceLastJump, getLayoutManager()));
}
public final void disposeHandlers() {
setOnUpdated(WidgetChatListAdapter$disposeHandlers$1.INSTANCE);
getRecycler().setOnTouchListener(null);
getRecycler().removeOnScrollListener(this.handlerOfScrolls);
this.eventHandler.onInteractionStateUpdated(new StoreChat.InteractionState(this.data.getChannelId(), 0, this.isTouchedSinceLastJump, (LinearLayoutManager) null));
}
public final AppPermissionsRequests getAppPermissionsRequests() {
return this.appPermissionsRequests;
}
public final ComponentProvider getBotUiComponentProvider() {
return this.botUiComponentProvider;
}
public final Clock getClock() {
return this.clock;
}
public final Data getData() {
return this.data;
}
public final EventHandler getEventHandler() {
return this.eventHandler;
}
public final AppFlexInputViewModel getFlexInputViewModel() {
return this.flexInputViewModel;
}
public final FragmentManager getFragmentManager() {
return this.fragmentManager;
}
public final LinearLayoutManager getLayoutManager() {
RecyclerView.LayoutManager layoutManager = getRecycler().getLayoutManager();
if (!(layoutManager instanceof LinearLayoutManager)) {
layoutManager = null;
}
return (LinearLayoutManager) layoutManager;
}
public final boolean getMentionMeMessageLevelHighlighting() {
return this.mentionMeMessageLevelHighlighting;
}
public final void onBotUiComponentClicked(long j, long j2, Long l, int i, RestAPIParams.ComponentInteractionData componentInteractionData) {
m.checkNotNullParameter(componentInteractionData, "componentSendData");
EventHandler eventHandler = this.eventHandler;
Guild guild = this.data.getGuild();
eventHandler.onBotUiComponentClicked(j, guild != null ? Long.valueOf(guild.getId()) : null, this.data.getChannelId(), j2, l, i, componentInteractionData);
}
@Override // androidx.recyclerview.widget.RecyclerView.Adapter
public MGRecyclerViewHolder<WidgetChatListAdapter, ChatListEntry> onCreateViewHolder(ViewGroup viewGroup, int i) {
m.checkNotNullParameter(viewGroup, "parent");
switch (i) {
case 0:
case 32:
return new WidgetChatListAdapterItemMessage(R.layout.widget_chat_list_adapter_item_text, this);
case 1:
return new WidgetChatListAdapterItemMessage(R.layout.widget_chat_list_adapter_item_minimal, this);
case 2:
return new WidgetChatListItem(R.layout.widget_chat_list_adapter_item_loading, this);
case 3:
return new WidgetChatListAdapterItemStart(this);
case 4:
return new WidgetChatListAdapterItemReactions(this);
case 5:
return new WidgetChatListAdapterItemSystemMessage(this);
case 6:
return new WidgetChatListAdapterItemUploadProgress(this);
case 7:
return new WidgetChatListItem(R.layout.widget_chat_list_adapter_item_spacer, this);
case 8:
return new WidgetChatListAdapterItemNewMessages(this);
case 9:
return new WidgetChatListAdapterItemTimestamp(this);
case 10:
return new WidgetChatListAdapterItemBlocked(this);
case 11:
return new WidgetChatListAdapterItemSearchResultCount(this);
case 12:
return new MGRecyclerViewHolder<>((int) R.layout.widget_chat_list_adapter_item_search_indexing, this);
case 13:
return new MGRecyclerViewHolder<>((int) R.layout.widget_chat_list_adapter_item_search_empty, this);
case 14:
return new MGRecyclerViewHolder<>((int) R.layout.widget_chat_list_adapter_item_search_error, this);
case 15:
return new MGRecyclerViewHolder<>((int) R.layout.widget_chat_list_adapter_item_divider, this);
case 16:
return new WidgetChatListAdapterItemEmptyPins(this);
case 17:
return new WidgetChatListAdapterItemMessageHeader(this);
case 18:
return new WidgetChatListAdapterItemMentionFooter(this);
case 19:
return new WidgetChatListAdapterItemCallMessage(this);
case 20:
return new WidgetChatListAdapterItemMessage(R.layout.widget_chat_list_adapter_item_failed, this);
case 21:
return new WidgetChatListAdapterItemEmbed(this);
case 22:
return new WidgetChatListAdapterItemGameInvite(this);
case 23:
return new WidgetChatListAdapterItemSpotifyListenTogether(this);
case 24:
return new WidgetChatListAdapterItemInvite(this);
case 25:
return new WidgetChatListAdapterItemGuildWelcome(this, null, 2, null);
case 26:
return new WidgetChatListAdapterItemGift(this);
case 27:
default:
throw invalidViewTypeException(i);
case 28:
return new WidgetChatListAdapterItemAttachment(this);
case 29:
return new WidgetChatListAdapterItemPrivateChannelStart(this);
case 30:
return new WidgetChatListAdapterItemGuildTemplate(this);
case 31:
return new WidgetChatListAdapterItemSticker(this);
case 33:
return new WidgetChatListAdapterItemApplicationCommand(this);
case 34:
return new WidgetChatListAdapterItemEphemeralMessage(this);
case 35:
return new WidgetChatListAdapterItemThreadEmbed(this);
case 36:
return new WidgetChatListAdapterItemBotComponentRow(this);
case 37:
return new WidgetChatListAdapterItemThreadDraftForm(this, this.flexInputViewModel);
case 38:
return new WidgetChatListAdapterItemGuildInviteReminder(this);
case 39:
return new WidgetChatListAdapterItemStageInvite(this);
case 40:
return new MGRecyclerViewHolder<>((int) R.layout.widget_chat_list_adapter_item_thread_starter_divider, this);
case 41:
return new WidgetChatListAdapterItemStickerGreet(this);
case 42:
return new WidgetChatListAdapterItemStickerGreetCompact(this);
case 43:
return new WidgetChatListAdapterItemGuildScheduledEventInvite(this, null, 2, null);
}
}
public final void onPause() {
int childCount = getRecycler().getChildCount();
for (int i = 0; i < childCount; i++) {
RecyclerView.ViewHolder childViewHolder = getRecycler().getChildViewHolder(getRecycler().getChildAt(i));
if (childViewHolder instanceof FragmentLifecycleListener) {
((FragmentLifecycleListener) childViewHolder).onPause();
}
}
}
public final void onQuickAddReactionClicked(long j) {
this.eventHandler.onQuickAddReactionClicked(this.data.getGuildId(), this.data.getUserId(), this.data.getChannelId(), j);
}
public final void onReactionClicked(long j, MessageReaction messageReaction, boolean z2) {
m.checkNotNullParameter(messageReaction, "reaction");
this.eventHandler.onReactionClicked(this.data.getGuildId(), this.data.getUserId(), this.data.getChannelId(), j, messageReaction, z2);
}
public final void onReactionLongClicked(long j, MessageReaction messageReaction) {
m.checkNotNullParameter(messageReaction, "reaction");
this.eventHandler.onReactionLongClicked(this.data.getGuildId(), this.data.getChannelId(), j, messageReaction);
}
public final void onResume() {
int childCount = getRecycler().getChildCount();
for (int i = 0; i < childCount; i++) {
RecyclerView.ViewHolder childViewHolder = getRecycler().getChildViewHolder(getRecycler().getChildAt(i));
if (childViewHolder instanceof FragmentLifecycleListener) {
((FragmentLifecycleListener) childViewHolder).onResume();
}
}
}
public final void onShareButtonClick(GuildScheduledEvent guildScheduledEvent, WeakReference<Context> weakReference, WeakReference<AppFragment> weakReference2) {
m.checkNotNullParameter(guildScheduledEvent, "guildEvent");
m.checkNotNullParameter(weakReference, "weakContext");
m.checkNotNullParameter(weakReference2, "weakFragment");
this.eventHandler.onShareButtonClick(guildScheduledEvent, weakReference, weakReference2);
}
public final void onStickerClicked(Message message, BaseSticker baseSticker) {
m.checkNotNullParameter(message, "message");
m.checkNotNullParameter(baseSticker, "sticker");
this.eventHandler.onStickerClicked(message, baseSticker);
}
public final void onThreadClicked(Channel channel) {
m.checkNotNullParameter(channel, "channel");
this.eventHandler.onThreadClicked(channel);
}
public final void onThreadLongClicked(Channel channel) {
m.checkNotNullParameter(channel, "channel");
this.eventHandler.onThreadLongClicked(channel);
}
public final void onUserActivityAction(long j, long j2, MessageActivityType messageActivityType, Activity activity, Application application) {
m.checkNotNullParameter(messageActivityType, "messageActivityType");
m.checkNotNullParameter(activity, ActivityChooserModel.ATTRIBUTE_ACTIVITY);
m.checkNotNullParameter(application, "application");
this.eventHandler.onUserActivityAction(j, this.data.getChannelId(), j2, messageActivityType, activity, application);
}
public final void scrollToMessageId(long j, Action0 action0) {
m.checkNotNullParameter(action0, "onCompleted");
ScrollToWithHighlight scrollToWithHighlight = this.scrollToWithHighlight;
if (scrollToWithHighlight != null && scrollToWithHighlight.getMessageId() > 0 && j <= 0) {
action0.call();
return;
}
this.isTouchedSinceLastJump = false;
ScrollToWithHighlight scrollToWithHighlight2 = this.scrollToWithHighlight;
if (scrollToWithHighlight2 != null) {
scrollToWithHighlight2.cancel();
}
this.scrollToWithHighlight = new ScrollToWithHighlight(this, j, new WidgetChatListAdapter$scrollToMessageId$1(this, action0));
}
public final void setData(Data data) {
m.checkNotNullParameter(data, "value");
this.data = data;
setData(data.getList());
}
public final void setFragmentManager(FragmentManager fragmentManager) {
m.checkNotNullParameter(fragmentManager, "<set-?>");
this.fragmentManager = fragmentManager;
}
public final void setHandlers() {
setOnUpdated(new WidgetChatListAdapter$setHandlers$1(this));
}
public final void setMentionMeMessageLevelHighlighting(boolean z2) {
this.mentionMeMessageLevelHighlighting = z2;
}
}