正在查看: Rilo v2.0.21 应用的 AddPaymentMethodActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Rilo v2.0.21 应用的 AddPaymentMethodActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.stripe.android.view;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.text.method.LinkMovementMethod;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.activity.ComponentActivity;
import androidx.core.text.util.LinkifyCompat;
import androidx.core.view.ViewCompat;
import androidx.fragment.app.FragmentActivity;
import androidx.lifecycle.LifecycleOwner;
import androidx.lifecycle.LifecycleOwnerKt;
import androidx.lifecycle.ViewModelLazy;
import androidx.lifecycle.ViewModelProvider;
import androidx.lifecycle.ViewModelStore;
import androidx.lifecycle.viewmodel.CreationExtras;
import com.stripe.android.CustomerSession;
import com.stripe.android.PaymentConfiguration;
import com.stripe.android.R;
import com.stripe.android.Stripe;
import com.stripe.android.databinding.StripeAddPaymentMethodActivityBinding;
import com.stripe.android.model.PaymentMethod;
import com.stripe.android.model.PaymentMethodCreateParams;
import com.stripe.android.utils.ActivityUtilsKt;
import com.stripe.android.view.AddPaymentMethodActivityStarter;
import com.stripe.android.view.AddPaymentMethodViewModel;
import java.util.Set;
import kotlin.Lazy;
import kotlin.LazyKt;
import kotlin.Metadata;
import kotlin.Result;
import kotlin.ResultKt;
import kotlin.Unit;
import kotlin.coroutines.CoroutineContext;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.jvm.internal.Intrinsics;
import kotlin.jvm.internal.Reflection;
import kotlinx.coroutines.BuildersKt;
import kotlinx.coroutines.CoroutineStart;
@Metadata(d1 = {"\u0000x\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0010\u000b\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0010\b\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0010\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0005\b\u0007\u0018\u0000 ?2\u00020\u0001:\u0001?B\u0005¢\u0006\u0002\u0010\u0002J\u0010\u0010&\u001a\u00020'2\u0006\u0010(\u001a\u00020)H\u0002J\u0010\u0010*\u001a\u00020'2\u0006\u0010\t\u001a\u00020\nH\u0002J\u0012\u0010+\u001a\u0004\u0018\u00010,2\u0006\u0010-\u001a\u00020.H\u0002J\u001f\u0010/\u001a\u00020'2\u0006\u0010!\u001a\u00020\"2\b\u00100\u001a\u0004\u0018\u000101H\u0000¢\u0006\u0002\b2J\u0010\u00103\u001a\u00020\u00042\u0006\u0010\t\u001a\u00020\nH\u0002J\u0010\u00104\u001a\u00020'2\u0006\u0010(\u001a\u00020)H\u0002J\u0010\u00105\u001a\u00020'2\u0006\u00106\u001a\u000207H\u0002J\b\u00108\u001a\u00020'H\u0016J\u0012\u00109\u001a\u00020'2\b\u0010:\u001a\u0004\u0018\u00010;H\u0014J\u0010\u0010<\u001a\u00020'2\u0006\u0010=\u001a\u00020\u0014H\u0014J\b\u0010>\u001a\u00020'H\u0014R\u001b\u0010\u0003\u001a\u00020\u00048BX\u0082\u0084\u0002¢\u0006\f\n\u0004\b\u0007\u0010\b\u001a\u0004\b\u0005\u0010\u0006R\u001b\u0010\t\u001a\u00020\n8BX\u0082\u0084\u0002¢\u0006\f\n\u0004\b\r\u0010\b\u001a\u0004\b\u000b\u0010\fR\u001b\u0010\u000e\u001a\u00020\u000f8BX\u0082\u0084\u0002¢\u0006\f\n\u0004\b\u0012\u0010\b\u001a\u0004\b\u0010\u0010\u0011R\u001b\u0010\u0013\u001a\u00020\u00148BX\u0082\u0084\u0002¢\u0006\f\n\u0004\b\u0017\u0010\b\u001a\u0004\b\u0015\u0010\u0016R\u001b\u0010\u0018\u001a\u00020\u00198BX\u0082\u0084\u0002¢\u0006\f\n\u0004\b\u001c\u0010\b\u001a\u0004\b\u001a\u0010\u001bR\u0014\u0010\u001d\u001a\u00020\u001e8CX\u0082\u0004¢\u0006\u0006\u001a\u0004\b\u001f\u0010 R\u001b\u0010!\u001a\u00020\"8BX\u0082\u0084\u0002¢\u0006\f\n\u0004\b%\u0010\b\u001a\u0004\b#\u0010$¨\u0006@"}, d2 = {"Lcom/stripe/android/view/AddPaymentMethodActivity;", "Lcom/stripe/android/view/StripeActivity;", "()V", "addPaymentMethodView", "Lcom/stripe/android/view/AddPaymentMethodView;", "getAddPaymentMethodView", "()Lcom/stripe/android/view/AddPaymentMethodView;", "addPaymentMethodView$delegate", "Lkotlin/Lazy;", "args", "Lcom/stripe/android/view/AddPaymentMethodActivityStarter$Args;", "getArgs", "()Lcom/stripe/android/view/AddPaymentMethodActivityStarter$Args;", "args$delegate", "paymentMethodType", "Lcom/stripe/android/model/PaymentMethod$Type;", "getPaymentMethodType", "()Lcom/stripe/android/model/PaymentMethod$Type;", "paymentMethodType$delegate", "shouldAttachToCustomer", "", "getShouldAttachToCustomer", "()Z", "shouldAttachToCustomer$delegate", "stripe", "Lcom/stripe/android/Stripe;", "getStripe", "()Lcom/stripe/android/Stripe;", "stripe$delegate", "titleStringRes", "", "getTitleStringRes", "()I", "viewModel", "Lcom/stripe/android/view/AddPaymentMethodViewModel;", "getViewModel", "()Lcom/stripe/android/view/AddPaymentMethodViewModel;", "viewModel$delegate", "attachPaymentMethodToCustomer", "", "paymentMethod", "Lcom/stripe/android/model/PaymentMethod;", "configureView", "createFooterView", "Landroid/view/View;", "contentRoot", "Landroid/view/ViewGroup;", "createPaymentMethod", "params", "Lcom/stripe/android/model/PaymentMethodCreateParams;", "createPaymentMethod$payments_core_release", "createPaymentMethodView", "finishWithPaymentMethod", "finishWithResult", "result", "Lcom/stripe/android/view/AddPaymentMethodActivityStarter$Result;", "onActionSave", "onCreate", "savedInstanceState", "Landroid/os/Bundle;", "onProgressBarVisibilityChanged", "visible", "onResume", "Companion", "payments-core_release"}, k = 1, mv = {1, 8, 0}, xi = 48)
public final class AddPaymentMethodActivity extends StripeActivity {
public static final String PRODUCT_TOKEN = "AddPaymentMethodActivity";
private final Lazy viewModel;
public static final int $stable = 8;
private final Lazy args = LazyKt.lazy(new Function0<AddPaymentMethodActivityStarter.Args>() {
{
super(0);
}
public final AddPaymentMethodActivityStarter.Args m951invoke() {
AddPaymentMethodActivityStarter.Args.Companion companion = AddPaymentMethodActivityStarter.Args.INSTANCE;
Intent intent = AddPaymentMethodActivity.this.getIntent();
Intrinsics.checkNotNullExpressionValue(intent, "intent");
return companion.create$payments_core_release(intent);
}
});
private final Lazy stripe = LazyKt.lazy(new Function0<Stripe>() {
{
super(0);
}
public final Stripe m955invoke() {
AddPaymentMethodActivityStarter.Args args;
args = AddPaymentMethodActivity.this.getArgs();
PaymentConfiguration paymentConfiguration$payments_core_release = args.getPaymentConfiguration$payments_core_release();
if (paymentConfiguration$payments_core_release == null) {
paymentConfiguration$payments_core_release = PaymentConfiguration.Companion.getInstance((Context) AddPaymentMethodActivity.this);
}
Context applicationContext = AddPaymentMethodActivity.this.getApplicationContext();
Intrinsics.checkNotNullExpressionValue(applicationContext, "applicationContext");
return new Stripe(applicationContext, paymentConfiguration$payments_core_release.getPublishableKey(), paymentConfiguration$payments_core_release.getStripeAccountId(), false, (Set) null, 24, (DefaultConstructorMarker) null);
}
});
private final Lazy paymentMethodType = LazyKt.lazy(new Function0<PaymentMethod.Type>() {
{
super(0);
}
public final PaymentMethod.Type m953invoke() {
AddPaymentMethodActivityStarter.Args args;
args = AddPaymentMethodActivity.this.getArgs();
return args.getPaymentMethodType$payments_core_release();
}
});
private final Lazy shouldAttachToCustomer = LazyKt.lazy(new Function0<Boolean>() {
{
super(0);
}
public final Boolean m954invoke() {
PaymentMethod.Type paymentMethodType;
boolean z;
AddPaymentMethodActivityStarter.Args args;
paymentMethodType = AddPaymentMethodActivity.this.getPaymentMethodType();
if (paymentMethodType.isReusable) {
args = AddPaymentMethodActivity.this.getArgs();
if (args.getShouldAttachToCustomer$payments_core_release()) {
z = true;
return Boolean.valueOf(z);
}
}
z = false;
return Boolean.valueOf(z);
}
});
private final Lazy addPaymentMethodView = LazyKt.lazy(new Function0<AddPaymentMethodView>() {
{
super(0);
}
public final AddPaymentMethodView m950invoke() {
AddPaymentMethodActivityStarter.Args args;
AddPaymentMethodView createPaymentMethodView;
AddPaymentMethodActivity addPaymentMethodActivity = AddPaymentMethodActivity.this;
args = addPaymentMethodActivity.getArgs();
createPaymentMethodView = addPaymentMethodActivity.createPaymentMethodView(args);
createPaymentMethodView.setId(R.id.stripe_add_payment_method_form);
return createPaymentMethodView;
}
});
@Metadata(k = 3, mv = {1, 8, 0}, xi = 48)
public class WhenMappings {
public static final int[] $EnumSwitchMapping$0;
static {
int[] iArr = new int[PaymentMethod.Type.values().length];
try {
iArr[PaymentMethod.Type.Card.ordinal()] = 1;
} catch (NoSuchFieldError unused) {
}
try {
iArr[PaymentMethod.Type.Fpx.ordinal()] = 2;
} catch (NoSuchFieldError unused2) {
}
try {
iArr[PaymentMethod.Type.Netbanking.ordinal()] = 3;
} catch (NoSuchFieldError unused3) {
}
$EnumSwitchMapping$0 = iArr;
}
}
public AddPaymentMethodActivity() {
final ComponentActivity componentActivity = (ComponentActivity) this;
final Function0 function0 = null;
this.viewModel = new ViewModelLazy(Reflection.getOrCreateKotlinClass(AddPaymentMethodViewModel.class), new Function0<ViewModelStore>() {
{
super(0);
}
public final ViewModelStore m948invoke() {
ViewModelStore viewModelStore = componentActivity.getViewModelStore();
Intrinsics.checkNotNullExpressionValue(viewModelStore, "viewModelStore");
return viewModelStore;
}
}, new Function0<ViewModelProvider.Factory>() {
{
super(0);
}
public final ViewModelProvider.Factory m956invoke() {
Stripe stripe;
AddPaymentMethodActivityStarter.Args args;
stripe = AddPaymentMethodActivity.this.getStripe();
args = AddPaymentMethodActivity.this.getArgs();
return new AddPaymentMethodViewModel.Factory(stripe, args);
}
}, new Function0<CreationExtras>() {
{
super(0);
}
public final CreationExtras m949invoke() {
CreationExtras creationExtras;
Function0 function02 = function0;
if (function02 != null && (creationExtras = (CreationExtras) function02.invoke()) != null) {
return creationExtras;
}
CreationExtras defaultViewModelCreationExtras = componentActivity.getDefaultViewModelCreationExtras();
Intrinsics.checkNotNullExpressionValue(defaultViewModelCreationExtras, "this.defaultViewModelCreationExtras");
return defaultViewModelCreationExtras;
}
});
}
public final AddPaymentMethodActivityStarter.Args getArgs() {
return (AddPaymentMethodActivityStarter.Args) this.args.getValue();
}
public final Stripe getStripe() {
return (Stripe) this.stripe.getValue();
}
public final PaymentMethod.Type getPaymentMethodType() {
return (PaymentMethod.Type) this.paymentMethodType.getValue();
}
public final boolean getShouldAttachToCustomer() {
return ((Boolean) this.shouldAttachToCustomer.getValue()).booleanValue();
}
private final AddPaymentMethodView getAddPaymentMethodView() {
return (AddPaymentMethodView) this.addPaymentMethodView.getValue();
}
public final AddPaymentMethodViewModel getViewModel() {
return (AddPaymentMethodViewModel) this.viewModel.getValue();
}
private final int getTitleStringRes() {
int i2 = WhenMappings.$EnumSwitchMapping$0[getPaymentMethodType().ordinal()];
if (i2 == 1) {
return R.string.stripe_title_add_a_card;
}
if (i2 == 2) {
return R.string.stripe_title_bank_account;
}
if (i2 == 3) {
return R.string.stripe_title_bank_account;
}
throw new IllegalArgumentException("Unsupported Payment Method type: " + getPaymentMethodType().code);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (ActivityUtilsKt.argsAreInvalid((Activity) this, new Function0<Unit>() {
{
super(0);
}
public Object invoke() {
m952invoke();
return Unit.INSTANCE;
}
public final void m952invoke() {
AddPaymentMethodActivity.this.getArgs();
}
})) {
return;
}
configureView(getArgs());
setResult(-1, new Intent().putExtras(AddPaymentMethodActivityStarter.Result.Canceled.INSTANCE.toBundle()));
}
protected void onResume() {
super.onResume();
getAddPaymentMethodView().requestFocus();
}
private final void configureView(AddPaymentMethodActivityStarter.Args args) {
Integer windowFlags$payments_core_release = args.getWindowFlags$payments_core_release();
if (windowFlags$payments_core_release != null) {
getWindow().addFlags(windowFlags$payments_core_release.intValue());
}
getViewStub$payments_core_release().setLayoutResource(R.layout.stripe_add_payment_method_activity);
View inflate = getViewStub$payments_core_release().inflate();
Intrinsics.checkNotNull(inflate, "null cannot be cast to non-null type android.view.ViewGroup");
StripeAddPaymentMethodActivityBinding bind = StripeAddPaymentMethodActivityBinding.bind((ViewGroup) inflate);
Intrinsics.checkNotNullExpressionValue(bind, "bind(scrollView)");
bind.root.addView(getAddPaymentMethodView());
LinearLayout linearLayout = bind.root;
Intrinsics.checkNotNullExpressionValue(linearLayout, "viewBinding.root");
View createFooterView = createFooterView(linearLayout);
if (createFooterView != null) {
if (Build.VERSION.SDK_INT >= 22) {
getAddPaymentMethodView().setAccessibilityTraversalBefore(createFooterView.getId());
createFooterView.setAccessibilityTraversalAfter(getAddPaymentMethodView().getId());
}
bind.root.addView(createFooterView);
}
setTitle(getTitleStringRes());
}
public final AddPaymentMethodView createPaymentMethodView(AddPaymentMethodActivityStarter.Args args) {
int i2 = WhenMappings.$EnumSwitchMapping$0[getPaymentMethodType().ordinal()];
if (i2 == 1) {
return new AddPaymentMethodCardView((Context) this, null, 0, args.getBillingAddressFields$payments_core_release(), 6, null);
}
if (i2 == 2) {
return AddPaymentMethodFpxView.INSTANCE.create$payments_core_release((FragmentActivity) this);
}
if (i2 == 3) {
return AddPaymentMethodNetbankingView.INSTANCE.create$payments_core_release((FragmentActivity) this);
}
throw new IllegalArgumentException("Unsupported Payment Method type: " + getPaymentMethodType().code);
}
private final View createFooterView(ViewGroup contentRoot) {
if (getArgs().getAddPaymentMethodFooterLayoutId$payments_core_release() <= 0) {
return null;
}
View inflate = getLayoutInflater().inflate(getArgs().getAddPaymentMethodFooterLayoutId$payments_core_release(), contentRoot, false);
inflate.setId(R.id.stripe_add_payment_method_footer);
if (!(inflate instanceof TextView)) {
return inflate;
}
TextView textView = (TextView) inflate;
LinkifyCompat.addLinks(textView, 15);
ViewCompat.enableAccessibleClickableSpanSupport(inflate);
textView.setMovementMethod(LinkMovementMethod.getInstance());
return inflate;
}
@Override
public void onActionSave() {
createPaymentMethod$payments_core_release(getViewModel(), getAddPaymentMethodView().getCreateParams());
}
public final void createPaymentMethod$payments_core_release(AddPaymentMethodViewModel viewModel, PaymentMethodCreateParams params) {
Intrinsics.checkNotNullParameter(viewModel, "viewModel");
if (params == null) {
return;
}
setProgressBarVisible(true);
BuildersKt.launch$default(LifecycleOwnerKt.getLifecycleScope((LifecycleOwner) this), (CoroutineContext) null, (CoroutineStart) null, new AddPaymentMethodActivity$createPaymentMethod$1(viewModel, params, this, null), 3, (Object) null);
}
public final void attachPaymentMethodToCustomer(PaymentMethod paymentMethod) {
Object m1547constructorimpl;
try {
Result.Companion companion = Result.INSTANCE;
AddPaymentMethodActivity addPaymentMethodActivity = this;
m1547constructorimpl = Result.m1547constructorimpl(CustomerSession.Companion.getInstance());
} catch (Throwable th) {
Result.Companion companion2 = Result.INSTANCE;
m1547constructorimpl = Result.m1547constructorimpl(ResultKt.createFailure(th));
}
Throwable m1550exceptionOrNullimpl = Result.m1550exceptionOrNullimpl(m1547constructorimpl);
if (m1550exceptionOrNullimpl == null) {
BuildersKt.launch$default(LifecycleOwnerKt.getLifecycleScope((LifecycleOwner) this), (CoroutineContext) null, (CoroutineStart) null, new AddPaymentMethodActivity$attachPaymentMethodToCustomer$2$1(this, (CustomerSession) m1547constructorimpl, paymentMethod, null), 3, (Object) null);
} else {
finishWithResult(new AddPaymentMethodActivityStarter.Result.Failure(m1550exceptionOrNullimpl));
}
}
public final void finishWithPaymentMethod(PaymentMethod paymentMethod) {
finishWithResult(new AddPaymentMethodActivityStarter.Result.Success(paymentMethod));
}
private final void finishWithResult(AddPaymentMethodActivityStarter.Result result) {
setProgressBarVisible(false);
setResult(-1, new Intent().putExtras(result.toBundle()));
finish();
}
@Override
protected void onProgressBarVisibilityChanged(boolean visible) {
getAddPaymentMethodView().setCommunicatingProgress(visible);
}
}