516 lines
28 KiB
Java
516 lines
28 KiB
Java
package com.discord.widgets.settings.billing;
|
|
|
|
import android.app.Dialog;
|
|
import android.content.Context;
|
|
import android.graphics.drawable.ColorDrawable;
|
|
import android.os.Bundle;
|
|
import android.text.Editable;
|
|
import android.view.View;
|
|
import android.view.Window;
|
|
import android.widget.CheckBox;
|
|
import android.widget.EditText;
|
|
import android.widget.TextView;
|
|
import androidx.annotation.MainThread;
|
|
import androidx.fragment.app.Fragment;
|
|
import androidx.fragment.app.FragmentManager;
|
|
import androidx.fragment.app.FragmentViewModelLazyKt;
|
|
import c.a.a.n;
|
|
import c.a.d.f0;
|
|
import c.a.d.h0;
|
|
import c.a.k.b;
|
|
import c.d.b.a.a;
|
|
import com.discord.R;
|
|
import com.discord.app.AppDialog;
|
|
import com.discord.databinding.WidgetPaymentSourceEditDialogBinding;
|
|
import com.discord.models.domain.ModelAuditLogEntry;
|
|
import com.discord.models.domain.ModelPaymentSource;
|
|
import com.discord.models.domain.PatchPaymentSourceRaw;
|
|
import com.discord.models.domain.billing.ModelBillingAddress;
|
|
import com.discord.utilities.accessibility.AccessibilityUtils;
|
|
import com.discord.utilities.error.Error;
|
|
import com.discord.utilities.rest.RestAPI;
|
|
import com.discord.utilities.rx.ObservableExtensionsKt;
|
|
import com.discord.utilities.view.extensions.ViewExtensions;
|
|
import com.discord.utilities.view.validators.BasicTextInputValidator;
|
|
import com.discord.utilities.view.validators.Input;
|
|
import com.discord.utilities.view.validators.InputValidator;
|
|
import com.discord.utilities.view.validators.ValidationManager;
|
|
import com.discord.utilities.viewbinding.FragmentViewBindingDelegate;
|
|
import com.discord.utilities.viewbinding.FragmentViewBindingDelegateKt;
|
|
import com.discord.widgets.settings.billing.PaymentSourceAdapter;
|
|
import com.google.android.material.button.MaterialButton;
|
|
import com.google.android.material.textfield.TextInputLayout;
|
|
import d0.g;
|
|
import d0.g0.t;
|
|
import d0.z.d.a0;
|
|
import d0.z.d.m;
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Objects;
|
|
import kotlin.Lazy;
|
|
import kotlin.jvm.functions.Function0;
|
|
import kotlin.jvm.functions.Function1;
|
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
|
import kotlin.reflect.KProperty;
|
|
import rx.Observable;
|
|
/* compiled from: WidgetPaymentSourceEditDialog.kt */
|
|
public final class WidgetPaymentSourceEditDialog extends AppDialog {
|
|
public static final /* synthetic */ KProperty[] $$delegatedProperties = {a.a0(WidgetPaymentSourceEditDialog.class, "binding", "getBinding()Lcom/discord/databinding/WidgetPaymentSourceEditDialogBinding;", 0)};
|
|
private static final String ARG_PAYMENT_SOURCE_ID = "ARG_PAYMENT_SOURCE_ID";
|
|
public static final Companion Companion = new Companion(null);
|
|
private final FragmentViewBindingDelegate binding$delegate = FragmentViewBindingDelegateKt.viewBinding$default(this, WidgetPaymentSourceEditDialog$binding$2.INSTANCE, null, 2, null);
|
|
private final Lazy caProvinces$delegate;
|
|
private final Lazy paymentSourceId$delegate = g.lazy(new WidgetPaymentSourceEditDialog$paymentSourceId$2(this));
|
|
private final Lazy usStates$delegate;
|
|
private ValidationManager validationManager;
|
|
private final Lazy viewModel$delegate;
|
|
|
|
/* compiled from: WidgetPaymentSourceEditDialog.kt */
|
|
public static final class Companion {
|
|
private Companion() {
|
|
}
|
|
|
|
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
|
|
this();
|
|
}
|
|
|
|
public static final /* synthetic */ String access$getTextOrEmpty(Companion companion, TextInputLayout textInputLayout) {
|
|
return companion.getTextOrEmpty(textInputLayout);
|
|
}
|
|
|
|
private final String getTextOrEmpty(TextInputLayout textInputLayout) {
|
|
Editable text;
|
|
EditText editText = textInputLayout.getEditText();
|
|
String obj = (editText == null || (text = editText.getText()) == null) ? null : text.toString();
|
|
return obj != null ? obj : "";
|
|
}
|
|
|
|
public final void launch(FragmentManager fragmentManager, String str) {
|
|
m.checkNotNullParameter(fragmentManager, "fragmentManager");
|
|
m.checkNotNullParameter(str, "paymentSourceId");
|
|
WidgetPaymentSourceEditDialog widgetPaymentSourceEditDialog = new WidgetPaymentSourceEditDialog();
|
|
Bundle bundle = new Bundle();
|
|
bundle.putString(WidgetPaymentSourceEditDialog.ARG_PAYMENT_SOURCE_ID, str);
|
|
widgetPaymentSourceEditDialog.setArguments(bundle);
|
|
widgetPaymentSourceEditDialog.show(fragmentManager, "javaClass");
|
|
}
|
|
}
|
|
|
|
/* compiled from: WidgetPaymentSourceEditDialog.kt */
|
|
public static final class StateEntry {
|
|
private final String label;
|
|
private final String value;
|
|
|
|
public StateEntry(String str, String str2) {
|
|
m.checkNotNullParameter(str, "label");
|
|
m.checkNotNullParameter(str2, "value");
|
|
this.label = str;
|
|
this.value = str2;
|
|
}
|
|
|
|
public static /* synthetic */ StateEntry copy$default(StateEntry stateEntry, String str, String str2, int i, Object obj) {
|
|
if ((i & 1) != 0) {
|
|
str = stateEntry.label;
|
|
}
|
|
if ((i & 2) != 0) {
|
|
str2 = stateEntry.value;
|
|
}
|
|
return stateEntry.copy(str, str2);
|
|
}
|
|
|
|
public final String component1() {
|
|
return this.label;
|
|
}
|
|
|
|
public final String component2() {
|
|
return this.value;
|
|
}
|
|
|
|
public final StateEntry copy(String str, String str2) {
|
|
m.checkNotNullParameter(str, "label");
|
|
m.checkNotNullParameter(str2, "value");
|
|
return new StateEntry(str, str2);
|
|
}
|
|
|
|
public boolean equals(Object obj) {
|
|
if (this == obj) {
|
|
return true;
|
|
}
|
|
if (!(obj instanceof StateEntry)) {
|
|
return false;
|
|
}
|
|
StateEntry stateEntry = (StateEntry) obj;
|
|
return m.areEqual(this.label, stateEntry.label) && m.areEqual(this.value, stateEntry.value);
|
|
}
|
|
|
|
public final String getLabel() {
|
|
return this.label;
|
|
}
|
|
|
|
public final String getValue() {
|
|
return this.value;
|
|
}
|
|
|
|
public int hashCode() {
|
|
String str = this.label;
|
|
int i = 0;
|
|
int hashCode = (str != null ? str.hashCode() : 0) * 31;
|
|
String str2 = this.value;
|
|
if (str2 != null) {
|
|
i = str2.hashCode();
|
|
}
|
|
return hashCode + i;
|
|
}
|
|
|
|
public String toString() {
|
|
StringBuilder P = a.P("StateEntry(label=");
|
|
P.append(this.label);
|
|
P.append(", value=");
|
|
return a.H(P, this.value, ")");
|
|
}
|
|
}
|
|
|
|
public WidgetPaymentSourceEditDialog() {
|
|
super(R.layout.widget_payment_source_edit_dialog);
|
|
WidgetPaymentSourceEditDialog$viewModel$2 widgetPaymentSourceEditDialog$viewModel$2 = WidgetPaymentSourceEditDialog$viewModel$2.INSTANCE;
|
|
f0 f0Var = new f0(this);
|
|
this.viewModel$delegate = FragmentViewModelLazyKt.createViewModelLazy(this, a0.getOrCreateKotlinClass(SettingsBillingViewModel.class), new WidgetPaymentSourceEditDialog$appViewModels$$inlined$viewModels$1(f0Var), new h0(widgetPaymentSourceEditDialog$viewModel$2));
|
|
this.usStates$delegate = g.lazy(new WidgetPaymentSourceEditDialog$usStates$2(this));
|
|
this.caProvinces$delegate = g.lazy(new WidgetPaymentSourceEditDialog$caProvinces$2(this));
|
|
}
|
|
|
|
public static final /* synthetic */ void access$deletePaymentSource(WidgetPaymentSourceEditDialog widgetPaymentSourceEditDialog, ModelPaymentSource modelPaymentSource) {
|
|
widgetPaymentSourceEditDialog.deletePaymentSource(modelPaymentSource);
|
|
}
|
|
|
|
public static final /* synthetic */ WidgetPaymentSourceEditDialogBinding access$getBinding$p(WidgetPaymentSourceEditDialog widgetPaymentSourceEditDialog) {
|
|
return widgetPaymentSourceEditDialog.getBinding();
|
|
}
|
|
|
|
public static final /* synthetic */ String access$getPaymentSourceId$p(WidgetPaymentSourceEditDialog widgetPaymentSourceEditDialog) {
|
|
return widgetPaymentSourceEditDialog.getPaymentSourceId();
|
|
}
|
|
|
|
public static final /* synthetic */ void access$initPaymentSourceInfo(WidgetPaymentSourceEditDialog widgetPaymentSourceEditDialog, PaymentSourceAdapter.PaymentSourceItem paymentSourceItem) {
|
|
widgetPaymentSourceEditDialog.initPaymentSourceInfo(paymentSourceItem);
|
|
}
|
|
|
|
public static final /* synthetic */ void access$selectState(WidgetPaymentSourceEditDialog widgetPaymentSourceEditDialog, StateEntry[] stateEntryArr) {
|
|
widgetPaymentSourceEditDialog.selectState(stateEntryArr);
|
|
}
|
|
|
|
public static final /* synthetic */ void access$updatePaymentSource(WidgetPaymentSourceEditDialog widgetPaymentSourceEditDialog, ModelPaymentSource modelPaymentSource) {
|
|
widgetPaymentSourceEditDialog.updatePaymentSource(modelPaymentSource);
|
|
}
|
|
|
|
private final void deletePaymentSource(ModelPaymentSource modelPaymentSource) {
|
|
getBinding().d.setIsLoading(true);
|
|
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.ui$default(ObservableExtensionsKt.restSubscribeOn$default(RestAPI.Companion.getApi().deletePaymentSource(modelPaymentSource.getId()), false, 1, null), this, null, 2, null), WidgetPaymentSourceEditDialog.class, requireContext(), (Function1) null, new WidgetPaymentSourceEditDialog$deletePaymentSource$2(this), new WidgetPaymentSourceEditDialog$deletePaymentSource$3(this), (Function0) null, new WidgetPaymentSourceEditDialog$deletePaymentSource$1(this), 36, (Object) null);
|
|
}
|
|
|
|
private final WidgetPaymentSourceEditDialogBinding getBinding() {
|
|
return (WidgetPaymentSourceEditDialogBinding) this.binding$delegate.getValue((Fragment) this, $$delegatedProperties[0]);
|
|
}
|
|
|
|
private final StateEntry[] getCaProvinces() {
|
|
return (StateEntry[]) this.caProvinces$delegate.getValue();
|
|
}
|
|
|
|
private static /* synthetic */ void getCaProvinces$annotations() {
|
|
}
|
|
|
|
private final String getPaymentSourceId() {
|
|
return (String) this.paymentSourceId$delegate.getValue();
|
|
}
|
|
|
|
private final StateEntry[] getStatesFor(ModelPaymentSource modelPaymentSource) {
|
|
String country = modelPaymentSource.getBillingAddress().getCountry();
|
|
int hashCode = country.hashCode();
|
|
if (hashCode != 2142) {
|
|
if (hashCode == 2718 && country.equals("US")) {
|
|
return getUsStates();
|
|
}
|
|
} else if (country.equals("CA")) {
|
|
return getCaProvinces();
|
|
}
|
|
return new StateEntry[0];
|
|
}
|
|
|
|
private final StateEntry[] getUsStates() {
|
|
return (StateEntry[]) this.usStates$delegate.getValue();
|
|
}
|
|
|
|
private static /* synthetic */ void getUsStates$annotations() {
|
|
}
|
|
|
|
private final SettingsBillingViewModel getViewModel() {
|
|
return (SettingsBillingViewModel) this.viewModel$delegate.getValue();
|
|
}
|
|
|
|
private final void initPaymentSourceInfo(PaymentSourceAdapter.PaymentSourceItem paymentSourceItem) {
|
|
StateEntry stateEntry;
|
|
String str;
|
|
initValidator(paymentSourceItem);
|
|
ModelPaymentSource component1 = paymentSourceItem.component1();
|
|
boolean component2 = paymentSourceItem.component2();
|
|
getBinding().o.bind(component1, component2);
|
|
TextView textView = getBinding().k;
|
|
m.checkNotNullExpressionValue(textView, "binding.paymentSourceEditHelp");
|
|
boolean z2 = false;
|
|
textView.setText(component1 instanceof ModelPaymentSource.ModelPaymentSourcePaypal ? b.k(this, R.string.payment_source_edit_help_paypal, new Object[]{"https://www.paypal.com"}, null, 4) : b.k(this, R.string.payment_source_edit_help_card, new Object[0], null, 4));
|
|
StateEntry[] statesFor = getStatesFor(component1);
|
|
ModelBillingAddress billingAddress = component1.getBillingAddress();
|
|
TextInputLayout textInputLayout = getBinding().l;
|
|
m.checkNotNullExpressionValue(textInputLayout, "binding.paymentSourceEditName");
|
|
ViewExtensions.setText(textInputLayout, billingAddress.getName());
|
|
TextInputLayout textInputLayout2 = getBinding().e;
|
|
m.checkNotNullExpressionValue(textInputLayout2, "binding.paymentSourceEditAddress1");
|
|
ViewExtensions.setText(textInputLayout2, billingAddress.getLine_1());
|
|
TextInputLayout textInputLayout3 = getBinding().f;
|
|
m.checkNotNullExpressionValue(textInputLayout3, "binding.paymentSourceEditAddress2");
|
|
ViewExtensions.setText(textInputLayout3, billingAddress.getLine_2());
|
|
TextInputLayout textInputLayout4 = getBinding().g;
|
|
m.checkNotNullExpressionValue(textInputLayout4, "binding.paymentSourceEditCity");
|
|
ViewExtensions.setText(textInputLayout4, billingAddress.getCity());
|
|
TextInputLayout textInputLayout5 = getBinding().m;
|
|
m.checkNotNullExpressionValue(textInputLayout5, "binding.paymentSourceEditPostalCode");
|
|
ViewExtensions.setText(textInputLayout5, billingAddress.getPostalCode());
|
|
TextInputLayout textInputLayout6 = getBinding().n;
|
|
m.checkNotNullExpressionValue(textInputLayout6, "binding.paymentSourceEditState");
|
|
m.checkNotNullExpressionValue(statesFor, "states");
|
|
int length = statesFor.length;
|
|
int i = 0;
|
|
while (true) {
|
|
if (i >= length) {
|
|
stateEntry = null;
|
|
break;
|
|
}
|
|
stateEntry = statesFor[i];
|
|
if (m.areEqual(stateEntry.getValue(), billingAddress.getState())) {
|
|
break;
|
|
}
|
|
i++;
|
|
}
|
|
if (stateEntry == null || (str = stateEntry.getLabel()) == null) {
|
|
str = billingAddress.getState();
|
|
}
|
|
ViewExtensions.setText(textInputLayout6, str);
|
|
TextInputLayout textInputLayout7 = getBinding().h;
|
|
m.checkNotNullExpressionValue(textInputLayout7, "binding.paymentSourceEditCountry");
|
|
ViewExtensions.setText(textInputLayout7, billingAddress.getCountry());
|
|
CheckBox checkBox = getBinding().i;
|
|
m.checkNotNullExpressionValue(checkBox, "binding.paymentSourceEditDefault");
|
|
checkBox.setChecked(component1.getDefault());
|
|
getBinding().d.setIsLoading(false);
|
|
if (component2) {
|
|
getBinding().f1921c.setOnClickListener(new WidgetPaymentSourceEditDialog$initPaymentSourceInfo$2(this));
|
|
MaterialButton materialButton = getBinding().f1921c;
|
|
m.checkNotNullExpressionValue(materialButton, "binding.dialogDelete");
|
|
materialButton.setAlpha(0.3f);
|
|
} else {
|
|
getBinding().f1921c.setOnClickListener(new WidgetPaymentSourceEditDialog$initPaymentSourceInfo$3(this, component1));
|
|
}
|
|
getBinding().d.setOnClickListener(new WidgetPaymentSourceEditDialog$initPaymentSourceInfo$4(this, component1));
|
|
if (m.areEqual(component1.getBillingAddress().getCountry(), "CA")) {
|
|
TextInputLayout textInputLayout8 = getBinding().n;
|
|
m.checkNotNullExpressionValue(textInputLayout8, "binding.paymentSourceEditState");
|
|
textInputLayout8.setHint(b.k(this, R.string.billing_address_province, new Object[0], null, 4));
|
|
TextInputLayout textInputLayout9 = getBinding().m;
|
|
m.checkNotNullExpressionValue(textInputLayout9, "binding.paymentSourceEditPostalCode");
|
|
textInputLayout9.setHint(b.k(this, R.string.billing_address_postal_code, new Object[0], null, 4));
|
|
}
|
|
if (statesFor.length == 0) {
|
|
z2 = true;
|
|
}
|
|
if (z2) {
|
|
TextInputLayout textInputLayout10 = getBinding().n;
|
|
m.checkNotNullExpressionValue(textInputLayout10, "binding.paymentSourceEditState");
|
|
EditText editText = textInputLayout10.getEditText();
|
|
if (editText != null) {
|
|
editText.setInputType(1);
|
|
}
|
|
TextInputLayout textInputLayout11 = getBinding().n;
|
|
m.checkNotNullExpressionValue(textInputLayout11, "binding.paymentSourceEditState");
|
|
EditText editText2 = textInputLayout11.getEditText();
|
|
if (editText2 != null) {
|
|
editText2.setFocusableInTouchMode(true);
|
|
return;
|
|
}
|
|
return;
|
|
}
|
|
TextInputLayout textInputLayout12 = getBinding().n;
|
|
m.checkNotNullExpressionValue(textInputLayout12, "binding.paymentSourceEditState");
|
|
ViewExtensions.setOnEditTextClickListener(textInputLayout12, new WidgetPaymentSourceEditDialog$initPaymentSourceInfo$5(this, statesFor));
|
|
TextInputLayout textInputLayout13 = getBinding().n;
|
|
m.checkNotNullExpressionValue(textInputLayout13, "binding.paymentSourceEditState");
|
|
ViewExtensions.setOnEditorActionListener(textInputLayout13, new WidgetPaymentSourceEditDialog$initPaymentSourceInfo$6(this, statesFor));
|
|
}
|
|
|
|
/* JADX DEBUG: Can't convert new array creation: APUT found in different block: 0x009d: APUT
|
|
(r1v1 com.discord.utilities.view.validators.Input[])
|
|
(3 ??[int, float, short, byte, char])
|
|
(wrap: com.discord.utilities.view.validators.Input$TextInputLayoutInput : 0x0099: CONSTRUCTOR (r2v3 com.discord.utilities.view.validators.Input$TextInputLayoutInput) =
|
|
("state")
|
|
(r3v8 com.google.android.material.textfield.TextInputLayout)
|
|
(r5v6 com.discord.utilities.view.validators.InputValidator[])
|
|
call: com.discord.utilities.view.validators.Input.TextInputLayoutInput.<init>(java.lang.String, com.google.android.material.textfield.TextInputLayout, com.discord.utilities.view.validators.InputValidator[]):void type: CONSTRUCTOR)
|
|
*/
|
|
/* JADX DEBUG: Can't convert new array creation: APUT found in different block: 0x0095: APUT
|
|
(r5v6 com.discord.utilities.view.validators.InputValidator[])
|
|
(0 ??[int, short, byte, char])
|
|
(wrap: com.discord.utilities.view.validators.BasicTextInputValidator : 0x0091: INVOKE (r10v6 com.discord.utilities.view.validators.BasicTextInputValidator) = (r6v0 com.discord.utilities.view.validators.BasicTextInputValidator$Companion), (r10v5 int) type: VIRTUAL call: com.discord.utilities.view.validators.BasicTextInputValidator.Companion.createRequiredInputValidator(int):com.discord.utilities.view.validators.BasicTextInputValidator)
|
|
*/
|
|
private final void initValidator(PaymentSourceAdapter.PaymentSourceItem paymentSourceItem) {
|
|
ModelPaymentSource component1 = paymentSourceItem.component1();
|
|
Input[] inputArr = new Input[5];
|
|
TextInputLayout textInputLayout = getBinding().l;
|
|
m.checkNotNullExpressionValue(textInputLayout, "binding.paymentSourceEditName");
|
|
BasicTextInputValidator.Companion companion = BasicTextInputValidator.Companion;
|
|
inputArr[0] = new Input.TextInputLayoutInput(ModelAuditLogEntry.CHANGE_KEY_NAME, textInputLayout, companion.createRequiredInputValidator(R.string.billing_address_name_error_required));
|
|
TextInputLayout textInputLayout2 = getBinding().e;
|
|
m.checkNotNullExpressionValue(textInputLayout2, "binding.paymentSourceEditAddress1");
|
|
inputArr[1] = new Input.TextInputLayoutInput("line_1", textInputLayout2, companion.createRequiredInputValidator(R.string.billing_address_address_error_required));
|
|
TextInputLayout textInputLayout3 = getBinding().g;
|
|
m.checkNotNullExpressionValue(textInputLayout3, "binding.paymentSourceEditCity");
|
|
inputArr[2] = new Input.TextInputLayoutInput("city", textInputLayout3, companion.createRequiredInputValidator(R.string.billing_address_city_error_required));
|
|
TextInputLayout textInputLayout4 = getBinding().n;
|
|
m.checkNotNullExpressionValue(textInputLayout4, "binding.paymentSourceEditState");
|
|
InputValidator[] inputValidatorArr = new InputValidator[1];
|
|
inputValidatorArr[0] = companion.createRequiredInputValidator(m.areEqual(component1.getBillingAddress().getCountry(), "CA") ? R.string.billing_address_province_error_required : R.string.billing_address_state_error_required);
|
|
inputArr[3] = new Input.TextInputLayoutInput("state", textInputLayout4, inputValidatorArr);
|
|
TextInputLayout textInputLayout5 = getBinding().m;
|
|
m.checkNotNullExpressionValue(textInputLayout5, "binding.paymentSourceEditPostalCode");
|
|
inputArr[4] = new Input.TextInputLayoutInput("postal_code", textInputLayout5, companion.createRequiredInputValidator(R.string.billing_address_postal_code_error_required));
|
|
this.validationManager = new ValidationManager(inputArr);
|
|
}
|
|
|
|
private final void selectState(StateEntry[] stateEntryArr) {
|
|
n.a aVar = n.j;
|
|
FragmentManager parentFragmentManager = getParentFragmentManager();
|
|
m.checkNotNullExpressionValue(parentFragmentManager, "parentFragmentManager");
|
|
CharSequence k = b.k(this, R.string.payment_source_edit_select_state, new Object[0], null, 4);
|
|
ArrayList arrayList = new ArrayList(stateEntryArr.length);
|
|
for (StateEntry stateEntry : stateEntryArr) {
|
|
arrayList.add(stateEntry.getLabel());
|
|
}
|
|
Object[] array = arrayList.toArray(new String[0]);
|
|
Objects.requireNonNull(array, "null cannot be cast to non-null type kotlin.Array<T>");
|
|
aVar.a(parentFragmentManager, k, (CharSequence[]) array, new WidgetPaymentSourceEditDialog$selectState$2(this, stateEntryArr));
|
|
getBinding().m.requestFocus();
|
|
}
|
|
|
|
private final void updatePaymentSource(ModelPaymentSource modelPaymentSource) {
|
|
StateEntry stateEntry;
|
|
String value;
|
|
Companion companion = Companion;
|
|
TextInputLayout textInputLayout = getBinding().n;
|
|
m.checkNotNullExpressionValue(textInputLayout, "binding.paymentSourceEditState");
|
|
String access$getTextOrEmpty = Companion.access$getTextOrEmpty(companion, textInputLayout);
|
|
StateEntry[] statesFor = getStatesFor(modelPaymentSource);
|
|
m.checkNotNullExpressionValue(statesFor, "getStatesFor(paymentSource)");
|
|
int length = statesFor.length;
|
|
int i = 0;
|
|
while (true) {
|
|
if (i >= length) {
|
|
stateEntry = null;
|
|
break;
|
|
}
|
|
stateEntry = statesFor[i];
|
|
if (t.equals(stateEntry.getLabel(), access$getTextOrEmpty, true)) {
|
|
break;
|
|
}
|
|
i++;
|
|
}
|
|
String str = (stateEntry == null || (value = stateEntry.getValue()) == null) ? access$getTextOrEmpty : value;
|
|
ValidationManager validationManager = this.validationManager;
|
|
if (validationManager == null) {
|
|
m.throwUninitializedPropertyAccessException("validationManager");
|
|
}
|
|
if (ValidationManager.validate$default(validationManager, false, 1, null)) {
|
|
Companion companion2 = Companion;
|
|
TextInputLayout textInputLayout2 = getBinding().l;
|
|
m.checkNotNullExpressionValue(textInputLayout2, "binding.paymentSourceEditName");
|
|
String access$getTextOrEmpty2 = Companion.access$getTextOrEmpty(companion2, textInputLayout2);
|
|
TextInputLayout textInputLayout3 = getBinding().e;
|
|
m.checkNotNullExpressionValue(textInputLayout3, "binding.paymentSourceEditAddress1");
|
|
String access$getTextOrEmpty3 = Companion.access$getTextOrEmpty(companion2, textInputLayout3);
|
|
TextInputLayout textInputLayout4 = getBinding().f;
|
|
m.checkNotNullExpressionValue(textInputLayout4, "binding.paymentSourceEditAddress2");
|
|
String access$getTextOrEmpty4 = Companion.access$getTextOrEmpty(companion2, textInputLayout4);
|
|
TextInputLayout textInputLayout5 = getBinding().g;
|
|
m.checkNotNullExpressionValue(textInputLayout5, "binding.paymentSourceEditCity");
|
|
String access$getTextOrEmpty5 = Companion.access$getTextOrEmpty(companion2, textInputLayout5);
|
|
TextInputLayout textInputLayout6 = getBinding().m;
|
|
m.checkNotNullExpressionValue(textInputLayout6, "binding.paymentSourceEditPostalCode");
|
|
String access$getTextOrEmpty6 = Companion.access$getTextOrEmpty(companion2, textInputLayout6);
|
|
TextInputLayout textInputLayout7 = getBinding().h;
|
|
m.checkNotNullExpressionValue(textInputLayout7, "binding.paymentSourceEditCountry");
|
|
ModelBillingAddress modelBillingAddress = new ModelBillingAddress(access$getTextOrEmpty2, access$getTextOrEmpty3, access$getTextOrEmpty4, access$getTextOrEmpty5, str, Companion.access$getTextOrEmpty(companion2, textInputLayout7), access$getTextOrEmpty6);
|
|
CheckBox checkBox = getBinding().i;
|
|
m.checkNotNullExpressionValue(checkBox, "binding.paymentSourceEditDefault");
|
|
PatchPaymentSourceRaw patchPaymentSourceRaw = new PatchPaymentSourceRaw(modelBillingAddress, checkBox.isChecked());
|
|
TextView textView = getBinding().j;
|
|
m.checkNotNullExpressionValue(textView, "binding.paymentSourceEditError");
|
|
textView.setVisibility(8);
|
|
getBinding().d.setIsLoading(true);
|
|
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.ui$default(ObservableExtensionsKt.restSubscribeOn$default(RestAPI.Companion.getApi().updatePaymentSource(modelPaymentSource.getId(), patchPaymentSourceRaw), false, 1, null), this, null, 2, null), WidgetPaymentSourceEditDialog.class, (Context) null, (Function1) null, new WidgetPaymentSourceEditDialog$updatePaymentSource$2(this), new WidgetPaymentSourceEditDialog$updatePaymentSource$3(this), (Function0) null, new WidgetPaymentSourceEditDialog$updatePaymentSource$1(this), 38, (Object) null);
|
|
}
|
|
}
|
|
|
|
@MainThread
|
|
public final void handleError(Error error) {
|
|
m.checkNotNullParameter(error, "error");
|
|
TextView textView = getBinding().j;
|
|
m.checkNotNullExpressionValue(textView, "binding.paymentSourceEditError");
|
|
Error.Response response = error.getResponse();
|
|
m.checkNotNullExpressionValue(response, "error.response");
|
|
ViewExtensions.setTextAndVisibilityBy(textView, response.getMessage());
|
|
ValidationManager validationManager = this.validationManager;
|
|
if (validationManager == null) {
|
|
m.throwUninitializedPropertyAccessException("validationManager");
|
|
}
|
|
Error.Response response2 = error.getResponse();
|
|
m.checkNotNullExpressionValue(response2, "error.response");
|
|
Map<String, List<String>> messages = response2.getMessages();
|
|
m.checkNotNullExpressionValue(messages, "error.response.messages");
|
|
validationManager.setErrors(messages);
|
|
Error.Response response3 = error.getResponse();
|
|
m.checkNotNullExpressionValue(response3, "error.response");
|
|
String message = response3.getMessage();
|
|
if (message != null) {
|
|
if (message.length() > 0) {
|
|
c.a.d.m.h(getContext(), message, 0, null, 8);
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override // com.discord.app.AppDialog, androidx.fragment.app.DialogFragment, androidx.fragment.app.Fragment
|
|
public void onStart() {
|
|
Window window;
|
|
super.onStart();
|
|
Dialog dialog = getDialog();
|
|
if (dialog != null && (window = dialog.getWindow()) != null) {
|
|
if (!AccessibilityUtils.INSTANCE.isReducedMotionEnabled()) {
|
|
window.getAttributes().windowAnimations = R.style.UiKit_Dialog_Animation;
|
|
}
|
|
window.setLayout(-1, -1);
|
|
window.setBackgroundDrawable(new ColorDrawable(0));
|
|
window.setSoftInputMode(16);
|
|
}
|
|
}
|
|
|
|
@Override // com.discord.app.AppDialog
|
|
public void onViewBound(View view) {
|
|
m.checkNotNullParameter(view, "view");
|
|
super.onViewBound(view);
|
|
Observable<R> F = getViewModel().observeViewState().x(WidgetPaymentSourceEditDialog$onViewBound$$inlined$filterIs$1.INSTANCE).F(WidgetPaymentSourceEditDialog$onViewBound$$inlined$filterIs$2.INSTANCE);
|
|
m.checkNotNullExpressionValue(F, "filter { it is T }.map { it as T }");
|
|
Observable Y = F.F(WidgetPaymentSourceEditDialog$onViewBound$1.INSTANCE).F(new WidgetPaymentSourceEditDialog$onViewBound$2(this)).Y(1);
|
|
m.checkNotNullExpressionValue(Y, "viewModel\n .obser… }\n .take(1)");
|
|
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.bindToComponentLifecycle$default(Y, this, null, 2, null), WidgetPaymentSourceEditDialog.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new WidgetPaymentSourceEditDialog$onViewBound$3(this), 62, (Object) null);
|
|
getBinding().b.setNavigationOnClickListener(new WidgetPaymentSourceEditDialog$onViewBound$4(this));
|
|
getBinding().d.setOnClickListener(new WidgetPaymentSourceEditDialog$onViewBound$5(this));
|
|
}
|
|
}
|