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

462 lines
24 KiB
Java

package com.discord.widgets.chat.list.adapter;
import a0.a.a.b;
import android.content.Context;
import android.view.View;
import android.widget.TextView;
import androidx.constraintlayout.widget.ConstraintLayout;
import c.d.b.a.a;
import com.discord.api.channel.Channel;
import com.discord.api.guild.Guild;
import com.discord.api.guildmember.GuildMember;
import com.discord.api.stageinstance.RecommendedStageInstance;
import com.discord.api.stageinstance.StageInstance;
import com.discord.databinding.WidgetChatListAdapterItemStageInviteBinding;
import com.discord.models.domain.ModelInvite;
import com.discord.models.user.User;
import com.discord.nullserializable.NullSerializable;
import com.discord.stores.StoreAccessibility;
import com.discord.stores.StoreChannels;
import com.discord.stores.StoreGuilds;
import com.discord.stores.StoreInstantInvites;
import com.discord.stores.StoreRequestedStageChannels;
import com.discord.stores.StoreStageChannels;
import com.discord.stores.StoreStageInstances;
import com.discord.stores.StoreStream;
import com.discord.stores.StoreUser;
import com.discord.stores.updates.ObservationDeck;
import com.discord.stores.updates.ObservationDeckProvider;
import com.discord.utilities.guilds.GuildUtilsKt;
import com.discord.utilities.icon.IconUtils;
import com.discord.utilities.images.MGImages;
import com.discord.utilities.rx.ObservableExtensionsKt;
import com.discord.utilities.rx.ObservableExtensionsKt$filterNull$1;
import com.discord.utilities.rx.ObservableExtensionsKt$filterNull$2;
import com.discord.utilities.view.extensions.ViewExtensions;
import com.discord.views.discovery.speakers.DiscoveryStageCardSpeakersView;
import com.discord.widgets.chat.list.entries.ChatListEntry;
import com.discord.widgets.chat.list.entries.StageInviteEntry;
import com.discord.widgets.stage.StageRoles;
import com.discord.widgets.stage.discovery.StageCardSpeaker;
import com.facebook.drawee.view.SimpleDraweeView;
import com.google.android.material.button.MaterialButton;
import d0.t.o;
import d0.z.d.m;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlinx.coroutines.Job;
import rx.Observable;
import rx.Subscription;
/* compiled from: WidgetChatListAdapterItemStageInvite.kt */
public final class WidgetChatListAdapterItemStageInvite extends WidgetChatListAdapterItemInviteBase {
private final WidgetChatListAdapterItemStageInviteBinding binding;
private String iconUrl;
private Job inviteJoinJob;
private StageInviteEntry item;
private Subscription subscription;
/* compiled from: WidgetChatListAdapterItemStageInvite.kt */
public static final class Model {
public static final Companion Companion = new Companion(null);
private final User authorUser;
private final Channel channel;
private final ModelInvite invite;
private final Integer listenersCount;
private final long meId;
private final boolean shouldAnimateGuildIcon;
private final List<StageCardSpeaker> speakers;
private final StageInstance stageInstance;
/* compiled from: WidgetChatListAdapterItemStageInvite.kt */
public static final class Companion {
private Companion() {
}
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
this();
}
public static final /* synthetic */ List access$speakersFromLocalStore(Companion companion, StoreGuilds storeGuilds, StoreUser storeUser, StoreStageChannels storeStageChannels, long j, long j2) {
return companion.speakersFromLocalStore(storeGuilds, storeUser, storeStageChannels, j, j2);
}
public static final /* synthetic */ List access$speakersFromRequest(Companion companion, StoreRequestedStageChannels.StageInstanceState stageInstanceState) {
return companion.speakersFromRequest(stageInstanceState);
}
public static /* synthetic */ Observable observe$default(Companion companion, StageInviteEntry stageInviteEntry, StoreUser storeUser, StoreChannels storeChannels, StoreGuilds storeGuilds, StoreAccessibility storeAccessibility, StoreStageInstances storeStageInstances, StoreRequestedStageChannels storeRequestedStageChannels, StoreStageChannels storeStageChannels, ObservationDeck observationDeck, int i, Object obj) {
return companion.observe(stageInviteEntry, (i & 2) != 0 ? StoreStream.Companion.getUsers() : storeUser, (i & 4) != 0 ? StoreStream.Companion.getChannels() : storeChannels, (i & 8) != 0 ? StoreStream.Companion.getGuilds() : storeGuilds, (i & 16) != 0 ? StoreStream.Companion.getAccessibility() : storeAccessibility, (i & 32) != 0 ? StoreStream.Companion.getStageInstances() : storeStageInstances, (i & 64) != 0 ? StoreStream.Companion.getRequestedStageChannels() : storeRequestedStageChannels, (i & 128) != 0 ? StoreStream.Companion.getStageChannels() : storeStageChannels, (i & 256) != 0 ? ObservationDeckProvider.get() : observationDeck);
}
private final List<StageCardSpeaker> speakersFromLocalStore(StoreGuilds storeGuilds, StoreUser storeUser, StoreStageChannels storeStageChannels, long j, long j2) {
User user;
Map<Long, StageRoles> channelRoles = storeStageChannels.getChannelRoles(j);
if (channelRoles == null) {
return null;
}
ArrayList arrayList = new ArrayList();
for (Map.Entry<Long, StageRoles> entry : channelRoles.entrySet()) {
long longValue = entry.getKey().longValue();
StageCardSpeaker stageCardSpeaker = (!StageRoles.m26isSpeakerimpl(entry.getValue().m28unboximpl()) || (user = storeUser.getUsers().get(Long.valueOf(longValue))) == null) ? null : Model.Companion.toStageCardSpeaker(user, storeGuilds.getMember(j2, longValue));
if (stageCardSpeaker != null) {
arrayList.add(stageCardSpeaker);
}
}
return arrayList;
}
private final List<StageCardSpeaker> speakersFromRequest(StoreRequestedStageChannels.StageInstanceState stageInstanceState) {
RecommendedStageInstance stageInstance;
if (stageInstanceState == null || (stageInstance = stageInstanceState.getStageInstance()) == null) {
return null;
}
List<GuildMember> d = stageInstance.d();
ArrayList arrayList = new ArrayList(o.collectionSizeOrDefault(d, 10));
for (GuildMember guildMember : d) {
long i = guildMember.j().i();
String b = guildMember.b();
if (b == null) {
NullSerializable<String> a = guildMember.j().a();
b = a != null ? a.a() : null;
}
String e = guildMember.e();
if (e == null) {
e = guildMember.j().r();
}
arrayList.add(new StageCardSpeaker(i, b, e));
}
return arrayList;
}
private final StageCardSpeaker toStageCardSpeaker(User user, com.discord.models.member.GuildMember guildMember) {
String str;
long id2 = user.getId();
String avatar = user.getAvatar();
if (guildMember == null || (str = guildMember.getNick()) == null) {
str = user.getUsername();
}
return new StageCardSpeaker(id2, avatar, str);
}
public final Observable<Model> observe(StageInviteEntry stageInviteEntry, StoreUser storeUser, StoreChannels storeChannels, StoreGuilds storeGuilds, StoreAccessibility storeAccessibility, StoreStageInstances storeStageInstances, StoreRequestedStageChannels storeRequestedStageChannels, StoreStageChannels storeStageChannels, ObservationDeck observationDeck) {
m.checkNotNullParameter(stageInviteEntry, "item");
m.checkNotNullParameter(storeUser, "userStore");
m.checkNotNullParameter(storeChannels, "channelStore");
m.checkNotNullParameter(storeGuilds, "guildStore");
m.checkNotNullParameter(storeAccessibility, "accessibilityStore");
m.checkNotNullParameter(storeStageInstances, "stageInstanceStore");
m.checkNotNullParameter(storeRequestedStageChannels, "requestedInstanceStore");
m.checkNotNullParameter(storeStageChannels, "stageChannelStore");
m.checkNotNullParameter(observationDeck, "observationDeck");
return ObservationDeck.connectRx$default(observationDeck, new ObservationDeck.UpdateSource[]{storeUser, storeChannels, storeGuilds, storeAccessibility, storeStageInstances, storeRequestedStageChannels, storeStageChannels}, false, null, null, new WidgetChatListAdapterItemStageInvite$Model$Companion$observe$1(storeUser, stageInviteEntry, storeChannels, storeAccessibility, storeStageInstances, storeRequestedStageChannels, storeStageChannels, storeGuilds), 14, null);
}
}
public Model(ModelInvite modelInvite, long j, User user, Channel channel, boolean z2, StageInstance stageInstance, List<StageCardSpeaker> list, Integer num) {
m.checkNotNullParameter(modelInvite, "invite");
m.checkNotNullParameter(channel, "channel");
m.checkNotNullParameter(list, "speakers");
this.invite = modelInvite;
this.meId = j;
this.authorUser = user;
this.channel = channel;
this.shouldAnimateGuildIcon = z2;
this.stageInstance = stageInstance;
this.speakers = list;
this.listenersCount = num;
}
public static /* synthetic */ Model copy$default(Model model, ModelInvite modelInvite, long j, User user, Channel channel, boolean z2, StageInstance stageInstance, List list, Integer num, int i, Object obj) {
return model.copy((i & 1) != 0 ? model.invite : modelInvite, (i & 2) != 0 ? model.meId : j, (i & 4) != 0 ? model.authorUser : user, (i & 8) != 0 ? model.channel : channel, (i & 16) != 0 ? model.shouldAnimateGuildIcon : z2, (i & 32) != 0 ? model.stageInstance : stageInstance, (i & 64) != 0 ? model.speakers : list, (i & 128) != 0 ? model.listenersCount : num);
}
public final ModelInvite component1() {
return this.invite;
}
public final long component2() {
return this.meId;
}
public final User component3() {
return this.authorUser;
}
public final Channel component4() {
return this.channel;
}
public final boolean component5() {
return this.shouldAnimateGuildIcon;
}
public final StageInstance component6() {
return this.stageInstance;
}
public final List<StageCardSpeaker> component7() {
return this.speakers;
}
public final Integer component8() {
return this.listenersCount;
}
public final Model copy(ModelInvite modelInvite, long j, User user, Channel channel, boolean z2, StageInstance stageInstance, List<StageCardSpeaker> list, Integer num) {
m.checkNotNullParameter(modelInvite, "invite");
m.checkNotNullParameter(channel, "channel");
m.checkNotNullParameter(list, "speakers");
return new Model(modelInvite, j, user, channel, z2, stageInstance, list, num);
}
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof Model)) {
return false;
}
Model model = (Model) obj;
return m.areEqual(this.invite, model.invite) && this.meId == model.meId && m.areEqual(this.authorUser, model.authorUser) && m.areEqual(this.channel, model.channel) && this.shouldAnimateGuildIcon == model.shouldAnimateGuildIcon && m.areEqual(this.stageInstance, model.stageInstance) && m.areEqual(this.speakers, model.speakers) && m.areEqual(this.listenersCount, model.listenersCount);
}
public final User getAuthorUser() {
return this.authorUser;
}
public final Channel getChannel() {
return this.channel;
}
public final ModelInvite getInvite() {
return this.invite;
}
public final Integer getListenersCount() {
return this.listenersCount;
}
public final long getMeId() {
return this.meId;
}
public final boolean getShouldAnimateGuildIcon() {
return this.shouldAnimateGuildIcon;
}
public final List<StageCardSpeaker> getSpeakers() {
return this.speakers;
}
public final StageInstance getStageInstance() {
return this.stageInstance;
}
public int hashCode() {
ModelInvite modelInvite = this.invite;
int i = 0;
int a = (b.a(this.meId) + ((modelInvite != null ? modelInvite.hashCode() : 0) * 31)) * 31;
User user = this.authorUser;
int hashCode = (a + (user != null ? user.hashCode() : 0)) * 31;
Channel channel = this.channel;
int hashCode2 = (hashCode + (channel != null ? channel.hashCode() : 0)) * 31;
boolean z2 = this.shouldAnimateGuildIcon;
if (z2) {
z2 = true;
}
int i2 = z2 ? 1 : 0;
int i3 = z2 ? 1 : 0;
int i4 = z2 ? 1 : 0;
int i5 = (hashCode2 + i2) * 31;
StageInstance stageInstance = this.stageInstance;
int hashCode3 = (i5 + (stageInstance != null ? stageInstance.hashCode() : 0)) * 31;
List<StageCardSpeaker> list = this.speakers;
int hashCode4 = (hashCode3 + (list != null ? list.hashCode() : 0)) * 31;
Integer num = this.listenersCount;
if (num != null) {
i = num.hashCode();
}
return hashCode4 + i;
}
public String toString() {
StringBuilder K = a.K("Model(invite=");
K.append(this.invite);
K.append(", meId=");
K.append(this.meId);
K.append(", authorUser=");
K.append(this.authorUser);
K.append(", channel=");
K.append(this.channel);
K.append(", shouldAnimateGuildIcon=");
K.append(this.shouldAnimateGuildIcon);
K.append(", stageInstance=");
K.append(this.stageInstance);
K.append(", speakers=");
K.append(this.speakers);
K.append(", listenersCount=");
return a.z(K, this.listenersCount, ")");
}
}
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public WidgetChatListAdapterItemStageInvite(WidgetChatListAdapter widgetChatListAdapter) {
super(2131558964, widgetChatListAdapter);
m.checkNotNullParameter(widgetChatListAdapter, "adapter");
View view = this.itemView;
int i = 2131363778;
TextView textView = (TextView) view.findViewById(2131363778);
if (textView != null) {
i = 2131363779;
TextView textView2 = (TextView) view.findViewById(2131363779);
if (textView2 != null) {
i = 2131363780;
TextView textView3 = (TextView) view.findViewById(2131363780);
if (textView3 != null) {
i = 2131363783;
SimpleDraweeView simpleDraweeView = (SimpleDraweeView) view.findViewById(2131363783);
if (simpleDraweeView != null) {
i = 2131363784;
TextView textView4 = (TextView) view.findViewById(2131363784);
if (textView4 != null) {
i = 2131363785;
MaterialButton materialButton = (MaterialButton) view.findViewById(2131363785);
if (materialButton != null) {
ConstraintLayout constraintLayout = (ConstraintLayout) view;
i = 2131363803;
TextView textView5 = (TextView) view.findViewById(2131363803);
if (textView5 != null) {
i = 2131365121;
DiscoveryStageCardSpeakersView discoveryStageCardSpeakersView = (DiscoveryStageCardSpeakersView) view.findViewById(2131365121);
if (discoveryStageCardSpeakersView != null) {
WidgetChatListAdapterItemStageInviteBinding widgetChatListAdapterItemStageInviteBinding = new WidgetChatListAdapterItemStageInviteBinding(constraintLayout, textView, textView2, textView3, simpleDraweeView, textView4, materialButton, constraintLayout, textView5, discoveryStageCardSpeakersView);
m.checkNotNullExpressionValue(widgetChatListAdapterItemStageInviteBinding, "WidgetChatListAdapterIte…iteBinding.bind(itemView)");
this.binding = widgetChatListAdapterItemStageInviteBinding;
return;
}
}
}
}
}
}
}
}
throw new NullPointerException("Missing required view with ID: ".concat(view.getResources().getResourceName(i)));
}
public static final /* synthetic */ void access$configureUI(WidgetChatListAdapterItemStageInvite widgetChatListAdapterItemStageInvite, Model model) {
widgetChatListAdapterItemStageInvite.configureUI(model);
}
public static final /* synthetic */ WidgetChatListAdapter access$getAdapter$p(WidgetChatListAdapterItemStageInvite widgetChatListAdapterItemStageInvite) {
return (WidgetChatListAdapter) widgetChatListAdapterItemStageInvite.adapter;
}
public static final /* synthetic */ Job access$getInviteJoinJob$p(WidgetChatListAdapterItemStageInvite widgetChatListAdapterItemStageInvite) {
return widgetChatListAdapterItemStageInvite.inviteJoinJob;
}
public static final /* synthetic */ Subscription access$getSubscription$p(WidgetChatListAdapterItemStageInvite widgetChatListAdapterItemStageInvite) {
return widgetChatListAdapterItemStageInvite.subscription;
}
public static final /* synthetic */ void access$setInviteJoinJob$p(WidgetChatListAdapterItemStageInvite widgetChatListAdapterItemStageInvite, Job job) {
widgetChatListAdapterItemStageInvite.inviteJoinJob = job;
}
public static final /* synthetic */ void access$setSubscription$p(WidgetChatListAdapterItemStageInvite widgetChatListAdapterItemStageInvite, Subscription subscription) {
widgetChatListAdapterItemStageInvite.subscription = subscription;
}
/* JADX WARNING: Code restructure failed: missing block: B:16:0x005e, code lost:
if ((r1.length() > 0) == true) goto L_0x0062;
*/
private final void configureUI(Model model) {
String str;
String str2;
Guild guild;
String u;
View view = this.itemView;
m.checkNotNullExpressionValue(view, "itemView");
Context context = view.getContext();
Guild guild2 = model.getInvite().getGuild();
String str3 = null;
Long valueOf = guild2 != null ? Long.valueOf(guild2.o()) : null;
Guild guild3 = model.getInvite().getGuild();
updateIconUrlIfChanged(IconUtils.getForGuild$default(valueOf, guild3 != null ? guild3.n() : null, "asset://asset/images/default_icon_selected.jpg", model.getShouldAnimateGuildIcon(), null, 16, null));
Guild guild4 = model.getInvite().getGuild();
boolean z2 = true;
if (!(guild4 == null || (r1 = guild4.n()) == null)) {
}
z2 = false;
TextView textView = this.binding.e;
m.checkNotNullExpressionValue(textView, "binding.itemInviteImageText");
ViewExtensions.setTextAndVisibilityBy(textView, (z2 || (guild = model.getInvite().getGuild()) == null || (u = guild.u()) == null) ? null : GuildUtilsKt.computeShortName(u));
TextView textView2 = this.binding.f1749c;
m.checkNotNullExpressionValue(textView2, "binding.itemInviteGuildName");
Guild guild5 = model.getInvite().getGuild();
if (guild5 == null || (str = guild5.u()) == null) {
str = model.getChannel().m();
}
textView2.setText(str);
TextView textView3 = this.binding.b;
m.checkNotNullExpressionValue(textView3, "binding.itemInviteChannelTopic");
StageInstance stageInstance = model.getStageInstance();
if (stageInstance == null || (str2 = stageInstance.f()) == null) {
str2 = model.getChannel().z();
}
if (str2 == null) {
str2 = model.getChannel().m();
}
ViewExtensions.setTextAndVisibilityBy(textView3, str2);
TextView textView4 = this.binding.g;
m.checkNotNullExpressionValue(textView4, "binding.itemListenersCount");
Integer listenersCount = model.getListenersCount();
if (listenersCount != null) {
str3 = String.valueOf(listenersCount.intValue());
}
ViewExtensions.setTextAndVisibilityBy(textView4, str3);
DiscoveryStageCardSpeakersView.a(this.binding.h, model.getSpeakers(), 0, 0, 6);
this.binding.f.setOnClickListener(new WidgetChatListAdapterItemStageInvite$configureUI$2(this, model, context));
}
private final void updateIconUrlIfChanged(String str) {
if (!m.areEqual(this.iconUrl, str)) {
SimpleDraweeView simpleDraweeView = this.binding.d;
m.checkNotNullExpressionValue(simpleDraweeView, "binding.itemInviteImage");
IconUtils.setIcon$default(simpleDraweeView, str, 2131165289, (Function1) null, (MGImages.ChangeDetector) null, 24, (Object) null);
this.iconUrl = str;
}
}
@Override // com.discord.utilities.mg_recycler.MGRecyclerViewHolder
public Subscription getSubscription() {
return this.subscription;
}
@Override // com.discord.widgets.chat.list.adapter.WidgetChatListItem
public void onConfigure(int i, ChatListEntry chatListEntry) {
m.checkNotNullParameter(chatListEntry, "data");
super.onConfigure(i, chatListEntry);
this.item = (StageInviteEntry) chatListEntry;
StoreInstantInvites instantInvites = StoreStream.Companion.getInstantInvites();
StageInviteEntry stageInviteEntry = this.item;
if (stageInviteEntry == null) {
m.throwUninitializedPropertyAccessException("item");
}
instantInvites.fetchInviteIfNotLoaded(stageInviteEntry.getInviteCode(), "Invite Button Embed");
Model.Companion companion = Model.Companion;
StageInviteEntry stageInviteEntry2 = this.item;
if (stageInviteEntry2 == null) {
m.throwUninitializedPropertyAccessException("item");
}
Observable F = ObservableExtensionsKt.ui(Model.Companion.observe$default(companion, stageInviteEntry2, null, null, null, null, null, null, null, null, 510, null)).x(ObservableExtensionsKt$filterNull$1.INSTANCE).F(ObservableExtensionsKt$filterNull$2.INSTANCE);
m.checkNotNullExpressionValue(F, "filter { it != null }.map { it!! }");
ObservableExtensionsKt.appSubscribe$default(F, WidgetChatListAdapterItemStageInvite.class, (Context) null, new WidgetChatListAdapterItemStageInvite$onConfigure$2(this), (Function1) null, (Function0) null, (Function0) null, new WidgetChatListAdapterItemStageInvite$onConfigure$1(this), 58, (Object) null);
}
}