导航菜单

页面标题

页面副标题

Crafto v9.3.3 - GooglePayPaymentMethodLauncherActivity.java 源代码

正在查看: Crafto v9.3.3 应用的 GooglePayPaymentMethodLauncherActivity.java JAVA 源代码文件

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


package com.stripe.android.googlepaylauncher;

import Hk.k;
import android.app.Application;
import android.content.Intent;
import android.os.Bundle;
import android.os.Parcelable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.lifecycle.J;
import androidx.lifecycle.T;
import androidx.lifecycle.u0;
import androidx.lifecycle.v0;
import androidx.lifecycle.x0;
import com.google.android.gms.common.api.Status;
import com.google.android.gms.tasks.Task;
import com.google.android.gms.wallet.PaymentData;
import com.stripe.android.camera.scanui.CameraView;
import com.stripe.android.googlepaylauncher.GooglePayPaymentMethodLauncher;
import com.stripe.android.googlepaylauncher.GooglePayPaymentMethodLauncherContract;
import com.stripe.android.googlepaylauncher.GooglePayPaymentMethodLauncherViewModel;
import dl.g;
import kotlin.Metadata;
import kotlin.Pair;
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 org.jetbrains.annotations.NotNull;

@Metadata
public final class GooglePayPaymentMethodLauncherActivity extends AppCompatActivity {

    @NotNull
    private static final Companion Companion = new Companion(null);

    @Deprecated
    private static final int LOAD_PAYMENT_DATA_REQUEST_CODE = 4444;
    private GooglePayPaymentMethodLauncherContract.Args args;

    @NotNull
    private final k viewModel$delegate = new u0(Reflection.getOrCreateKotlinClass(GooglePayPaymentMethodLauncherViewModel.class), new Function0<x0>() {
        {
            super(0);
        }

        @NotNull
        public final x0 m158invoke() {
            x0 viewModelStore = this.getViewModelStore();
            Intrinsics.checkNotNullExpressionValue(viewModelStore, "viewModelStore");
            return viewModelStore;
        }
    }, new Function0<v0.b>() {
        {
            super(0);
        }

        @NotNull
        public final v0.b m159invoke() {
            GooglePayPaymentMethodLauncherContract.Args args;
            Application application = GooglePayPaymentMethodLauncherActivity.this.getApplication();
            Intrinsics.checkNotNullExpressionValue(application, "application");
            args = GooglePayPaymentMethodLauncherActivity.this.args;
            if (args == null) {
                Intrinsics.throwUninitializedPropertyAccessException("args");
                args = null;
            }
            return new GooglePayPaymentMethodLauncherViewModel.Factory(application, args, GooglePayPaymentMethodLauncherActivity.this, null, 8, null);
        }
    });

    @Metadata
    public static final class Companion {
        public Companion(DefaultConstructorMarker defaultConstructorMarker) {
            this();
        }

        private Companion() {
        }
    }

    private final void disableAnimations() {
        overridePendingTransition(0, 0);
    }

    public final void finishWithResult(GooglePayPaymentMethodLauncher.Result result) {
        setResult(-1, new Intent().putExtras(Q1.c.a(new Pair[]{new Pair("extra_result", result)})));
        finish();
    }

    public final GooglePayPaymentMethodLauncherViewModel getViewModel() {
        return (GooglePayPaymentMethodLauncherViewModel) this.viewModel$delegate.getValue();
    }

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

    public final void launchGooglePay(Task<PaymentData> task) {
        Ee.c.a(task, this);
    }

    public static final void m156onCreate$lambda0(GooglePayPaymentMethodLauncherActivity googlePayPaymentMethodLauncherActivity, GooglePayPaymentMethodLauncher.Result result) {
        Intrinsics.checkNotNullParameter(googlePayPaymentMethodLauncherActivity, "this$0");
        if (result != null) {
            googlePayPaymentMethodLauncherActivity.finishWithResult(result);
        }
    }

    private final void onGooglePayResult(Intent intent) {
        if (intent != null) {
            Parcelable.Creator creator = PaymentData.CREATOR;
            byte[] byteArrayExtra = intent.getByteArrayExtra("com.google.android.gms.wallet.PaymentData");
            PaymentData paymentData = (PaymentData) (byteArrayExtra == null ? null : he.b.a(byteArrayExtra, creator));
            if (paymentData != null) {
                g.b(J.a(this), (CoroutineContext) null, (dl.J) null, new GooglePayPaymentMethodLauncherActivity$onGooglePayResult$2$1(this, paymentData, null), 3);
                return;
            }
        }
        updateResult(new GooglePayPaymentMethodLauncher.Result.Failed(new IllegalArgumentException("Google Pay data was not available"), 1));
        Unit unit = Unit.a;
    }

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

    public void finish() {
        super/*android.app.Activity*/.finish();
        disableAnimations();
    }

    public void onActivityResult(int i, int i2, Intent intent) {
        super/*androidx.fragment.app.FragmentActivity*/.onActivityResult(i, i2, intent);
        if (i == LOAD_PAYMENT_DATA_REQUEST_CODE) {
            if (i2 == -1) {
                onGooglePayResult(intent);
                return;
            }
            if (i2 == 0) {
                updateResult(GooglePayPaymentMethodLauncher.Result.Canceled.INSTANCE);
                return;
            }
            if (i2 != 1) {
                updateResult(new GooglePayPaymentMethodLauncher.Result.Failed(new RuntimeException("Google Pay returned an expected result code."), 1));
                return;
            }
            int i3 = Ee.c.c;
            Status parcelableExtra = intent == null ? null : intent.getParcelableExtra("com.google.android.gms.common.api.AutoResolveHelper.status");
            String str = parcelableExtra != null ? parcelableExtra.b : null;
            if (str == null) {
                str = CameraView.FILL_ASPECT_RATIO;
            }
            StringBuilder sb = new StringBuilder("Google Pay failed with error ");
            sb.append(parcelableExtra != null ? Integer.valueOf(parcelableExtra.a) : null);
            sb.append(": ");
            sb.append(str);
            updateResult(new GooglePayPaymentMethodLauncher.Result.Failed(new RuntimeException(sb.toString()), parcelableExtra != null ? googlePayStatusCodeToErrorCode(parcelableExtra.a) : 1));
        }
    }

    public void onCreate(Bundle bundle) {
        super/*androidx.fragment.app.FragmentActivity*/.onCreate(bundle);
        int intExtra = getIntent().getIntExtra("extra_status_bar_color", -1);
        if (intExtra != -1) {
            getWindow().setStatusBarColor(intExtra);
        }
        disableAnimations();
        GooglePayPaymentMethodLauncherContract.Args.Companion companion = GooglePayPaymentMethodLauncherContract.Args.Companion;
        Intent intent = getIntent();
        Intrinsics.checkNotNullExpressionValue(intent, "intent");
        GooglePayPaymentMethodLauncherContract.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;
        getViewModel().getGooglePayResult$payments_core_release().observe(this, new T() {
            public final void onChanged(Object obj) {
                GooglePayPaymentMethodLauncherActivity.m156onCreate$lambda0(GooglePayPaymentMethodLauncherActivity.this, (GooglePayPaymentMethodLauncher.Result) obj);
            }
        });
        if (getViewModel().getHasLaunched$payments_core_release()) {
            return;
        }
        g.b(J.a(this), (CoroutineContext) null, (dl.J) null, new GooglePayPaymentMethodLauncherActivity$onCreate$2(this, null), 3);
    }
}