470 lines
21 KiB
Java
470 lines
21 KiB
Java
package com.discord.widgets.search.results;
|
|
|
|
import a0.a.a.b;
|
|
import android.content.Context;
|
|
import android.net.Uri;
|
|
import android.view.View;
|
|
import androidx.fragment.app.Fragment;
|
|
import androidx.fragment.app.FragmentManager;
|
|
import androidx.recyclerview.widget.RecyclerView;
|
|
import c.a.d.l;
|
|
import c.d.b.a.a;
|
|
import com.discord.api.activity.Activity;
|
|
import com.discord.api.application.Application;
|
|
import com.discord.api.channel.Channel;
|
|
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.databinding.WidgetSearchResultsBinding;
|
|
import com.discord.models.guild.Guild;
|
|
import com.discord.models.message.Message;
|
|
import com.discord.restapi.RestAPIParams;
|
|
import com.discord.stores.SelectedChannelAnalyticsLocation;
|
|
import com.discord.stores.StoreChat;
|
|
import com.discord.stores.StoreStream;
|
|
import com.discord.utilities.channel.ChannelSelector;
|
|
import com.discord.utilities.mg_recycler.MGRecyclerAdapter;
|
|
import com.discord.utilities.rx.ObservableExtensionsKt;
|
|
import com.discord.utilities.viewbinding.FragmentViewBindingDelegate;
|
|
import com.discord.utilities.viewbinding.FragmentViewBindingDelegateKt;
|
|
import com.discord.widgets.chat.WidgetUrlActions;
|
|
import com.discord.widgets.chat.list.ThreadSpineItemDecoration;
|
|
import com.discord.widgets.chat.list.adapter.WidgetChatListAdapter;
|
|
import com.discord.widgets.chat.list.adapter.WidgetChatListAdapterItemCallMessage;
|
|
import com.discord.widgets.chat.list.entries.ChatListEntry;
|
|
import d0.z.d.m;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Set;
|
|
import kotlin.jvm.functions.Function0;
|
|
import kotlin.jvm.functions.Function1;
|
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
|
import kotlin.reflect.KProperty;
|
|
import rx.Observable;
|
|
/* compiled from: WidgetSearchResults.kt */
|
|
public final class WidgetSearchResults extends AppFragment {
|
|
public static final /* synthetic */ KProperty[] $$delegatedProperties = {a.V(WidgetSearchResults.class, "binding", "getBinding()Lcom/discord/databinding/WidgetSearchResultsBinding;", 0)};
|
|
private WidgetChatListAdapter adapter;
|
|
private final FragmentViewBindingDelegate binding$delegate = FragmentViewBindingDelegateKt.viewBinding$default(this, WidgetSearchResults$binding$2.INSTANCE, null, 2, null);
|
|
|
|
/* compiled from: WidgetSearchResults.kt */
|
|
public static final class Model implements WidgetChatListAdapter.Data {
|
|
public static final Companion Companion = new Companion(null);
|
|
private final long channelId;
|
|
private final Map<Long, String> channelNames;
|
|
private final Guild guild;
|
|
private final long guildId;
|
|
private final boolean isSpoilerClickAllowed;
|
|
private final List<ChatListEntry> list;
|
|
private final Set<Long> myRoleIds;
|
|
private final long newMessagesMarkerMessageId;
|
|
private final long oldestMessageId;
|
|
private final long userId;
|
|
|
|
/* compiled from: WidgetSearchResults.kt */
|
|
public static final class Companion {
|
|
private Companion() {
|
|
}
|
|
|
|
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
|
|
this();
|
|
}
|
|
|
|
public final Observable<Model> get() {
|
|
Observable r = StoreStream.Companion.getSearch().getStoreSearchQuery().getState().Y(WidgetSearchResults$Model$Companion$get$1.INSTANCE).r();
|
|
m.checkNotNullExpressionValue(r, "StoreStream\n … .distinctUntilChanged()");
|
|
return ObservableExtensionsKt.computationLatest(r);
|
|
}
|
|
}
|
|
|
|
/* JADX DEBUG: Multi-variable search result rejected for r2v0, resolved type: java.util.List<? extends com.discord.widgets.chat.list.entries.ChatListEntry> */
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
public Model(List<? extends ChatListEntry> list, long j, Map<Long, String> map, long j2, Set<Long> set) {
|
|
m.checkNotNullParameter(list, "list");
|
|
m.checkNotNullParameter(map, "channelNames");
|
|
m.checkNotNullParameter(set, "myRoleIds");
|
|
this.list = list;
|
|
this.userId = j;
|
|
this.channelNames = map;
|
|
this.oldestMessageId = j2;
|
|
this.myRoleIds = set;
|
|
}
|
|
|
|
/* JADX INFO: this call moved to the top of the method (can break code semantics) */
|
|
public /* synthetic */ Model(List list, long j, Map map, long j2, Set set, int i, DefaultConstructorMarker defaultConstructorMarker) {
|
|
this(list, (i & 2) != 0 ? 0 : j, map, j2, set);
|
|
}
|
|
|
|
/* JADX DEBUG: Multi-variable search result rejected for r5v0, resolved type: com.discord.widgets.search.results.WidgetSearchResults$Model */
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
public static /* synthetic */ Model copy$default(Model model, List list, long j, Map map, long j2, Set set, int i, Object obj) {
|
|
if ((i & 1) != 0) {
|
|
list = model.getList();
|
|
}
|
|
if ((i & 2) != 0) {
|
|
j = model.getUserId();
|
|
}
|
|
if ((i & 4) != 0) {
|
|
map = model.getChannelNames();
|
|
}
|
|
if ((i & 8) != 0) {
|
|
j2 = model.getOldestMessageId();
|
|
}
|
|
if ((i & 16) != 0) {
|
|
set = model.getMyRoleIds();
|
|
}
|
|
return model.copy(list, j, map, j2, set);
|
|
}
|
|
|
|
public final List<ChatListEntry> component1() {
|
|
return getList();
|
|
}
|
|
|
|
public final long component2() {
|
|
return getUserId();
|
|
}
|
|
|
|
public final Map<Long, String> component3() {
|
|
return getChannelNames();
|
|
}
|
|
|
|
public final long component4() {
|
|
return getOldestMessageId();
|
|
}
|
|
|
|
public final Set<Long> component5() {
|
|
return getMyRoleIds();
|
|
}
|
|
|
|
public final Model copy(List<? extends ChatListEntry> list, long j, Map<Long, String> map, long j2, Set<Long> set) {
|
|
m.checkNotNullParameter(list, "list");
|
|
m.checkNotNullParameter(map, "channelNames");
|
|
m.checkNotNullParameter(set, "myRoleIds");
|
|
return new Model(list, j, map, j2, set);
|
|
}
|
|
|
|
public boolean equals(Object obj) {
|
|
if (this == obj) {
|
|
return true;
|
|
}
|
|
if (!(obj instanceof Model)) {
|
|
return false;
|
|
}
|
|
Model model = (Model) obj;
|
|
return m.areEqual(getList(), model.getList()) && getUserId() == model.getUserId() && m.areEqual(getChannelNames(), model.getChannelNames()) && getOldestMessageId() == model.getOldestMessageId() && m.areEqual(getMyRoleIds(), model.getMyRoleIds());
|
|
}
|
|
|
|
@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;
|
|
}
|
|
|
|
public int hashCode() {
|
|
List<ChatListEntry> list = getList();
|
|
int i = 0;
|
|
int a = (b.a(getUserId()) + ((list != null ? list.hashCode() : 0) * 31)) * 31;
|
|
Map<Long, String> channelNames = getChannelNames();
|
|
int a2 = (b.a(getOldestMessageId()) + ((a + (channelNames != null ? channelNames.hashCode() : 0)) * 31)) * 31;
|
|
Set<Long> myRoleIds = getMyRoleIds();
|
|
if (myRoleIds != null) {
|
|
i = myRoleIds.hashCode();
|
|
}
|
|
return a2 + i;
|
|
}
|
|
|
|
@Override // com.discord.widgets.chat.list.adapter.WidgetChatListAdapter.Data
|
|
public boolean isSpoilerClickAllowed() {
|
|
return this.isSpoilerClickAllowed;
|
|
}
|
|
|
|
public String toString() {
|
|
StringBuilder K = a.K("Model(list=");
|
|
K.append(getList());
|
|
K.append(", userId=");
|
|
K.append(getUserId());
|
|
K.append(", channelNames=");
|
|
K.append(getChannelNames());
|
|
K.append(", oldestMessageId=");
|
|
K.append(getOldestMessageId());
|
|
K.append(", myRoleIds=");
|
|
K.append(getMyRoleIds());
|
|
K.append(")");
|
|
return K.toString();
|
|
}
|
|
}
|
|
|
|
/* compiled from: WidgetSearchResults.kt */
|
|
public static final class SearchResultAdapterEventHandler implements WidgetChatListAdapter.EventHandler {
|
|
private final ChannelSelector channelSelector;
|
|
private final Context context;
|
|
private final FragmentManager fragmentManager;
|
|
private long oldestMessageId;
|
|
|
|
public SearchResultAdapterEventHandler(Context context, FragmentManager fragmentManager, ChannelSelector channelSelector) {
|
|
m.checkNotNullParameter(context, "context");
|
|
m.checkNotNullParameter(fragmentManager, "fragmentManager");
|
|
m.checkNotNullParameter(channelSelector, "channelSelector");
|
|
this.context = context;
|
|
this.fragmentManager = fragmentManager;
|
|
this.channelSelector = channelSelector;
|
|
}
|
|
|
|
private final void jumpToChat(Message message) {
|
|
StoreStream.Companion.getMessagesLoader().jumpToMessage(message.getChannelId(), message.getId());
|
|
l.c(this.context, false, null, 6);
|
|
}
|
|
|
|
@Override // com.discord.widgets.chat.list.adapter.WidgetChatListAdapter.EventHandler
|
|
public void onBotUiComponentClicked(long j, Long l, long j2, long j3, Long l2, int i, RestAPIParams.ComponentInteractionData componentInteractionData) {
|
|
m.checkNotNullParameter(componentInteractionData, "componentSendData");
|
|
}
|
|
|
|
@Override // com.discord.widgets.chat.list.adapter.WidgetChatListAdapter.EventHandler
|
|
public void onCallMessageClicked(long j, WidgetChatListAdapterItemCallMessage.CallStatus callStatus) {
|
|
m.checkNotNullParameter(callStatus, "callStatus");
|
|
}
|
|
|
|
@Override // com.discord.widgets.chat.list.adapter.WidgetChatListAdapter.EventHandler
|
|
public void onCommandClicked(long j, Long l, long j2, long j3, long j4, long j5, String str) {
|
|
}
|
|
|
|
@Override // com.discord.widgets.chat.list.adapter.WidgetChatListAdapter.EventHandler
|
|
public void onDismissClicked(Message message) {
|
|
m.checkNotNullParameter(message, "message");
|
|
}
|
|
|
|
@Override // com.discord.widgets.chat.list.adapter.WidgetChatListAdapter.EventHandler
|
|
public void onInteractionStateUpdated(StoreChat.InteractionState interactionState) {
|
|
m.checkNotNullParameter(interactionState, "interactionState");
|
|
if (interactionState.isAtTop() && this.oldestMessageId != Long.MAX_VALUE) {
|
|
StoreStream.Companion.getSearch().loadMore(this.oldestMessageId);
|
|
}
|
|
}
|
|
|
|
@Override // com.discord.widgets.chat.list.adapter.WidgetChatListAdapter.EventHandler
|
|
public void onListClicked() {
|
|
}
|
|
|
|
@Override // com.discord.widgets.chat.list.adapter.WidgetChatListAdapter.EventHandler
|
|
public void onMessageAuthorAvatarClicked(Message message, long j) {
|
|
m.checkNotNullParameter(message, "message");
|
|
jumpToChat(message);
|
|
}
|
|
|
|
@Override // com.discord.widgets.chat.list.adapter.WidgetChatListAdapter.EventHandler
|
|
public void onMessageAuthorLongClicked(Message message, Long l) {
|
|
m.checkNotNullParameter(message, "message");
|
|
jumpToChat(message);
|
|
}
|
|
|
|
@Override // com.discord.widgets.chat.list.adapter.WidgetChatListAdapter.EventHandler
|
|
public void onMessageAuthorNameClicked(Message message, long j) {
|
|
m.checkNotNullParameter(message, "message");
|
|
jumpToChat(message);
|
|
}
|
|
|
|
@Override // com.discord.widgets.chat.list.adapter.WidgetChatListAdapter.EventHandler
|
|
public void onMessageBlockedGroupClicked(Message message) {
|
|
m.checkNotNullParameter(message, "message");
|
|
jumpToChat(message);
|
|
}
|
|
|
|
@Override // com.discord.widgets.chat.list.adapter.WidgetChatListAdapter.EventHandler
|
|
public void onMessageClicked(Message message, boolean z2) {
|
|
m.checkNotNullParameter(message, "message");
|
|
jumpToChat(message);
|
|
}
|
|
|
|
@Override // com.discord.widgets.chat.list.adapter.WidgetChatListAdapter.EventHandler
|
|
public void onMessageLongClicked(Message message, CharSequence charSequence, boolean z2) {
|
|
m.checkNotNullParameter(message, "message");
|
|
m.checkNotNullParameter(charSequence, "formattedMessage");
|
|
jumpToChat(message);
|
|
}
|
|
|
|
@Override // com.discord.widgets.chat.list.adapter.WidgetChatListAdapter.EventHandler
|
|
public void onOldestMessageId(long j, long j2) {
|
|
this.oldestMessageId = j2;
|
|
}
|
|
|
|
@Override // com.discord.widgets.chat.list.adapter.WidgetChatListAdapter.EventHandler
|
|
public void onOpenPinsClicked(Message message) {
|
|
m.checkNotNullParameter(message, "message");
|
|
}
|
|
|
|
@Override // com.discord.widgets.chat.list.adapter.WidgetChatListAdapter.EventHandler
|
|
public void onQuickAddReactionClicked(long j, long j2, long j3, long j4) {
|
|
}
|
|
|
|
@Override // com.discord.widgets.chat.list.adapter.WidgetChatListAdapter.EventHandler
|
|
public boolean onQuickDownloadClicked(Uri uri, String str) {
|
|
m.checkNotNullParameter(uri, "uri");
|
|
m.checkNotNullParameter(str, "fileName");
|
|
return false;
|
|
}
|
|
|
|
@Override // com.discord.widgets.chat.list.adapter.WidgetChatListAdapter.EventHandler
|
|
public void onReactionClicked(long j, long j2, long j3, long j4, MessageReaction messageReaction, boolean z2) {
|
|
m.checkNotNullParameter(messageReaction, "reaction");
|
|
}
|
|
|
|
@Override // com.discord.widgets.chat.list.adapter.WidgetChatListAdapter.EventHandler
|
|
public void onReactionLongClicked(long j, long j2, long j3, MessageReaction messageReaction) {
|
|
m.checkNotNullParameter(messageReaction, "reaction");
|
|
}
|
|
|
|
@Override // com.discord.widgets.chat.list.adapter.WidgetChatListAdapter.EventHandler
|
|
public void onSendGreetMessageClicked(long j, int i, Sticker sticker) {
|
|
m.checkNotNullParameter(sticker, "sticker");
|
|
WidgetChatListAdapter.EventHandler.DefaultImpls.onSendGreetMessageClicked(this, j, i, sticker);
|
|
}
|
|
|
|
@Override // com.discord.widgets.chat.list.adapter.WidgetChatListAdapter.EventHandler
|
|
public void onStickerClicked(Message message, BaseSticker baseSticker) {
|
|
m.checkNotNullParameter(message, "message");
|
|
m.checkNotNullParameter(baseSticker, "sticker");
|
|
jumpToChat(message);
|
|
}
|
|
|
|
@Override // com.discord.widgets.chat.list.adapter.WidgetChatListAdapter.EventHandler
|
|
public void onThreadClicked(Channel channel) {
|
|
m.checkNotNullParameter(channel, "channel");
|
|
ChannelSelector.selectChannel$default(this.channelSelector, channel, null, SelectedChannelAnalyticsLocation.EMBED, 2, null);
|
|
l.c(this.context, false, null, 6);
|
|
}
|
|
|
|
@Override // com.discord.widgets.chat.list.adapter.WidgetChatListAdapter.EventHandler
|
|
public void onThreadLongClicked(Channel channel) {
|
|
m.checkNotNullParameter(channel, "channel");
|
|
}
|
|
|
|
@Override // com.discord.widgets.chat.list.adapter.WidgetChatListAdapter.EventHandler
|
|
public void onUrlLongClicked(String str) {
|
|
m.checkNotNullParameter(str, "url");
|
|
WidgetUrlActions.Companion.launch(this.fragmentManager, str);
|
|
}
|
|
|
|
@Override // com.discord.widgets.chat.list.adapter.WidgetChatListAdapter.EventHandler
|
|
public void onUserActivityAction(long j, long j2, long j3, MessageActivityType messageActivityType, Activity activity, Application application) {
|
|
m.checkNotNullParameter(messageActivityType, "actionType");
|
|
m.checkNotNullParameter(activity, "activity");
|
|
m.checkNotNullParameter(application, "application");
|
|
}
|
|
|
|
@Override // com.discord.widgets.chat.list.adapter.WidgetChatListAdapter.EventHandler
|
|
public void onUserMentionClicked(long j, long j2, long j3) {
|
|
}
|
|
}
|
|
|
|
public WidgetSearchResults() {
|
|
super(2131559147);
|
|
}
|
|
|
|
public static final /* synthetic */ void access$configureUI(WidgetSearchResults widgetSearchResults, Model model) {
|
|
widgetSearchResults.configureUI(model);
|
|
}
|
|
|
|
private final void addThreadSpineItemDecoration(WidgetChatListAdapter widgetChatListAdapter) {
|
|
getBinding().b.addItemDecoration(new ThreadSpineItemDecoration(requireContext(), widgetChatListAdapter));
|
|
}
|
|
|
|
private final void configureUI(Model model) {
|
|
WidgetChatListAdapter widgetChatListAdapter = this.adapter;
|
|
if (widgetChatListAdapter != null) {
|
|
widgetChatListAdapter.setData(model);
|
|
}
|
|
}
|
|
|
|
private final WidgetSearchResultsBinding getBinding() {
|
|
return (WidgetSearchResultsBinding) this.binding$delegate.getValue((Fragment) this, $$delegatedProperties[0]);
|
|
}
|
|
|
|
@Override // androidx.fragment.app.Fragment
|
|
public void onDestroy() {
|
|
super.onDestroy();
|
|
WidgetChatListAdapter widgetChatListAdapter = this.adapter;
|
|
if (widgetChatListAdapter != null) {
|
|
widgetChatListAdapter.dispose();
|
|
}
|
|
}
|
|
|
|
@Override // com.discord.app.AppFragment, androidx.fragment.app.Fragment
|
|
public void onPause() {
|
|
super.onPause();
|
|
WidgetChatListAdapter widgetChatListAdapter = this.adapter;
|
|
if (widgetChatListAdapter != null) {
|
|
widgetChatListAdapter.disposeHandlers();
|
|
}
|
|
}
|
|
|
|
@Override // com.discord.app.AppFragment
|
|
public void onViewBound(View view) {
|
|
m.checkNotNullParameter(view, "view");
|
|
super.onViewBound(view);
|
|
MGRecyclerAdapter.Companion companion = MGRecyclerAdapter.Companion;
|
|
RecyclerView recyclerView = getBinding().b;
|
|
m.checkNotNullExpressionValue(recyclerView, "binding.searchResultsList");
|
|
FragmentManager parentFragmentManager = getParentFragmentManager();
|
|
m.checkNotNullExpressionValue(parentFragmentManager, "parentFragmentManager");
|
|
Context context = view.getContext();
|
|
m.checkNotNullExpressionValue(context, "view.context");
|
|
FragmentManager parentFragmentManager2 = getParentFragmentManager();
|
|
m.checkNotNullExpressionValue(parentFragmentManager2, "parentFragmentManager");
|
|
WidgetChatListAdapter widgetChatListAdapter = (WidgetChatListAdapter) companion.configure(new WidgetChatListAdapter(recyclerView, this, parentFragmentManager, new SearchResultAdapterEventHandler(context, parentFragmentManager2, ChannelSelector.Companion.getInstance()), null, null, 48, null));
|
|
addThreadSpineItemDecoration(widgetChatListAdapter);
|
|
this.adapter = widgetChatListAdapter;
|
|
}
|
|
|
|
@Override // com.discord.app.AppFragment
|
|
public void onViewBoundOrOnResume() {
|
|
super.onViewBoundOrOnResume();
|
|
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.ui$default(Model.Companion.get(), this, null, 2, null), WidgetSearchResults.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new WidgetSearchResults$onViewBoundOrOnResume$1(this), 62, (Object) null);
|
|
WidgetChatListAdapter widgetChatListAdapter = this.adapter;
|
|
if (widgetChatListAdapter != null) {
|
|
widgetChatListAdapter.setHandlers();
|
|
}
|
|
}
|
|
}
|