393 lines
20 KiB
Java
393 lines
20 KiB
Java
package com.discord.widgets.chat.list.adapter;
|
|
|
|
import android.content.Context;
|
|
import android.view.View;
|
|
import android.widget.TextView;
|
|
import androidx.constraintlayout.widget.Barrier;
|
|
import androidx.constraintlayout.widget.ConstraintLayout;
|
|
import androidx.recyclerview.widget.RecyclerView;
|
|
import c.a.k.b;
|
|
import c.d.b.a.a;
|
|
import com.discord.api.activity.Activity;
|
|
import com.discord.api.activity.ActivityAssets;
|
|
import com.discord.api.activity.ActivityParty;
|
|
import com.discord.databinding.WidgetChatListAdapterItemSpotifyListenTogetherBinding;
|
|
import com.discord.models.presence.Presence;
|
|
import com.discord.models.user.MeUser;
|
|
import com.discord.models.user.User;
|
|
import com.discord.stores.StoreStream;
|
|
import com.discord.utilities.icon.IconUtils;
|
|
import com.discord.utilities.images.MGImages;
|
|
import com.discord.utilities.platform.Platform;
|
|
import com.discord.utilities.presence.PresenceUtils;
|
|
import com.discord.utilities.rx.ObservableExtensionsKt;
|
|
import com.discord.utilities.time.ClockFactory;
|
|
import com.discord.utilities.time.TimeUtils;
|
|
import com.discord.widgets.channels.list.WidgetCollapsedUsersListAdapter;
|
|
import com.discord.widgets.channels.list.items.CollapsedUser;
|
|
import com.discord.widgets.chat.list.entries.ChatListEntry;
|
|
import com.discord.widgets.chat.list.entries.SpotifyListenTogetherEntry;
|
|
import com.facebook.drawee.view.SimpleDraweeView;
|
|
import d0.d0.f;
|
|
import d0.g;
|
|
import d0.g0.w;
|
|
import d0.t.c0;
|
|
import d0.t.u;
|
|
import d0.z.d.m;
|
|
import java.util.Collection;
|
|
import java.util.HashMap;
|
|
import java.util.Iterator;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import kotlin.Lazy;
|
|
import kotlin.jvm.functions.Function0;
|
|
import kotlin.jvm.functions.Function1;
|
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
|
import rx.Observable;
|
|
import rx.Subscription;
|
|
/* compiled from: WidgetChatListAdapterItemSpotifyListenTogether.kt */
|
|
public final class WidgetChatListAdapterItemSpotifyListenTogether extends WidgetChatListItem {
|
|
public static final Companion Companion = new Companion(null);
|
|
private static final long EMBED_LIFETIME_MILLIS = 7200000;
|
|
private static final int MAX_USERS_SHOWN = 6;
|
|
private final WidgetChatListAdapterItemSpotifyListenTogetherBinding binding;
|
|
private Subscription subscription;
|
|
private final Lazy userAdapter$delegate;
|
|
|
|
/* compiled from: WidgetChatListAdapterItemSpotifyListenTogether.kt */
|
|
public static final class Companion {
|
|
private Companion() {
|
|
}
|
|
|
|
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
|
|
this();
|
|
}
|
|
}
|
|
|
|
/* compiled from: WidgetChatListAdapterItemSpotifyListenTogether.kt */
|
|
public static final class Model {
|
|
public static final Companion Companion = new Companion(null);
|
|
private final boolean isMe;
|
|
private final SpotifyListenTogetherEntry item;
|
|
private final Presence presence;
|
|
private final List<CollapsedUser> users;
|
|
|
|
/* compiled from: WidgetChatListAdapterItemSpotifyListenTogether.kt */
|
|
public static final class Companion {
|
|
private Companion() {
|
|
}
|
|
|
|
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
|
|
this();
|
|
}
|
|
|
|
public static final /* synthetic */ Model access$create(Companion companion, Presence presence, Map map, SpotifyListenTogetherEntry spotifyListenTogetherEntry, boolean z2) {
|
|
return companion.create(presence, map, spotifyListenTogetherEntry, z2);
|
|
}
|
|
|
|
private final Model create(Presence presence, Map<Long, ? extends User> map, SpotifyListenTogetherEntry spotifyListenTogetherEntry, boolean z2) {
|
|
ActivityParty i;
|
|
HashMap hashMap = new HashMap();
|
|
for (User user : map.values()) {
|
|
hashMap.put(Long.valueOf(user.getId()), new CollapsedUser(user, false, 0, 6, null));
|
|
}
|
|
if (z2) {
|
|
MeUser me2 = StoreStream.Companion.getUsers().getMe();
|
|
hashMap.put(Long.valueOf(me2.getId()), new CollapsedUser(me2, false, 0, 6, null));
|
|
}
|
|
Activity spotifyListeningActivity = presence != null ? PresenceUtils.INSTANCE.getSpotifyListeningActivity(presence) : null;
|
|
int maxSize = (spotifyListeningActivity == null || (i = spotifyListeningActivity.i()) == null) ? 0 : PresenceUtils.INSTANCE.getMaxSize(i);
|
|
Collection values = hashMap.values();
|
|
m.checkNotNullExpressionValue(values, "collapsedUserMap.values");
|
|
List mutableList = u.toMutableList(values);
|
|
Iterator<Integer> it = f.until(map.size(), Math.min(6, maxSize)).iterator();
|
|
while (it.hasNext()) {
|
|
mutableList.add(CollapsedUser.Companion.createEmptyUser(((c0) it).nextInt() == 5 ? maxSize - 6 : 0));
|
|
}
|
|
return new Model(presence, mutableList, spotifyListenTogetherEntry, z2);
|
|
}
|
|
|
|
public final Observable<Model> get(SpotifyListenTogetherEntry spotifyListenTogetherEntry) {
|
|
m.checkNotNullParameter(spotifyListenTogetherEntry, "item");
|
|
StoreStream.Companion companion = StoreStream.Companion;
|
|
Observable i = Observable.i(companion.getPresences().observePresenceForUser(spotifyListenTogetherEntry.getUserId()), companion.getGameParty().observeUsersForPartyId(spotifyListenTogetherEntry.getActivity().a()), companion.getUsers().observeMeId(), new WidgetChatListAdapterItemSpotifyListenTogether$Model$Companion$get$1(spotifyListenTogetherEntry));
|
|
m.checkNotNullExpressionValue(i, "Observable\n …m.userId)\n }");
|
|
Observable<Model> r = ObservableExtensionsKt.computationLatest(i).r();
|
|
m.checkNotNullExpressionValue(r, "Observable\n … .distinctUntilChanged()");
|
|
return r;
|
|
}
|
|
}
|
|
|
|
public Model(Presence presence, List<CollapsedUser> list, SpotifyListenTogetherEntry spotifyListenTogetherEntry, boolean z2) {
|
|
m.checkNotNullParameter(list, "users");
|
|
m.checkNotNullParameter(spotifyListenTogetherEntry, "item");
|
|
this.presence = presence;
|
|
this.users = list;
|
|
this.item = spotifyListenTogetherEntry;
|
|
this.isMe = z2;
|
|
}
|
|
|
|
/* JADX DEBUG: Multi-variable search result rejected for r0v0, resolved type: com.discord.widgets.chat.list.adapter.WidgetChatListAdapterItemSpotifyListenTogether$Model */
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
public static /* synthetic */ Model copy$default(Model model, Presence presence, List list, SpotifyListenTogetherEntry spotifyListenTogetherEntry, boolean z2, int i, Object obj) {
|
|
if ((i & 1) != 0) {
|
|
presence = model.presence;
|
|
}
|
|
if ((i & 2) != 0) {
|
|
list = model.users;
|
|
}
|
|
if ((i & 4) != 0) {
|
|
spotifyListenTogetherEntry = model.item;
|
|
}
|
|
if ((i & 8) != 0) {
|
|
z2 = model.isMe;
|
|
}
|
|
return model.copy(presence, list, spotifyListenTogetherEntry, z2);
|
|
}
|
|
|
|
public final Presence component1() {
|
|
return this.presence;
|
|
}
|
|
|
|
public final List<CollapsedUser> component2() {
|
|
return this.users;
|
|
}
|
|
|
|
public final SpotifyListenTogetherEntry component3() {
|
|
return this.item;
|
|
}
|
|
|
|
public final boolean component4() {
|
|
return this.isMe;
|
|
}
|
|
|
|
public final Model copy(Presence presence, List<CollapsedUser> list, SpotifyListenTogetherEntry spotifyListenTogetherEntry, boolean z2) {
|
|
m.checkNotNullParameter(list, "users");
|
|
m.checkNotNullParameter(spotifyListenTogetherEntry, "item");
|
|
return new Model(presence, list, spotifyListenTogetherEntry, 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.presence, model.presence) && m.areEqual(this.users, model.users) && m.areEqual(this.item, model.item) && this.isMe == model.isMe;
|
|
}
|
|
|
|
public final SpotifyListenTogetherEntry getItem() {
|
|
return this.item;
|
|
}
|
|
|
|
public final Presence getPresence() {
|
|
return this.presence;
|
|
}
|
|
|
|
public final List<CollapsedUser> getUsers() {
|
|
return this.users;
|
|
}
|
|
|
|
public int hashCode() {
|
|
Presence presence = this.presence;
|
|
int i = 0;
|
|
int hashCode = (presence != null ? presence.hashCode() : 0) * 31;
|
|
List<CollapsedUser> list = this.users;
|
|
int hashCode2 = (hashCode + (list != null ? list.hashCode() : 0)) * 31;
|
|
SpotifyListenTogetherEntry spotifyListenTogetherEntry = this.item;
|
|
if (spotifyListenTogetherEntry != null) {
|
|
i = spotifyListenTogetherEntry.hashCode();
|
|
}
|
|
int i2 = (hashCode2 + i) * 31;
|
|
boolean z2 = this.isMe;
|
|
if (z2) {
|
|
z2 = true;
|
|
}
|
|
int i3 = z2 ? 1 : 0;
|
|
int i4 = z2 ? 1 : 0;
|
|
int i5 = z2 ? 1 : 0;
|
|
return i2 + i3;
|
|
}
|
|
|
|
public final boolean isMe() {
|
|
return this.isMe;
|
|
}
|
|
|
|
public String toString() {
|
|
StringBuilder K = a.K("Model(presence=");
|
|
K.append(this.presence);
|
|
K.append(", users=");
|
|
K.append(this.users);
|
|
K.append(", item=");
|
|
K.append(this.item);
|
|
K.append(", isMe=");
|
|
return a.F(K, this.isMe, ")");
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public WidgetChatListAdapterItemSpotifyListenTogether(WidgetChatListAdapter widgetChatListAdapter) {
|
|
super(2131558963, widgetChatListAdapter);
|
|
m.checkNotNullParameter(widgetChatListAdapter, "adapter");
|
|
View view = this.itemView;
|
|
int i = 2131362111;
|
|
Barrier barrier = (Barrier) view.findViewById(2131362111);
|
|
if (barrier != null) {
|
|
i = 2131363795;
|
|
SimpleDraweeView simpleDraweeView = (SimpleDraweeView) view.findViewById(2131363795);
|
|
if (simpleDraweeView != null) {
|
|
i = 2131363796;
|
|
TextView textView = (TextView) view.findViewById(2131363796);
|
|
if (textView != null) {
|
|
ConstraintLayout constraintLayout = (ConstraintLayout) view;
|
|
i = 2131363798;
|
|
TextView textView2 = (TextView) view.findViewById(2131363798);
|
|
if (textView2 != null) {
|
|
i = 2131363799;
|
|
TextView textView3 = (TextView) view.findViewById(2131363799);
|
|
if (textView3 != null) {
|
|
i = 2131363800;
|
|
RecyclerView recyclerView = (RecyclerView) view.findViewById(2131363800);
|
|
if (recyclerView != null) {
|
|
i = 2131363801;
|
|
TextView textView4 = (TextView) view.findViewById(2131363801);
|
|
if (textView4 != null) {
|
|
i = 2131363802;
|
|
TextView textView5 = (TextView) view.findViewById(2131363802);
|
|
if (textView5 != null) {
|
|
WidgetChatListAdapterItemSpotifyListenTogetherBinding widgetChatListAdapterItemSpotifyListenTogetherBinding = new WidgetChatListAdapterItemSpotifyListenTogetherBinding(constraintLayout, barrier, simpleDraweeView, textView, constraintLayout, textView2, textView3, recyclerView, textView4, textView5);
|
|
m.checkNotNullExpressionValue(widgetChatListAdapterItemSpotifyListenTogetherBinding, "WidgetChatListAdapterIte…herBinding.bind(itemView)");
|
|
this.binding = widgetChatListAdapterItemSpotifyListenTogetherBinding;
|
|
this.userAdapter$delegate = g.lazy(new WidgetChatListAdapterItemSpotifyListenTogether$userAdapter$2(this));
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
throw new NullPointerException("Missing required view with ID: ".concat(view.getResources().getResourceName(i)));
|
|
}
|
|
|
|
public static final /* synthetic */ void access$configureUI(WidgetChatListAdapterItemSpotifyListenTogether widgetChatListAdapterItemSpotifyListenTogether, Model model) {
|
|
widgetChatListAdapterItemSpotifyListenTogether.configureUI(model);
|
|
}
|
|
|
|
public static final /* synthetic */ WidgetChatListAdapterItemSpotifyListenTogetherBinding access$getBinding$p(WidgetChatListAdapterItemSpotifyListenTogether widgetChatListAdapterItemSpotifyListenTogether) {
|
|
return widgetChatListAdapterItemSpotifyListenTogether.binding;
|
|
}
|
|
|
|
public static final /* synthetic */ Subscription access$getSubscription$p(WidgetChatListAdapterItemSpotifyListenTogether widgetChatListAdapterItemSpotifyListenTogether) {
|
|
return widgetChatListAdapterItemSpotifyListenTogether.subscription;
|
|
}
|
|
|
|
public static final /* synthetic */ void access$setSubscription$p(WidgetChatListAdapterItemSpotifyListenTogether widgetChatListAdapterItemSpotifyListenTogether, Subscription subscription) {
|
|
widgetChatListAdapterItemSpotifyListenTogether.subscription = subscription;
|
|
}
|
|
|
|
/* JADX DEBUG: Can't convert new array creation: APUT found in different block: 0x00fd: APUT (r5v1 java.lang.Object[]), (0 ??[int, short, byte, char]), (r6v5 java.lang.String) */
|
|
private final void configureUI(Model model) {
|
|
String a;
|
|
TextView textView = this.binding.e;
|
|
m.checkNotNullExpressionValue(textView, "binding.itemListenTogetherHeader");
|
|
TextView textView2 = this.binding.e;
|
|
m.checkNotNullExpressionValue(textView2, "binding.itemListenTogetherHeader");
|
|
Context context = textView2.getContext();
|
|
m.checkNotNullExpressionValue(context, "binding.itemListenTogetherHeader.context");
|
|
TextView textView3 = this.binding.e;
|
|
m.checkNotNullExpressionValue(textView3, "binding.itemListenTogetherHeader");
|
|
Context context2 = textView3.getContext();
|
|
m.checkNotNullExpressionValue(context2, "binding.itemListenTogetherHeader.context");
|
|
String str = null;
|
|
textView.setText(b.g(context, 2131890666, new Object[]{getActivityName(context2, model.getItem())}, null, 4));
|
|
boolean isDeadInvite = isDeadInvite(model.getPresence(), model.getItem());
|
|
Presence presence = model.getPresence();
|
|
Activity spotifyListeningActivity = presence != null ? PresenceUtils.INSTANCE.getSpotifyListeningActivity(presence) : null;
|
|
TextView textView4 = this.binding.g;
|
|
m.checkNotNullExpressionValue(textView4, "binding.itemListenTogetherSessionEnded");
|
|
int i = 8;
|
|
textView4.setVisibility(isDeadInvite ? 0 : 8);
|
|
RecyclerView recyclerView = this.binding.f;
|
|
m.checkNotNullExpressionValue(recyclerView, "binding.itemListenTogetherRecycler");
|
|
recyclerView.setVisibility(isDeadInvite ^ true ? 0 : 8);
|
|
TextView textView5 = this.binding.h;
|
|
m.checkNotNullExpressionValue(textView5, "binding.itemListenTogetherTrack");
|
|
textView5.setVisibility(isDeadInvite ^ true ? 0 : 8);
|
|
TextView textView6 = this.binding.f1749c;
|
|
m.checkNotNullExpressionValue(textView6, "binding.itemListenTogetherArtist");
|
|
textView6.setVisibility(isDeadInvite ^ true ? 0 : 8);
|
|
SimpleDraweeView simpleDraweeView = this.binding.b;
|
|
m.checkNotNullExpressionValue(simpleDraweeView, "binding.itemListenTogetherAlbumImage");
|
|
if (!isDeadInvite) {
|
|
i = 0;
|
|
}
|
|
simpleDraweeView.setVisibility(i);
|
|
ConstraintLayout constraintLayout = this.binding.d;
|
|
m.checkNotNullExpressionValue(constraintLayout, "binding.itemListenTogetherContainer");
|
|
constraintLayout.setSelected(true);
|
|
if (!isDeadInvite) {
|
|
getUserAdapter().setData(model.getUsers());
|
|
TextView textView7 = this.binding.h;
|
|
m.checkNotNullExpressionValue(textView7, "binding.itemListenTogetherTrack");
|
|
textView7.setText(spotifyListeningActivity != null ? spotifyListeningActivity.e() : null);
|
|
TextView textView8 = this.binding.f1749c;
|
|
m.checkNotNullExpressionValue(textView8, "binding.itemListenTogetherArtist");
|
|
Object[] objArr = new Object[1];
|
|
objArr[0] = spotifyListeningActivity != null ? spotifyListeningActivity.l() : null;
|
|
b.m(textView8, 2131894430, objArr, null, 4);
|
|
ActivityAssets b = spotifyListeningActivity != null ? spotifyListeningActivity.b() : null;
|
|
if (!(b == null || (a = b.a()) == null)) {
|
|
SimpleDraweeView simpleDraweeView2 = this.binding.b;
|
|
m.checkNotNullExpressionValue(simpleDraweeView2, "binding.itemListenTogetherAlbumImage");
|
|
MGImages.setImage$default(simpleDraweeView2, IconUtils.getAssetImage$default(IconUtils.INSTANCE, null, a, 0, 4, null), 0, 0, false, null, null, 124, null);
|
|
}
|
|
SimpleDraweeView simpleDraweeView3 = this.binding.b;
|
|
m.checkNotNullExpressionValue(simpleDraweeView3, "binding.itemListenTogetherAlbumImage");
|
|
if (b != null) {
|
|
str = b.b();
|
|
}
|
|
simpleDraweeView3.setContentDescription(str);
|
|
this.binding.h.setOnClickListener(new WidgetChatListAdapterItemSpotifyListenTogether$configureUI$2(spotifyListeningActivity));
|
|
this.binding.b.setOnClickListener(new WidgetChatListAdapterItemSpotifyListenTogether$configureUI$3(model, spotifyListeningActivity));
|
|
}
|
|
}
|
|
|
|
private final String getActivityName(Context context, SpotifyListenTogetherEntry spotifyListenTogetherEntry) {
|
|
String a = spotifyListenTogetherEntry.getActivity().a();
|
|
Platform platform = Platform.SPOTIFY;
|
|
if (w.contains((CharSequence) a, (CharSequence) platform.getPlatformId(), true)) {
|
|
return platform.getProperName();
|
|
}
|
|
String string = context.getString(2131888646);
|
|
m.checkNotNullExpressionValue(string, "context.getString(R.stri….form_label_desktop_only)");
|
|
return string;
|
|
}
|
|
|
|
private final WidgetCollapsedUsersListAdapter getUserAdapter() {
|
|
return (WidgetCollapsedUsersListAdapter) this.userAdapter$delegate.getValue();
|
|
}
|
|
|
|
private final boolean isDeadInvite(Presence presence, SpotifyListenTogetherEntry spotifyListenTogetherEntry) {
|
|
ActivityParty i;
|
|
String a;
|
|
Activity spotifyListeningActivity = presence != null ? PresenceUtils.INSTANCE.getSpotifyListeningActivity(presence) : null;
|
|
return !((spotifyListeningActivity == null || (i = spotifyListeningActivity.i()) == null || (a = i.a()) == null) ? false : a.equals(spotifyListenTogetherEntry.getActivity().a())) || TimeUtils.parseSnowflake(Long.valueOf(spotifyListenTogetherEntry.getMessageId())) + 7200000 < ClockFactory.get().currentTimeMillis();
|
|
}
|
|
|
|
@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);
|
|
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.ui(Model.Companion.get((SpotifyListenTogetherEntry) chatListEntry)), WidgetChatListAdapterItemSpotifyListenTogether.class, (Context) null, new WidgetChatListAdapterItemSpotifyListenTogether$onConfigure$1(this), (Function1) null, (Function0) null, (Function0) null, new WidgetChatListAdapterItemSpotifyListenTogether$onConfigure$2(this), 58, (Object) null);
|
|
}
|
|
}
|