discord-jadx/app/src/main/java/com/discord/widgets/settings/billing/PaymentSourceView.java
2021-07-04 01:36:06 +02:00

113 lines
5.7 KiB
Java

package com.discord.widgets.settings.billing;
import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.StyleRes;
import androidx.cardview.widget.CardView;
import androidx.constraintlayout.widget.ConstraintLayout;
import c.a.l.b;
import com.discord.databinding.PaymentSourceViewBinding;
import com.discord.models.domain.ModelPaymentSource;
import com.discord.utilities.billing.PremiumUtilsKt;
import com.discord.utilities.time.TimeUtils;
import d0.z.d.m;
import kotlin.jvm.internal.DefaultConstructorMarker;
/* compiled from: PaymentSourceView.kt */
public final class PaymentSourceView extends ConstraintLayout {
private final PaymentSourceViewBinding binding;
public PaymentSourceView(Context context) {
this(context, null, 0, 6, null);
}
public PaymentSourceView(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 PaymentSourceView(Context context, AttributeSet attributeSet, @StyleRes int i) {
super(context, attributeSet, i);
m.checkNotNullParameter(context, "context");
LayoutInflater.from(context).inflate(2131558618, this);
int i2 = 2131364223;
ImageView imageView = (ImageView) findViewById(2131364223);
if (imageView != null) {
i2 = 2131364224;
CardView cardView = (CardView) findViewById(2131364224);
if (cardView != null) {
i2 = 2131364225;
TextView textView = (TextView) findViewById(2131364225);
if (textView != null) {
i2 = 2131364226;
ImageView imageView2 = (ImageView) findViewById(2131364226);
if (imageView2 != null) {
i2 = 2131364227;
TextView textView2 = (TextView) findViewById(2131364227);
if (textView2 != null) {
i2 = 2131364228;
TextView textView3 = (TextView) findViewById(2131364228);
if (textView3 != null) {
PaymentSourceViewBinding paymentSourceViewBinding = new PaymentSourceViewBinding(this, imageView, cardView, textView, imageView2, textView2, textView3);
m.checkNotNullExpressionValue(paymentSourceViewBinding, "PaymentSourceViewBinding…ater.from(context), this)");
this.binding = paymentSourceViewBinding;
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 */ PaymentSourceView(Context context, AttributeSet attributeSet, int i, int i2, DefaultConstructorMarker defaultConstructorMarker) {
this(context, (i2 & 2) != 0 ? null : attributeSet, (i2 & 4) != 0 ? 0 : i);
}
private final void bindCard(ModelPaymentSource.ModelPaymentSourceCard modelPaymentSourceCard) {
TextView textView = this.binding.f;
m.checkNotNullExpressionValue(textView, "binding.paymentSourceViewTitle");
b.m(textView, 2131891878, new Object[]{modelPaymentSourceCard.getBrand(), modelPaymentSourceCard.getLast4()}, null, 4);
TimeUtils timeUtils = TimeUtils.INSTANCE;
int expiresMonth = modelPaymentSourceCard.getExpiresMonth();
TextView textView2 = this.binding.e;
m.checkNotNullExpressionValue(textView2, "binding.paymentSourceViewSubtext");
Context context = textView2.getContext();
m.checkNotNullExpressionValue(context, "binding.paymentSourceViewSubtext.context");
String localizedMonthName = timeUtils.getLocalizedMonthName(expiresMonth, context);
TextView textView3 = this.binding.e;
m.checkNotNullExpressionValue(textView3, "binding.paymentSourceViewSubtext");
b.m(textView3, 2131891880, new Object[]{localizedMonthName, Integer.valueOf(modelPaymentSourceCard.getExpiresYear())}, null, 4);
}
private final void bindPaypal(ModelPaymentSource.ModelPaymentSourcePaypal modelPaymentSourcePaypal) {
this.binding.f.setText(2131891905);
TextView textView = this.binding.e;
m.checkNotNullExpressionValue(textView, "binding.paymentSourceViewSubtext");
textView.setText(modelPaymentSourcePaypal.getEmail());
}
public final void bind(ModelPaymentSource modelPaymentSource, boolean z2) {
m.checkNotNullParameter(modelPaymentSource, "paymentSource");
this.binding.b.setImageResource(PremiumUtilsKt.getPaymentSourceIcon(modelPaymentSource));
TextView textView = this.binding.f1617c;
m.checkNotNullExpressionValue(textView, "binding.paymentSourceViewInvalid");
int i = 0;
textView.setVisibility(modelPaymentSource.getInvalid() ? 0 : 8);
ImageView imageView = this.binding.d;
m.checkNotNullExpressionValue(imageView, "binding.paymentSourceViewPremium");
if (!z2) {
i = 8;
}
imageView.setVisibility(i);
if (modelPaymentSource instanceof ModelPaymentSource.ModelPaymentSourcePaypal) {
bindPaypal((ModelPaymentSource.ModelPaymentSourcePaypal) modelPaymentSource);
} else if (modelPaymentSource instanceof ModelPaymentSource.ModelPaymentSourceCard) {
bindCard((ModelPaymentSource.ModelPaymentSourceCard) modelPaymentSource);
}
}
}