package com.discord.widgets.user.search; import android.content.Context; import android.text.SpannableStringBuilder; import android.text.style.StyleSpan; import android.util.AttributeSet; import android.view.LayoutInflater; import android.widget.ImageView; import android.widget.TextView; import androidx.constraintlayout.widget.ConstraintLayout; import androidx.constraintlayout.widget.Guideline; import com.airbnb.lottie.parser.AnimatableValueParser; import com.discord.api.channel.Channel; import com.discord.databinding.ViewGlobalSearchItemBinding; import com.discord.models.guild.Guild; import com.discord.models.user.User; import com.discord.utilities.color.ColorCompat; import com.discord.utilities.icon.IconUtils; import com.discord.utilities.images.MGImages; import com.discord.utilities.user.UserUtils; import com.discord.utilities.view.extensions.ViewExtensions; import com.discord.widgets.user.search.WidgetGlobalSearchModel; import com.facebook.drawee.view.SimpleDraweeView; import d0.t.u; import d0.z.d.m; import java.util.ArrayList; import java.util.List; import kotlin.jvm.functions.Function1; import kotlin.jvm.internal.DefaultConstructorMarker; /* compiled from: ViewGlobalSearchItem.kt */ public final class ViewGlobalSearchItem extends ConstraintLayout { private final ViewGlobalSearchItemBinding binding; public ViewGlobalSearchItem(Context context) { this(context, null, 0, 6, null); } public ViewGlobalSearchItem(Context context, AttributeSet attributeSet) { this(context, attributeSet, 0, 4, null); } /* JADX INFO: super call moved to the top of the method (can break code semantics) */ public ViewGlobalSearchItem(Context context, AttributeSet attributeSet, int i) { super(context, attributeSet, i); m.checkNotNullParameter(context, "ctx"); LayoutInflater.from(context).inflate(2131558756, this); int i2 = 2131363395; Guideline guideline = (Guideline) findViewById(2131363395); if (guideline != null) { i2 = 2131363732; TextView textView = (TextView) findViewById(2131363732); if (textView != null) { i2 = 2131363754; TextView textView2 = (TextView) findViewById(2131363754); if (textView2 != null) { i2 = 2131363766; SimpleDraweeView simpleDraweeView = (SimpleDraweeView) findViewById(2131363766); if (simpleDraweeView != null) { i2 = 2131363796; TextView textView3 = (TextView) findViewById(2131363796); if (textView3 != null) { i2 = 2131363798; TextView textView4 = (TextView) findViewById(2131363798); if (textView4 != null) { i2 = 2131363802; ImageView imageView = (ImageView) findViewById(2131363802); if (imageView != null) { ViewGlobalSearchItemBinding viewGlobalSearchItemBinding = new ViewGlobalSearchItemBinding(this, guideline, textView, textView2, simpleDraweeView, textView3, textView4, imageView); m.checkNotNullExpressionValue(viewGlobalSearchItemBinding, "ViewGlobalSearchItemBind…Inflater.from(ctx), this)"); this.binding = viewGlobalSearchItemBinding; return; } } } } } } } throw new NullPointerException("Missing required view with ID: ".concat(getResources().getResourceName(i2))); } /* JADX INFO: this call moved to the top of the method (can break code semantics) */ public /* synthetic */ ViewGlobalSearchItem(Context context, AttributeSet attributeSet, int i, int i2, DefaultConstructorMarker defaultConstructorMarker) { this(context, (i2 & 2) != 0 ? null : attributeSet, (i2 & 4) != 0 ? 0 : i); } private final CharSequence toStyledText(WidgetGlobalSearchModel.MatchedResult matchedResult, String str) { if (matchedResult.getFirstMatchIndex() < 0) { return str; } SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(matchedResult.getValue()); spannableStringBuilder.setSpan(new StyleSpan(1), matchedResult.getFirstMatchIndex(), matchedResult.getFilterLength() + matchedResult.getFirstMatchIndex(), 17); return spannableStringBuilder; } public final void configure(WidgetGlobalSearchModel.ItemDataPayload itemDataPayload) { m.checkNotNullParameter(itemDataPayload, "$this$configure"); Integer valueOf = Integer.valueOf(itemDataPayload.getMentions()); int i = 0; String str = null; if (!(valueOf.intValue() > 0)) { valueOf = null; } if (valueOf != null) { str = String.valueOf(valueOf.intValue()); } TextView textView = this.binding.e; m.checkNotNullExpressionValue(textView, "binding.itemMentionsTv"); ViewExtensions.setTextAndVisibilityBy(textView, str); ImageView imageView = this.binding.g; m.checkNotNullExpressionValue(imageView, "binding.itemUnread"); if (!itemDataPayload.getUnread()) { i = 8; } imageView.setVisibility(i); } public final void onConfigure(WidgetGlobalSearchModel.ItemChannel itemChannel) { m.checkNotNullParameter(itemChannel, "data"); configure(itemChannel); SimpleDraweeView simpleDraweeView = this.binding.d; m.checkNotNullExpressionValue(simpleDraweeView, "binding.itemIconIv"); String str = null; simpleDraweeView.setController(null); if (AnimatableValueParser.s1(itemChannel.getChannel())) { SimpleDraweeView simpleDraweeView2 = this.binding.d; m.checkNotNullExpressionValue(simpleDraweeView2, "binding.itemIconIv"); IconUtils.setIcon$default(simpleDraweeView2, itemChannel.getChannel(), 2131165296, null, 8, null); } else if (AnimatableValueParser.l1(itemChannel.getChannel())) { MGImages mGImages = MGImages.INSTANCE; SimpleDraweeView simpleDraweeView3 = this.binding.d; m.checkNotNullExpressionValue(simpleDraweeView3, "binding.itemIconIv"); MGImages.setImage$default(mGImages, simpleDraweeView3, 2131231507, (MGImages.ChangeDetector) null, 4, (Object) null); } else { MGImages mGImages2 = MGImages.INSTANCE; SimpleDraweeView simpleDraweeView4 = this.binding.d; m.checkNotNullExpressionValue(simpleDraweeView4, "binding.itemIconIv"); MGImages.setImage$default(mGImages2, simpleDraweeView4, 2131231498, (MGImages.ChangeDetector) null, 4, (Object) null); } TextView textView = this.binding.f1656c; m.checkNotNullExpressionValue(textView, "binding.itemGroupTv"); Guild guild = itemChannel.getGuild(); ViewExtensions.setTextAndVisibilityBy(textView, guild != null ? guild.getName() : null); TextView textView2 = this.binding.f; m.checkNotNullExpressionValue(textView2, "binding.itemNameTv"); textView2.setText(toStyledText(itemChannel.getMatchedResult(), AnimatableValueParser.y0(itemChannel.getChannel()))); int A = itemChannel.getChannel().A(); if (A != 0) { if (A == 1) { TextView textView3 = this.binding.b; m.checkNotNullExpressionValue(textView3, "binding.itemDescriptionTv"); textView3.setVisibility(8); TextView textView4 = this.binding.f1656c; m.checkNotNullExpressionValue(textView4, "binding.itemGroupTv"); User v0 = AnimatableValueParser.v0(itemChannel.getChannel()); if (v0 != null) { str = v0.getUsername() + UserUtils.INSTANCE.getDiscriminatorWithPadding(v0); } ViewExtensions.setTextAndVisibilityBy(textView4, str); return; } else if (A != 2) { if (A == 3) { TextView textView5 = this.binding.b; m.checkNotNullExpressionValue(textView5, "binding.itemDescriptionTv"); int color = ColorCompat.getColor(textView5, 2131100465); TextView textView6 = this.binding.b; m.checkNotNullExpressionValue(textView6, "binding.itemDescriptionTv"); textView6.setText(u.joinToString$default(AnimatableValueParser.G0(itemChannel.getChannel()), null, null, null, 0, null, new ViewGlobalSearchItem$onConfigure$2(color), 31, null)); TextView textView7 = this.binding.b; m.checkNotNullExpressionValue(textView7, "binding.itemDescriptionTv"); textView7.setVisibility(8); TextView textView8 = this.binding.b; m.checkNotNullExpressionValue(textView8, "binding.itemDescriptionTv"); textView8.setAllCaps(false); return; } else if (!(A == 5 || A == 13)) { return; } } } TextView textView9 = this.binding.b; m.checkNotNullExpressionValue(textView9, "binding.itemDescriptionTv"); Channel parentChannel = itemChannel.getParentChannel(); if (parentChannel != null) { str = AnimatableValueParser.y0(parentChannel); } ViewExtensions.setTextAndVisibilityBy(textView9, str); TextView textView10 = this.binding.b; m.checkNotNullExpressionValue(textView10, "binding.itemDescriptionTv"); textView10.setAllCaps(true); } public final void onConfigure(WidgetGlobalSearchModel.ItemGuild itemGuild) { m.checkNotNullParameter(itemGuild, "data"); configure(itemGuild); SimpleDraweeView simpleDraweeView = this.binding.d; m.checkNotNullExpressionValue(simpleDraweeView, "binding.itemIconIv"); IconUtils.setIcon$default(simpleDraweeView, IconUtils.getForGuild$default(itemGuild.getGuild(), "asset://asset/images/default_icon.jpg", false, null, 12, null), 0, (Function1) null, (MGImages.ChangeDetector) null, 28, (Object) null); TextView textView = this.binding.f; m.checkNotNullExpressionValue(textView, "binding.itemNameTv"); textView.setText(toStyledText(itemGuild.getMatchedResult(), itemGuild.getGuild().getName())); TextView textView2 = this.binding.f1656c; m.checkNotNullExpressionValue(textView2, "binding.itemGroupTv"); ViewExtensions.setTextAndVisibilityBy(textView2, null); TextView textView3 = this.binding.b; m.checkNotNullExpressionValue(textView3, "binding.itemDescriptionTv"); ViewExtensions.setTextAndVisibilityBy(textView3, null); } public final void onConfigure(WidgetGlobalSearchModel.ItemUser itemUser) { m.checkNotNullParameter(itemUser, "data"); configure(itemUser); SimpleDraweeView simpleDraweeView = this.binding.d; m.checkNotNullExpressionValue(simpleDraweeView, "binding.itemIconIv"); IconUtils.setIcon$default(simpleDraweeView, itemUser.getUser(), 0, null, null, null, 60, null); if (itemUser.isFriend()) { this.binding.f1656c.setText(2131888812); } else { TextView textView = this.binding.f1656c; m.checkNotNullExpressionValue(textView, "binding.itemGroupTv"); textView.setText((CharSequence) null); } TextView textView2 = this.binding.f; m.checkNotNullExpressionValue(textView2, "binding.itemNameTv"); textView2.setText(toStyledText(itemUser.getMatchedResult(), itemUser.getMatchedResult().getValue().toString())); TextView textView3 = this.binding.f; m.checkNotNullExpressionValue(textView3, "binding.itemNameTv"); textView3.setImportantForAccessibility(2); TextView textView4 = this.binding.f1656c; m.checkNotNullExpressionValue(textView4, "binding.itemGroupTv"); ViewExtensions.setTextAndVisibilityBy(textView4, (CharSequence) u.firstOrNull((List) itemUser.getAliases())); TextView textView5 = this.binding.b; m.checkNotNullExpressionValue(textView5, "binding.itemDescriptionTv"); textView5.setAllCaps(false); TextView textView6 = this.binding.b; m.checkNotNullExpressionValue(textView6, "binding.itemDescriptionTv"); List drop = u.drop(itemUser.getAliases(), 1); ArrayList arrayList = new ArrayList(); for (Object obj : drop) { if (!m.areEqual((CharSequence) obj, itemUser.getMatchedResult().getValue())) { arrayList.add(obj); } } ViewExtensions.setTextAndVisibilityBy(textView6, u.joinToString$default(arrayList, null, null, null, 0, null, null, 63, null)); } }