导航菜单

页面标题

页面副标题

Rilo v2.0.21 - GooglePayLauncherActivity.java 源代码

正在查看: Rilo v2.0.21 应用的 GooglePayLauncherActivity.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.GooglePayLauncher;
import com.stripe.android.googlepaylauncher.GooglePayLauncherContract;
import com.stripe.android.googlepaylauncher.GooglePayLauncherViewModel;
import com.stripe.android.model.PaymentMethodCreateParams;
import com.stripe.android.utils.AnimationConstants;
import com.stripe.android.view.AuthActivityStarterHost;
import kotlin.Deprecated;
import kotlin.Lazy;
import kotlin.Metadata;
import kotlin.Pair;
import kotlin.Result;
import kotlin.ResultKt;
import kotlin.TuplesKt;
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;
import org.json.JSONObject;

@Metadata(d1 = {"\u0000N\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\u0002\b\u0002\n\u0002\u0010\b\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0003\b\u0000\u0018\u0000 \u001f2\u00020\u0001:\u0001\u001fB\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\"\u0010\u0010\u001a\u00020\f2\u0006\u0010\u0011\u001a\u00020\u00122\u0006\u0010\u0013\u001a\u00020\u00122\b\u0010\u0014\u001a\u0004\u0018\u00010\u0015H\u0017J\u0012\u0010\u0016\u001a\u00020\f2\b\u0010\u0017\u001a\u0004\u0018\u00010\u0018H\u0015J\u0012\u0010\u0019\u001a\u00020\f2\b\u0010\u0014\u001a\u0004\u0018\u00010\u0015H\u0002J\u0016\u0010\u001a\u001a\u00020\f2\f\u0010\u001b\u001a\b\u0012\u0004\u0012\u00020\u001d0\u001cH\u0002J\b\u0010\u001e\u001a\u00020\fH\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/GooglePayLauncherActivity;", "Landroidx/appcompat/app/AppCompatActivity;", "()V", "args", "Lcom/stripe/android/googlepaylauncher/GooglePayLauncherContract$Args;", "viewModel", "Lcom/stripe/android/googlepaylauncher/GooglePayLauncherViewModel;", "getViewModel", "()Lcom/stripe/android/googlepaylauncher/GooglePayLauncherViewModel;", "viewModel$delegate", "Lkotlin/Lazy;", "finish", "", "finishWithResult", "result", "Lcom/stripe/android/googlepaylauncher/GooglePayLauncher$Result;", "onActivityResult", "requestCode", "", "resultCode", Constants.ScionAnalytics.MessageType.DATA_MESSAGE, "Landroid/content/Intent;", "onCreate", "savedInstanceState", "Landroid/os/Bundle;", "onGooglePayResult", "payWithGoogle", "task", "Lcom/google/android/gms/tasks/Task;", "Lcom/google/android/gms/wallet/PaymentData;", "setFadeAnimations", "Companion", "payments-core_release"}, k = 1, mv = {1, 8, 0}, xi = 48)
public final class GooglePayLauncherActivity extends AppCompatActivity {
    private static final Companion Companion = new Companion(null);
    private static final int LOAD_PAYMENT_DATA_REQUEST_CODE = 4444;
    private GooglePayLauncherContract.Args args;

    private final Lazy viewModel;

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

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

            public final ViewModelProvider.Factory m545invoke() {
                GooglePayLauncherContract.Args args;
                args = GooglePayLauncherActivity.this.args;
                if (args == null) {
                    Intrinsics.throwUninitializedPropertyAccessException("args");
                    args = null;
                }
                return new GooglePayLauncherViewModel.Factory(args, false, null, 6, null);
            }
        }, new Function0<CreationExtras>() {
            {
                super(0);
            }

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

    protected void onCreate(Bundle savedInstanceState) {
        Object obj;
        GooglePayLauncherContract.Args fromIntent$payments_core_release;
        super.onCreate(savedInstanceState);
        setFadeAnimations();
        try {
            Result.Companion companion = Result.Companion;
            GooglePayLauncherActivity googlePayLauncherActivity = this;
            GooglePayLauncherContract.Args.Companion companion2 = GooglePayLauncherContract.Args.INSTANCE;
            Intent intent = getIntent();
            Intrinsics.checkNotNullExpressionValue(intent, "intent");
            fromIntent$payments_core_release = companion2.fromIntent$payments_core_release(intent);
        } catch (Throwable th) {
            Result.Companion companion3 = Result.Companion;
            obj = Result.constructor-impl(ResultKt.createFailure(th));
        }
        if (fromIntent$payments_core_release == null) {
            throw new IllegalArgumentException("GooglePayLauncherActivity was started without arguments.".toString());
        }
        obj = Result.constructor-impl(fromIntent$payments_core_release);
        Throwable th2 = Result.exceptionOrNull-impl(obj);
        if (th2 != null) {
            finishWithResult(new GooglePayLauncher.Result.Failed(th2));
            return;
        }
        this.args = (GooglePayLauncherContract.Args) obj;
        LifecycleOwner lifecycleOwner = (LifecycleOwner) this;
        BuildersKt.launch$default(LifecycleOwnerKt.getLifecycleScope(lifecycleOwner), (CoroutineContext) null, (CoroutineStart) null, new GooglePayLauncherActivity$onCreate$3(this, null), 3, (Object) null);
        if (getViewModel().getHasLaunched()) {
            return;
        }
        BuildersKt.launch$default(LifecycleOwnerKt.getLifecycleScope(lifecycleOwner), (CoroutineContext) null, (CoroutineStart) null, new GooglePayLauncherActivity$onCreate$4(this, null), 3, (Object) null);
    }

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

    public final void payWithGoogle(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) {
            BuildersKt.launch$default(LifecycleOwnerKt.getLifecycleScope((LifecycleOwner) this), (CoroutineContext) null, (CoroutineStart) null, new GooglePayLauncherActivity$onActivityResult$1(this, requestCode, data, null), 3, (Object) null);
            return;
        }
        if (resultCode == -1) {
            onGooglePayResult(data);
            return;
        }
        if (resultCode == 0) {
            getViewModel().updateResult(GooglePayLauncher.Result.Canceled.INSTANCE);
            return;
        }
        if (resultCode == 1) {
            Status statusFromIntent = AutoResolveHelper.getStatusFromIntent(data);
            String statusMessage = statusFromIntent != null ? statusFromIntent.getStatusMessage() : null;
            if (statusMessage == null) {
                statusMessage = "";
            }
            getViewModel().updateResult(new GooglePayLauncher.Result.Failed(new RuntimeException("Google Pay failed with error: " + statusMessage)));
            return;
        }
        getViewModel().updateResult(new GooglePayLauncher.Result.Failed(new RuntimeException("Google Pay returned an expected result code.")));
    }

    private final void onGooglePayResult(Intent data) {
        PaymentData fromIntent = data != null ? PaymentData.getFromIntent(data) : null;
        if (fromIntent == null) {
            getViewModel().updateResult(new GooglePayLauncher.Result.Failed(new IllegalArgumentException("Google Pay data was not available")));
        } else {
            BuildersKt.launch$default(LifecycleOwnerKt.getLifecycleScope((LifecycleOwner) this), (CoroutineContext) null, (CoroutineStart) null, new GooglePayLauncherActivity$onGooglePayResult$1(this, AuthActivityStarterHost.Companion.create$payments_core_release$default(AuthActivityStarterHost.Companion, (ComponentActivity) this, (Integer) null, 2, (Object) null), PaymentMethodCreateParams.Companion.createFromGooglePay(new JSONObject(fromIntent.toJson())), null), 3, (Object) null);
        }
    }

    public final void finishWithResult(GooglePayLauncher.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/GooglePayLauncherActivity$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() {
        }
    }
}