导航菜单

页面标题

页面副标题

BodyTech v7.6.4 - POSSelectPaymentsActivity.java 源代码

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

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


package com.fitnessmobileapps.fma.views;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import androidx.annotation.Px;
import androidx.appcompat.widget.Toolbar;
import androidx.compose.ui.platform.ComposeView;
import androidx.fragment.app.FragmentManager;
import androidx.preference.PreferenceManager;
import androidx.recyclerview.widget.RecyclerView;
import com.fitnessmobileapps.bodytech39559.R;
import com.fitnessmobileapps.fma.core.compose.AddPaymentSelectionOptionKt;
import com.fitnessmobileapps.fma.core.compose.CustomAlertDialog;
import com.fitnessmobileapps.fma.core.compose.d;
import com.fitnessmobileapps.fma.core.feature.analytics.metrics.MetricsName;
import com.fitnessmobileapps.fma.core.flags.DevelopmentFlags;
import com.fitnessmobileapps.fma.feature.common.activity.BmaAppCompatActivity;
import com.fitnessmobileapps.fma.feature.common.navigation.ToolbarKt;
import com.fitnessmobileapps.fma.model.payment.AlternatePaymentsConfigData;
import com.fitnessmobileapps.fma.model.payment.AlternatePaymentsConfigDataKt;
import com.fitnessmobileapps.fma.util.POSCache;
import com.fitnessmobileapps.fma.views.fragments.adapters.h;
import com.fitnessmobileapps.fma.views.fragments.dialogs.i;
import com.fitnessmobileapps.fma.views.widgets.custom.MBLinearLayoutCompat;
import com.mindbodyonline.android.api.sales.model.payments.PaymentMethod;
import com.mindbodyonline.android.api.sales.model.pos.packages.CartPackage;
import com.mindbodyonline.connect.utils.POSPaymentUtils;
import java.math.BigDecimal;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import kotlin.Lazy;
import kotlin.Unit;
import kotlin.jvm.functions.Function1;
import lf.b;
import org.koin.android.compat.ViewModelCompat;
import org.koin.java.KoinJavaComponent;

public class POSSelectPaymentsActivity extends BmaAppCompatActivity {
    public static final String U;
    private static final String V;
    private static final String W;
    private static final String X;
    private static final String Y;
    private static final String Z;

    private static final String f10618a0;

    private static final String f10619b0;

    private static final String f10620c0;
    private TextView A;
    private TextView B;
    private RelativeLayout C;
    private CheckBox G;
    private TextView H;
    private TextView I;

    @Px
    private int J;
    private lf.b K;
    private lf.b L;
    private com.fitnessmobileapps.fma.views.fragments.dialogs.i M;
    private lf.b N;
    private lf.b O;
    private lf.b P;
    private com.fitnessmobileapps.fma.views.fragments.dialogs.b Q;
    private com.fitnessmobileapps.fma.views.fragments.dialogs.a R;

    private POSCache f10622e;

    private CartPackage f10623k;

    private BigDecimal f10624n;

    private NumberFormat f10625p;

    private TextView f10626q;

    private RecyclerView f10627r;

    private com.fitnessmobileapps.fma.views.fragments.adapters.h f10628t;

    private TextView f10629v;

    private ImageView f10630w;

    private MBLinearLayoutCompat f10631x;

    private RelativeLayout f10632y;

    private CheckBox f10633z;

    private final Lazy<com.fitnessmobileapps.fma.views.viewmodels.l> f10621d = ViewModelCompat.b(this, com.fitnessmobileapps.fma.views.viewmodels.l.class);
    private Lazy<com.fitnessmobileapps.fma.feature.buy.d> S = KoinJavaComponent.e(com.fitnessmobileapps.fma.feature.buy.d.class);
    private Boolean T = Boolean.FALSE;

    static {
        String simpleName = POSSelectPaymentsActivity.class.getSimpleName();
        U = simpleName + ".ARG_POS_CACHE";
        V = simpleName + ".ACCEPTED_CARDS_DIALOG";
        W = simpleName + ".ERROR_DIALOG_TAG";
        X = simpleName + ".CONTRACT_DIALOG_TAG";
        Y = simpleName + ".CHOOSE_AUTOPAY_DIALOG_TAG";
        Z = simpleName + ".ADD_A_CARD_TAG";
        f10618a0 = simpleName + ".ACCOUNT_CREDIT_CONFIRMATION_DIALOG_TAG";
        f10619b0 = simpleName + ".GIFT_CARD_CONFIRMATION_DIALOG_TAG";
        f10620c0 = simpleName + ".CARD_ADDED_DIALOG_TAG";
    }

    private void A0(PaymentMethod paymentMethod) {
        if (this.f10623k == null || paymentMethod == null || !POSPaymentUtils.n(this.f10622e.c())) {
            return;
        }
        this.f10623k.setContractPaymentMethod(paymentMethod);
        PreferenceManager.getDefaultSharedPreferences(this).edit().putString(getString(R.string.last_used_contract_payment_method), this.f10623k.getContractPaymentMethod().getUniqueIdentifier()).apply();
    }

    private void B0() {
        int m02 = POSPaymentUtils.m0(this.f10622e.d(), this.f10623k, this.f10622e.c());
        if (m02 == 0) {
            U();
            return;
        }
        if (m02 == 1 || m02 == 4) {
            z0();
            return;
        }
        if (m02 != 6) {
            return;
        }
        List<PaymentMethod> k10 = this.f10622e.d().k();
        List<PaymentMethod> N = POSPaymentUtils.N(this.f10622e.e(), this.f10622e.b(), "CreditCard", null);
        if (k10.isEmpty() && N.isEmpty()) {
            this.N.U(getSupportFragmentManager());
        } else if (k10.isEmpty()) {
            q0();
            this.M.U(getSupportFragmentManager());
        } else {
            p0();
            this.L.U(getSupportFragmentManager());
        }
    }

    private void O() {
        this.f10632y = (RelativeLayout) findViewById(R.id.layout_account_credit);
        this.f10633z = (CheckBox) findViewById(R.id.checkbox_account_credit);
        this.A = (TextView) findViewById(R.id.text_account_credit);
        this.B = (TextView) findViewById(R.id.text_account_credit_amount);
    }

    private void P() {
        this.C = (RelativeLayout) findViewById(R.id.layout_gift_card);
        this.G = (CheckBox) findViewById(R.id.checkbox_gift_card);
        this.H = (TextView) findViewById(R.id.text_gift_card);
        this.I = (TextView) findViewById(R.id.text_gift_card_amount);
    }

    private void Q(POSCache pOSCache) {
        if (POSPaymentUtils.n(pOSCache.c())) {
            new CustomAlertDialog().a(new d.RecurringPaymentAlert(this), null);
        }
    }

    public static Intent R(Context context, POSCache pOSCache, Boolean bool) {
        Intent intent = new Intent(context, (Class<?>) POSSelectPaymentsActivity.class);
        intent.putExtra(U, pOSCache.j());
        intent.putExtra("isGooglePayReady", bool);
        return intent;
    }

    private void S() {
        CartPackage o02 = POSPaymentUtils.o0(this.f10622e.c());
        this.f10623k = o02;
        if (o02 != null) {
            o02.setContractPaymentMethod(null);
        }
    }

    private void T() {
        this.f10624n = this.f10622e.c().getTotals().getTotal();
    }

    private void U() {
        if (DevelopmentFlags.V.d()) {
            c2.c.f1548a.a(System.currentTimeMillis(), MetricsName.CHANGE_PAYMENT_METHOD, null);
        }
        if (this.f10621d.getValue().b()) {
            this.f10621d.getValue().c(this.f10622e);
        } else {
            Intent intent = new Intent();
            intent.putExtra(U, this.f10622e.j());
            setResult(-1, intent);
        }
        finish();
    }

    public void V(CompoundButton compoundButton, boolean z10) {
        POSPaymentUtils.r0(this.f10622e.b(), this.f10622e.d());
        T();
        l0(z10);
        this.f10628t.g(this.f10624n);
        r0();
    }

    public void W(View view) {
        POSPaymentUtils.t(this.f10622e.b());
        this.f10624n.subtract(POSPaymentUtils.F(this.f10622e.c(), "CreditCard", true));
        if (this.f10633z.isChecked()) {
            this.f10633z.toggle();
        } else {
            m0();
            this.O.U(getSupportFragmentManager());
        }
    }

    public void X(lf.b bVar, View view) {
        bVar.dismiss();
        this.f10633z.toggle();
    }

    public void Y(lf.b bVar, View view) {
        startActivityForResult(AddPaymentCardActivity.B0(this, this.f10622e.e(), Boolean.FALSE), 444);
        bVar.dismiss();
    }

    public Unit Z(String str) {
        if (str.equals("CreditCard")) {
            startActivityForResult(AddPaymentCardActivity.B0(this, this.f10622e.e(), Boolean.FALSE), 444);
        } else {
            if (this.f10621d.getValue().b()) {
                this.f10621d.getValue().d(this.f10622e, str);
            } else {
                setResult(48238492, new Intent().putExtra("paymentMethodType", str));
            }
            finish();
        }
        return Unit.f33247a;
    }

    public void a0(View view) {
        startActivityForResult(AddPaymentCardActivity.B0(this, this.f10622e.e(), Boolean.FALSE), 444);
    }

    public void b0(View view) {
        this.R.U(getSupportFragmentManager());
    }

    public void c0(PaymentMethod paymentMethod, lf.b bVar, View view) {
        A0(paymentMethod);
        bVar.dismiss();
        B0();
    }

    public void d0(List list, com.fitnessmobileapps.fma.views.fragments.dialogs.i iVar, int i10, String str) {
        A0((PaymentMethod) list.get(i10));
        iVar.dismiss();
        B0();
    }

    public void e0(CompoundButton compoundButton, boolean z10) {
        POSPaymentUtils.s0(this.f10622e.b(), this.f10622e.d());
        T();
        s0(z10);
        this.f10628t.g(this.f10624n);
        k0();
    }

    public void f0(View view) {
        BigDecimal w10 = POSPaymentUtils.w(this.f10622e.b(), "GiftCard");
        BigDecimal subtract = this.f10624n.subtract(POSPaymentUtils.F(this.f10622e.c(), "CreditCard", true));
        if (this.G.isChecked() || w10.compareTo(subtract) > 0) {
            this.G.toggle();
        } else {
            t0();
            this.P.U(getSupportFragmentManager());
        }
    }

    public void g0(lf.b bVar, View view) {
        bVar.dismiss();
        this.G.toggle();
    }

    public void h0(boolean z10, PaymentMethod paymentMethod) {
        k0();
        r0();
    }

    public void i0(View view) {
        finish();
    }

    private void j0(Bundle bundle) {
        this.f10622e = new POSCache(bundle.getBundle(U));
        if (bundle.containsKey("isGooglePayReady")) {
            this.T = Boolean.valueOf(bundle.getBoolean("isGooglePayReady"));
        }
    }

    private void k0() {
        PaymentMethod t10 = POSPaymentUtils.t(this.f10622e.b());
        boolean z10 = POSPaymentUtils.t(this.f10622e.d().q()) != null;
        BigDecimal balance = t10 != null ? t10.getBalance() : BigDecimal.ZERO;
        this.f10632y.setVisibility(balance.compareTo(BigDecimal.ZERO) > 0 ? 0 : 8);
        this.A.setText(com.fitnessmobileapps.fma.util.w0.a(this, getString(R.string.account_credit_label), getString(R.string.balance, this.f10625p.format(balance)), this.J, false, R.color.grey_3));
        this.f10633z.setOnCheckedChangeListener(null);
        this.f10633z.setChecked(z10);
        this.f10633z.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public final void onCheckedChanged(CompoundButton compoundButton, boolean z11) {
                POSSelectPaymentsActivity.this.V(compoundButton, z11);
            }
        });
        m0();
        l0(this.f10633z.isChecked());
        this.f10632y.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                POSSelectPaymentsActivity.this.W(view);
            }
        });
    }

    private void l0(boolean z10) {
        this.B.setText(z10 ? this.f10625p.format(this.f10622e.d().j(POSPaymentUtils.t(this.f10622e.b()))) : "");
    }

    private void m0() {
        this.O = com.fitnessmobileapps.fma.util.w0.h(getSupportFragmentManager(), f10618a0, R.string.message_account_credit_usage, new b.d() {
            @Override
            public final void a(lf.b bVar, View view) {
                POSSelectPaymentsActivity.this.X(bVar, view);
            }
        });
    }

    private void n0() {
        lf.b c10 = com.fitnessmobileapps.fma.util.w0.c(getSupportFragmentManager(), this.f10623k != null, Z);
        this.N = c10;
        c10.P(new b.d() {
            @Override
            public final void a(lf.b bVar, View view) {
                POSSelectPaymentsActivity.this.Y(bVar, view);
            }
        });
    }

    private void o0() {
        AlternatePaymentsConfigData alternatePaymentsConfigData = AlternatePaymentsConfigDataKt.getAlternatePaymentsConfigData(this.S.getValue().invoke(Unit.f33247a).booleanValue(), this.T.booleanValue(), POSPaymentUtils.n(this.f10622e.c()), this.f10622e);
        if (alternatePaymentsConfigData.isAnyAPMFlagEnabled() && !y0()) {
            findViewById(R.id.add_card_container).setVisibility(8);
            AddPaymentSelectionOptionKt.d((ComposeView) findViewById(R.id.alternate_payment_choose), new Function1() {
                @Override
                public final Object invoke(Object obj) {
                    Unit Z2;
                    Z2 = POSSelectPaymentsActivity.this.Z((String) obj);
                    return Z2;
                }
            }, alternatePaymentsConfigData);
            return;
        }
        TextView textView = (TextView) findViewById(R.id.label_add_card);
        this.f10629v = textView;
        textView.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                POSSelectPaymentsActivity.this.a0(view);
            }
        });
        this.f10630w = (ImageView) findViewById(R.id.image_add_card_info);
        FragmentManager supportFragmentManager = getSupportFragmentManager();
        String str = V;
        com.fitnessmobileapps.fma.views.fragments.dialogs.a aVar = (com.fitnessmobileapps.fma.views.fragments.dialogs.a) supportFragmentManager.findFragmentByTag(str);
        this.R = aVar;
        if (aVar == null) {
            this.R = com.fitnessmobileapps.fma.views.fragments.dialogs.a.X(this.f10622e.e()).V(R.string.accepted_here_title).M(android.R.string.ok).D(str);
        }
        this.f10630w.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                POSSelectPaymentsActivity.this.b0(view);
            }
        });
    }

    private void p0() {
        final PaymentMethod q02 = POSPaymentUtils.q0(this.f10622e.e(), this.f10622e.d().q(), null);
        String upperCase = String.format("%s %s", q02.getCardType(), q02.getCardLastFour()).toUpperCase(Locale.getDefault());
        FragmentManager supportFragmentManager = getSupportFragmentManager();
        String str = X;
        lf.b bVar = (lf.b) supportFragmentManager.findFragmentByTag(str);
        this.L = bVar;
        if (bVar == null) {
            this.L = new lf.b().V(R.string.recurring_payment_title).I(getString(R.string.recurring_payment_message, upperCase)).G(true).M(android.R.string.ok).J(android.R.string.cancel).D(str);
        }
        this.L.P(new b.d() {
            @Override
            public final void a(lf.b bVar2, View view) {
                POSSelectPaymentsActivity.this.c0(q02, bVar2, view);
            }
        });
    }

    private void q0() {
        ArrayList arrayList = new ArrayList();
        final List<PaymentMethod> N = POSPaymentUtils.N(this.f10622e.e(), this.f10622e.b(), "CreditCard", null);
        for (PaymentMethod paymentMethod : N) {
            arrayList.add(String.format("%s %s", paymentMethod.getCardType(), paymentMethod.getCardLastFour()).toUpperCase(Locale.getDefault()));
        }
        FragmentManager supportFragmentManager = getSupportFragmentManager();
        String str = Y;
        com.fitnessmobileapps.fma.views.fragments.dialogs.i iVar = (com.fitnessmobileapps.fma.views.fragments.dialogs.i) supportFragmentManager.findFragmentByTag(str);
        this.M = iVar;
        if (iVar == null) {
            this.M = new com.fitnessmobileapps.fma.views.fragments.dialogs.i().Z(arrayList).V(R.string.select_card_title).H(R.string.select_card_message).J(android.R.string.cancel).D(str);
        }
        this.M.b0(new i.b() {
            @Override
            public final void a(com.fitnessmobileapps.fma.views.fragments.dialogs.i iVar2, int i10, String str2) {
                POSSelectPaymentsActivity.this.d0(N, iVar2, i10, str2);
            }
        });
    }

    private void r0() {
        boolean z10 = !POSPaymentUtils.J(this.f10622e.d().q()).isEmpty();
        BigDecimal w10 = POSPaymentUtils.w(this.f10622e.b(), "GiftCard");
        this.C.setVisibility(w10.compareTo(BigDecimal.ZERO) > 0 ? 0 : 8);
        this.H.setText(com.fitnessmobileapps.fma.util.w0.a(this, getString(R.string.gift_card_label), getString(R.string.balance, this.f10625p.format(w10)), this.J, false, R.color.grey_3));
        this.G.setOnCheckedChangeListener(null);
        this.G.setChecked(z10);
        this.G.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public final void onCheckedChanged(CompoundButton compoundButton, boolean z11) {
                POSSelectPaymentsActivity.this.e0(compoundButton, z11);
            }
        });
        t0();
        s0(this.G.isChecked());
        this.G.setChecked(z10);
        this.C.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                POSSelectPaymentsActivity.this.f0(view);
            }
        });
    }

    private void t0() {
        this.P = com.fitnessmobileapps.fma.util.w0.h(getSupportFragmentManager(), f10619b0, R.string.message_gift_card_usage, new b.d() {
            @Override
            public final void a(lf.b bVar, View view) {
                POSSelectPaymentsActivity.this.g0(bVar, view);
            }
        });
    }

    private void u0() {
        RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recyclerview_payment_methods);
        this.f10627r = recyclerView;
        recyclerView.setNestedScrollingEnabled(false);
        if (this.f10628t == null) {
            this.f10628t = new com.fitnessmobileapps.fma.views.fragments.adapters.h(this.f10622e, this.f10624n, new h.a() {
                @Override
                public final void a(boolean z10, PaymentMethod paymentMethod) {
                    POSSelectPaymentsActivity.this.h0(z10, paymentMethod);
                }
            });
        }
        if (this.f10627r.getAdapter() != null) {
            RecyclerView.Adapter adapter = this.f10627r.getAdapter();
            com.fitnessmobileapps.fma.views.fragments.adapters.h hVar = this.f10628t;
            if (adapter == hVar) {
                hVar.f(this.f10622e);
                this.f10628t.notifyDataSetChanged();
                return;
            }
        }
        this.f10627r.addItemDecoration(new r6.a(this, R.drawable.list_divider, 1));
        this.f10627r.setAdapter(this.f10628t);
    }

    private void v0() {
        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);
        if (getSupportActionBar() != null) {
            getSupportActionBar().setTitle(R.string.select_payments_title);
        }
        ToolbarKt.j(toolbar, new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                POSSelectPaymentsActivity.this.i0(view);
            }
        });
    }

    private void w0() {
        if (this.f10626q == null) {
            this.f10626q = (TextView) findViewById(R.id.label_order_total_amount);
        }
        this.f10626q.setText(this.f10625p.format(this.f10624n));
    }

    private void x0() {
        w0();
        P();
        r0();
        O();
        k0();
        if (of.b0.e(this.S.getValue().invoke(Unit.f33247a).booleanValue()) && of.b0.c(this.f10622e.c())) {
            this.f10631x.setVisibility(8);
        } else {
            this.f10631x.setVisibility((this.f10632y.getVisibility() == 8 && this.C.getVisibility() == 8) ? 8 : 0);
        }
        u0();
        o0();
        n0();
    }

    private boolean y0() {
        BigDecimal total = this.f10622e.c().getTotals().getTotal();
        return total != null && total.compareTo(BigDecimal.ZERO) < 1;
    }

    private void z0() {
        String K = POSPaymentUtils.K(this, this.f10622e.d());
        FragmentManager supportFragmentManager = getSupportFragmentManager();
        String str = W;
        lf.b bVar = (lf.b) supportFragmentManager.findFragmentByTag(str);
        this.K = bVar;
        if (bVar == null) {
            this.K = new lf.b().I(K).M(android.R.string.ok).D(str);
        }
        this.K.U(getSupportFragmentManager());
    }

    @Override
    protected void onActivityResult(int i10, int i11, Intent intent) {
        PaymentMethod paymentMethod;
        super.onActivityResult(i10, i11, intent);
        if (i10 == 444 && i11 == -1 && (paymentMethod = (PaymentMethod) cf.d.b(intent.getStringExtra("ADD_CARD_EXTRA"), PaymentMethod.class)) != null) {
            this.f10622e.a(paymentMethod);
            this.f10622e.d().b(paymentMethod);
            x0();
            this.Q.show(getSupportFragmentManager(), f10620c0);
        }
    }

    @Override
    protected void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        setContentView(R.layout.activity_pos_select_payments);
        this.f10625p = POSPaymentUtils.M();
        this.J = getResources().getDimensionPixelSize(R.dimen.subtext_font_size);
        Bundle extras = getIntent().getExtras();
        if (extras != null) {
            j0(extras);
            Q(this.f10622e);
        }
        if (bundle != null) {
            j0(bundle);
        }
        this.f10631x = (MBLinearLayoutCompat) findViewById(R.id.layout_account_credit_giftcard);
        T();
        S();
        v0();
        x0();
        this.Q = com.fitnessmobileapps.fma.util.w0.e(getSupportFragmentManager(), f10620c0, null);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.one_action_menu, menu);
        menu.findItem(R.id.menu_item).setTitle("Next");
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem menuItem) {
        if (menuItem.getItemId() == 16908332) {
            finish();
            return true;
        }
        if (menuItem.getItemId() == R.id.menu_item) {
            B0();
        }
        return super.onOptionsItemSelected(menuItem);
    }

    @Override
    protected void onSaveInstanceState(Bundle bundle) {
        super.onSaveInstanceState(bundle);
        bundle.putBundle(U, this.f10622e.j());
        bundle.putBoolean("isGooglePayReady", this.T.booleanValue());
    }

    public void s0(boolean z10) {
        this.I.setText(z10 ? this.f10625p.format(POSPaymentUtils.G(this.f10622e.d().l(), "GiftCard", false)) : "");
    }
}