169 lines
9.4 KiB
Java
169 lines
9.4 KiB
Java
package com.discord.widgets.contact_sync;
|
|
|
|
import android.annotation.SuppressLint;
|
|
import android.content.Context;
|
|
import android.view.View;
|
|
import android.view.ViewGroup;
|
|
import android.widget.TextView;
|
|
import androidx.constraintlayout.widget.ConstraintLayout;
|
|
import androidx.recyclerview.widget.RecyclerView;
|
|
import com.discord.api.friendsuggestions.FriendSuggestion;
|
|
import com.discord.api.friendsuggestions.FriendSuggestionReason;
|
|
import com.discord.api.user.User;
|
|
import com.discord.databinding.ViewSelectableFriendSuggestionBinding;
|
|
import com.discord.nullserializable.NullSerializable;
|
|
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.contact_sync.WidgetContactSyncViewModel;
|
|
import com.facebook.drawee.view.SimpleDraweeView;
|
|
import com.google.android.material.checkbox.MaterialCheckBox;
|
|
import d0.g0.s;
|
|
import d0.g0.t;
|
|
import d0.z.d.m;
|
|
import java.util.Iterator;
|
|
import kotlin.Unit;
|
|
import kotlin.jvm.functions.Function1;
|
|
import kotlin.jvm.functions.Function2;
|
|
/* compiled from: ContactSyncFriendSuggestionListAdapter.kt */
|
|
public final class ContactSyncFriendSuggestionListAdapter extends MGRecyclerAdapterSimple<WidgetContactSyncViewModel.Item> {
|
|
private Function2<? super Long, ? super Boolean, Unit> onClickFriendSuggestion = ContactSyncFriendSuggestionListAdapter$onClickFriendSuggestion$1.INSTANCE;
|
|
private final int spacing;
|
|
|
|
/* compiled from: ContactSyncFriendSuggestionListAdapter.kt */
|
|
public static final class ItemFriendSuggestion extends MGRecyclerViewHolder<ContactSyncFriendSuggestionListAdapter, WidgetContactSyncViewModel.Item> {
|
|
private final ViewSelectableFriendSuggestionBinding binding;
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public ItemFriendSuggestion(ContactSyncFriendSuggestionListAdapter contactSyncFriendSuggestionListAdapter) {
|
|
super(2131558800, contactSyncFriendSuggestionListAdapter);
|
|
m.checkNotNullParameter(contactSyncFriendSuggestionListAdapter, "adapter");
|
|
View view = this.itemView;
|
|
int i = 2131363288;
|
|
SimpleDraweeView simpleDraweeView = (SimpleDraweeView) view.findViewById(2131363288);
|
|
if (simpleDraweeView != null) {
|
|
ConstraintLayout constraintLayout = (ConstraintLayout) view;
|
|
i = 2131363290;
|
|
TextView textView = (TextView) view.findViewById(2131363290);
|
|
if (textView != null) {
|
|
i = 2131363291;
|
|
TextView textView2 = (TextView) view.findViewById(2131363291);
|
|
if (textView2 != null) {
|
|
i = 2131363292;
|
|
TextView textView3 = (TextView) view.findViewById(2131363292);
|
|
if (textView3 != null) {
|
|
i = 2131363293;
|
|
MaterialCheckBox materialCheckBox = (MaterialCheckBox) view.findViewById(2131363293);
|
|
if (materialCheckBox != null) {
|
|
ViewSelectableFriendSuggestionBinding viewSelectableFriendSuggestionBinding = new ViewSelectableFriendSuggestionBinding(constraintLayout, simpleDraweeView, constraintLayout, textView, textView2, textView3, materialCheckBox);
|
|
m.checkNotNullExpressionValue(viewSelectableFriendSuggestionBinding, "ViewSelectableFriendSugg…ionBinding.bind(itemView)");
|
|
this.binding = viewSelectableFriendSuggestionBinding;
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
throw new NullPointerException("Missing required view with ID: ".concat(view.getResources().getResourceName(i)));
|
|
}
|
|
|
|
public static final /* synthetic */ ContactSyncFriendSuggestionListAdapter access$getAdapter$p(ItemFriendSuggestion itemFriendSuggestion) {
|
|
return (ContactSyncFriendSuggestionListAdapter) itemFriendSuggestion.adapter;
|
|
}
|
|
|
|
@SuppressLint({"SetTextI18n"})
|
|
public void onConfigure(int i, WidgetContactSyncViewModel.Item item) {
|
|
String str;
|
|
Object obj;
|
|
m.checkNotNullParameter(item, "data");
|
|
super.onConfigure(i, (int) item);
|
|
WidgetContactSyncViewModel.Item.FriendSuggestionItem friendSuggestionItem = (WidgetContactSyncViewModel.Item.FriendSuggestionItem) item;
|
|
FriendSuggestion suggestion = friendSuggestionItem.getSuggestion();
|
|
User b = suggestion.b();
|
|
ConstraintLayout constraintLayout = this.binding.f1664c;
|
|
m.checkNotNullExpressionValue(constraintLayout, "binding.friendSuggestionContainer");
|
|
int paddingLeft = constraintLayout.getPaddingLeft();
|
|
ConstraintLayout constraintLayout2 = this.binding.f1664c;
|
|
m.checkNotNullExpressionValue(constraintLayout2, "binding.friendSuggestionContainer");
|
|
int i2 = 0;
|
|
constraintLayout.setPadding(paddingLeft, 0, constraintLayout2.getPaddingRight(), ContactSyncFriendSuggestionListAdapter.access$getSpacing$p((ContactSyncFriendSuggestionListAdapter) this.adapter));
|
|
TextView textView = this.binding.e;
|
|
m.checkNotNullExpressionValue(textView, "binding.friendSuggestionName");
|
|
textView.setText(b.r());
|
|
TextView textView2 = this.binding.d;
|
|
m.checkNotNullExpressionValue(textView2, "binding.friendSuggestionDiscriminator");
|
|
textView2.setText('#' + b.f());
|
|
Iterator<T> it = suggestion.a().iterator();
|
|
while (true) {
|
|
str = null;
|
|
if (!it.hasNext()) {
|
|
obj = null;
|
|
break;
|
|
}
|
|
obj = it.next();
|
|
if (m.areEqual(((FriendSuggestionReason) obj).b(), "contacts")) {
|
|
break;
|
|
}
|
|
}
|
|
FriendSuggestionReason friendSuggestionReason = (FriendSuggestionReason) obj;
|
|
String a = friendSuggestionReason != null ? friendSuggestionReason.a() : null;
|
|
if (a == null) {
|
|
TextView textView3 = this.binding.f;
|
|
m.checkNotNullExpressionValue(textView3, "binding.friendSuggestionNickname");
|
|
textView3.setVisibility(8);
|
|
} else {
|
|
TextView textView4 = this.binding.f;
|
|
m.checkNotNullExpressionValue(textView4, "binding.friendSuggestionNickname");
|
|
textView4.setText(a);
|
|
TextView textView5 = this.binding.f;
|
|
m.checkNotNullExpressionValue(textView5, "binding.friendSuggestionNickname");
|
|
if (!(!t.isBlank(a))) {
|
|
i2 = 8;
|
|
}
|
|
textView5.setVisibility(i2);
|
|
}
|
|
MaterialCheckBox materialCheckBox = this.binding.g;
|
|
m.checkNotNullExpressionValue(materialCheckBox, "binding.friendSuggestionSelected");
|
|
materialCheckBox.setChecked(friendSuggestionItem.getSelected());
|
|
SimpleDraweeView simpleDraweeView = this.binding.b;
|
|
m.checkNotNullExpressionValue(simpleDraweeView, "binding.friendSuggestionAvatar");
|
|
Long valueOf = Long.valueOf(b.i());
|
|
NullSerializable<String> a2 = b.a();
|
|
if (a2 != null) {
|
|
str = a2.a();
|
|
}
|
|
IconUtils.setIcon$default(simpleDraweeView, IconUtils.getForUser$default(valueOf, str, s.toIntOrNull(b.f()), false, null, 16, null), 2131165296, (Function1) null, (MGImages.ChangeDetector) null, 24, (Object) null);
|
|
this.binding.g.setOnCheckedChangeListener(new ContactSyncFriendSuggestionListAdapter$ItemFriendSuggestion$onConfigure$1(this, suggestion.b().i()));
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public ContactSyncFriendSuggestionListAdapter(RecyclerView recyclerView) {
|
|
super(recyclerView, false, 2, null);
|
|
m.checkNotNullParameter(recyclerView, "recycler");
|
|
Context context = recyclerView.getContext();
|
|
m.checkNotNullExpressionValue(context, "recycler.context");
|
|
this.spacing = context.getResources().getDimensionPixelSize(2131165725);
|
|
}
|
|
|
|
public static final /* synthetic */ int access$getSpacing$p(ContactSyncFriendSuggestionListAdapter contactSyncFriendSuggestionListAdapter) {
|
|
return contactSyncFriendSuggestionListAdapter.spacing;
|
|
}
|
|
|
|
/* JADX DEBUG: Type inference failed for r0v0. Raw type applied. Possible types: kotlin.jvm.functions.Function2<? super java.lang.Long, ? super java.lang.Boolean, kotlin.Unit>, kotlin.jvm.functions.Function2<java.lang.Long, java.lang.Boolean, kotlin.Unit> */
|
|
public final Function2<Long, Boolean, Unit> getOnClickFriendSuggestion() {
|
|
return this.onClickFriendSuggestion;
|
|
}
|
|
|
|
@Override // androidx.recyclerview.widget.RecyclerView.Adapter
|
|
public MGRecyclerViewHolder<?, WidgetContactSyncViewModel.Item> onCreateViewHolder(ViewGroup viewGroup, int i) {
|
|
m.checkNotNullParameter(viewGroup, "parent");
|
|
return new ItemFriendSuggestion(this);
|
|
}
|
|
|
|
public final void setOnClickFriendSuggestion(Function2<? super Long, ? super Boolean, Unit> function2) {
|
|
m.checkNotNullParameter(function2, "<set-?>");
|
|
this.onClickFriendSuggestion = function2;
|
|
}
|
|
}
|