forked from Juby210/discord-jadx
129 lines
7.1 KiB
Java
129 lines
7.1 KiB
Java
package com.discord.widgets.guilds.invite;
|
|
|
|
import android.view.ViewGroup;
|
|
import android.widget.TextView;
|
|
import androidx.recyclerview.widget.RecyclerView;
|
|
import com.airbnb.lottie.parser.AnimatableValueParser;
|
|
import com.discord.R;
|
|
import com.discord.api.channel.Channel;
|
|
import com.discord.databinding.WidgetGuildInviteShareItemBinding;
|
|
import com.discord.models.user.User;
|
|
import com.discord.utilities.icon.IconUtils;
|
|
import com.discord.utilities.images.MGImages;
|
|
import com.discord.utilities.mg_recycler.MGRecyclerAdapterSimple;
|
|
import com.discord.utilities.mg_recycler.MGRecyclerViewHolder;
|
|
import com.discord.widgets.guilds.invite.InviteSuggestionItemV2;
|
|
import com.discord.widgets.user.UserNameFormatterKt;
|
|
import com.facebook.drawee.view.SimpleDraweeView;
|
|
import com.google.android.material.button.MaterialButton;
|
|
import d0.z.d.m;
|
|
import kotlin.Unit;
|
|
import kotlin.jvm.functions.Function1;
|
|
/* compiled from: InviteSuggestionsAdapter.kt */
|
|
public final class InviteSuggestionsAdapter extends MGRecyclerAdapterSimple<InviteSuggestionItemV2> {
|
|
private Function1<? super InviteSuggestionItemV2, Unit> onClick = InviteSuggestionsAdapter$onClick$1.INSTANCE;
|
|
|
|
/* compiled from: InviteSuggestionsAdapter.kt */
|
|
public static final class EmptySearchResultsViewHolder extends MGRecyclerViewHolder<InviteSuggestionsAdapter, InviteSuggestionItemV2> {
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public EmptySearchResultsViewHolder(InviteSuggestionsAdapter inviteSuggestionsAdapter) {
|
|
super((int) R.layout.guild_invite_empty_search_results_item, inviteSuggestionsAdapter);
|
|
m.checkNotNullParameter(inviteSuggestionsAdapter, "adapter");
|
|
}
|
|
}
|
|
|
|
/* compiled from: InviteSuggestionsAdapter.kt */
|
|
public static final class InviteSuggestionViewHolder extends MGRecyclerViewHolder<InviteSuggestionsAdapter, InviteSuggestionItemV2> {
|
|
private final WidgetGuildInviteShareItemBinding binding;
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public InviteSuggestionViewHolder(InviteSuggestionsAdapter inviteSuggestionsAdapter) {
|
|
super((int) R.layout.widget_guild_invite_share_item, inviteSuggestionsAdapter);
|
|
m.checkNotNullParameter(inviteSuggestionsAdapter, "adapter");
|
|
WidgetGuildInviteShareItemBinding a = WidgetGuildInviteShareItemBinding.a(this.itemView);
|
|
m.checkNotNullExpressionValue(a, "WidgetGuildInviteShareItemBinding.bind(itemView)");
|
|
this.binding = a;
|
|
}
|
|
|
|
public static final /* synthetic */ InviteSuggestionsAdapter access$getAdapter$p(InviteSuggestionViewHolder inviteSuggestionViewHolder) {
|
|
return (InviteSuggestionsAdapter) inviteSuggestionViewHolder.adapter;
|
|
}
|
|
|
|
private final void configureItemForChannel(Channel channel) {
|
|
SimpleDraweeView simpleDraweeView = this.binding.b;
|
|
m.checkNotNullExpressionValue(simpleDraweeView, "binding.itemIconIv");
|
|
IconUtils.setIcon$default(simpleDraweeView, channel, 0, (MGImages.ChangeDetector) null, 12, (Object) null);
|
|
TextView textView = this.binding.d;
|
|
m.checkNotNullExpressionValue(textView, "binding.itemNameTv");
|
|
textView.setText(AnimatableValueParser.y0(channel));
|
|
}
|
|
|
|
private final void configureItemForUser(User user) {
|
|
SimpleDraweeView simpleDraweeView = this.binding.b;
|
|
m.checkNotNullExpressionValue(simpleDraweeView, "binding.itemIconIv");
|
|
IconUtils.setIcon$default(simpleDraweeView, user, 0, null, null, null, 60, null);
|
|
TextView textView = this.binding.d;
|
|
m.checkNotNullExpressionValue(textView, "binding.itemNameTv");
|
|
textView.setText(UserNameFormatterKt.getSpannableForUserNameWithDiscrim(user, null, ((InviteSuggestionsAdapter) this.adapter).getContext(), R.attr.colorHeaderPrimary, R.attr.font_primary_semibold, R.integer.uikit_textsize_large_sp, R.attr.colorTextMuted, R.attr.font_primary_normal, R.integer.uikit_textsize_large_sp));
|
|
}
|
|
|
|
public void onConfigure(int i, InviteSuggestionItemV2 inviteSuggestionItemV2) {
|
|
m.checkNotNullParameter(inviteSuggestionItemV2, "data");
|
|
super.onConfigure(i, (int) inviteSuggestionItemV2);
|
|
boolean z2 = inviteSuggestionItemV2 instanceof InviteSuggestionItemV2.ChannelItem;
|
|
if (z2) {
|
|
InviteSuggestionItemV2.ChannelItem channelItem = (InviteSuggestionItemV2.ChannelItem) inviteSuggestionItemV2;
|
|
User v0 = AnimatableValueParser.v0(channelItem.getChannel());
|
|
if (v0 != null) {
|
|
configureItemForUser(v0);
|
|
} else {
|
|
configureItemForChannel(channelItem.getChannel());
|
|
}
|
|
} else if (inviteSuggestionItemV2 instanceof InviteSuggestionItemV2.UserItem) {
|
|
configureItemForUser(((InviteSuggestionItemV2.UserItem) inviteSuggestionItemV2).getUser());
|
|
}
|
|
if (z2 || (inviteSuggestionItemV2 instanceof InviteSuggestionItemV2.UserItem)) {
|
|
MaterialButton materialButton = this.binding.e;
|
|
m.checkNotNullExpressionValue(materialButton, "binding.itemSent");
|
|
int i2 = 0;
|
|
materialButton.setVisibility(inviteSuggestionItemV2.hasSentInvite() ? 0 : 8);
|
|
MaterialButton materialButton2 = this.binding.f1857c;
|
|
m.checkNotNullExpressionValue(materialButton2, "binding.itemInviteBtn");
|
|
if (!(!inviteSuggestionItemV2.hasSentInvite())) {
|
|
i2 = 8;
|
|
}
|
|
materialButton2.setVisibility(i2);
|
|
this.binding.f1857c.setOnClickListener(new InviteSuggestionsAdapter$InviteSuggestionViewHolder$onConfigure$1(this, inviteSuggestionItemV2));
|
|
}
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public InviteSuggestionsAdapter(RecyclerView recyclerView) {
|
|
super(recyclerView, false, 2, null);
|
|
m.checkNotNullParameter(recyclerView, "recycler");
|
|
}
|
|
|
|
/* JADX DEBUG: Type inference failed for r0v0. Raw type applied. Possible types: kotlin.jvm.functions.Function1<? super com.discord.widgets.guilds.invite.InviteSuggestionItemV2, kotlin.Unit>, kotlin.jvm.functions.Function1<com.discord.widgets.guilds.invite.InviteSuggestionItemV2, kotlin.Unit> */
|
|
public final Function1<InviteSuggestionItemV2, Unit> getOnClick() {
|
|
return this.onClick;
|
|
}
|
|
|
|
@Override // androidx.recyclerview.widget.RecyclerView.Adapter
|
|
public MGRecyclerViewHolder<InviteSuggestionsAdapter, InviteSuggestionItemV2> onCreateViewHolder(ViewGroup viewGroup, int i) {
|
|
m.checkNotNullParameter(viewGroup, "parent");
|
|
if (i == 1) {
|
|
return new EmptySearchResultsViewHolder(this);
|
|
}
|
|
if (i == 2 || i == 3) {
|
|
return new InviteSuggestionViewHolder(this);
|
|
}
|
|
throw invalidViewTypeException(i);
|
|
}
|
|
|
|
public final void setOnClick(Function1<? super InviteSuggestionItemV2, Unit> function1) {
|
|
m.checkNotNullParameter(function1, "<set-?>");
|
|
this.onClick = function1;
|
|
}
|
|
}
|