discord-jadx/app/src/main/java/com/discord/widgets/chat/input/WidgetChatInputAutocomplete...

165 lines
12 KiB
Java

package com.discord.widgets.chat.input;
import android.content.res.Resources;
import android.widget.TextView;
import c.a.l.b;
import com.discord.api.sticker.Sticker;
import com.discord.app.AppFragment;
import com.discord.models.commands.Application;
import com.discord.stores.StoreStream;
import com.discord.widgets.chat.input.applicationcommands.WidgetChatInputApplicationCommands;
import com.discord.widgets.chat.input.applicationcommands.WidgetChatInputModelMappingFunctions;
import com.discord.widgets.chat.input.autocomplete.Autocompletable;
import com.discord.widgets.chat.input.autocomplete.EmojiAutocompletable;
import com.discord.widgets.chat.input.autocomplete.EmojiUpsellPlaceholder;
import com.discord.widgets.chat.input.autocomplete.LeadingIdentifier;
import com.discord.widgets.chat.input.autocomplete.adapter.ChatInputAutocompleteAdapter;
import com.discord.widgets.chat.input.models.AutocompleteInputSelectionModel;
import com.discord.widgets.chat.input.models.MentionToken;
import d0.t.n;
import d0.t.t;
import d0.t.u;
import d0.z.d.m;
import d0.z.d.o;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import kotlin.Pair;
import kotlin.Unit;
import kotlin.jvm.functions.Function1;
/* compiled from: WidgetChatInputAutocomplete.kt */
public final class WidgetChatInputAutocomplete$configureDataSubscriptions$13 extends o implements Function1<Pair<? extends AutocompleteInputSelectionModel, ? extends Boolean>, Unit> {
public final /* synthetic */ boolean $emojiAutocompleteUpsellEnabled;
public final /* synthetic */ AppFragment $fragment;
public final /* synthetic */ WidgetChatInputAutocomplete this$0;
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public WidgetChatInputAutocomplete$configureDataSubscriptions$13(WidgetChatInputAutocomplete widgetChatInputAutocomplete, boolean z2, AppFragment appFragment) {
super(1);
this.this$0 = widgetChatInputAutocomplete;
this.$emojiAutocompleteUpsellEnabled = z2;
this.$fragment = appFragment;
}
/* Return type fixed from 'java.lang.Object' to match base method */
/* JADX DEBUG: Method arguments types fixed to match base method, original types: [java.lang.Object] */
@Override // kotlin.jvm.functions.Function1
public /* bridge */ /* synthetic */ Unit invoke(Pair<? extends AutocompleteInputSelectionModel, ? extends Boolean> pair) {
invoke((Pair<AutocompleteInputSelectionModel, Boolean>) pair);
return Unit.a;
}
/* JADX DEBUG: Can't convert new array creation: APUT found in different block: 0x02f3: APUT (r10v2 java.lang.Object[]), (0 ??[int, short, byte, char]), (r11v3 java.lang.String) */
public final void invoke(Pair<AutocompleteInputSelectionModel, Boolean> pair) {
List<? extends Autocompletable> list;
AutocompleteInputSelectionModel component1 = pair.component1();
Boolean component2 = pair.component2();
WidgetChatInputAutocomplete widgetChatInputAutocomplete = this.this$0;
MentionToken autocompleteToken = component1.getAutocompleteToken();
WidgetChatInputAutocomplete.access$setLastToken$p(widgetChatInputAutocomplete, autocompleteToken != null ? autocompleteToken.getToken() : null);
Resources resources = this.this$0.getEditText().getResources();
m.checkNotNullExpressionValue(resources, "editText.resources");
boolean z2 = (resources.getConfiguration().orientation == 2) && WidgetChatInputAutocomplete.access$getHideMentionsInLandscape$p(this.this$0);
int size = component1.getFilteredAutocompletables().size();
WidgetChatInputApplicationCommands access$getApplicationCommands$p = WidgetChatInputAutocomplete.access$getApplicationCommands$p(this.this$0);
m.checkNotNullExpressionValue(component1, "model");
access$getApplicationCommands$p.configureUi(component1, z2);
MentionToken autocompleteToken2 = component1.getAutocompleteToken();
int i = 8;
if (autocompleteToken2 == null || z2) {
ChatInputAutocompleteAdapter.setData$default(WidgetChatInputAutocomplete.access$getMentionsAdapter$p(this.this$0), n.emptyList(), false, false, null, 14, null);
this.this$0.getMentionsRecycler().setVisibility(8);
WidgetChatInputAutocomplete.access$getCategoriesAdapter$p(this.this$0).getRecycler().setVisibility(8);
this.this$0.getStickersContainer().setVisibility(8);
WidgetChatInputAutocomplete.access$getEmojiHeader$p(this.this$0).setVisibility(8);
StoreStream.Companion.getAutocomplete().setAutocompleteVisible(false);
return;
}
List<Sticker> stickerMatches = component1.getStickerMatches();
ArrayList arrayList = new ArrayList(d0.t.o.collectionSizeOrDefault(stickerMatches, 10));
for (Sticker sticker : stickerMatches) {
arrayList.add(new AutocompleteStickerItem(sticker, null, 0, 6, null));
}
boolean z3 = autocompleteToken2.isAtStart() && autocompleteToken2.getLeadingIdentifier() == LeadingIdentifier.APP_COMMAND && autocompleteToken2.getToken().length() == 1;
WidgetChatInputDiscoveryCommandsModel discoveryCommands = component1.getInputSelectionModel().getInputModel().getCommands().getDiscoveryCommands();
if (!z3 || discoveryCommands == null) {
List<Autocompletable> filterMentionsFromToken = WidgetChatInputModelMappingFunctions.INSTANCE.filterMentionsFromToken(autocompleteToken2, component1.getInputSelectionModel(), component1.getFilteredAutocompletables());
size = filterMentionsFromToken.size();
boolean isReducedMotionEnabled = StoreStream.Companion.getAccessibility().isReducedMotionEnabled();
m.checkNotNullExpressionValue(component2, "allowAnimatedEmoji");
boolean z4 = component2.booleanValue() && !isReducedMotionEnabled;
if (this.$emojiAutocompleteUpsellEnabled) {
List filterIsInstance = t.filterIsInstance(filterMentionsFromToken, EmojiAutocompletable.class);
ArrayList arrayList2 = new ArrayList();
ArrayList arrayList3 = new ArrayList();
for (Object obj : filterIsInstance) {
if (!((EmojiAutocompletable) obj).getEmoji().isUsable()) {
arrayList2.add(obj);
} else {
arrayList3.add(obj);
}
}
Pair pair2 = new Pair(arrayList2, arrayList3);
List list2 = (List) pair2.component1();
list = (List) pair2.component2();
int size2 = list2.size();
List<EmojiAutocompletable> take = u.take(list2, 3);
ArrayList arrayList4 = new ArrayList(d0.t.o.collectionSizeOrDefault(take, 10));
for (EmojiAutocompletable emojiAutocompletable : take) {
arrayList4.add(emojiAutocompletable.getEmoji());
}
EmojiUpsellPlaceholder emojiUpsellPlaceholder = new EmojiUpsellPlaceholder(size2, arrayList4, z4);
if (!list2.isEmpty()) {
list = u.plus((Collection<? extends EmojiUpsellPlaceholder>) list, emojiUpsellPlaceholder);
}
} else {
list = u.toList(filterMentionsFromToken);
}
WidgetChatInputAutocomplete.access$getMentionsAdapter$p(this.this$0).setData(list, true, !arrayList.isEmpty(), WidgetChatInputAutocomplete.access$getUserAndRoles$p(this.this$0));
this.this$0.getMentionsRecycler().setVisibility(0);
WidgetChatInputAutocomplete.access$getCategoriesAdapter$p(this.this$0).getRecycler().setVisibility(8);
WidgetChatInputAutocomplete.access$getMentionsAdapter$p(this.this$0).setVisiblePositionListener(WidgetChatInputAutocomplete.access$getOnScrollVisibleMentions$p(this.this$0));
WidgetChatInputAutocomplete.access$getOnAutocompletionsUpdated$p(this.this$0).mo1invoke();
} else {
WidgetChatInputAutocomplete.access$getMentionsAdapter$p(this.this$0).setVisiblePositionListener(WidgetChatInputAutocomplete.access$getOnScrollVisibleDiscoveryCommands$p(this.this$0));
WidgetChatInputAutocomplete.access$getMentionsAdapter$p(this.this$0).setData(discoveryCommands.getFlattenCommandsModel(), false, !arrayList.isEmpty(), WidgetChatInputAutocomplete.access$getUserAndRoles$p(this.this$0));
this.this$0.getMentionsRecycler().setVisibility(0);
WidgetChatInputAutocomplete.access$getCategoriesAdapter$p(this.this$0).getRecycler().setVisibility(component1.getInputSelectionModel().getInputModel().getCommands().getApplications().size() > 1 ? 0 : 8);
WidgetChatInputCategoriesAdapter access$getCategoriesAdapter$p = WidgetChatInputAutocomplete.access$getCategoriesAdapter$p(this.this$0);
List<Application> applications = component1.getInputSelectionModel().getInputModel().getCommands().getApplications();
ArrayList arrayList5 = new ArrayList(d0.t.o.collectionSizeOrDefault(applications, 10));
for (Application application : applications) {
long id2 = application.getId();
Long access$getSelectedCommandApplicationId$p = WidgetChatInputAutocomplete.access$getSelectedCommandApplicationId$p(this.this$0);
arrayList5.add(new CommandCategoryItem(application, access$getSelectedCommandApplicationId$p != null && id2 == access$getSelectedCommandApplicationId$p.longValue(), null, 0, 12, null));
}
access$getCategoriesAdapter$p.setData(arrayList5);
if (discoveryCommands.getJumpedApplicationId() != null) {
int jumpedSequenceId = discoveryCommands.getJumpedSequenceId();
Integer access$getLastJumpedSequenceId$p = WidgetChatInputAutocomplete.access$getLastJumpedSequenceId$p(this.this$0);
if (access$getLastJumpedSequenceId$p == null || jumpedSequenceId != access$getLastJumpedSequenceId$p.intValue()) {
WidgetChatInputAutocomplete.access$jumpToApplication(this.this$0, discoveryCommands.getJumpedApplicationId().longValue());
WidgetChatInputAutocomplete.access$setLastJumpedSequenceId$p(this.this$0, Integer.valueOf(discoveryCommands.getJumpedSequenceId()));
}
}
}
WidgetChatInputAutocomplete.access$getStickersAdapter$p(this.this$0).setData(arrayList);
this.this$0.getStickersContainer().setVisibility(arrayList.isEmpty() ^ true ? 0 : 8);
TextView stickersHeader = this.this$0.getStickersHeader();
AppFragment appFragment = this.$fragment;
Object[] objArr = new Object[1];
String access$getLastToken$p = WidgetChatInputAutocomplete.access$getLastToken$p(this.this$0);
objArr[0] = access$getLastToken$p != null ? d0.g0.t.replace$default(access$getLastToken$p, String.valueOf(':'), "", false, 4, (Object) null) : null;
stickersHeader.setText(b.j(appFragment, 2131893677, objArr, null, 4));
TextView access$getEmojiHeader$p = WidgetChatInputAutocomplete.access$getEmojiHeader$p(this.this$0);
if (component1.getAutocompleteToken().getLeadingIdentifier() == LeadingIdentifier.EMOJI_AND_STICKERS && size > 0) {
i = 0;
}
access$getEmojiHeader$p.setVisibility(i);
WidgetChatInputAutocomplete.access$getEmojiHeader$p(this.this$0).setText(b.j(this.$fragment, 2131888288, new Object[]{WidgetChatInputAutocomplete.access$getLastToken$p(this.this$0)}, null, 4));
StoreStream.Companion companion = StoreStream.Companion;
companion.getAnalytics().trackAutocompleteOpen(companion.getChannelsSelected().getId(), component1.getAutocompleteType(), component1.getEmojiNumCount(), component1.getStickerNumCount());
companion.getAutocomplete().setAutocompleteVisible(true);
}
}