package com.discord.widgets.chat.pins; import a0.a.a.b; import android.content.Context; import android.content.Intent; 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.airbnb.lottie.parser.AnimatableValueParser; 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.WidgetChannelPinnedMessagesBinding; 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.actions.WidgetChatListActions; 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 j0.l.e.j; 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: WidgetChannelPinnedMessages.kt */ public final class WidgetChannelPinnedMessages extends AppFragment { public static final /* synthetic */ KProperty[] $$delegatedProperties = {a.V(WidgetChannelPinnedMessages.class, "binding", "getBinding()Lcom/discord/databinding/WidgetChannelPinnedMessagesBinding;", 0)}; public static final Companion Companion = new Companion(null); private static final String INTENT_EXTRA_CHANNEL_ID = "INTENT_EXTRA_CHANNEL_ID"; private WidgetChatListAdapter adapter; private final FragmentViewBindingDelegate binding$delegate = FragmentViewBindingDelegateKt.viewBinding$default(this, WidgetChannelPinnedMessages$binding$2.INSTANCE, null, 2, null); /* compiled from: WidgetChannelPinnedMessages.kt */ public static final class ChannelPinnedMessagesAdapterEventHandler implements WidgetChatListAdapter.EventHandler { private final ChannelSelector channelSelector; private final Context context; private final FragmentManager fragmentManager; public ChannelPinnedMessagesAdapterEventHandler(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; } @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"); WidgetChatListAdapter.EventHandler.DefaultImpls.onBotUiComponentClicked(this, j, l, j2, j3, l2, i, componentInteractionData); } @Override // com.discord.widgets.chat.list.adapter.WidgetChatListAdapter.EventHandler public void onCallMessageClicked(long j, WidgetChatListAdapterItemCallMessage.CallStatus callStatus) { m.checkNotNullParameter(callStatus, "callStatus"); WidgetChatListAdapter.EventHandler.DefaultImpls.onCallMessageClicked(this, j, 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) { WidgetChatListAdapter.EventHandler.DefaultImpls.onCommandClicked(this, j, l, j2, j3, j4, j5, str); } @Override // com.discord.widgets.chat.list.adapter.WidgetChatListAdapter.EventHandler public void onDismissClicked(Message message) { m.checkNotNullParameter(message, "message"); WidgetChatListAdapter.EventHandler.DefaultImpls.onDismissClicked(this, message); } @Override // com.discord.widgets.chat.list.adapter.WidgetChatListAdapter.EventHandler public void onInteractionStateUpdated(StoreChat.InteractionState interactionState) { m.checkNotNullParameter(interactionState, "interactionState"); WidgetChatListAdapter.EventHandler.DefaultImpls.onInteractionStateUpdated(this, interactionState); } @Override // com.discord.widgets.chat.list.adapter.WidgetChatListAdapter.EventHandler public void onListClicked() { WidgetChatListAdapter.EventHandler.DefaultImpls.onListClicked(this); } @Override // com.discord.widgets.chat.list.adapter.WidgetChatListAdapter.EventHandler public void onMessageAuthorAvatarClicked(Message message, long j) { m.checkNotNullParameter(message, "message"); WidgetChatListAdapter.EventHandler.DefaultImpls.onMessageAuthorAvatarClicked(this, message, j); } @Override // com.discord.widgets.chat.list.adapter.WidgetChatListAdapter.EventHandler public void onMessageAuthorLongClicked(Message message, Long l) { m.checkNotNullParameter(message, "message"); WidgetChatListAdapter.EventHandler.DefaultImpls.onMessageAuthorLongClicked(this, message, l); } @Override // com.discord.widgets.chat.list.adapter.WidgetChatListAdapter.EventHandler public void onMessageAuthorNameClicked(Message message, long j) { m.checkNotNullParameter(message, "message"); WidgetChatListAdapter.EventHandler.DefaultImpls.onMessageAuthorNameClicked(this, message, j); } @Override // com.discord.widgets.chat.list.adapter.WidgetChatListAdapter.EventHandler public void onMessageBlockedGroupClicked(Message message) { m.checkNotNullParameter(message, "message"); WidgetChatListAdapter.EventHandler.DefaultImpls.onMessageBlockedGroupClicked(this, message); } @Override // com.discord.widgets.chat.list.adapter.WidgetChatListAdapter.EventHandler public void onMessageClicked(Message message, boolean z2) { m.checkNotNullParameter(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 onMessageLongClicked(Message message, CharSequence charSequence, boolean z2) { m.checkNotNullParameter(message, "message"); m.checkNotNullParameter(charSequence, "formattedMessage"); WidgetChatListActions.Companion.showForPin(this.fragmentManager, message.getChannelId(), message.getId(), charSequence); } @Override // com.discord.widgets.chat.list.adapter.WidgetChatListAdapter.EventHandler public void onOldestMessageId(long j, long j2) { WidgetChatListAdapter.EventHandler.DefaultImpls.onOldestMessageId(this, j, j2); } @Override // com.discord.widgets.chat.list.adapter.WidgetChatListAdapter.EventHandler public void onOpenPinsClicked(Message message) { m.checkNotNullParameter(message, "message"); WidgetChatListAdapter.EventHandler.DefaultImpls.onOpenPinsClicked(this, message); } @Override // com.discord.widgets.chat.list.adapter.WidgetChatListAdapter.EventHandler public void onQuickAddReactionClicked(long j, long j2, long j3, long j4) { WidgetChatListAdapter.EventHandler.DefaultImpls.onQuickAddReactionClicked(this, j, j2, j3, 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 WidgetChatListAdapter.EventHandler.DefaultImpls.onQuickDownloadClicked(this, uri, str); } @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"); WidgetChatListAdapter.EventHandler.DefaultImpls.onReactionClicked(this, j, j2, j3, j4, messageReaction, z2); } @Override // com.discord.widgets.chat.list.adapter.WidgetChatListAdapter.EventHandler public void onReactionLongClicked(long j, long j2, long j3, MessageReaction messageReaction) { m.checkNotNullParameter(messageReaction, "reaction"); WidgetChatListAdapter.EventHandler.DefaultImpls.onReactionLongClicked(this, j, j2, j3, messageReaction); } @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"); StoreStream.Companion.getMessagesLoader().jumpToMessage(message.getChannelId(), message.getId()); } @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"); WidgetChatListAdapter.EventHandler.DefaultImpls.onThreadLongClicked(this, 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, "messageActivityType"); m.checkNotNullParameter(activity, "activity"); m.checkNotNullParameter(application, "application"); WidgetChatListAdapter.EventHandler.DefaultImpls.onUserActivityAction(this, j, j2, j3, messageActivityType, activity, application); } @Override // com.discord.widgets.chat.list.adapter.WidgetChatListAdapter.EventHandler public void onUserMentionClicked(long j, long j2, long j3) { WidgetChatListAdapter.EventHandler.DefaultImpls.onUserMentionClicked(this, j, j2, j3); } } /* compiled from: WidgetChannelPinnedMessages.kt */ public static final class Companion { private Companion() { } public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) { this(); } public final void show(Context context, long j) { m.checkNotNullParameter(context, "context"); Intent intent = new Intent(); intent.putExtra("INTENT_EXTRA_CHANNEL_ID", j); l.d(context, WidgetChannelPinnedMessages.class, intent); } } /* compiled from: WidgetChannelPinnedMessages.kt */ public static final class Model implements WidgetChatListAdapter.Data { public static final Companion Companion = new Companion(null); private final Channel channel; private final long channelId; private final Map channelNames; private final Guild guild; private final long guildId; private final boolean isSpoilerClickAllowed; private final List list; private final Set myRoleIds; private final long newMessagesMarkerMessageId; private final long oldestMessageId; private final long userId; /* compiled from: WidgetChannelPinnedMessages.kt */ public static final class Companion { private Companion() { } public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) { this(); } public final Observable get(Context context, long j) { m.checkNotNullParameter(context, "context"); StoreStream.Companion companion = StoreStream.Companion; Channel findChannelByIdInternal$app_productionBetaRelease = companion.getChannels().findChannelByIdInternal$app_productionBetaRelease(j); if (findChannelByIdInternal$app_productionBetaRelease != null) { Observable Y = companion.getPinnedMessages().observeForChannel(j).Y(new WidgetChannelPinnedMessages$Model$Companion$get$1(findChannelByIdInternal$app_productionBetaRelease, context)); m.checkNotNullExpressionValue(Y, "getPinnedMessages().obse… }\n }"); return Y; } j jVar = new j(null); m.checkNotNullExpressionValue(jVar, "Observable.just(null)"); return jVar; } } /* JADX DEBUG: Multi-variable search result rejected for r13v0, resolved type: java.util.List */ /* JADX WARN: Multi-variable type inference failed */ public Model(Channel channel, Guild guild, long j, Map map, List list, Set set, long j2, long j3, long j4, long j5, boolean z2) { m.checkNotNullParameter(channel, "channel"); m.checkNotNullParameter(map, "channelNames"); m.checkNotNullParameter(list, "list"); m.checkNotNullParameter(set, "myRoleIds"); this.channel = channel; this.guild = guild; this.userId = j; this.channelNames = map; this.list = list; this.myRoleIds = set; this.channelId = j2; this.guildId = j3; this.oldestMessageId = j4; this.newMessagesMarkerMessageId = j5; this.isSpoilerClickAllowed = z2; } /* JADX INFO: this call moved to the top of the method (can break code semantics) */ public /* synthetic */ Model(Channel channel, Guild guild, long j, Map map, List list, Set set, long j2, long j3, long j4, long j5, boolean z2, int i, DefaultConstructorMarker defaultConstructorMarker) { this(channel, guild, j, map, list, set, (i & 64) != 0 ? channel.h() : j2, (i & 128) != 0 ? channel.f() : j3, (i & 256) != 0 ? 0 : j4, (i & 512) != 0 ? 0 : j5, (i & 1024) != 0 ? false : z2); } public static /* synthetic */ Model copy$default(Model model, Channel channel, Guild guild, long j, Map map, List list, Set set, long j2, long j3, long j4, long j5, boolean z2, int i, Object obj) { return model.copy((i & 1) != 0 ? model.channel : channel, (i & 2) != 0 ? model.getGuild() : guild, (i & 4) != 0 ? model.getUserId() : j, (i & 8) != 0 ? model.getChannelNames() : map, (i & 16) != 0 ? model.getList() : list, (i & 32) != 0 ? model.getMyRoleIds() : set, (i & 64) != 0 ? model.getChannelId() : j2, (i & 128) != 0 ? model.getGuildId() : j3, (i & 256) != 0 ? model.getOldestMessageId() : j4, (i & 512) != 0 ? model.getNewMessagesMarkerMessageId() : j5, (i & 1024) != 0 ? model.isSpoilerClickAllowed() : z2); } public final Channel component1() { return this.channel; } public final long component10() { return getNewMessagesMarkerMessageId(); } public final boolean component11() { return isSpoilerClickAllowed(); } public final Guild component2() { return getGuild(); } public final long component3() { return getUserId(); } public final Map component4() { return getChannelNames(); } public final List component5() { return getList(); } public final Set component6() { return getMyRoleIds(); } public final long component7() { return getChannelId(); } public final long component8() { return getGuildId(); } public final long component9() { return getOldestMessageId(); } public final Model copy(Channel channel, Guild guild, long j, Map map, List list, Set set, long j2, long j3, long j4, long j5, boolean z2) { m.checkNotNullParameter(channel, "channel"); m.checkNotNullParameter(map, "channelNames"); m.checkNotNullParameter(list, "list"); m.checkNotNullParameter(set, "myRoleIds"); return new Model(channel, guild, j, map, list, set, j2, j3, j4, j5, z2); } public boolean equals(Object obj) { if (this == obj) { return true; } if (!(obj instanceof Model)) { return false; } Model model = (Model) obj; return m.areEqual(this.channel, model.channel) && m.areEqual(getGuild(), model.getGuild()) && getUserId() == model.getUserId() && m.areEqual(getChannelNames(), model.getChannelNames()) && m.areEqual(getList(), model.getList()) && m.areEqual(getMyRoleIds(), model.getMyRoleIds()) && getChannelId() == model.getChannelId() && getGuildId() == model.getGuildId() && getOldestMessageId() == model.getOldestMessageId() && getNewMessagesMarkerMessageId() == model.getNewMessagesMarkerMessageId() && isSpoilerClickAllowed() == model.isSpoilerClickAllowed(); } public final Channel getChannel() { return this.channel; } @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 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 getList() { return this.list; } @Override // com.discord.widgets.chat.list.adapter.WidgetChatListAdapter.Data public Set 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() { Channel channel = this.channel; int i = 0; int hashCode = (channel != null ? channel.hashCode() : 0) * 31; Guild guild = getGuild(); int a = (b.a(getUserId()) + ((hashCode + (guild != null ? guild.hashCode() : 0)) * 31)) * 31; Map channelNames = getChannelNames(); int hashCode2 = (a + (channelNames != null ? channelNames.hashCode() : 0)) * 31; List list = getList(); int hashCode3 = (hashCode2 + (list != null ? list.hashCode() : 0)) * 31; Set myRoleIds = getMyRoleIds(); if (myRoleIds != null) { i = myRoleIds.hashCode(); } int a2 = (b.a(getNewMessagesMarkerMessageId()) + ((b.a(getOldestMessageId()) + ((b.a(getGuildId()) + ((b.a(getChannelId()) + ((hashCode3 + i) * 31)) * 31)) * 31)) * 31)) * 31; boolean isSpoilerClickAllowed = isSpoilerClickAllowed(); if (isSpoilerClickAllowed) { isSpoilerClickAllowed = true; } int i2 = isSpoilerClickAllowed ? 1 : 0; int i3 = isSpoilerClickAllowed ? 1 : 0; int i4 = isSpoilerClickAllowed ? 1 : 0; return a2 + i2; } @Override // com.discord.widgets.chat.list.adapter.WidgetChatListAdapter.Data public boolean isSpoilerClickAllowed() { return this.isSpoilerClickAllowed; } public String toString() { StringBuilder K = a.K("Model(channel="); K.append(this.channel); K.append(", guild="); K.append(getGuild()); K.append(", userId="); K.append(getUserId()); K.append(", channelNames="); K.append(getChannelNames()); K.append(", list="); K.append(getList()); K.append(", myRoleIds="); K.append(getMyRoleIds()); K.append(", channelId="); K.append(getChannelId()); K.append(", guildId="); K.append(getGuildId()); K.append(", oldestMessageId="); K.append(getOldestMessageId()); K.append(", newMessagesMarkerMessageId="); K.append(getNewMessagesMarkerMessageId()); K.append(", isSpoilerClickAllowed="); K.append(isSpoilerClickAllowed()); K.append(")"); return K.toString(); } } public WidgetChannelPinnedMessages() { super(2131558883); } public static final /* synthetic */ void access$configureUI(WidgetChannelPinnedMessages widgetChannelPinnedMessages, Model model) { widgetChannelPinnedMessages.configureUI(model); } private final void addThreadSpineItemDecoration(WidgetChatListAdapter widgetChatListAdapter) { getBinding().b.addItemDecoration(new ThreadSpineItemDecoration(requireContext(), widgetChatListAdapter)); } private final void configureUI(Model model) { if (model == null) { requireActivity().finish(); return; } setActionBarSubtitle(AnimatableValueParser.A0(model.getChannel(), requireContext(), false, 2)); WidgetChatListAdapter widgetChatListAdapter = this.adapter; if (widgetChatListAdapter != null) { widgetChatListAdapter.setData(model); } } private final WidgetChannelPinnedMessagesBinding getBinding() { return (WidgetChannelPinnedMessagesBinding) 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); AppFragment.setActionBarDisplayHomeAsUpEnabled$default(this, false, 1, null); setActionBarTitle(2131892052); MGRecyclerAdapter.Companion companion = MGRecyclerAdapter.Companion; RecyclerView recyclerView = getBinding().b; m.checkNotNullExpressionValue(recyclerView, "binding.channelPinnedMessagesRecycler"); FragmentManager parentFragmentManager = getParentFragmentManager(); m.checkNotNullExpressionValue(parentFragmentManager, "parentFragmentManager"); Context requireContext = requireContext(); FragmentManager parentFragmentManager2 = getParentFragmentManager(); m.checkNotNullExpressionValue(parentFragmentManager2, "parentFragmentManager"); WidgetChatListAdapter widgetChatListAdapter = (WidgetChatListAdapter) companion.configure(new WidgetChatListAdapter(recyclerView, this, parentFragmentManager, new ChannelPinnedMessagesAdapterEventHandler(requireContext, parentFragmentManager2, ChannelSelector.Companion.getInstance()), null, null, 48, null)); addThreadSpineItemDecoration(widgetChatListAdapter); this.adapter = widgetChatListAdapter; } @Override // com.discord.app.AppFragment public void onViewBoundOrOnResume() { super.onViewBoundOrOnResume(); Observable r = Model.Companion.get(requireContext(), getMostRecentIntent().getLongExtra("INTENT_EXTRA_CHANNEL_ID", 0)).r(); m.checkNotNullExpressionValue(r, "Model\n .get(requi… .distinctUntilChanged()"); ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.ui$default(ObservableExtensionsKt.computationLatest(r), this, null, 2, null), WidgetChannelPinnedMessages.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new WidgetChannelPinnedMessages$onViewBoundOrOnResume$1(this), 62, (Object) null); WidgetChatListAdapter widgetChatListAdapter = this.adapter; if (widgetChatListAdapter != null) { widgetChatListAdapter.setHandlers(); } } }