107 lines
5.7 KiB
Java
107 lines
5.7 KiB
Java
|
package com.discord.widgets.channels.memberlist;
|
||
|
|
||
|
import c.d.b.a.a;
|
||
|
import com.airbnb.lottie.parser.AnimatableValueParser;
|
||
|
import com.discord.api.channel.Channel;
|
||
|
import com.discord.api.channel.ChannelRecipientNick;
|
||
|
import com.discord.models.domain.ModelApplicationStream;
|
||
|
import com.discord.models.presence.Presence;
|
||
|
import com.discord.models.user.User;
|
||
|
import com.discord.utilities.icon.IconUtils;
|
||
|
import com.discord.utilities.user.UserUtils;
|
||
|
import com.discord.widgets.channels.memberlist.WidgetChannelMembersListViewModel;
|
||
|
import com.discord.widgets.channels.memberlist.adapter.ChannelMembersListAdapter;
|
||
|
import d0.z.d.m;
|
||
|
import java.util.ArrayList;
|
||
|
import java.util.Comparator;
|
||
|
import java.util.Iterator;
|
||
|
import java.util.List;
|
||
|
import java.util.Locale;
|
||
|
import java.util.Map;
|
||
|
import java.util.Objects;
|
||
|
import java.util.TreeMap;
|
||
|
/* compiled from: PrivateChannelMemberListItemGenerator.kt */
|
||
|
public final class PrivateChannelMemberListItemGeneratorKt {
|
||
|
private static final ChannelMembersListAdapter.Item.Header createGroupDmHeader(int i) {
|
||
|
return new ChannelMembersListAdapter.Item.Header("%group_header_key", ChannelMembersListAdapter.Item.Header.Type.GROUP_DM, i);
|
||
|
}
|
||
|
|
||
|
private static final ChannelMembersListAdapter.Item.Member createMemberListItem(User user, Presence presence, boolean z2, String str, boolean z3) {
|
||
|
return new ChannelMembersListAdapter.Item.Member(user.getId(), null, str != null ? str : user.getUsername(), user.isBot(), Integer.valueOf(user.isSystemUser() ? 2131893944 : 2131887053), UserUtils.INSTANCE.isVerifiedBot(user), presence, null, IconUtils.getForUser$default(user, false, null, 6, null), z2, null, z3, true);
|
||
|
}
|
||
|
|
||
|
/* JADX WARN: Multi-variable type inference failed */
|
||
|
/* JADX DEBUG: Type inference failed for r5v4. Raw type applied. Possible types: java.util.Iterator<T>, java.util.Iterator */
|
||
|
/* JADX DEBUG: Type inference failed for r9v8. Raw type applied. Possible types: java.util.Iterator<T>, java.util.Iterator */
|
||
|
/* JADX WARNING: Unknown variable types count: 1 */
|
||
|
public static final WidgetChannelMembersListViewModel.MemberList generateGroupDmMemberListItems(Channel channel, Map<Long, ? extends User> map, Map<Long, Presence> map2, Map<Long, ? extends ModelApplicationStream> map3, boolean z2) {
|
||
|
Object obj;
|
||
|
boolean z3;
|
||
|
m.checkNotNullParameter(channel, "channel");
|
||
|
m.checkNotNullParameter(map, "users");
|
||
|
m.checkNotNullParameter(map2, "presences");
|
||
|
m.checkNotNullParameter(map3, "applicationStreams");
|
||
|
PrivateChannelMemberListItemGeneratorKt$generateGroupDmMemberListItems$memberItems$1 privateChannelMemberListItemGeneratorKt$generateGroupDmMemberListItems$memberItems$1 = PrivateChannelMemberListItemGeneratorKt$generateGroupDmMemberListItems$memberItems$1.INSTANCE;
|
||
|
if (privateChannelMemberListItemGeneratorKt$generateGroupDmMemberListItems$memberItems$1 != null) {
|
||
|
privateChannelMemberListItemGeneratorKt$generateGroupDmMemberListItems$memberItems$1 = new PrivateChannelMemberListItemGeneratorKt$sam$java_util_Comparator$0(privateChannelMemberListItemGeneratorKt$generateGroupDmMemberListItems$memberItems$1);
|
||
|
}
|
||
|
TreeMap treeMap = new TreeMap((Comparator) privateChannelMemberListItemGeneratorKt$generateGroupDmMemberListItems$memberItems$1);
|
||
|
Iterator it = map.values().iterator();
|
||
|
while (true) {
|
||
|
boolean z4 = false;
|
||
|
if (!it.hasNext()) {
|
||
|
break;
|
||
|
}
|
||
|
User user = (User) it.next();
|
||
|
StringBuilder sb = new StringBuilder();
|
||
|
String username = user.getUsername();
|
||
|
Locale locale = Locale.ROOT;
|
||
|
m.checkNotNullExpressionValue(locale, "Locale.ROOT");
|
||
|
Objects.requireNonNull(username, "null cannot be cast to non-null type java.lang.String");
|
||
|
String lowerCase = username.toLowerCase(locale);
|
||
|
m.checkNotNullExpressionValue(lowerCase, "(this as java.lang.String).toLowerCase(locale)");
|
||
|
sb.append(lowerCase);
|
||
|
sb.append(UserUtils.INSTANCE.getDiscriminatorWithPadding(user));
|
||
|
String sb2 = sb.toString();
|
||
|
List<ChannelRecipientNick> n = channel.n();
|
||
|
String str = null;
|
||
|
if (n != null) {
|
||
|
Iterator it2 = n.iterator();
|
||
|
while (true) {
|
||
|
if (!it2.hasNext()) {
|
||
|
obj = null;
|
||
|
break;
|
||
|
}
|
||
|
obj = it2.next();
|
||
|
if (((ChannelRecipientNick) obj).b() == user.getId()) {
|
||
|
z3 = true;
|
||
|
continue;
|
||
|
} else {
|
||
|
z3 = false;
|
||
|
continue;
|
||
|
}
|
||
|
if (z3) {
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
ChannelRecipientNick channelRecipientNick = (ChannelRecipientNick) obj;
|
||
|
if (channelRecipientNick != null) {
|
||
|
str = channelRecipientNick.c();
|
||
|
}
|
||
|
}
|
||
|
if (channel.q() == user.getId()) {
|
||
|
z4 = true;
|
||
|
}
|
||
|
treeMap.put(sb2, createMemberListItem(user, (Presence) a.c(user, map2), z4, str, map3.containsKey(Long.valueOf(user.getId()))));
|
||
|
}
|
||
|
int size = map.size();
|
||
|
ArrayList arrayList = new ArrayList(size + 1);
|
||
|
if (z2) {
|
||
|
arrayList.add(0, new ChannelMembersListAdapter.Item.AddMember(String.valueOf(channel.h()), AnimatableValueParser.k1(channel) ? 2131889148 : 2131887914));
|
||
|
}
|
||
|
arrayList.add(createGroupDmHeader(size));
|
||
|
arrayList.addAll(treeMap.values());
|
||
|
return new PrivateChannelMemberListItems(String.valueOf(channel.h()), arrayList);
|
||
|
}
|
||
|
}
|