discord-jadx/app/src/main/java/com/discord/widgets/settings/billing/PaymentSourceAdapter.java

349 lines
14 KiB
Java

package com.discord.widgets.settings.billing;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout;
import android.widget.TextView;
import androidx.recyclerview.widget.RecyclerView;
import c.d.b.a.a;
import com.discord.R;
import com.discord.databinding.PaymentMethodListItemBinding;
import com.discord.models.domain.ModelPaymentSource;
import com.discord.utilities.mg_recycler.MGRecyclerAdapterSimple;
import com.discord.utilities.mg_recycler.MGRecyclerDataPayload;
import com.discord.utilities.mg_recycler.MGRecyclerViewHolder;
import com.google.android.material.button.MaterialButton;
import d0.z.d.m;
import java.util.Objects;
import kotlin.NoWhenBranchMatchedException;
import kotlin.Unit;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.internal.DefaultConstructorMarker;
/* compiled from: PaymentSourceAdapter.kt */
public final class PaymentSourceAdapter extends MGRecyclerAdapterSimple<Item> {
public static final Companion Companion = new Companion(null);
private static final int VIEW_TYPE_HEADER = 2;
private static final int VIEW_TYPE_PAYMENT_ADD = 1;
private static final int VIEW_TYPE_PAYMENT_SOURCE = 0;
private final Function0<Unit> onAddClick;
private final Function1<ModelPaymentSource, Unit> onEditPaymentSource;
/* compiled from: PaymentSourceAdapter.kt */
public static final class Companion {
private Companion() {
}
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
this();
}
}
/* compiled from: PaymentSourceAdapter.kt */
public interface Item extends MGRecyclerDataPayload {
}
/* compiled from: PaymentSourceAdapter.kt */
public static final class PaymentSourceAddItem implements Item {
private final String key = "AddPaymentSource";
private final int type = 1;
@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;
}
}
/* compiled from: PaymentSourceAdapter.kt */
public static final class PaymentSourceAddViewHolder extends MGRecyclerViewHolder<PaymentSourceAdapter, Item> {
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public PaymentSourceAddViewHolder(PaymentSourceAdapter paymentSourceAdapter) {
super((int) R.layout.payment_method_list_add_item, paymentSourceAdapter);
m.checkNotNullParameter(paymentSourceAdapter, "adapter");
}
public static final /* synthetic */ PaymentSourceAdapter access$getAdapter$p(PaymentSourceAddViewHolder paymentSourceAddViewHolder) {
return (PaymentSourceAdapter) paymentSourceAddViewHolder.adapter;
}
public void onConfigure(int i, Item item) {
m.checkNotNullParameter(item, "data");
this.itemView.setOnClickListener(new PaymentSourceAdapter$PaymentSourceAddViewHolder$onConfigure$1(this));
}
}
/* compiled from: PaymentSourceAdapter.kt */
public static final class PaymentSourceHeader implements Item {
private final Type headerType;
private final String key;
private final int type = 2;
/* compiled from: PaymentSourceAdapter.kt */
public enum Type {
DEFAULT,
OTHER
}
public PaymentSourceHeader(Type type) {
m.checkNotNullParameter(type, "headerType");
this.headerType = type;
this.key = "headerType" + type;
}
public static /* synthetic */ PaymentSourceHeader copy$default(PaymentSourceHeader paymentSourceHeader, Type type, int i, Object obj) {
if ((i & 1) != 0) {
type = paymentSourceHeader.headerType;
}
return paymentSourceHeader.copy(type);
}
public final Type component1() {
return this.headerType;
}
public final PaymentSourceHeader copy(Type type) {
m.checkNotNullParameter(type, "headerType");
return new PaymentSourceHeader(type);
}
public boolean equals(Object obj) {
if (this != obj) {
return (obj instanceof PaymentSourceHeader) && m.areEqual(this.headerType, ((PaymentSourceHeader) obj).headerType);
}
return true;
}
public final Type getHeaderType() {
return this.headerType;
}
@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() {
Type type = this.headerType;
if (type != null) {
return type.hashCode();
}
return 0;
}
public String toString() {
StringBuilder P = a.P("PaymentSourceHeader(headerType=");
P.append(this.headerType);
P.append(")");
return P.toString();
}
}
/* compiled from: PaymentSourceAdapter.kt */
public static final class PaymentSourceHeaderViewHolder extends MGRecyclerViewHolder<PaymentSourceAdapter, Item> {
public final /* synthetic */ class WhenMappings {
public static final /* synthetic */ int[] $EnumSwitchMapping$0;
static {
PaymentSourceHeader.Type.values();
int[] iArr = new int[2];
$EnumSwitchMapping$0 = iArr;
iArr[PaymentSourceHeader.Type.DEFAULT.ordinal()] = 1;
iArr[PaymentSourceHeader.Type.OTHER.ordinal()] = 2;
}
}
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public PaymentSourceHeaderViewHolder(PaymentSourceAdapter paymentSourceAdapter) {
super((int) R.layout.payment_method_list_header, paymentSourceAdapter);
m.checkNotNullParameter(paymentSourceAdapter, "adapter");
}
public void onConfigure(int i, Item item) {
int i2;
m.checkNotNullParameter(item, "data");
View view = this.itemView;
Objects.requireNonNull(view, "null cannot be cast to non-null type android.widget.TextView");
TextView textView = (TextView) view;
int ordinal = ((PaymentSourceHeader) item).getHeaderType().ordinal();
if (ordinal == 0) {
i2 = R.string._default;
} else if (ordinal == 1) {
i2 = R.string.other_options;
} else {
throw new NoWhenBranchMatchedException();
}
textView.setText(i2);
}
}
/* compiled from: PaymentSourceAdapter.kt */
public static final class PaymentSourceItem implements Item {
private final boolean isPremium;
private final String key;
private final ModelPaymentSource paymentSource;
private final int type;
public PaymentSourceItem(ModelPaymentSource modelPaymentSource, boolean z2) {
m.checkNotNullParameter(modelPaymentSource, "paymentSource");
this.paymentSource = modelPaymentSource;
this.isPremium = z2;
this.key = modelPaymentSource.getId();
}
public static /* synthetic */ PaymentSourceItem copy$default(PaymentSourceItem paymentSourceItem, ModelPaymentSource modelPaymentSource, boolean z2, int i, Object obj) {
if ((i & 1) != 0) {
modelPaymentSource = paymentSourceItem.paymentSource;
}
if ((i & 2) != 0) {
z2 = paymentSourceItem.isPremium;
}
return paymentSourceItem.copy(modelPaymentSource, z2);
}
public final ModelPaymentSource component1() {
return this.paymentSource;
}
public final boolean component2() {
return this.isPremium;
}
public final PaymentSourceItem copy(ModelPaymentSource modelPaymentSource, boolean z2) {
m.checkNotNullParameter(modelPaymentSource, "paymentSource");
return new PaymentSourceItem(modelPaymentSource, z2);
}
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof PaymentSourceItem)) {
return false;
}
PaymentSourceItem paymentSourceItem = (PaymentSourceItem) obj;
return m.areEqual(this.paymentSource, paymentSourceItem.paymentSource) && this.isPremium == paymentSourceItem.isPremium;
}
@Override // com.discord.utilities.mg_recycler.MGRecyclerDataPayload, com.discord.utilities.recycler.DiffKeyProvider
public String getKey() {
return this.key;
}
public final ModelPaymentSource getPaymentSource() {
return this.paymentSource;
}
@Override // com.discord.utilities.mg_recycler.MGRecyclerDataPayload
public int getType() {
return this.type;
}
public int hashCode() {
ModelPaymentSource modelPaymentSource = this.paymentSource;
int hashCode = (modelPaymentSource != null ? modelPaymentSource.hashCode() : 0) * 31;
boolean z2 = this.isPremium;
if (z2) {
z2 = true;
}
int i = z2 ? 1 : 0;
int i2 = z2 ? 1 : 0;
int i3 = z2 ? 1 : 0;
return hashCode + i;
}
public final boolean isPremium() {
return this.isPremium;
}
public String toString() {
StringBuilder P = a.P("PaymentSourceItem(paymentSource=");
P.append(this.paymentSource);
P.append(", isPremium=");
return a.L(P, this.isPremium, ")");
}
}
/* compiled from: PaymentSourceAdapter.kt */
public static final class PaymentSourceItemViewHolder extends MGRecyclerViewHolder<PaymentSourceAdapter, Item> {
private final PaymentMethodListItemBinding binding;
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public PaymentSourceItemViewHolder(PaymentSourceAdapter paymentSourceAdapter) {
super((int) R.layout.payment_method_list_item, paymentSourceAdapter);
m.checkNotNullParameter(paymentSourceAdapter, "adapter");
View view = this.itemView;
int i = R.id.payment_method_edit;
MaterialButton materialButton = (MaterialButton) view.findViewById(R.id.payment_method_edit);
if (materialButton != null) {
i = R.id.payment_method_summary;
PaymentSourceView paymentSourceView = (PaymentSourceView) view.findViewById(R.id.payment_method_summary);
if (paymentSourceView != null) {
PaymentMethodListItemBinding paymentMethodListItemBinding = new PaymentMethodListItemBinding((RelativeLayout) view, materialButton, paymentSourceView);
m.checkNotNullExpressionValue(paymentMethodListItemBinding, "PaymentMethodListItemBinding.bind(itemView)");
this.binding = paymentMethodListItemBinding;
return;
}
}
throw new NullPointerException("Missing required view with ID: ".concat(view.getResources().getResourceName(i)));
}
public static final /* synthetic */ PaymentSourceAdapter access$getAdapter$p(PaymentSourceItemViewHolder paymentSourceItemViewHolder) {
return (PaymentSourceAdapter) paymentSourceItemViewHolder.adapter;
}
public void onConfigure(int i, Item item) {
m.checkNotNullParameter(item, "data");
PaymentSourceItem paymentSourceItem = (PaymentSourceItem) item;
ModelPaymentSource paymentSource = paymentSourceItem.getPaymentSource();
this.binding.f1646c.bind(paymentSource, paymentSourceItem.isPremium());
this.binding.b.setOnClickListener(new PaymentSourceAdapter$PaymentSourceItemViewHolder$onConfigure$1(this, paymentSource));
}
}
/* JADX DEBUG: Multi-variable search result rejected for r6v0, resolved type: kotlin.jvm.functions.Function1<? super com.discord.models.domain.ModelPaymentSource, kotlin.Unit> */
/* JADX WARN: Multi-variable type inference failed */
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public PaymentSourceAdapter(RecyclerView recyclerView, Function0<Unit> function0, Function1<? super ModelPaymentSource, Unit> function1) {
super(recyclerView, false, 2, null);
m.checkNotNullParameter(recyclerView, "recycler");
m.checkNotNullParameter(function0, "onAddClick");
m.checkNotNullParameter(function1, "onEditPaymentSource");
this.onAddClick = function0;
this.onEditPaymentSource = function1;
}
public static final /* synthetic */ Function0 access$getOnAddClick$p(PaymentSourceAdapter paymentSourceAdapter) {
return paymentSourceAdapter.onAddClick;
}
public static final /* synthetic */ Function1 access$getOnEditPaymentSource$p(PaymentSourceAdapter paymentSourceAdapter) {
return paymentSourceAdapter.onEditPaymentSource;
}
@Override // androidx.recyclerview.widget.RecyclerView.Adapter
public MGRecyclerViewHolder<?, Item> onCreateViewHolder(ViewGroup viewGroup, int i) {
m.checkNotNullParameter(viewGroup, "parent");
if (i == 0) {
return new PaymentSourceItemViewHolder(this);
}
if (i == 1) {
return new PaymentSourceAddViewHolder(this);
}
if (i == 2) {
return new PaymentSourceHeaderViewHolder(this);
}
throw new IllegalArgumentException(a.l("unknown type ", i));
}
}