导航菜单

页面标题

页面副标题

Rilo v2.0.21 - GooglePayPaymentMethodLauncherActivity.java 源代码

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

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


package com.stripe.android.googlepaylauncher;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import androidx.activity.ComponentActivity;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.os.BundleKt;
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.google.android.gms.common.api.Status;
import com.google.android.gms.tasks.Task;
import com.google.android.gms.wallet.AutoResolveHelper;
import com.google.android.gms.wallet.PaymentData;
import com.google.firebase.messaging.Constants;
import com.stripe.android.googlepaylauncher.GooglePayPaymentMethodLauncher;
import com.stripe.android.googlepaylauncher.GooglePayPaymentMethodLauncherContractV2;
import com.stripe.android.googlepaylauncher.GooglePayPaymentMethodLauncherViewModel;
import com.stripe.android.utils.AnimationConstants;
import kotlin.Deprecated;
import kotlin.Lazy;
import kotlin.Metadata;
import kotlin.Pair;
import kotlin.TuplesKt;
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 = {"\u0000P\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0010\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\b\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0005\b\u0000\u0018\u0000 #2\u00020\u0001:\u0001#B\u0005¢\u0006\u0002\u0010\u0002J\b\u0010\u000b\u001a\u00020\fH\u0016J\u0010\u0010\r\u001a\u00020\f2\u0006\u0010\u000e\u001a\u00020\u000fH\u0002J\u0015\u0010\u0010\u001a\u00070\u0011¢\u0006\u0002\b\u00122\u0006\u0010\u0013\u001a\u00020\u0011H\u0002J\u0016\u0010\u0014\u001a\u00020\f2\f\u0010\u0015\u001a\b\u0012\u0004\u0012\u00020\u00170\u0016H\u0002J\"\u0010\u0018\u001a\u00020\f2\u0006\u0010\u0019\u001a\u00020\u00112\u0006\u0010\u001a\u001a\u00020\u00112\b\u0010\u001b\u001a\u0004\u0018\u00010\u001cH\u0017J\u0012\u0010\u001d\u001a\u00020\f2\b\u0010\u001e\u001a\u0004\u0018\u00010\u001fH\u0014J\u0012\u0010 \u001a\u00020\f2\b\u0010\u001b\u001a\u0004\u0018\u00010\u001cH\u0002J\b\u0010!\u001a\u00020\fH\u0002J\u0010\u0010\"\u001a\u00020\f2\u0006\u0010\u000e\u001a\u00020\u000fH\u0002R\u000e\u0010\u0003\u001a\u00020\u0004X\u0082.¢\u0006\u0002\n\u0000R\u001b\u0010\u0005\u001a\u00020\u00068BX\u0082\u0084\u0002¢\u0006\f\n\u0004\b\t\u0010\n\u001a\u0004\b\u0007\u0010\b¨\u0006$"}, d2 = {"Lcom/stripe/android/googlepaylauncher/GooglePayPaymentMethodLauncherActivity;", "Landroidx/appcompat/app/AppCompatActivity;", "()V", "args", "Lcom/stripe/android/googlepaylauncher/GooglePayPaymentMethodLauncherContractV2$Args;", "viewModel", "Lcom/stripe/android/googlepaylauncher/GooglePayPaymentMethodLauncherViewModel;", "getViewModel", "()Lcom/stripe/android/googlepaylauncher/GooglePayPaymentMethodLauncherViewModel;", "viewModel$delegate", "Lkotlin/Lazy;", "finish", "", "finishWithResult", "result", "Lcom/stripe/android/googlepaylauncher/GooglePayPaymentMethodLauncher$Result;", "googlePayStatusCodeToErrorCode", "", "Lcom/stripe/android/googlepaylauncher/GooglePayPaymentMethodLauncher$ErrorCode;", "googlePayStatusCode", "launchGooglePay", "task", "Lcom/google/android/gms/tasks/Task;", "Lcom/google/android/gms/wallet/PaymentData;", "onActivityResult", "requestCode", "resultCode", Constants.ScionAnalytics.MessageType.DATA_MESSAGE, "Landroid/content/Intent;", "onCreate", "savedInstanceState", "Landroid/os/Bundle;", "onGooglePayResult", "setFadeAnimations", "updateResult", "Companion", "payments-core_release"}, k = 1, mv = {1, 8, 0}, xi = 48)
public final class GooglePayPaymentMethodLauncherActivity extends AppCompatActivity {
    private static final Companion Companion = new Companion(null);
    private static final int LOAD_PAYMENT_DATA_REQUEST_CODE = 4444;
    private GooglePayPaymentMethodLauncherContractV2.Args args;

    private final Lazy viewModel;

    private final int googlePayStatusCodeToErrorCode(int googlePayStatusCode) {
        if (googlePayStatusCode != 7) {
            return googlePayStatusCode != 10 ? 1 : 2;
        }
        return 3;
    }

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

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

            public final ViewModelProvider.Factory m556invoke() {
                GooglePayPaymentMethodLauncherContractV2.Args args;
                args = GooglePayPaymentMethodLauncherActivity.this.args;
                if (args == null) {
                    Intrinsics.throwUninitializedPropertyAccessException("args");
                    args = null;
                }
                return new GooglePayPaymentMethodLauncherViewModel.Factory(args);
            }
        }, new Function0<CreationExtras>() {
            {
                super(0);
            }

            public final CreationExtras m555invoke() {
                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 GooglePayPaymentMethodLauncherViewModel getViewModel() {
        return (GooglePayPaymentMethodLauncherViewModel) this.viewModel.getValue();
    }

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setFadeAnimations();
        GooglePayPaymentMethodLauncherContractV2.Args.Companion companion = GooglePayPaymentMethodLauncherContractV2.Args.INSTANCE;
        Intent intent = getIntent();
        Intrinsics.checkNotNullExpressionValue(intent, "intent");
        GooglePayPaymentMethodLauncherContractV2.Args fromIntent = companion.fromIntent(intent);
        if (fromIntent == null) {
            finishWithResult(new GooglePayPaymentMethodLauncher.Result.Failed(new RuntimeException("GooglePayPaymentMethodLauncherActivity was started without arguments."), 2));
            return;
        }
        this.args = fromIntent;
        LifecycleOwner lifecycleOwner = (LifecycleOwner) this;
        BuildersKt.launch$default(LifecycleOwnerKt.getLifecycleScope(lifecycleOwner), (CoroutineContext) null, (CoroutineStart) null, new GooglePayPaymentMethodLauncherActivity$onCreate$1(this, null), 3, (Object) null);
        if (getViewModel().getHasLaunched$payments_core_release()) {
            return;
        }
        BuildersKt.launch$default(LifecycleOwnerKt.getLifecycleScope(lifecycleOwner), (CoroutineContext) null, (CoroutineStart) null, new GooglePayPaymentMethodLauncherActivity$onCreate$2(this, null), 3, (Object) null);
    }

    public void finish() {
        super.finish();
        setFadeAnimations();
    }

    public final void launchGooglePay(Task<PaymentData> task) {
        AutoResolveHelper.resolveTask(task, (Activity) this, LOAD_PAYMENT_DATA_REQUEST_CODE);
    }

    @Deprecated(message = "Deprecated in Java")
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == LOAD_PAYMENT_DATA_REQUEST_CODE) {
            if (resultCode == -1) {
                onGooglePayResult(data);
                return;
            }
            if (resultCode == 0) {
                updateResult(GooglePayPaymentMethodLauncher.Result.Canceled.INSTANCE);
                return;
            }
            if (resultCode == 1) {
                Status statusFromIntent = AutoResolveHelper.getStatusFromIntent(data);
                String statusMessage = statusFromIntent != null ? statusFromIntent.getStatusMessage() : null;
                if (statusMessage == null) {
                    statusMessage = "";
                }
                updateResult(new GooglePayPaymentMethodLauncher.Result.Failed(new RuntimeException("Google Pay failed with error " + (statusFromIntent != null ? Integer.valueOf(statusFromIntent.getStatusCode()) : null) + ": " + statusMessage), statusFromIntent != null ? googlePayStatusCodeToErrorCode(statusFromIntent.getStatusCode()) : 1));
                return;
            }
            updateResult(new GooglePayPaymentMethodLauncher.Result.Failed(new RuntimeException("Google Pay returned an expected result code."), 1));
        }
    }

    private final void onGooglePayResult(Intent data) {
        PaymentData fromIntent;
        if (data == null || (fromIntent = PaymentData.getFromIntent(data)) == null || BuildersKt.launch$default(LifecycleOwnerKt.getLifecycleScope((LifecycleOwner) this), (CoroutineContext) null, (CoroutineStart) null, new GooglePayPaymentMethodLauncherActivity$onGooglePayResult$2$1(this, fromIntent, null), 3, (Object) null) == null) {
            updateResult(new GooglePayPaymentMethodLauncher.Result.Failed(new IllegalArgumentException("Google Pay data was not available"), 1));
            Unit unit = Unit.INSTANCE;
        }
    }

    public final void updateResult(GooglePayPaymentMethodLauncher.Result result) {
        getViewModel().updateResult(result);
    }

    public final void finishWithResult(GooglePayPaymentMethodLauncher.Result result) {
        setResult(-1, new Intent().putExtras(BundleKt.bundleOf(new Pair[]{TuplesKt.to("extra_result", result)})));
        finish();
    }

    private final void setFadeAnimations() {
        overridePendingTransition(AnimationConstants.INSTANCE.getFADE_IN(), AnimationConstants.INSTANCE.getFADE_OUT());
    }

    @Metadata(d1 = {"\u0000\u0012\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0002\n\u0002\u0010\b\n\u0000\b\u0082\u0003\u0018\u00002\u00020\u0001B\u0007\b\u0002¢\u0006\u0002\u0010\u0002R\u000e\u0010\u0003\u001a\u00020\u0004X\u0082T¢\u0006\u0002\n\u0000¨\u0006\u0005"}, d2 = {"Lcom/stripe/android/googlepaylauncher/GooglePayPaymentMethodLauncherActivity$Companion;", "", "()V", "LOAD_PAYMENT_DATA_REQUEST_CODE", "", "payments-core_release"}, k = 1, mv = {1, 8, 0}, xi = 48)
    private static final class Companion {
        public Companion(DefaultConstructorMarker defaultConstructorMarker) {
            this();
        }

        private Companion() {
        }
    }
}