导航菜单

页面标题

页面副标题

Rilo v2.0.21 - PaymentSheetActivity.java 源代码

正在查看: Rilo v2.0.21 应用的 PaymentSheetActivity.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package com.stripe.android.paymentsheet;

import android.content.Intent;
import android.os.Bundle;
import androidx.activity.ComponentActivity;
import androidx.activity.compose.ComponentActivityKt;
import androidx.activity.result.ActivityResultCaller;
import androidx.activity.result.ActivityResultLauncher;
import androidx.activity.result.contract.ActivityResultContract;
import androidx.compose.runtime.Composer;
import androidx.compose.runtime.ComposerKt;
import androidx.compose.runtime.CompositionContext;
import androidx.compose.runtime.SnapshotStateKt;
import androidx.compose.runtime.State;
import androidx.compose.runtime.internal.ComposableLambdaKt;
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.common.ui.BottomSheetState;
import com.stripe.android.googlepaylauncher.GooglePayPaymentMethodLauncherContractV2;
import com.stripe.android.paymentsheet.PaymentSheetContractV2;
import com.stripe.android.paymentsheet.PaymentSheetResult;
import com.stripe.android.paymentsheet.PaymentSheetViewModel;
import com.stripe.android.paymentsheet.ui.BaseSheetActivity;
import com.stripe.android.uicore.StripeThemeKt;
import java.security.InvalidParameterException;
import kotlin.Lazy;
import kotlin.LazyKt;
import kotlin.Metadata;
import kotlin.Result;
import kotlin.ResultKt;
import kotlin.Unit;
import kotlin.coroutines.Continuation;
import kotlin.coroutines.CoroutineContext;
import kotlin.coroutines.intrinsics.IntrinsicsKt;
import kotlin.coroutines.jvm.internal.DebugMetadata;
import kotlin.coroutines.jvm.internal.SuspendLambda;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.functions.Function2;
import kotlin.jvm.internal.FunctionReferenceImpl;
import kotlin.jvm.internal.Intrinsics;
import kotlin.jvm.internal.Lambda;
import kotlin.jvm.internal.Reflection;
import kotlinx.coroutines.CoroutineScope;
import kotlinx.coroutines.flow.FlowCollector;
import kotlinx.coroutines.flow.FlowKt;

@Metadata(d1 = {"\u0000R\n\u0002\u0018\u0002\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\u0006\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u0002\n\u0000\n\u0002\u0010\u0003\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0010\u000b\b\u0000\u0018\u00002\b\u0012\u0004\u0012\u00020\u00020\u0001B\u0005¢\u0006\u0002\u0010\u0003J\f\u0010\u0016\u001a\u00060\u0017j\u0002`\u0018H\u0002J\u0012\u0010\u0019\u001a\u00020\u001a2\b\u0010\u001b\u001a\u0004\u0018\u00010\u001cH\u0002J \u0010\u001d\u001a\n\u0012\u0006\u0012\u0004\u0018\u00010\u00050\u001eH\u0002ø\u0001\u0000ø\u0001\u0001ø\u0001\u0002¢\u0006\u0004\b\u001f\u0010 J\u0012\u0010!\u001a\u00020\u001a2\b\u0010\"\u001a\u0004\u0018\u00010#H\u0014J\u0010\u0010$\u001a\u00020\u001a2\u0006\u0010%\u001a\u00020\u0002H\u0016R\u001d\u0010\u0004\u001a\u0004\u0018\u00010\u00058BX\u0082\u0084\u0002¢\u0006\f\n\u0004\b\b\u0010\t\u001a\u0004\b\u0006\u0010\u0007R\u001b\u0010\n\u001a\u00020\u000b8VX\u0096\u0084\u0002¢\u0006\f\n\u0004\b\u000e\u0010\t\u001a\u0004\b\f\u0010\rR$\u0010\u000f\u001a\u00020\u00108\u0000@\u0000X\u0081\u000e¢\u0006\u0014\n\u0000\u0012\u0004\b\u0011\u0010\u0003\u001a\u0004\b\u0012\u0010\u0013\"\u0004\b\u0014\u0010\u0015\u0082\u0002\u000f\n\u0002\b!\n\u0005\b¡\u001e0\u0001\n\u0002\b\u0019¨\u0006&²\u0006\n\u0010'\u001a\u00020(X\u008a\u0084\u0002"}, d2 = {"Lcom/stripe/android/paymentsheet/PaymentSheetActivity;", "Lcom/stripe/android/paymentsheet/ui/BaseSheetActivity;", "Lcom/stripe/android/paymentsheet/PaymentSheetResult;", "()V", "starterArgs", "Lcom/stripe/android/paymentsheet/PaymentSheetContractV2$Args;", "getStarterArgs", "()Lcom/stripe/android/paymentsheet/PaymentSheetContractV2$Args;", "starterArgs$delegate", "Lkotlin/Lazy;", "viewModel", "Lcom/stripe/android/paymentsheet/PaymentSheetViewModel;", "getViewModel", "()Lcom/stripe/android/paymentsheet/PaymentSheetViewModel;", "viewModel$delegate", "viewModelFactory", "Landroidx/lifecycle/ViewModelProvider$Factory;", "getViewModelFactory$paymentsheet_release$annotations", "getViewModelFactory$paymentsheet_release", "()Landroidx/lifecycle/ViewModelProvider$Factory;", "setViewModelFactory$paymentsheet_release", "(Landroidx/lifecycle/ViewModelProvider$Factory;)V", "defaultInitializationError", "Ljava/lang/IllegalArgumentException;", "Lkotlin/IllegalArgumentException;", "finishWithError", "", "error", "", "initializeArgs", "Lkotlin/Result;", "initializeArgs-d1pmJ48", "()Ljava/lang/Object;", "onCreate", "savedInstanceState", "Landroid/os/Bundle;", "setActivityResult", "result", "paymentsheet_release", "isProcessing", ""}, k = 1, mv = {1, 8, 0}, xi = 48)
public final class PaymentSheetActivity extends BaseSheetActivity<PaymentSheetResult> {

    private final Lazy viewModel;
    private ViewModelProvider.Factory viewModelFactory = new PaymentSheetViewModel.Factory(new Function0<PaymentSheetContractV2.Args>() {
        {
            super(0);
        }

        public final PaymentSheetContractV2.Args m309invoke() {
            PaymentSheetContractV2.Args starterArgs;
            starterArgs = PaymentSheetActivity.this.getStarterArgs();
            if (starterArgs != null) {
                return starterArgs;
            }
            throw new IllegalArgumentException("Required value was null.".toString());
        }
    });

    private final Lazy starterArgs = LazyKt.lazy(new Function0<PaymentSheetContractV2.Args>() {
        {
            super(0);
        }

        public final PaymentSheetContractV2.Args m307invoke() {
            PaymentSheetContractV2.Args.Companion companion = PaymentSheetContractV2.Args.INSTANCE;
            Intent intent = PaymentSheetActivity.this.getIntent();
            Intrinsics.checkNotNullExpressionValue(intent, "intent");
            return companion.fromIntent$paymentsheet_release(intent);
        }
    });

    public static void getViewModelFactory$paymentsheet_release$annotations() {
    }

    public PaymentSheetActivity() {
        final ComponentActivity componentActivity = (ComponentActivity) this;
        final Function0 function0 = null;
        this.viewModel = new ViewModelLazy(Reflection.getOrCreateKotlinClass(PaymentSheetViewModel.class), new Function0<ViewModelStore>() {
            {
                super(0);
            }

            public final ViewModelStore m304invoke() {
                ViewModelStore viewModelStore = componentActivity.getViewModelStore();
                Intrinsics.checkNotNullExpressionValue(viewModelStore, "viewModelStore");
                return viewModelStore;
            }
        }, new Function0<ViewModelProvider.Factory>() {
            {
                super(0);
            }

            public final ViewModelProvider.Factory m308invoke() {
                return PaymentSheetActivity.this.getViewModelFactory();
            }
        }, new Function0<CreationExtras>() {
            {
                super(0);
            }

            public final CreationExtras m305invoke() {
                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 ViewModelProvider.Factory getViewModelFactory() {
        return this.viewModelFactory;
    }

    public final void setViewModelFactory$paymentsheet_release(ViewModelProvider.Factory factory) {
        Intrinsics.checkNotNullParameter(factory, "<set-?>");
        this.viewModelFactory = factory;
    }

    @Override
    public PaymentSheetViewModel getViewModel() {
        return (PaymentSheetViewModel) this.viewModel.getValue();
    }

    public final PaymentSheetContractV2.Args getStarterArgs() {
        return (PaymentSheetContractV2.Args) this.starterArgs.getValue();
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        Object m302initializeArgsd1pmJ48 = m302initializeArgsd1pmJ48();
        super.onCreate(savedInstanceState);
        if (((PaymentSheetContractV2.Args) (Result.m1553isFailureimpl(m302initializeArgsd1pmJ48) ? null : m302initializeArgsd1pmJ48)) == null) {
            finishWithError(Result.m1550exceptionOrNullimpl(m302initializeArgsd1pmJ48));
            return;
        }
        LifecycleOwner lifecycleOwner = (LifecycleOwner) this;
        getViewModel().registerFromActivity((ActivityResultCaller) this, lifecycleOwner);
        PaymentSheetViewModel viewModel = getViewModel();
        CoroutineScope coroutineScope = (CoroutineScope) LifecycleOwnerKt.getLifecycleScope(lifecycleOwner);
        ActivityResultLauncher<GooglePayPaymentMethodLauncherContractV2.Args> registerForActivityResult = registerForActivityResult((ActivityResultContract) new GooglePayPaymentMethodLauncherContractV2(), new PaymentSheetActivity$onCreate$1(getViewModel()));
        Intrinsics.checkNotNullExpressionValue(registerForActivityResult, "registerForActivityResul…lePayResult\n            )");
        viewModel.setupGooglePay(coroutineScope, registerForActivityResult);
        ComponentActivityKt.setContent$default((ComponentActivity) this, (CompositionContext) null, ComposableLambdaKt.composableLambdaInstance(485212172, true, new Function2<Composer, Integer, Unit>() {
            {
                super(2);
            }

            @Metadata(d1 = {"\u0000\n\n\u0000\n\u0002\u0010\u0002\n\u0002\b\u0002\u0010\u0000\u001a\u00020\u0001H\u000b¢\u0006\u0004\b\u0002\u0010\u0003"}, d2 = {"<anonymous>", "", "invoke", "(Landroidx/compose/runtime/Composer;I)V"}, k = 3, mv = {1, 8, 0}, xi = 48)
            static final class AnonymousClass1 extends Lambda implements Function2<Composer, Integer, Unit> {
                final PaymentSheetActivity this$0;

                AnonymousClass1(PaymentSheetActivity paymentSheetActivity) {
                    super(2);
                    this.this$0 = paymentSheetActivity;
                }

                public Object invoke(Object obj, Object obj2) {
                    invoke((Composer) obj, ((Number) obj2).intValue());
                    return Unit.INSTANCE;
                }

                public final void invoke(Composer composer, int i2) {
                    if ((i2 & 11) != 2 || !composer.getSkipping()) {
                        if (ComposerKt.isTraceInProgress()) {
                            ComposerKt.traceEventStart(952004382, i2, -1, "com.stripe.android.paymentsheet.PaymentSheetActivity.onCreate.<anonymous>.<anonymous> (PaymentSheetActivity.kt:62)");
                        }
                        final State collectAsState = SnapshotStateKt.collectAsState(this.this$0.getViewModel().getProcessing(), (CoroutineContext) null, composer, 8, 1);
                        composer.startReplaceableGroup(1157296644);
                        ComposerKt.sourceInformation(composer, "CC(remember)P(1):Composables.kt#9igjgp");
                        boolean changed = composer.changed(collectAsState);
                        Object rememberedValue = composer.rememberedValue();
                        if (changed || rememberedValue == Composer.Companion.getEmpty()) {
                            rememberedValue = (Function1) 
                            throw new UnsupportedOperationException("Method not decompiled: com.stripe.android.paymentsheet.PaymentSheetActivity$onCreate$2.AnonymousClass1.invoke(androidx.compose.runtime.Composer, int):void");
                        }

                        @Metadata(d1 = {"\u0000\n\n\u0000\n\u0002\u0010\u0002\n\u0002\u0018\u0002\u0010\u0000\u001a\u00020\u0001*\u00020\u0002H\u008a@"}, d2 = {"<anonymous>", "", "Lkotlinx/coroutines/CoroutineScope;"}, k = 3, mv = {1, 8, 0}, xi = 48)
                        @DebugMetadata(c = "com.stripe.android.paymentsheet.PaymentSheetActivity$onCreate$2$1$1", f = "PaymentSheetActivity.kt", i = {}, l = {71}, m = "invokeSuspend", n = {}, s = {})
                        static final class C00031 extends SuspendLambda implements Function2<CoroutineScope, Continuation<? super Unit>, Object> {
                            final BottomSheetState $bottomSheetState;
                            int label;
                            final PaymentSheetActivity this$0;

                            C00031(PaymentSheetActivity paymentSheetActivity, BottomSheetState bottomSheetState, Continuation<? super C00031> continuation) {
                                super(2, continuation);
                                this.this$0 = paymentSheetActivity;
                                this.$bottomSheetState = bottomSheetState;
                            }

                            public final Continuation<Unit> create(Object obj, Continuation<?> continuation) {
                                return new C00031(this.this$0, this.$bottomSheetState, continuation);
                            }

                            public final Object invoke(CoroutineScope coroutineScope, Continuation<? super Unit> continuation) {
                                return create(coroutineScope, continuation).invokeSuspend(Unit.INSTANCE);
                            }

                            @Metadata(d1 = {"\u0000\f\n\u0000\n\u0002\u0010\u0002\n\u0000\n\u0002\u0018\u0002\u0010\u0000\u001a\u00020\u00012\u0006\u0010\u0002\u001a\u00020\u0003H\u008a@"}, d2 = {"<anonymous>", "", "sheetResult", "Lcom/stripe/android/paymentsheet/PaymentSheetResult;"}, k = 3, mv = {1, 8, 0}, xi = 48)
                            static final class C00041 implements FlowCollector<PaymentSheetResult> {
                                final BottomSheetState $bottomSheetState;
                                final PaymentSheetActivity this$0;

                                C00041(PaymentSheetActivity paymentSheetActivity, BottomSheetState bottomSheetState) {
                                    this.this$0 = paymentSheetActivity;
                                    this.$bottomSheetState = bottomSheetState;
                                }

                                public final java.lang.Object emit(com.stripe.android.paymentsheet.PaymentSheetResult r5, kotlin.coroutines.Continuation<? super kotlin.Unit> r6) {
                                    throw new UnsupportedOperationException("Method not decompiled: com.stripe.android.paymentsheet.PaymentSheetActivity$onCreate$2.AnonymousClass1.C00031.C00041.emit(com.stripe.android.paymentsheet.PaymentSheetResult, kotlin.coroutines.Continuation):java.lang.Object");
                                }

                                public Object emit(Object obj, Continuation continuation) {
                                    return emit((PaymentSheetResult) obj, (Continuation<? super Unit>) continuation);
                                }
                            }

                            public final Object invokeSuspend(Object obj) {
                                Object coroutine_suspended = IntrinsicsKt.getCOROUTINE_SUSPENDED();
                                int i2 = this.label;
                                if (i2 == 0) {
                                    ResultKt.throwOnFailure(obj);
                                    this.label = 1;
                                    if (FlowKt.filterNotNull(this.this$0.getViewModel().getPaymentSheetResult$paymentsheet_release()).collect(new C00041(this.this$0, this.$bottomSheetState), (Continuation) this) == coroutine_suspended) {
                                        return coroutine_suspended;
                                    }
                                } else {
                                    if (i2 != 1) {
                                        throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                                    }
                                    ResultKt.throwOnFailure(obj);
                                }
                                return Unit.INSTANCE;
                            }
                        }

                        @Metadata(k = 3, mv = {1, 8, 0}, xi = 48)
                        class AnonymousClass2 extends FunctionReferenceImpl implements Function0<Unit> {
                            AnonymousClass2(Object obj) {
                                super(0, obj, PaymentSheetViewModel.class, "onUserCancel", "onUserCancel()V", 0);
                            }

                            public Object invoke() {
                                m306invoke();
                                return Unit.INSTANCE;
                            }

                            public final void m306invoke() {
                                ((PaymentSheetViewModel) this.receiver).onUserCancel();
                            }
                        }

                        public static final boolean invoke$lambda$0(State<Boolean> state) {
                            return ((Boolean) state.getValue()).booleanValue();
                        }
                    }

                    public Object invoke(Object obj, Object obj2) {
                        invoke((Composer) obj, ((Number) obj2).intValue());
                        return Unit.INSTANCE;
                    }

                    public final void invoke(Composer composer, int i2) {
                        if ((i2 & 11) != 2 || !composer.getSkipping()) {
                            if (ComposerKt.isTraceInProgress()) {
                                ComposerKt.traceEventStart(485212172, i2, -1, "com.stripe.android.paymentsheet.PaymentSheetActivity.onCreate.<anonymous> (PaymentSheetActivity.kt:61)");
                            }
                            StripeThemeKt.StripeTheme(null, null, null, ComposableLambdaKt.composableLambda(composer, 952004382, true, new AnonymousClass1(PaymentSheetActivity.this)), composer, 3072, 7);
                            if (ComposerKt.isTraceInProgress()) {
                                ComposerKt.traceEventEnd();
                                return;
                            }
                            return;
                        }
                        composer.skipToGroupEnd();
                    }
                }), 1, (Object) null);
            }

            private final Object m302initializeArgsd1pmJ48() {
                Object m1547constructorimpl;
                PaymentSheetContractV2.Args starterArgs = getStarterArgs();
                if (starterArgs == null) {
                    Result.Companion companion = Result.INSTANCE;
                    m1547constructorimpl = Result.m1547constructorimpl(ResultKt.createFailure(defaultInitializationError()));
                } else {
                    try {
                        starterArgs.getInitializationMode$paymentsheet_release().validate$paymentsheet_release();
                        PaymentSheetConfigurationKtxKt.validate(starterArgs.getConfig$paymentsheet_release());
                        PaymentSheetConfigurationKtxKt.parseAppearance(starterArgs.getConfig$paymentsheet_release().getAppearance());
                        Result.Companion companion2 = Result.INSTANCE;
                        m1547constructorimpl = Result.m1547constructorimpl(starterArgs);
                    } catch (InvalidParameterException e2) {
                        Result.Companion companion3 = Result.INSTANCE;
                        m1547constructorimpl = Result.m1547constructorimpl(ResultKt.createFailure(e2));
                    }
                }
                setEarlyExitDueToIllegalState(Result.m1553isFailureimpl(m1547constructorimpl));
                return m1547constructorimpl;
            }

            @Override
            public void setActivityResult(PaymentSheetResult result) {
                Intrinsics.checkNotNullParameter(result, "result");
                setResult(-1, new Intent().putExtras(new PaymentSheetContractV2.Result(result).toBundle()));
            }

            private final void finishWithError(Throwable error) {
                if (error == null) {
                    error = defaultInitializationError();
                }
                setActivityResult((PaymentSheetResult) new PaymentSheetResult.Failed(error));
                finish();
            }

            private final IllegalArgumentException defaultInitializationError() {
                return new IllegalArgumentException("PaymentSheet started without arguments.");
            }
        }