导航菜单

页面标题

页面副标题

BodyTech v7.6.4 - PaymentFlowActivity.java 源代码

正在查看: BodyTech v7.6.4 应用的 PaymentFlowActivity.java JAVA 源代码文件

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


package com.stripe.android.view;

import android.content.Intent;
import android.os.Bundle;
import android.os.Parcelable;
import android.view.View;
import android.view.ViewGroup;
import androidx.activity.OnBackPressedCallback;
import androidx.activity.OnBackPressedDispatcher;
import androidx.activity.OnBackPressedDispatcherKt;
import androidx.compose.runtime.internal.StabilityInferred;
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 androidx.viewpager.widget.ViewPager;
import com.stripe.android.PaymentSessionConfig;
import com.stripe.android.model.PaymentMethod;
import com.stripe.android.model.ShippingInformation;
import com.stripe.android.model.ShippingMethod;
import com.stripe.android.view.Args;
import com.stripe.android.view.PaymentFlowViewModel;
import java.util.List;
import java.util.Set;
import kotlin.Lazy;
import kotlin.Metadata;
import kotlin.Unit;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.functions.Function1;
import kotlinx.coroutines.BuildersKt__Builders_commonKt;

@StabilityInferred(parameters = 0)
@Metadata(d1 = {"\u0000\u008e\u0001\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010 \n\u0002\u0018\u0002\n\u0002\b\u0006\n\u0002\u0010\u000b\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u0003\n\u0002\b\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\u0018\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b\f\b\u0007\u0018\u0000 N2\u00020\u0001:\u0001OB\u0007¢\u0006\u0004\bL\u0010MJ\u0012\u0010\u0005\u001a\u00020\u00042\b\u0010\u0003\u001a\u0004\u0018\u00010\u0002H\u0014J\b\u0010\u0006\u001a\u00020\u0004H\u0016J)\u0010\f\u001a\u00020\u00042\b\u0010\b\u001a\u0004\u0018\u00010\u00072\u000e\b\u0002\u0010\u000b\u001a\b\u0012\u0004\u0012\u00020\n0\tH\u0000¢\u0006\u0004\b\f\u0010\rJ\u0016\u0010\u000e\u001a\u00020\u00042\f\u0010\u000b\u001a\b\u0012\u0004\u0012\u00020\n0\tH\u0002J\u0016\u0010\u000f\u001a\u00020\u00042\f\u0010\u000b\u001a\b\u0012\u0004\u0012\u00020\n0\tH\u0002J\b\u0010\u0010\u001a\u00020\u0004H\u0002J\b\u0010\u0012\u001a\u00020\u0011H\u0002J\b\u0010\u0013\u001a\u00020\u0011H\u0002J\b\u0010\u0014\u001a\u00020\u0004H\u0002J\"\u0010\u0019\u001a\u00020\u00042\u0006\u0010\u0016\u001a\u00020\u00152\b\u0010\u0018\u001a\u0004\u0018\u00010\u00172\u0006\u0010\b\u001a\u00020\u0007H\u0002J\u0010\u0010\u001c\u001a\u00020\u00042\u0006\u0010\u001b\u001a\u00020\u001aH\u0002J\u0010\u0010\u001f\u001a\u00020\u00042\u0006\u0010\u001e\u001a\u00020\u001dH\u0002R\u001b\u0010%\u001a\u00020 8BX\u0082\u0084\u0002¢\u0006\f\n\u0004\b!\u0010\"\u001a\u0004\b#\u0010$R\u001b\u0010*\u001a\u00020&8BX\u0082\u0084\u0002¢\u0006\f\n\u0004\b'\u0010\"\u001a\u0004\b(\u0010)R\u001b\u0010/\u001a\u00020+8BX\u0082\u0084\u0002¢\u0006\f\n\u0004\b,\u0010\"\u001a\u0004\b-\u0010.R\u001b\u00104\u001a\u0002008BX\u0082\u0084\u0002¢\u0006\f\n\u0004\b1\u0010\"\u001a\u0004\b2\u00103R\u001b\u00109\u001a\u0002058BX\u0082\u0084\u0002¢\u0006\f\n\u0004\b6\u0010\"\u001a\u0004\b7\u00108R\u001b\u0010>\u001a\u00020:8BX\u0082\u0084\u0002¢\u0006\f\n\u0004\b;\u0010\"\u001a\u0004\b<\u0010=R\u001b\u0010C\u001a\u00020?8BX\u0082\u0084\u0002¢\u0006\f\n\u0004\b@\u0010\"\u001a\u0004\bA\u0010BR\u001b\u0010H\u001a\u00020D8BX\u0082\u0084\u0002¢\u0006\f\n\u0004\bE\u0010\"\u001a\u0004\bF\u0010GR\u0016\u0010K\u001a\u0004\u0018\u00010\u00078BX\u0082\u0004¢\u0006\u0006\u001a\u0004\bI\u0010J¨\u0006P"}, d2 = {"Lcom/stripe/android/view/PaymentFlowActivity;", "Lcom/stripe/android/view/StripeActivity;", "Landroid/os/Bundle;", "savedInstanceState", "", "onCreate", "G", "Lcom/stripe/android/model/ShippingInformation;", "shippingInformation", "", "Lcom/stripe/android/model/ShippingMethod;", "shippingMethods", "h0", "(Lcom/stripe/android/model/ShippingInformation;Ljava/util/List;)V", "j0", "l0", "i0", "", "e0", "f0", "k0", "Lcom/stripe/android/PaymentSessionConfig$ShippingInformationValidator;", "shippingInfoValidator", "Lcom/stripe/android/PaymentSessionConfig$ShippingMethodsFactory;", "shippingMethodsFactory", "m0", "", "error", "g0", "Lcom/stripe/android/t;", "paymentSessionData", "U", "Luh/n;", "r", "Lkotlin/Lazy;", "b0", "()Luh/n;", "viewBinding", "Lcom/stripe/android/view/PaymentFlowViewPager;", "t", "d0", "()Lcom/stripe/android/view/PaymentFlowViewPager;", "viewPager", "Lcom/stripe/android/f;", "v", "W", "()Lcom/stripe/android/f;", "customerSession", "Lcom/stripe/android/view/e1;", "w", "V", "()Lcom/stripe/android/view/e1;", "args", "Lcom/stripe/android/PaymentSessionConfig;", "x", "Z", "()Lcom/stripe/android/PaymentSessionConfig;", "paymentSessionConfig", "Lcom/stripe/android/view/PaymentFlowViewModel;", "y", "c0", "()Lcom/stripe/android/view/PaymentFlowViewModel;", "viewModel", "Lcom/stripe/android/view/f1;", "z", "Y", "()Lcom/stripe/android/view/f1;", "paymentFlowPagerAdapter", "Lcom/stripe/android/view/z0;", "A", "X", "()Lcom/stripe/android/view/z0;", "keyboardController", "a0", "()Lcom/stripe/android/model/ShippingInformation;", "shippingInfo", "<init>", "()V", "B", "a", "payments-core_release"}, k = 1, mv = {1, 9, 0})
public final class PaymentFlowActivity extends StripeActivity {
    public static final int C = 8;

    private final Lazy keyboardController;

    private final Lazy viewBinding;

    private final Lazy viewPager;

    private final Lazy customerSession;

    private final Lazy args;

    private final Lazy paymentSessionConfig;

    private final Lazy viewModel;

    private final Lazy paymentFlowPagerAdapter;

    public PaymentFlowActivity() {
        Lazy b2;
        Lazy b3;
        Lazy b4;
        Lazy b5;
        Lazy b6;
        Lazy b7;
        Lazy b8;
        b2 = kotlin.d.b(new Function0<uh.n>() {
            {
                super(0);
            }

            @Override
            public final uh.n invoke() {
                PaymentFlowActivity.this.F().setLayoutResource(com.stripe.android.a0.w);
                View inflate = PaymentFlowActivity.this.F().inflate();
                kotlin.jvm.internal.r.g(inflate, "null cannot be cast to non-null type android.view.ViewGroup");
                uh.n a = uh.n.a((ViewGroup) inflate);
                kotlin.jvm.internal.r.h(a, "bind(...)");
                return a;
            }
        });
        this.viewBinding = b2;
        b3 = kotlin.d.b(new Function0<PaymentFlowViewPager>() {
            {
                super(0);
            }

            @Override
            public final PaymentFlowViewPager invoke() {
                uh.n b0;
                b0 = PaymentFlowActivity.this.b0();
                PaymentFlowViewPager shippingFlowViewpager = b0.d;
                kotlin.jvm.internal.r.h(shippingFlowViewpager, "shippingFlowViewpager");
                return shippingFlowViewpager;
            }
        });
        this.viewPager = b3;
        b4 = kotlin.d.b(new Function0<com.stripe.android.f>() {
            @Override
            public final com.stripe.android.f invoke() {
                return com.stripe.android.f.a.a();
            }
        });
        this.customerSession = b4;
        b5 = kotlin.d.b(new Function0<Args>() {
            {
                super(0);
            }

            @Override
            public final Args invoke() {
                Args.Companion companion = Args.INSTANCE;
                Intent intent = PaymentFlowActivity.this.getIntent();
                kotlin.jvm.internal.r.h(intent, "getIntent(...)");
                return companion.a(intent);
            }
        });
        this.args = b5;
        b6 = kotlin.d.b(new Function0<PaymentSessionConfig>() {
            {
                super(0);
            }

            @Override
            public final PaymentSessionConfig invoke() {
                Args V;
                V = PaymentFlowActivity.this.V();
                return V.getPaymentSessionConfig();
            }
        });
        this.paymentSessionConfig = b6;
        final Function0 function0 = null;
        this.viewModel = new ViewModelLazy(kotlin.jvm.internal.v.b(PaymentFlowViewModel.class), new Function0<ViewModelStore>() {
            {
                super(0);
            }

            @Override
            public final ViewModelStore invoke() {
                return this.getViewModelStore();
            }
        }, new Function0<ViewModelProvider.Factory>() {
            {
                super(0);
            }

            @Override
            public final ViewModelProvider.Factory invoke() {
                com.stripe.android.f W;
                Args V;
                W = PaymentFlowActivity.this.W();
                V = PaymentFlowActivity.this.V();
                return new PaymentFlowViewModel.b(W, V.getPaymentSessionData());
            }
        }, new Function0<CreationExtras>() {
            {
                super(0);
            }

            @Override
            public final CreationExtras invoke() {
                CreationExtras creationExtras;
                Function0 function02 = Function0.this;
                return (function02 == null || (creationExtras = (CreationExtras) function02.invoke()) == null) ? this.getDefaultViewModelCreationExtras() : creationExtras;
            }
        });
        b7 = kotlin.d.b(new Function0<f1>() {
            {
                super(0);
            }

            @Override
            public final f1 invoke() {
                PaymentSessionConfig Z;
                PaymentSessionConfig Z2;
                ?? r1 = PaymentFlowActivity.this;
                Z = r1.Z();
                Z2 = PaymentFlowActivity.this.Z();
                Set b9 = Z2.b();
                final PaymentFlowActivity paymentFlowActivity = PaymentFlowActivity.this;
                return new f1(r1, Z, b9, new Function1<ShippingMethod, Unit>() {
                    {
                        super(1);
                    }

                    public final void a(ShippingMethod it) {
                        kotlin.jvm.internal.r.i(it, "it");
                        PaymentFlowActivity.this.c0().j(it);
                    }

                    @Override
                    public Unit invoke(ShippingMethod shippingMethod) {
                        a(shippingMethod);
                        return Unit.a;
                    }
                });
            }
        });
        this.paymentFlowPagerAdapter = b7;
        b8 = kotlin.d.b(new Function0<z0>() {
            {
                super(0);
            }

            @Override
            public final z0 invoke() {
                return new z0(PaymentFlowActivity.this);
            }
        });
        this.keyboardController = b8;
    }

    private final void U(com.stripe.android.t paymentSessionData) {
        setResult(-1, new Intent().putExtra("extra_payment_session_data", (Parcelable) paymentSessionData));
        finish();
    }

    public final Args V() {
        return (Args) this.args.getValue();
    }

    public final com.stripe.android.f W() {
        return (com.stripe.android.f) this.customerSession.getValue();
    }

    private final z0 X() {
        return (z0) this.keyboardController.getValue();
    }

    public final f1 Y() {
        return (f1) this.paymentFlowPagerAdapter.getValue();
    }

    public final PaymentSessionConfig Z() {
        return (PaymentSessionConfig) this.paymentSessionConfig.getValue();
    }

    private final ShippingInformation a0() {
        return ((ShippingInfoWidget) d0().findViewById(com.stripe.android.y.k0)).getShippingInformation();
    }

    public final uh.n b0() {
        return (uh.n) this.viewBinding.getValue();
    }

    public final PaymentFlowViewModel c0() {
        return (PaymentFlowViewModel) this.viewModel.getValue();
    }

    public final PaymentFlowViewPager d0() {
        return (PaymentFlowViewPager) this.viewPager.getValue();
    }

    private final boolean e0() {
        return d0().getCurrentItem() + 1 < Y().getCount();
    }

    public final boolean f0() {
        return d0().getCurrentItem() != 0;
    }

    public final void g0(Throwable error) {
        String message = error.getMessage();
        I(false);
        if (message == null || message.length() == 0) {
            String string = getString(com.stripe.android.c0.x0);
            kotlin.jvm.internal.r.h(string, "getString(...)");
            J(string);
        } else {
            J(message);
        }
        c0().i(com.stripe.android.t.c(c0().getPaymentSessionData(), false, false, 0L, 0L, (ShippingInformation) null, (ShippingMethod) null, (PaymentMethod) null, false, 239, (Object) null));
    }

    private final void i0() {
        X().a();
        ShippingInformation a0 = a0();
        if (a0 != null) {
            c0().i(com.stripe.android.t.c(c0().getPaymentSessionData(), false, false, 0L, 0L, a0, (ShippingMethod) null, (PaymentMethod) null, false, 239, (Object) null));
            I(true);
            m0(Z().i(), Z().m(), a0);
        }
    }

    public final void j0(List<ShippingMethod> shippingMethods) {
        ShippingInformation e = c0().getPaymentSessionData().e();
        if (e != null) {
            BuildersKt__Builders_commonKt.launch$default(LifecycleOwnerKt.getLifecycleScope(this), null, null, new PaymentFlowActivity$onShippingInfoValidated$1$1(this, e, shippingMethods, null), 3, null);
        }
    }

    private final void k0() {
        U(com.stripe.android.t.c(c0().getPaymentSessionData(), false, false, 0L, 0L, (ShippingInformation) null, ((SelectShippingMethodWidget) d0().findViewById(com.stripe.android.y.h0)).getSelectedShippingMethod(), (PaymentMethod) null, false, 223, (Object) null));
    }

    private final void l0(List<ShippingMethod> shippingMethods) {
        I(false);
        Y().i(shippingMethods);
        Y().g(true);
        if (!e0()) {
            U(c0().getPaymentSessionData());
            return;
        }
        PaymentFlowViewModel c0 = c0();
        c0.h(c0.getCurrentPage() + 1);
        d0().setCurrentItem(c0().getCurrentPage());
    }

    private final void m0(PaymentSessionConfig.ShippingInformationValidator shippingInfoValidator, PaymentSessionConfig.ShippingMethodsFactory shippingMethodsFactory, ShippingInformation shippingInformation) {
        BuildersKt__Builders_commonKt.launch$default(LifecycleOwnerKt.getLifecycleScope(this), null, null, new PaymentFlowActivity$validateShippingInformation$1(this, shippingInfoValidator, shippingMethodsFactory, shippingInformation, null), 3, null);
    }

    @Override
    public void G() {
        if (PaymentFlowPage.c == Y().b(d0().getCurrentItem())) {
            i0();
        } else {
            k0();
        }
    }

    public final void h0(ShippingInformation shippingInformation, List shippingMethods) {
        kotlin.jvm.internal.r.i(shippingMethods, "shippingMethods");
        l0(shippingMethods);
        c0().i(com.stripe.android.t.c(c0().getPaymentSessionData(), false, false, 0L, 0L, shippingInformation, (ShippingMethod) null, (PaymentMethod) null, false, 239, (Object) null));
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (com.stripe.android.utils.a.a(this, new Function0<Unit>() {
            {
                super(0);
            }

            @Override
            public Unit invoke() {
                invoke2();
                return Unit.a;
            }

            public final void invoke2() {
                PaymentFlowActivity.this.V();
            }
        })) {
            return;
        }
        Args.Companion companion = Args.INSTANCE;
        Intent intent = getIntent();
        kotlin.jvm.internal.r.h(intent, "getIntent(...)");
        Integer windowFlags = companion.a(intent).getWindowFlags();
        if (windowFlags != null) {
            getWindow().addFlags(windowFlags.intValue());
        }
        ShippingInformation submittedShippingInfo = c0().getSubmittedShippingInfo();
        if (submittedShippingInfo == null) {
            submittedShippingInfo = Z().g();
        }
        Y().i(c0().d());
        Y().g(c0().getIsShippingInfoSubmitted());
        Y().h(submittedShippingInfo);
        Y().f(c0().getSelectedShippingMethod());
        OnBackPressedDispatcher onBackPressedDispatcher = getOnBackPressedDispatcher();
        kotlin.jvm.internal.r.h(onBackPressedDispatcher, "<get-onBackPressedDispatcher>(...)");
        OnBackPressedCallback addCallback$default = OnBackPressedDispatcherKt.addCallback$default(onBackPressedDispatcher, (LifecycleOwner) null, false, new Function1<OnBackPressedCallback, Unit>() {
            {
                super(1);
            }

            @Override
            public Unit invoke(OnBackPressedCallback onBackPressedCallback) {
                invoke2(onBackPressedCallback);
                return Unit.a;
            }

            public final void invoke2(OnBackPressedCallback addCallback) {
                PaymentFlowViewPager d0;
                kotlin.jvm.internal.r.i(addCallback, "$this$addCallback");
                PaymentFlowActivity.this.c0().h(r2.getCurrentPage() - 1);
                d0 = PaymentFlowActivity.this.d0();
                d0.setCurrentItem(PaymentFlowActivity.this.c0().getCurrentPage());
            }
        }, 3, (Object) null);
        d0().setAdapter(Y());
        d0().addOnPageChangeListener(new b(addCallback$default));
        d0().setCurrentItem(c0().getCurrentPage());
        addCallback$default.setEnabled(f0());
        setTitle(Y().getPageTitle(d0().getCurrentItem()));
    }

    @Metadata(d1 = {"\u0000\u001f\n\u0000\n\u0002\u0018\u0002\n\u0002\u0010\b\n\u0000\n\u0002\u0010\u0007\n\u0002\b\u0002\n\u0002\u0010\u0002\n\u0002\b\u0004*\u0001\u0000\b\n\u0018\u00002\u00020\u0001J \u0010\b\u001a\u00020\u00072\u0006\u0010\u0003\u001a\u00020\u00022\u0006\u0010\u0005\u001a\u00020\u00042\u0006\u0010\u0006\u001a\u00020\u0002H\u0016J\u0010\u0010\t\u001a\u00020\u00072\u0006\u0010\u0003\u001a\u00020\u0002H\u0016J\u0010\u0010\n\u001a\u00020\u00072\u0006\u0010\u0003\u001a\u00020\u0002H\u0016¨\u0006\u000b"}, d2 = {"com/stripe/android/view/PaymentFlowActivity$b", "Landroidx/viewpager/widget/ViewPager$OnPageChangeListener;", "", "i", "", "v", "i1", "", "onPageScrolled", "onPageSelected", "onPageScrollStateChanged", "payments-core_release"}, k = 1, mv = {1, 9, 0})
    public static final class b implements ViewPager.OnPageChangeListener {
        final OnBackPressedCallback b;

        b(OnBackPressedCallback onBackPressedCallback) {
            this.b = onBackPressedCallback;
        }

        public void onPageSelected(int i) {
            ?? r0 = PaymentFlowActivity.this;
            r0.setTitle(r0.Y().getPageTitle(i));
            if (PaymentFlowActivity.this.Y().b(i) == PaymentFlowPage.c) {
                PaymentFlowActivity.this.c0().k(false);
                PaymentFlowActivity.this.Y().g(false);
            }
            this.b.setEnabled(PaymentFlowActivity.this.f0());
        }

        public void onPageScrollStateChanged(int i) {
        }

        public void onPageScrolled(int i, float v, int i1) {
        }
    }
}