discord-jadx/app/src/main/java/com/discord/widgets/user/profile/UserProfileConnectionsView.java
2021-07-24 04:37:17 +02:00

317 lines
15 KiB
Java

package com.discord.widgets.user.profile;
import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.annotation.LayoutRes;
import androidx.core.view.ViewCompat;
import androidx.recyclerview.widget.RecyclerView;
import c.d.b.a.a;
import com.discord.databinding.UserProfileConnectionsViewBinding;
import com.discord.models.domain.ModelConnectedAccount;
import com.discord.utilities.mg_recycler.MGRecyclerAdapter;
import com.discord.utilities.mg_recycler.MGRecyclerAdapterSimple;
import com.discord.utilities.mg_recycler.MGRecyclerDataPayload;
import com.discord.utilities.mg_recycler.MGRecyclerViewHolder;
import com.discord.utilities.platform.Platform;
import com.discord.utilities.view.extensions.ViewExtensions;
import d0.z.d.m;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import kotlin.Unit;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.functions.Function3;
/* compiled from: UserProfileConnectionsView.kt */
public final class UserProfileConnectionsView extends LinearLayout {
private final UserProfileConnectionsViewBinding binding;
private final ConnectedAccountsAdapter connectedAccountsAdapter;
/* compiled from: UserProfileConnectionsView.kt */
public static final class ConnectedAccountItem implements MGRecyclerDataPayload {
private final ModelConnectedAccount connectedAccount;
private final String key;
private final int type;
public ConnectedAccountItem(ModelConnectedAccount modelConnectedAccount) {
m.checkNotNullParameter(modelConnectedAccount, "connectedAccount");
this.connectedAccount = modelConnectedAccount;
String id2 = modelConnectedAccount.getId();
m.checkNotNullExpressionValue(id2, "connectedAccount.id");
this.key = id2;
}
public static /* synthetic */ ConnectedAccountItem copy$default(ConnectedAccountItem connectedAccountItem, ModelConnectedAccount modelConnectedAccount, int i, Object obj) {
if ((i & 1) != 0) {
modelConnectedAccount = connectedAccountItem.connectedAccount;
}
return connectedAccountItem.copy(modelConnectedAccount);
}
public final ModelConnectedAccount component1() {
return this.connectedAccount;
}
public final ConnectedAccountItem copy(ModelConnectedAccount modelConnectedAccount) {
m.checkNotNullParameter(modelConnectedAccount, "connectedAccount");
return new ConnectedAccountItem(modelConnectedAccount);
}
public boolean equals(Object obj) {
if (this != obj) {
return (obj instanceof ConnectedAccountItem) && m.areEqual(this.connectedAccount, ((ConnectedAccountItem) obj).connectedAccount);
}
return true;
}
public final ModelConnectedAccount getConnectedAccount() {
return this.connectedAccount;
}
@Override // com.discord.utilities.mg_recycler.MGRecyclerDataPayload, com.discord.utilities.recycler.DiffKeyProvider
public String getKey() {
return this.key;
}
@Override // com.discord.utilities.mg_recycler.MGRecyclerDataPayload
public int getType() {
return this.type;
}
public int hashCode() {
ModelConnectedAccount modelConnectedAccount = this.connectedAccount;
if (modelConnectedAccount != null) {
return modelConnectedAccount.hashCode();
}
return 0;
}
public String toString() {
StringBuilder K = a.K("ConnectedAccountItem(connectedAccount=");
K.append(this.connectedAccount);
K.append(")");
return K.toString();
}
}
/* compiled from: UserProfileConnectionsView.kt */
public static final class ConnectedAccountsAdapter extends MGRecyclerAdapterSimple<ConnectedAccountItem> {
private Function3<? super String, ? super Integer, ? super String, Unit> onConnectedAccountClick = UserProfileConnectionsView$ConnectedAccountsAdapter$onConnectedAccountClick$1.INSTANCE;
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public ConnectedAccountsAdapter(RecyclerView recyclerView) {
super(recyclerView, false, 2, null);
m.checkNotNullParameter(recyclerView, "recyclerView");
}
/* JADX DEBUG: Type inference failed for r0v0. Raw type applied. Possible types: kotlin.jvm.functions.Function3<? super java.lang.String, ? super java.lang.Integer, ? super java.lang.String, kotlin.Unit>, kotlin.jvm.functions.Function3<java.lang.String, java.lang.Integer, java.lang.String, kotlin.Unit> */
public final Function3<String, Integer, String, Unit> getOnConnectedAccountClick() {
return this.onConnectedAccountClick;
}
@Override // androidx.recyclerview.widget.RecyclerView.Adapter
public MGRecyclerViewHolder<ConnectedAccountsAdapter, ConnectedAccountItem> onCreateViewHolder(ViewGroup viewGroup, int i) {
m.checkNotNullParameter(viewGroup, "parent");
return new ViewHolder(2131558524, this);
}
public final void setOnConnectedAccountClick(Function3<? super String, ? super Integer, ? super String, Unit> function3) {
m.checkNotNullParameter(function3, "<set-?>");
this.onConnectedAccountClick = function3;
}
}
/* compiled from: UserProfileConnectionsView.kt */
public static final class ViewHolder extends MGRecyclerViewHolder<ConnectedAccountsAdapter, ConnectedAccountItem> {
private final TextView listItemTextView;
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public ViewHolder(@LayoutRes int i, ConnectedAccountsAdapter connectedAccountsAdapter) {
super(i, connectedAccountsAdapter);
m.checkNotNullParameter(connectedAccountsAdapter, "adapter");
View view = this.itemView;
Objects.requireNonNull(view, "null cannot be cast to non-null type android.widget.TextView");
this.listItemTextView = (TextView) view;
}
public static final /* synthetic */ ConnectedAccountsAdapter access$getAdapter$p(ViewHolder viewHolder) {
return (ConnectedAccountsAdapter) viewHolder.adapter;
}
public void onConfigure(int i, ConnectedAccountItem connectedAccountItem) {
m.checkNotNullParameter(connectedAccountItem, "data");
super.onConfigure(i, (int) connectedAccountItem);
ModelConnectedAccount connectedAccount = connectedAccountItem.getConnectedAccount();
String username = connectedAccount.getUsername();
Platform from = Platform.Companion.from(connectedAccount);
Integer platformImage = from.getPlatformImage();
int intValue = platformImage != null ? platformImage.intValue() : 0;
String profileUrl = from.getProfileUrl(connectedAccount);
ViewExtensions.setCompoundDrawableWithIntrinsicBounds$default(this.listItemTextView, intValue, 0, 0, 0, 14, null);
this.listItemTextView.setText(connectedAccount.getUsername());
TextView textView = this.listItemTextView;
String format = String.format("%s, %s", Arrays.copyOf(new Object[]{connectedAccount.getType(), connectedAccount.getUsername()}, 2));
m.checkNotNullExpressionValue(format, "java.lang.String.format(format, *args)");
textView.setContentDescription(format);
this.itemView.setOnClickListener(new UserProfileConnectionsView$ViewHolder$onConfigure$1(this, from, username, intValue, profileUrl));
}
}
/* compiled from: UserProfileConnectionsView.kt */
public static final class ViewState {
private final List<ConnectedAccountItem> connectedAccountItems;
private final boolean showConnectionsSection;
private final boolean showMutualGuildsAndFriends;
public ViewState(boolean z2, boolean z3, List<ConnectedAccountItem> list) {
m.checkNotNullParameter(list, "connectedAccountItems");
this.showConnectionsSection = z2;
this.showMutualGuildsAndFriends = z3;
this.connectedAccountItems = list;
}
/* JADX DEBUG: Multi-variable search result rejected for r0v0, resolved type: com.discord.widgets.user.profile.UserProfileConnectionsView$ViewState */
/* JADX WARN: Multi-variable type inference failed */
public static /* synthetic */ ViewState copy$default(ViewState viewState, boolean z2, boolean z3, List list, int i, Object obj) {
if ((i & 1) != 0) {
z2 = viewState.showConnectionsSection;
}
if ((i & 2) != 0) {
z3 = viewState.showMutualGuildsAndFriends;
}
if ((i & 4) != 0) {
list = viewState.connectedAccountItems;
}
return viewState.copy(z2, z3, list);
}
public final boolean component1() {
return this.showConnectionsSection;
}
public final boolean component2() {
return this.showMutualGuildsAndFriends;
}
public final List<ConnectedAccountItem> component3() {
return this.connectedAccountItems;
}
public final ViewState copy(boolean z2, boolean z3, List<ConnectedAccountItem> list) {
m.checkNotNullParameter(list, "connectedAccountItems");
return new ViewState(z2, z3, list);
}
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof ViewState)) {
return false;
}
ViewState viewState = (ViewState) obj;
return this.showConnectionsSection == viewState.showConnectionsSection && this.showMutualGuildsAndFriends == viewState.showMutualGuildsAndFriends && m.areEqual(this.connectedAccountItems, viewState.connectedAccountItems);
}
public final List<ConnectedAccountItem> getConnectedAccountItems() {
return this.connectedAccountItems;
}
public final boolean getShowConnectionsSection() {
return this.showConnectionsSection;
}
public final boolean getShowMutualGuildsAndFriends() {
return this.showMutualGuildsAndFriends;
}
public int hashCode() {
boolean z2 = this.showConnectionsSection;
int i = 1;
if (z2) {
z2 = true;
}
int i2 = z2 ? 1 : 0;
int i3 = z2 ? 1 : 0;
int i4 = z2 ? 1 : 0;
int i5 = i2 * 31;
boolean z3 = this.showMutualGuildsAndFriends;
if (!z3) {
i = z3 ? 1 : 0;
}
int i6 = (i5 + i) * 31;
List<ConnectedAccountItem> list = this.connectedAccountItems;
return i6 + (list != null ? list.hashCode() : 0);
}
public String toString() {
StringBuilder K = a.K("ViewState(showConnectionsSection=");
K.append(this.showConnectionsSection);
K.append(", showMutualGuildsAndFriends=");
K.append(this.showMutualGuildsAndFriends);
K.append(", connectedAccountItems=");
return a.D(K, this.connectedAccountItems, ")");
}
}
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public UserProfileConnectionsView(Context context, AttributeSet attributeSet) {
super(context, attributeSet);
m.checkNotNullParameter(context, "context");
m.checkNotNullParameter(attributeSet, "attrs");
View inflate = LayoutInflater.from(context).inflate(2131558716, (ViewGroup) this, false);
addView(inflate);
int i = 2131365554;
TextView textView = (TextView) inflate.findViewById(2131365554);
if (textView != null) {
i = 2131365555;
TextView textView2 = (TextView) inflate.findViewById(2131365555);
if (textView2 != null) {
i = 2131365556;
RecyclerView recyclerView = (RecyclerView) inflate.findViewById(2131365556);
if (recyclerView != null) {
UserProfileConnectionsViewBinding userProfileConnectionsViewBinding = new UserProfileConnectionsViewBinding((LinearLayout) inflate, textView, textView2, recyclerView);
m.checkNotNullExpressionValue(userProfileConnectionsViewBinding, "UserProfileConnectionsVi…rom(context), this, true)");
this.binding = userProfileConnectionsViewBinding;
MGRecyclerAdapter.Companion companion = MGRecyclerAdapter.Companion;
m.checkNotNullExpressionValue(recyclerView, "binding.userProfileConnectionsViewRecycler");
this.connectedAccountsAdapter = (ConnectedAccountsAdapter) companion.configure(new ConnectedAccountsAdapter(recyclerView));
return;
}
}
}
throw new NullPointerException("Missing required view with ID: ".concat(inflate.getResources().getResourceName(i)));
}
@Override // android.view.View, android.view.ViewGroup
public void onAttachedToWindow() {
super.onAttachedToWindow();
this.binding.d.setHasFixedSize(false);
ViewCompat.setNestedScrollingEnabled(this.binding.d, false);
}
public final void updateViewState(ViewState viewState, Function3<? super String, ? super Integer, ? super String, Unit> function3, Function0<Unit> function0, Function0<Unit> function02) {
m.checkNotNullParameter(viewState, "viewState");
m.checkNotNullParameter(function3, "onConnectedAccountClick");
m.checkNotNullParameter(function0, "onMutualGuildsItemClick");
m.checkNotNullParameter(function02, "onMutualFriendsItemClick");
this.connectedAccountsAdapter.setOnConnectedAccountClick(new UserProfileConnectionsView$updateViewState$1(function3));
this.connectedAccountsAdapter.setData(viewState.getConnectedAccountItems());
this.binding.f1642c.setOnClickListener(new UserProfileConnectionsView$updateViewState$2(function0));
TextView textView = this.binding.f1642c;
m.checkNotNullExpressionValue(textView, "binding.userProfileConnectionsMutualGuildsItem");
int i = 0;
textView.setVisibility(viewState.getShowMutualGuildsAndFriends() ? 0 : 8);
this.binding.b.setOnClickListener(new UserProfileConnectionsView$updateViewState$3(function02));
TextView textView2 = this.binding.b;
m.checkNotNullExpressionValue(textView2, "binding.userProfileConnectionsMutualFriendsItem");
if (!viewState.getShowMutualGuildsAndFriends()) {
i = 8;
}
textView2.setVisibility(i);
}
}