导航菜单

页面标题

页面副标题

Rilo v2.0.21 - PaymentDetailsActivity.java 源代码

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

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


package app.callpe.ui.payment;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle;
import android.text.SpannableString;
import android.text.style.ForegroundColorSpan;
import android.text.style.StyleSpan;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.activity.ComponentActivity;
import androidx.activity.result.ActivityResult;
import androidx.activity.result.ActivityResultCallback;
import androidx.activity.result.ActivityResultLauncher;
import androidx.activity.result.contract.ActivityResultContract;
import androidx.activity.result.contract.ActivityResultContracts;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.widget.Toolbar;
import androidx.core.content.ContextCompat;
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 app.callpe.adapters.CardAppAdapter;
import app.callpe.adapters.CurrencyAdapter;
import app.callpe.adapters.ParentPaymentMethodsAdapter;
import app.callpe.adapters.UPIAppAdapter;
import app.callpe.common.utils.Constants;
import app.callpe.common.utils.custom.CustomLinearLayoutManager;
import app.callpe.common.utils.extensions.ActivityExtKt;
import app.callpe.common.utils.extensions.ListExtKt;
import app.callpe.common.utils.extensions.NumberExtKt;
import app.callpe.common.utils.helper_functions.AnalyticsHelper;
import app.callpe.common.utils.sharedpref.PrefKeys;
import app.callpe.common.utils.sharedpref.SharedPref;
import app.callpe.data.model.CouponCodeModel;
import app.callpe.data.model.ExcludedApp;
import app.callpe.data.model.PaymentMethodChildV3;
import app.callpe.data.model.PaymentMethodParentV3;
import app.callpe.data.model.TopUpModel;
import app.callpe.data.model.UPIApp;
import app.callpe.data.model.UpiType;
import app.callpe.databinding.ActivityPaymentDetailsBinding;
import app.callpe.ui.chat.ChatActivity;
import app.callpe.ui.chat.SupportChatActivity;
import app.callpe.ui.home.AccountViewModel;
import app.callpe.ui.home.BaseActivity;
import app.callpe.ui.home.StreamerDetailActivity;
import app.callpe.ui.home.UserAccountFragment;
import app.callpe.ui.home.fragments.ChatListFragment;
import app.callpe.ui.home.fragments.HomeFragment;
import app.callpe.ui.home.fragments.SystemChatListFragment;
import app.callpe.ui.livestreaming.bottomsheet.CouponAppliedSheet;
import app.callpe.ui.misc.BlockListActivity;
import com.facebook.internal.NativeProtocol;
import com.google.android.material.snackbar.Snackbar;
import com.google.gson.Gson;
import dagger.hilt.android.AndroidEntryPoint;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import kotlin.Lazy;
import kotlin.Metadata;
import kotlin.Unit;
import kotlin.collections.CollectionsKt;
import kotlin.comparisons.ComparisonsKt;
import kotlin.coroutines.CoroutineContext;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.functions.Function2;
import kotlin.jvm.internal.Intrinsics;
import kotlin.jvm.internal.Reflection;
import kotlin.jvm.internal.StringCompanionObject;
import kotlin.text.StringsKt;
import kotlinx.coroutines.BuildersKt;
import kotlinx.coroutines.CoroutineStart;
import kotlinx.coroutines.Job;
import timber.log.Timber;

@Metadata(d1 = {"\u0000è\u0001\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\b\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\u0010\u000e\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\t\n\u0000\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0010\u0006\n\u0000\n\u0002\u0010\u000b\n\u0002\b\u0007\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0010\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0003\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\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u0011\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0010\n\u0002\u0018\u0002\n\u0002\b\u0002\b\u0007\u0018\u0000 p2\b\u0012\u0004\u0012\u00020\u00020\u0001:\u0001pB\u0005¢\u0006\u0002\u0010\u0003J\u0016\u00103\u001a\u0002042\f\u00105\u001a\b\u0012\u0004\u0012\u00020706H\u0002J\b\u00108\u001a\u000204H\u0002J\b\u00109\u001a\u000204H\u0002J\b\u0010:\u001a\u00020;H\u0002J\u0014\u0010<\u001a\u0002042\n\b\u0002\u0010=\u001a\u0004\u0018\u00010\fH\u0002J\"\u0010>\u001a\u0012\u0012\u0004\u0012\u00020?06j\b\u0012\u0004\u0012\u00020?`@2\b\b\u0002\u0010A\u001a\u00020\u001eH\u0002J\b\u0010B\u001a\u000204H\u0002J\u0010\u0010C\u001a\u0002042\u0006\u0010D\u001a\u00020EH\u0002JX\u0010F\u001a\u0002042\u0016\u0010G\u001a\u0012\u0012\u0004\u0012\u00020H06j\b\u0012\u0004\u0012\u00020H`@2\u001a\u0010I\u001a\u0016\u0012\u0004\u0012\u00020\f\u0018\u000106j\n\u0012\u0004\u0012\u00020\f\u0018\u0001`@2\u001a\u0010\u0018\u001a\u0016\u0012\u0004\u0012\u00020J\u0018\u000106j\n\u0012\u0004\u0012\u00020J\u0018\u0001`@H\u0002J)\u0010K\u001a\u00020L2\u0006\u0010M\u001a\u00020\f2\u0012\u0010N\u001a\n\u0012\u0006\b\u0001\u0012\u00020\f0O\"\u00020\fH\u0002¢\u0006\u0002\u0010PJ\u0010\u0010Q\u001a\u00020\u00022\u0006\u0010R\u001a\u00020SH\u0016J\b\u0010T\u001a\u000204H\u0002J\b\u0010U\u001a\u00020VH\u0002J\b\u0010W\u001a\u000204H\u0002J\u0012\u0010X\u001a\u0002042\b\u0010Y\u001a\u0004\u0018\u00010ZH\u0014J\b\u0010[\u001a\u000204H\u0014J\u0010\u0010\\\u001a\u00020\u001e2\u0006\u0010]\u001a\u00020^H\u0016J\u0010\u0010_\u001a\u0002042\u0006\u0010`\u001a\u00020ZH\u0014J\u0012\u0010a\u001a\u0002042\b\b\u0002\u0010b\u001a\u00020\u001eH\u0002J\u0010\u0010c\u001a\u0002042\u0006\u0010D\u001a\u00020EH\u0002J\u0010\u0010d\u001a\u0002042\u0006\u0010e\u001a\u00020EH\u0002J\b\u0010f\u001a\u000204H\u0002J\b\u0010g\u001a\u000204H\u0002J\u0014\u0010h\u001a\u0002042\n\b\u0002\u0010=\u001a\u0004\u0018\u00010\fH\u0002J\b\u0010i\u001a\u000204H\u0002J\u0010\u0010j\u001a\u0002042\u0006\u0010k\u001a\u00020\u0007H\u0002J\u001e\u0010l\u001a\u0002042\u0006\u0010m\u001a\u00020\f2\f\u0010n\u001a\b\u0012\u0004\u0012\u0002040oH\u0002R\u0010\u0010\u0004\u001a\u0004\u0018\u00010\u0005X\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u0006\u001a\u00020\u0007X\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u0010\b\u001a\u0004\u0018\u00010\tX\u0082\u000e¢\u0006\u0002\n\u0000R*\u0010\n\u001a\u001e\u0012\u0004\u0012\u00020\f\u0012\u0004\u0012\u00020\u00070\u000bj\u000e\u0012\u0004\u0012\u00020\f\u0012\u0004\u0012\u00020\u0007`\rX\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u0010\u000e\u001a\u0004\u0018\u00010\u000fX\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u0010\u001a\u00020\u0011X\u0082\u000e¢\u0006\u0002\n\u0000R\u001c\u0010\u0012\u001a\u0010\u0012\f\u0012\n \u0015*\u0004\u0018\u00010\u00140\u00140\u0013X\u0082\u0004¢\u0006\u0002\n\u0000R\u0010\u0010\u0016\u001a\u0004\u0018\u00010\u0017X\u0082\u000e¢\u0006\u0002\n\u0000R*\u0010\u0018\u001a\u001e\u0012\u0004\u0012\u00020\f\u0012\u0004\u0012\u00020\f0\u000bj\u000e\u0012\u0004\u0012\u00020\f\u0012\u0004\u0012\u00020\f`\rX\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u0019\u001a\u00020\u0007X\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u001a\u001a\u00020\u0007X\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u001b\u001a\u00020\u001cX\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u001d\u001a\u00020\u001eX\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u001f\u001a\u00020\u001eX\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010 \u001a\u00020\u001eX\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010!\u001a\u00020\u001eX\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\"\u001a\u00020\u0007X\u0082\u000e¢\u0006\u0002\n\u0000R\u001c\u0010#\u001a\u0010\u0012\f\u0012\n \u0015*\u0004\u0018\u00010\u00140\u00140\u0013X\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010$\u001a\u00020\u001eX\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u0010%\u001a\u0004\u0018\u00010&X\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010'\u001a\u00020\fX\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010(\u001a\u00020)X\u0082.¢\u0006\u0002\n\u0000R\u000e\u0010*\u001a\u00020\u001eX\u0082\u000e¢\u0006\u0002\n\u0000R*\u0010+\u001a\u001e\u0012\u0004\u0012\u00020\f\u0012\u0004\u0012\u00020\u00070\u000bj\u000e\u0012\u0004\u0012\u00020\f\u0012\u0004\u0012\u00020\u0007`\rX\u0082\u000e¢\u0006\u0002\n\u0000R\u001c\u0010,\u001a\u0010\u0012\f\u0012\n \u0015*\u0004\u0018\u00010\u00140\u00140\u0013X\u0082\u000e¢\u0006\u0002\n\u0000R\u001b\u0010-\u001a\u00020.8BX\u0082\u0084\u0002¢\u0006\f\n\u0004\b1\u00102\u001a\u0004\b/\u00100¨\u0006q"}, d2 = {"Lapp/callpe/ui/payment/PaymentDetailsActivity;", "Lapp/callpe/ui/home/BaseActivity;", "Lapp/callpe/databinding/ActivityPaymentDetailsBinding;", "()V", "adapter", "Lapp/callpe/adapters/UPIAppAdapter;", "bonusPercentage", "", "cardAppAdapter", "Lapp/callpe/adapters/CardAppAdapter;", "cardsMap", "Ljava/util/HashMap;", "", "Lkotlin/collections/HashMap;", "couponAppliedSheet", "Lapp/callpe/ui/livestreaming/bottomsheet/CouponAppliedSheet;", "couponCodeId", "", "couponCodeLauncher", "Landroidx/activity/result/ActivityResultLauncher;", "Landroid/content/Intent;", "kotlin.jvm.PlatformType", "currencyAdapter", "Lapp/callpe/adapters/CurrencyAdapter;", "excludedApps", "extraAmountWhenCouponApplied", "finalAmountBeforeCouponBonus", "finalPayableAmountByUser", "", "forGames", "", "isEaseBuzz", "isPhonePe", "isRazorPay", "lastPayableAmount", "launcher", "newGstUI", "parentPgAdapter", "Lapp/callpe/adapters/ParentPaymentMethodsAdapter;", "paymentBenefitDetails", "toolbar", "Landroidx/appcompat/widget/Toolbar;", "upiAppAvailable", "upiAppsUpi", "upiLauncher", "viewModel", "Lapp/callpe/ui/home/AccountViewModel;", "getViewModel", "()Lapp/callpe/ui/home/AccountViewModel;", "viewModel$delegate", "Lkotlin/Lazy;", "applyCoupon", "", "discountCoupons", "Ljava/util/ArrayList;", "Lapp/callpe/data/model/CouponCodeModel;", "assignSharedPrefValues", "getCards", "getContext", "Landroid/content/Context;", "getTopUpPlan", "updatedPlan", "getUPIAppList", "Lapp/callpe/data/model/UPIApp;", "Lkotlin/collections/ArrayList;", "showAll", "getUpiApps", "handleAmountText", "plan", "Lapp/callpe/data/model/TopUpModel;", "handlePaymentMethodsV3", "methods", "Lapp/callpe/data/model/PaymentMethodParentV3;", "cardTypes", "Lapp/callpe/data/model/ExcludedApp;", "highlightTextsInFullText", "Landroid/text/SpannableString;", "fullText", "highlightTexts", "", "(Ljava/lang/String;[Ljava/lang/String;)Landroid/text/SpannableString;", "inflateLayout", "layoutInflater", "Landroid/view/LayoutInflater;", "initViews", "observeEvent", "Lkotlinx/coroutines/Job;", "onClicks", "onCreate", "savedInstanceState", "Landroid/os/Bundle;", "onDestroy", "onOptionsItemSelected", "item", "Landroid/view/MenuItem;", "onSaveInstanceState", "outState", "paymentSuccess", "resultSuccess", "prefillData", "prefillGameData", "model", "refresh", "setRecycler", "setUpCouponAppliedUI", "setUpToolbar", "showCouponAddedDialog", "couponBonusAmount", "showSnackbar", "message", "function", "Lkotlin/Function0;", "Companion", "app_riloRelease"}, k = 1, mv = {1, 8, 0}, xi = 48)
@AndroidEntryPoint
public final class PaymentDetailsActivity extends BaseActivity<ActivityPaymentDetailsBinding> {
    public static final String PAYMENT_SUCCESS_EVENT = "PAYMENT_SUCCESS_EVENT";
    private UPIAppAdapter adapter;
    private int bonusPercentage;
    private CardAppAdapter cardAppAdapter;
    private CouponAppliedSheet couponAppliedSheet;
    private final ActivityResultLauncher<Intent> couponCodeLauncher;
    private CurrencyAdapter currencyAdapter;
    private int extraAmountWhenCouponApplied;
    private int finalAmountBeforeCouponBonus;
    private double finalPayableAmountByUser;
    private boolean forGames;
    private boolean isEaseBuzz;
    private boolean isPhonePe;
    private boolean isRazorPay;
    private int lastPayableAmount;
    private ActivityResultLauncher<Intent> launcher;
    private boolean newGstUI;
    private ParentPaymentMethodsAdapter parentPgAdapter;
    private String paymentBenefitDetails;
    private Toolbar toolbar;
    private boolean upiAppAvailable;
    private ActivityResultLauncher<Intent> upiLauncher;

    private final Lazy viewModel;
    private HashMap<String, Integer> upiAppsUpi = new HashMap<>();
    private HashMap<String, Integer> cardsMap = new HashMap<>();
    private HashMap<String, String> excludedApps = new HashMap<>();
    private long couponCodeId = -1;

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

            public final ViewModelStore m2152invoke() {
                return componentActivity.getViewModelStore();
            }
        }, new Function0<ViewModelProvider.Factory>() {
            {
                super(0);
            }

            public final ViewModelProvider.Factory m2151invoke() {
                return componentActivity.getDefaultViewModelProviderFactory();
            }
        }, new Function0<CreationExtras>() {
            {
                super(0);
            }

            public final CreationExtras m2153invoke() {
                CreationExtras creationExtras;
                Function0 function02 = function0;
                return (function02 == null || (creationExtras = (CreationExtras) function02.invoke()) == null) ? componentActivity.getDefaultViewModelCreationExtras() : creationExtras;
            }
        });
        ActivityResultLauncher<Intent> registerForActivityResult = registerForActivityResult((ActivityResultContract) new ActivityResultContracts.StartActivityForResult(), new ActivityResultCallback() {
            public final void onActivityResult(Object obj) {
                PaymentDetailsActivity.launcher$lambda$0(PaymentDetailsActivity.this, (ActivityResult) obj);
            }
        });
        Intrinsics.checkNotNullExpressionValue(registerForActivityResult, "registerForActivityResul… }\n        finish()\n    }");
        this.launcher = registerForActivityResult;
        ActivityResultLauncher<Intent> registerForActivityResult2 = registerForActivityResult((ActivityResultContract) new ActivityResultContracts.StartActivityForResult(), new ActivityResultCallback() {
            public final void onActivityResult(Object obj) {
                PaymentDetailsActivity.upiLauncher$lambda$1(PaymentDetailsActivity.this, (ActivityResult) obj);
            }
        });
        Intrinsics.checkNotNullExpressionValue(registerForActivityResult2, "registerForActivityResul… }\n        finish()\n    }");
        this.upiLauncher = registerForActivityResult2;
        ActivityResultLauncher<Intent> registerForActivityResult3 = registerForActivityResult((ActivityResultContract) new ActivityResultContracts.StartActivityForResult(), new ActivityResultCallback() {
            public final void onActivityResult(Object obj) {
                PaymentDetailsActivity.couponCodeLauncher$lambda$3(PaymentDetailsActivity.this, (ActivityResult) obj);
            }
        });
        Intrinsics.checkNotNullExpressionValue(registerForActivityResult3, "registerForActivityResul…        }\n        }\n    }");
        this.couponCodeLauncher = registerForActivityResult3;
        this.paymentBenefitDetails = "";
    }

    @Override
    public ActivityPaymentDetailsBinding inflateLayout(LayoutInflater layoutInflater) {
        Intrinsics.checkNotNullParameter(layoutInflater, "layoutInflater");
        ActivityPaymentDetailsBinding inflate = ActivityPaymentDetailsBinding.inflate(layoutInflater);
        Intrinsics.checkNotNullExpressionValue(inflate, "inflate(layoutInflater)");
        return inflate;
    }

    public final AccountViewModel getViewModel() {
        return (AccountViewModel) this.viewModel.getValue();
    }

    public static final void launcher$lambda$0(PaymentDetailsActivity paymentDetailsActivity, ActivityResult activityResult) {
        Intrinsics.checkNotNullParameter(paymentDetailsActivity, "this$0");
        Intrinsics.checkNotNullParameter(activityResult, "result");
        if (activityResult.getResultCode() == -1) {
            paymentDetailsActivity.paymentSuccess(true);
        }
        paymentDetailsActivity.finish();
    }

    public static final void upiLauncher$lambda$1(PaymentDetailsActivity paymentDetailsActivity, ActivityResult activityResult) {
        Intrinsics.checkNotNullParameter(paymentDetailsActivity, "this$0");
        Intrinsics.checkNotNullParameter(activityResult, "result");
        if (activityResult.getResultCode() == -1) {
            paymentSuccess$default(paymentDetailsActivity, false, 1, null);
        }
        paymentDetailsActivity.finish();
    }

    public static final void couponCodeLauncher$lambda$3(PaymentDetailsActivity paymentDetailsActivity, ActivityResult activityResult) {
        Intent data;
        Intrinsics.checkNotNullParameter(paymentDetailsActivity, "this$0");
        Intrinsics.checkNotNullParameter(activityResult, "result");
        if (activityResult.getResultCode() != -1 || (data = activityResult.getData()) == null) {
            return;
        }
        if (data.getLongExtra("topUpId", -1L) != -1) {
            String stringExtra = data.getStringExtra("plan");
            paymentDetailsActivity.couponCodeId = data.getLongExtra("couponCodeId", -1L);
            paymentDetailsActivity.getViewModel().setCouponCode(Long.valueOf(paymentDetailsActivity.couponCodeId));
            paymentDetailsActivity.bonusPercentage = data.getIntExtra("bonusPercentage", 0);
            paymentDetailsActivity.setUpCouponAppliedUI(stringExtra);
            return;
        }
        paymentDetailsActivity.couponCodeId = data.getLongExtra("couponCodeId", -1L);
        paymentDetailsActivity.getViewModel().setCouponCode(Long.valueOf(paymentDetailsActivity.couponCodeId));
        paymentDetailsActivity.bonusPercentage = data.getIntExtra("bonusPercentage", 0);
        setUpCouponAppliedUI$default(paymentDetailsActivity, null, 1, null);
    }

    static void setUpCouponAppliedUI$default(PaymentDetailsActivity paymentDetailsActivity, String str, int i, Object obj) {
        if ((i & 1) != 0) {
            str = null;
        }
        paymentDetailsActivity.setUpCouponAppliedUI(str);
    }

    private final void setUpCouponAppliedUI(String updatedPlan) {
        getTopUpPlan(updatedPlan);
        View view = getBinding().bonusParent;
        Intrinsics.checkNotNullExpressionValue(view, "binding.bonusParent");
        view.setVisibility(0);
        View view2 = getBinding().applyCouponButton;
        Intrinsics.checkNotNullExpressionValue(view2, "binding.applyCouponButton");
        view2.setVisibility(8);
        this.extraAmountWhenCouponApplied = (this.bonusPercentage * this.lastPayableAmount) / 100;
        getBinding().couponBonusText.setText(NumberExtKt.formatByNumberRupee$default((Number) Integer.valueOf(this.extraAmountWhenCouponApplied), false, 1, (Object) null) + " bonus added");
        TextView textView = getBinding().initialTalktimeAmount;
        Intrinsics.checkNotNullExpressionValue(textView, "binding.initialTalktimeAmount");
        textView.setVisibility(0);
        getBinding().initialTalktimeAmount.setText(NumberExtKt.formatByNumberRupee$default((Number) Integer.valueOf(this.finalAmountBeforeCouponBonus), false, 1, (Object) null));
        int i = this.finalAmountBeforeCouponBonus + this.extraAmountWhenCouponApplied;
        getBinding().talktimeAmount.setText(NumberExtKt.formatByNumberRupee$default((Number) Integer.valueOf(i), false, 1, (Object) null));
        Timber.d("initial amount = " + this.finalAmountBeforeCouponBonus + "\n coupon bonus amount = " + this.extraAmountWhenCouponApplied + "\n finalAmount = " + i, new Object[0]);
        long j = this.couponCodeId;
        Long couponCode = getViewModel().getCouponCode();
        if (couponCode == null || j != couponCode.longValue()) {
            getViewModel().setCouponCode(Long.valueOf(this.couponCodeId));
        }
        showCouponAddedDialog(this.extraAmountWhenCouponApplied);
    }

    static void paymentSuccess$default(PaymentDetailsActivity paymentDetailsActivity, boolean z, int i, Object obj) {
        if ((i & 1) != 0) {
            z = false;
        }
        paymentDetailsActivity.paymentSuccess(z);
    }

    private final void paymentSuccess(boolean resultSuccess) {
        UserAccountFragment.INSTANCE.setRefresh(true);
        ChatActivity.refresh = true;
        ChatListFragment.Companion companion = ChatListFragment.INSTANCE;
        ChatListFragment.refreshScreen = true;
        StreamerDetailActivity.INSTANCE.setRefresh(true);
        BlockListActivity.INSTANCE.setRefreshScreen(true);
        SupportChatActivity.refresh = true;
        SystemChatListFragment.Companion companion2 = SystemChatListFragment.INSTANCE;
        SystemChatListFragment.refreshScreen = true;
        HomeFragment.INSTANCE.setResume(true);
        if (resultSuccess) {
            Context context = (Context) this;
            SharedPref.setBoolean(context, PrefKeys.FIRST_RECHARGE_DONE, true);
            if (getViewModel().getIs499Plus()) {
                AnalyticsHelper.sendEvent$default("plus499", context, false, 4, null);
            }
            AccountViewModel.getUserDetails$default(getViewModel(), false, false, 3, null);
            setResult(-1);
        }
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        boolean z = false;
        setWindowFlag((Activity) this, 67108864, false);
        getWindow().setStatusBarColor(ContextCompat.getColor((Context) this, 2131100053));
        if (savedInstanceState != null) {
            this.forGames = savedInstanceState.getBoolean(Constants.FOR_GAMES);
        } else {
            Intent intent = getIntent();
            if (intent != null && intent.getBooleanExtra(Constants.FOR_GAMES, false)) {
                z = true;
            }
            this.forGames = z;
        }
        assignSharedPrefValues();
        initViews();
        getTopUpPlan$default(this, null, 1, null);
        setUpToolbar();
        observeEvent();
        refresh();
        onClicks();
    }

    private final void assignSharedPrefValues() {
        this.newGstUI = SharedPref.getBoolean((Context) this, PrefKeys.NEW_GST_UI);
        LinearLayout linearLayout = ((ActivityPaymentDetailsBinding) getBinding()).newGstUiStyle;
        Intrinsics.checkNotNullExpressionValue(linearLayout, "binding.newGstUiStyle");
        linearLayout.setVisibility(this.newGstUI ? 0 : 8);
    }

    @Override
    protected void onSaveInstanceState(Bundle outState) {
        Intrinsics.checkNotNullParameter(outState, "outState");
        outState.putBoolean(Constants.FOR_GAMES, this.forGames);
        super.onSaveInstanceState(outState);
    }

    private final void setUpToolbar() {
        try {
            Toolbar toolbar = this.toolbar;
            if (toolbar == null) {
                Intrinsics.throwUninitializedPropertyAccessException("toolbar");
                toolbar = null;
            }
            setSupportActionBar(toolbar);
            ActionBar supportActionBar = getSupportActionBar();
            if (supportActionBar != null) {
                supportActionBar.setDisplayHomeAsUpEnabled(true);
            }
        } catch (Exception e) {
            Timber.e(e, "setUpToolbar: Error ", new Object[0]);
        }
    }

    static void getTopUpPlan$default(PaymentDetailsActivity paymentDetailsActivity, String str, int i, Object obj) {
        if ((i & 1) != 0) {
            str = null;
        }
        paymentDetailsActivity.getTopUpPlan(str);
    }

    private final void getTopUpPlan(String updatedPlan) {
        Unit unit;
        Context context = (Context) this;
        this.isPhonePe = SharedPref.getBoolean(context, PrefKeys.IS_PHONE_PE);
        this.isRazorPay = SharedPref.getBoolean(context, PrefKeys.IS_RAZORPAY);
        this.isEaseBuzz = SharedPref.getBoolean(context, PrefKeys.IS_EASE_BUZZ);
        getIntent().getLongExtra("topUpId", -1L);
        if (updatedPlan != null) {
            getIntent().putExtra("plan", updatedPlan);
        } else {
            updatedPlan = getIntent().getStringExtra("plan");
        }
        if (updatedPlan != null) {
            TopUpModel topUpModel = (TopUpModel) new Gson().fromJson(updatedPlan, TopUpModel.class);
            if (topUpModel == null) {
                return;
            }
            Intrinsics.checkNotNullExpressionValue(topUpModel, "Gson().fromJson(topUp, T…el::class.java) ?: return");
            getViewModel().setTopUpPlan(topUpModel);
            getViewModel().setTopUpId(Long.valueOf(topUpModel.getId()));
            getViewModel().setUpiPgId(topUpModel.getUpiPgId());
            getViewModel().setCouponCode(topUpModel.getCouponCode());
            if (this.couponCodeId != -1) {
                getViewModel().setCouponCode(Long.valueOf(this.couponCodeId));
            }
            if (this.forGames) {
                prefillGameData(topUpModel);
            } else {
                prefillData(topUpModel);
            }
            unit = Unit.INSTANCE;
        } else {
            unit = null;
        }
        if (unit == null) {
            finish();
        }
    }

    private final void prefillGameData(TopUpModel model) {
        double amount = model.getAmount() / 1.28d;
        double amount2 = model.getAmount() - amount;
        double amount3 = model.getAmount();
        double talktime = model.getTalktime() - amount;
        int talktime2 = model.getTalktime();
        getBinding().gameDepositAmount.setText(NumberExtKt.formatByNumber2DecimalRupee(amount, true));
        getBinding().gameTaxes.setText(NumberExtKt.formatByNumber2DecimalRupee(amount2, true));
        getBinding().gamePayableAmount.setText(NumberExtKt.formatByNumberRupee((Number) Integer.valueOf((int) amount3), true));
        getBinding().youGetGameAmount.setText(NumberExtKt.formatByNumberRupee((Number) Integer.valueOf(talktime2), true));
        if (talktime >= 0.0d) {
            getBinding().gamePromotionalBonus.setText(NumberExtKt.formatByNumber2DecimalRupee(talktime, true));
            return;
        }
        getBinding().gamePromotionalBonus.setText("- " + NumberExtKt.formatByNumber2DecimalRupee(Math.abs(talktime), true));
    }

    private final void prefillData(TopUpModel plan) {
        this.finalPayableAmountByUser = plan.getAmount();
        int talktime = plan.getTalktime();
        String formatByNumberRupee$default = NumberExtKt.formatByNumberRupee$default((Number) Integer.valueOf(talktime), false, 1, (Object) null);
        String formatByNumberDecimalRupee = NumberExtKt.formatByNumberDecimalRupee(plan.getAmount(), true);
        String formatByNumberDecimalRupee$default = NumberExtKt.formatByNumberDecimalRupee$default(plan.getAmount(), false, 1, null);
        getBinding().freeCards.setText(String.valueOf(plan.getFreeCards()));
        getBinding().talktimeAmount.setText(formatByNumberRupee$default);
        getBinding().initialTalktimeAmount.setText(formatByNumberDecimalRupee$default);
        getViewModel().setPayableAmount(formatByNumberDecimalRupee);
        if (!this.newGstUI) {
            LinearLayout linearLayout = getBinding().rechargeAmountParent;
            Intrinsics.checkNotNullExpressionValue(linearLayout, "binding.rechargeAmountParent");
            linearLayout.setVisibility(8);
            LinearLayout linearLayout2 = getBinding().talktimeGstParent;
            Intrinsics.checkNotNullExpressionValue(linearLayout2, "binding.talktimeGstParent");
            linearLayout2.setVisibility(8);
            if (Intrinsics.areEqual(plan.getTopupType(), "TALKTIME")) {
                LinearLayout linearLayout3 = getBinding().talktimeParent;
                Intrinsics.checkNotNullExpressionValue(linearLayout3, "binding.talktimeParent");
                linearLayout3.setVisibility(0);
                LinearLayout linearLayout4 = getBinding().vipParent;
                Intrinsics.checkNotNullExpressionValue(linearLayout4, "binding.vipParent");
                linearLayout4.setVisibility(8);
            } else {
                getBinding().vipValidity.setText(plan.getValidity() + ' ' + getString(2131951931));
                LinearLayout linearLayout5 = getBinding().talktimeParent;
                Intrinsics.checkNotNullExpressionValue(linearLayout5, "binding.talktimeParent");
                linearLayout5.setVisibility(plan.getTalktime() > 0 ? 0 : 8);
                LinearLayout linearLayout6 = getBinding().vipParent;
                Intrinsics.checkNotNullExpressionValue(linearLayout6, "binding.vipParent");
                linearLayout6.setVisibility(0);
            }
        } else {
            LinearLayout linearLayout7 = getBinding().talktimeParent;
            Intrinsics.checkNotNullExpressionValue(linearLayout7, "binding.talktimeParent");
            linearLayout7.setVisibility(8);
            LinearLayout linearLayout8 = getBinding().freeCardParent;
            Intrinsics.checkNotNullExpressionValue(linearLayout8, "binding.freeCardParent");
            linearLayout8.setVisibility(8);
            LinearLayout linearLayout9 = getBinding().vipParent;
            Intrinsics.checkNotNullExpressionValue(linearLayout9, "binding.vipParent");
            linearLayout9.setVisibility(8);
            LinearLayout linearLayout10 = getBinding().rechargeAmountParent;
            Intrinsics.checkNotNullExpressionValue(linearLayout10, "binding.rechargeAmountParent");
            linearLayout10.setVisibility(0);
            LinearLayout linearLayout11 = getBinding().talktimeGstParent;
            Intrinsics.checkNotNullExpressionValue(linearLayout11, "binding.talktimeGstParent");
            linearLayout11.setVisibility(0);
        }
        double amount = plan.getAmount();
        double d = ((10000 * amount) / 118) / 100.0d;
        double d2 = 100;
        getBinding().rechargeAmountTxt.setText(NumberExtKt.formatByNumber2DecimalRupee(d, true));
        getBinding().talktimeGstTxt.setText(NumberExtKt.formatByNumber2DecimalRupee(((amount * d2) - (d2 * d)) / 100.0d, true));
        String formatByNumberRupee$default2 = NumberExtKt.formatByNumberRupee$default((Number) Integer.valueOf(this.extraAmountWhenCouponApplied + talktime), false, 1, (Object) null);
        if (Intrinsics.areEqual(plan.getTopupType(), "TALKTIME")) {
            if (plan.getFreeCards() != 0) {
                this.paymentBenefitDetails = "You'll get " + formatByNumberRupee$default2 + " talktime, and " + plan.getFreeCards() + " free call on this recharge.";
            } else {
                this.paymentBenefitDetails = "You'll get " + formatByNumberRupee$default2 + " talktime on this recharge.";
            }
        } else {
            String str = plan.getValidity() + ' ' + getString(2131951931);
            if (plan.getTalktime() > 0) {
                if (plan.getFreeCards() != 0) {
                    this.paymentBenefitDetails = "You'll get " + str + " of VIP membership, " + formatByNumberRupee$default2 + " talktime, and " + plan.getFreeCards() + " free call on this recharge.";
                } else {
                    this.paymentBenefitDetails = "You'll get " + str + " of VIP membership, and " + formatByNumberRupee$default2 + " talktime on this recharge.";
                }
            } else if (plan.getFreeCards() != 0) {
                this.paymentBenefitDetails = "You'll get " + str + " of VIP membership, and " + plan.getFreeCards() + " free call on this recharge.";
            } else {
                this.paymentBenefitDetails = "You'll get " + str + " of VIP on this recharge.";
            }
        }
        getBinding().paymentBenefitDetails.setText(highlightTextsInFullText(this.paymentBenefitDetails, String.valueOf(formatByNumberRupee$default2), String.valueOf(plan.getFreeCards()), String.valueOf(plan.getValidity())));
        if (!this.newGstUI) {
            if (plan.getFreeCards() != 0) {
                getBinding().freeCardParent.setVisibility(0);
            } else {
                getBinding().freeCardParent.setVisibility(8);
            }
        }
        getViewModel().set499Plus(plan.getAmount() >= 499.0d);
        if (getViewModel().getCouponCode() != null) {
            getBinding().initialTalktimeAmount.setVisibility(0);
        } else {
            getBinding().initialTalktimeAmount.setVisibility(8);
        }
        this.lastPayableAmount = (int) plan.getAmount();
        this.finalAmountBeforeCouponBonus = talktime;
        handleAmountText(plan);
    }

    private final SpannableString highlightTextsInFullText(String fullText, String... highlightTexts) {
        int indexOf$default;
        try {
            SpannableString spannableString = new SpannableString(fullText);
            for (String str : highlightTexts) {
                int i = 0;
                while (i < fullText.length() && (indexOf$default = StringsKt.indexOf$default(fullText, str, i, false, 4, (Object) null)) != -1) {
                    int length = str.length() + indexOf$default;
                    if (length <= fullText.length()) {
                        spannableString.setSpan(new ForegroundColorSpan(-16777216), indexOf$default, length, 33);
                        spannableString.setSpan(new StyleSpan(1), indexOf$default, length, 33);
                    }
                    i = indexOf$default + str.length();
                }
            }
            return spannableString;
        } catch (Exception e) {
            e.printStackTrace();
            return new SpannableString(fullText);
        }
    }

    public final void refresh() {
        getViewModel().getAllowedPaymentMethodV3(getViewModel().getUpiPgId());
    }

    private final void onClicks() {
        getBinding().applyCouponButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                PaymentDetailsActivity.onClicks$lambda$7(PaymentDetailsActivity.this, view);
            }
        });
        getBinding().removeCoupon.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                PaymentDetailsActivity.onClicks$lambda$8(PaymentDetailsActivity.this, view);
            }
        });
    }

    public static final void onClicks$lambda$7(PaymentDetailsActivity paymentDetailsActivity, View view) {
        Intrinsics.checkNotNullParameter(paymentDetailsActivity, "this$0");
        Intent intent = new Intent((Context) paymentDetailsActivity, (Class<?>) CouponCodeActivity.class);
        intent.putExtra("topupAmount", paymentDetailsActivity.lastPayableAmount);
        intent.putExtra("upiPgId", paymentDetailsActivity.getViewModel().getUpiPgId());
        paymentDetailsActivity.couponCodeLauncher.launch(intent);
    }

    public static final void onClicks$lambda$8(PaymentDetailsActivity paymentDetailsActivity, View view) {
        Intrinsics.checkNotNullParameter(paymentDetailsActivity, "this$0");
        paymentDetailsActivity.extraAmountWhenCouponApplied = 0;
        View view2 = paymentDetailsActivity.getBinding().bonusParent;
        Intrinsics.checkNotNullExpressionValue(view2, "binding.bonusParent");
        view2.setVisibility(8);
        View view3 = paymentDetailsActivity.getBinding().applyCouponButton;
        Intrinsics.checkNotNullExpressionValue(view3, "binding.applyCouponButton");
        view3.setVisibility(0);
        paymentDetailsActivity.getViewModel().setCouponCode(null);
        paymentDetailsActivity.couponCodeId = -1L;
        TextView textView = paymentDetailsActivity.getBinding().initialTalktimeAmount;
        Intrinsics.checkNotNullExpressionValue(textView, "binding.initialTalktimeAmount");
        textView.setVisibility(8);
        paymentDetailsActivity.getBinding().initialTalktimeAmount.setText("");
        paymentDetailsActivity.getBinding().talktimeAmount.setText(NumberExtKt.formatByNumberRupee$default((Number) Integer.valueOf(paymentDetailsActivity.finalAmountBeforeCouponBonus), false, 1, (Object) null));
        getTopUpPlan$default(paymentDetailsActivity, null, 1, null);
    }

    private final void initViews() {
        Toolbar toolbar = getBinding().toolbar;
        Intrinsics.checkNotNullExpressionValue(toolbar, "binding.toolbar");
        this.toolbar = toolbar;
        setRecycler();
        if (this.forGames) {
            LinearLayout linearLayout = getBinding().talktimeRechargeBox;
            Intrinsics.checkNotNullExpressionValue(linearLayout, "binding.talktimeRechargeBox");
            linearLayout.setVisibility(8);
            LinearLayout linearLayout2 = getBinding().gameRechargeBox;
            Intrinsics.checkNotNullExpressionValue(linearLayout2, "binding.gameRechargeBox");
            linearLayout2.setVisibility(0);
            LinearLayout linearLayout3 = getBinding().couponBox;
            Intrinsics.checkNotNullExpressionValue(linearLayout3, "binding.couponBox");
            linearLayout3.setVisibility(8);
            return;
        }
        LinearLayout linearLayout4 = getBinding().talktimeRechargeBox;
        Intrinsics.checkNotNullExpressionValue(linearLayout4, "binding.talktimeRechargeBox");
        linearLayout4.setVisibility(0);
        LinearLayout linearLayout5 = getBinding().gameRechargeBox;
        Intrinsics.checkNotNullExpressionValue(linearLayout5, "binding.gameRechargeBox");
        linearLayout5.setVisibility(8);
    }

    private final void setRecycler() {
        ((ActivityPaymentDetailsBinding) getBinding()).parentPgRv.setLayoutManager(new CustomLinearLayoutManager((Context) this));
        this.parentPgAdapter = new ParentPaymentMethodsAdapter(new ArrayList(), new ParentPaymentMethodsAdapter.ItemClickListener() {
            @Override
            public void onParentItemClick(PaymentMethodParentV3 parentPaymentMethod) {
                Class cls;
                AccountViewModel viewModel;
                AccountViewModel viewModel2;
                AccountViewModel viewModel3;
                AccountViewModel viewModel4;
                AccountViewModel viewModel5;
                ActivityResultLauncher activityResultLauncher;
                Intrinsics.checkNotNullParameter(parentPaymentMethod, "parentPaymentMethod");
                ArrayList<PaymentMethodChildV3> items = parentPaymentMethod.getItems();
                if (items == null || items.isEmpty()) {
                    String paymentMethod = parentPaymentMethod.getPaymentMethod();
                    int hashCode = paymentMethod.hashCode();
                    if (hashCode == 84238) {
                        if (paymentMethod.equals("UPI")) {
                            cls = UPICheckoutActivity.class;
                        }
                        cls = CheckoutActivity.class;
                    } else if (hashCode != 68645222) {
                        if (hashCode == 1310753099 && paymentMethod.equals("QR_CODE")) {
                            cls = QRPaymentActivity.class;
                        }
                        cls = CheckoutActivity.class;
                    } else {
                        if (paymentMethod.equals("SCREENSHOT")) {
                            cls = ScreenshotUpiActivity.class;
                        }
                        cls = CheckoutActivity.class;
                    }
                    Intent intent = new Intent((Context) PaymentDetailsActivity.this, (Class<?>) cls);
                    PaymentDetailsActivity paymentDetailsActivity = PaymentDetailsActivity.this;
                    viewModel = paymentDetailsActivity.getViewModel();
                    intent.putExtra("topUpId", viewModel.getTopUpId());
                    viewModel2 = paymentDetailsActivity.getViewModel();
                    intent.putExtra("upiPgId", viewModel2.getUpiPgId());
                    viewModel3 = paymentDetailsActivity.getViewModel();
                    intent.putExtra("couponCode", viewModel3.getCouponCode());
                    if (Intrinsics.areEqual(parentPaymentMethod.getPaymentMethod(), "CARD")) {
                        intent.putExtra("cardType", "VISA");
                    } else if (Intrinsics.areEqual(parentPaymentMethod.getPaymentMethod(), "SCREENSHOT")) {
                        viewModel5 = paymentDetailsActivity.getViewModel();
                        intent.putExtra("payableAmount", viewModel5.getPayableAmount());
                    } else {
                        viewModel4 = paymentDetailsActivity.getViewModel();
                        intent.putExtra("upiPgId", viewModel4.getUpiPgId());
                    }
                    intent.putExtra("paymentMethod", parentPaymentMethod.getPaymentMethod());
                    activityResultLauncher = paymentDetailsActivity.launcher;
                    activityResultLauncher.launch(intent);
                }
            }

            @Override
            public void onChildItemClick(PaymentMethodChildV3 childParentMethod, String paymentMethod) {
                Class cls;
                AccountViewModel viewModel;
                AccountViewModel viewModel2;
                AccountViewModel viewModel3;
                ActivityResultLauncher activityResultLauncher;
                AccountViewModel viewModel4;
                Intrinsics.checkNotNullParameter(childParentMethod, "childParentMethod");
                Intrinsics.checkNotNullParameter(paymentMethod, "paymentMethod");
                int hashCode = paymentMethod.hashCode();
                if (hashCode == 84238) {
                    if (paymentMethod.equals("UPI")) {
                        cls = UPICheckoutActivity.class;
                    }
                    cls = CheckoutActivity.class;
                } else if (hashCode != 68645222) {
                    if (hashCode == 1310753099 && paymentMethod.equals("QR_CODE")) {
                        cls = QRPaymentActivity.class;
                    }
                    cls = CheckoutActivity.class;
                } else {
                    if (paymentMethod.equals("SCREENSHOT")) {
                        cls = ScreenshotUpiActivity.class;
                    }
                    cls = CheckoutActivity.class;
                }
                Intent intent = new Intent((Context) PaymentDetailsActivity.this, (Class<?>) cls);
                PaymentDetailsActivity paymentDetailsActivity = PaymentDetailsActivity.this;
                viewModel = paymentDetailsActivity.getViewModel();
                intent.putExtra("topUpId", viewModel.getTopUpId());
                viewModel2 = paymentDetailsActivity.getViewModel();
                intent.putExtra("couponCode", viewModel2.getCouponCode());
                int hashCode2 = paymentMethod.hashCode();
                if (hashCode2 == 84238) {
                    if (paymentMethod.equals("UPI")) {
                        String value = childParentMethod.getValue();
                        if (value == null) {
                            value = "";
                        }
                        intent.putExtra("packageName", value);
                        String label = childParentMethod.getLabel();
                        intent.putExtra("appName", label != null ? label : "");
                    }
                    viewModel3 = paymentDetailsActivity.getViewModel();
                    intent.putExtra("upiPgId", viewModel3.getUpiPgId());
                } else if (hashCode2 != 2061072) {
                    if (hashCode2 == 68645222 && paymentMethod.equals("SCREENSHOT")) {
                        viewModel4 = paymentDetailsActivity.getViewModel();
                        intent.putExtra("payableAmount", viewModel4.getPayableAmount());
                    }
                    viewModel3 = paymentDetailsActivity.getViewModel();
                    intent.putExtra("upiPgId", viewModel3.getUpiPgId());
                } else {
                    if (paymentMethod.equals("CARD")) {
                        intent.putExtra("cardType", childParentMethod.getValue());
                    }
                    viewModel3 = paymentDetailsActivity.getViewModel();
                    intent.putExtra("upiPgId", viewModel3.getUpiPgId());
                }
                intent.putExtra("paymentMethod", paymentMethod);
                activityResultLauncher = paymentDetailsActivity.launcher;
                activityResultLauncher.launch(intent);
            }
        });
        ((ActivityPaymentDetailsBinding) getBinding()).parentPgRv.setAdapter(this.parentPgAdapter);
    }

    private final Job observeEvent() {
        return BuildersKt.launch$default(LifecycleOwnerKt.getLifecycleScope((LifecycleOwner) this), (CoroutineContext) null, (CoroutineStart) null, new PaymentDetailsActivity$observeEvent$1(this, null), 3, (Object) null);
    }

    public final void applyCoupon(ArrayList<CouponCodeModel> discountCoupons) {
        getBinding().availableOffer.setText(discountCoupons.size() == 1 ? '(' + discountCoupons.size() + " offer available)" : '(' + discountCoupons.size() + " offers available)");
        ArrayList arrayList = new ArrayList();
        for (Object obj : discountCoupons) {
            if (this.lastPayableAmount >= ((CouponCodeModel) obj).getMinRechargeAmount()) {
                arrayList.add(obj);
            }
        }
        List sortedWith = CollectionsKt.sortedWith(arrayList, new Comparator() {
            @Override
            public final int compare(T t, T t2) {
                return ComparisonsKt.compareValues(Integer.valueOf(((CouponCodeModel) t2).getBonusPercentage()), Integer.valueOf(((CouponCodeModel) t).getBonusPercentage()));
            }
        });
        if (!sortedWith.isEmpty()) {
            CouponCodeModel couponCodeModel = (CouponCodeModel) CollectionsKt.first(sortedWith);
            this.couponCodeId = couponCodeModel.getId();
            getViewModel().setCouponCode(Long.valueOf(this.couponCodeId));
            this.bonusPercentage = couponCodeModel.getBonusPercentage();
            setUpCouponAppliedUI$default(this, null, 1, null);
        }
    }

    private final void handleAmountText(TopUpModel plan) {
        String str = getString(2131952545) + " represents Indian Rupees (INR)";
        boolean z = SharedPref.getBoolean((Context) this, PrefKeys.USER_IS_INDIAN, false);
        TextView textView = ((ActivityPaymentDetailsBinding) getBinding()).conversionText;
        Intrinsics.checkNotNullExpressionValue(textView, "binding.conversionText");
        textView.setVisibility(z ^ true ? 0 : 8);
        ((ActivityPaymentDetailsBinding) getBinding()).conversionText.setText(str);
        String payButtonLabel = plan.getPayButtonLabel();
        ((ActivityPaymentDetailsBinding) getBinding()).payableAmount.setText(payButtonLabel);
        ((ActivityPaymentDetailsBinding) getBinding()).amount.setText(payButtonLabel);
    }

    public final void handlePaymentMethodsV3(ArrayList<PaymentMethodParentV3> methods, ArrayList<String> cardTypes, ArrayList<ExcludedApp> excludedApps) {
        Object obj;
        this.excludedApps.clear();
        if (excludedApps != null) {
            for (ExcludedApp excludedApp : excludedApps) {
                if (!this.excludedApps.containsKey(excludedApp.getPackageId())) {
                    this.excludedApps.put(excludedApp.getPackageId(), excludedApp.getPackageId());
                }
            }
        }
        Iterator<T> it = methods.iterator();
        while (true) {
            if (it.hasNext()) {
                obj = it.next();
                if (Intrinsics.areEqual(((PaymentMethodParentV3) obj).getPaymentMethod(), "UPI")) {
                    break;
                }
            } else {
                obj = null;
                break;
            }
        }
        PaymentMethodParentV3 paymentMethodParentV3 = (PaymentMethodParentV3) obj;
        if (paymentMethodParentV3 != null) {
            ArrayList<UPIApp> uPIAppList = getUPIAppList(true);
            ArrayList arrayList = new ArrayList(CollectionsKt.collectionSizeOrDefault(uPIAppList, 10));
            for (UPIApp uPIApp : uPIAppList) {
                String name = uPIApp.getName();
                String packageName = uPIApp.getPackageName();
                if (packageName == null) {
                    packageName = "";
                }
                arrayList.add(new PaymentMethodChildV3(name, "", packageName, uPIApp.getIconDrawable()));
            }
            paymentMethodParentV3.setItems(ListExtKt.toArrayList(arrayList));
        }
        ParentPaymentMethodsAdapter parentPaymentMethodsAdapter = this.parentPgAdapter;
        if (parentPaymentMethodsAdapter != null) {
            parentPaymentMethodsAdapter.addItems(methods);
        }
    }

    private final Context getContext() {
        return (Context) this;
    }

    protected void onDestroy() {
        super.onDestroy();
    }

    public boolean onOptionsItemSelected(MenuItem item) {
        Intrinsics.checkNotNullParameter(item, "item");
        if (item.getItemId() != 16908332) {
            return true;
        }
        finish();
        return true;
    }

    static ArrayList getUPIAppList$default(PaymentDetailsActivity paymentDetailsActivity, boolean z, int i, Object obj) {
        if ((i & 1) != 0) {
            z = false;
        }
        return paymentDetailsActivity.getUPIAppList(z);
    }

    private final ArrayList<UPIApp> getUPIAppList(boolean showAll) {
        ArrayList arrayList;
        Drawable loadIcon;
        getUpiApps();
        ArrayList<UPIApp> arrayList2 = new ArrayList<>();
        try {
            PackageManager packageManager = getPackageManager();
            Intent intent = new Intent("android.intent.action.VIEW");
            StringCompanionObject stringCompanionObject = StringCompanionObject.INSTANCE;
            String format = String.format("%s://%s", Arrays.copyOf(new Object[]{"upi", "pay"}, 2));
            Intrinsics.checkNotNullExpressionValue(format, "format(format, *args)");
            intent.setData(Uri.parse(format));
            List<ResolveInfo> queryIntentActivities = packageManager.queryIntentActivities(intent, NativeProtocol.MESSAGE_GET_ACCESS_TOKEN_REQUEST);
            Intrinsics.checkNotNullExpressionValue(queryIntentActivities, "packageManager.queryInte…nager.MATCH_DEFAULT_ONLY)");
            final Function2<ResolveInfo, ResolveInfo, Integer> function2 = new Function2<ResolveInfo, ResolveInfo, Integer>() {
                {
                    super(2);
                }

                public final Integer invoke(ResolveInfo resolveInfo, ResolveInfo resolveInfo2) {
                    HashMap hashMap;
                    HashMap hashMap2;
                    int i;
                    ActivityInfo activityInfo = resolveInfo.activityInfo;
                    String str = activityInfo != null ? activityInfo.packageName : null;
                    ActivityInfo activityInfo2 = resolveInfo2.activityInfo;
                    String str2 = activityInfo2 != null ? activityInfo2.packageName : null;
                    hashMap = PaymentDetailsActivity.this.upiAppsUpi;
                    Integer num = (Integer) hashMap.get(str);
                    hashMap2 = PaymentDetailsActivity.this.upiAppsUpi;
                    Integer num2 = (Integer) hashMap2.get(str2);
                    if (num == null || num2 == null) {
                        i = num != null ? -1 : num2 != null ? 1 : 0;
                    } else {
                        i = Intrinsics.compare(num.intValue(), num2.intValue());
                    }
                    return Integer.valueOf(i);
                }
            };
            CollectionsKt.sortWith(queryIntentActivities, new Comparator() {
                @Override
                public final int compare(Object obj, Object obj2) {
                    int uPIAppList$lambda$14;
                    uPIAppList$lambda$14 = PaymentDetailsActivity.getUPIAppList$lambda$14(function2, obj, obj2);
                    return uPIAppList$lambda$14;
                }
            });
            Iterator<ResolveInfo> it = queryIntentActivities.iterator();
            while (true) {
                String str = "";
                if (!it.hasNext()) {
                    break;
                }
                ResolveInfo next = it.next();
                ActivityInfo activityInfo = next.activityInfo;
                String str2 = activityInfo != null ? activityInfo.packageName : null;
                if (str2 != null) {
                    str = str2;
                }
                Timber.i("packageName " + str, new Object[0]);
                if (this.upiAppsUpi.containsKey(str) && !this.excludedApps.containsKey(str)) {
                    CharSequence loadLabel = next.loadLabel(packageManager);
                    if (Intrinsics.areEqual(str, "com.google.android.apps.nbu.paisa.user")) {
                        loadIcon = ContextCompat.getDrawable(getContext(), 2131231611);
                    } else {
                        loadIcon = next.loadIcon(packageManager);
                    }
                    Integer num = this.upiAppsUpi.get(str);
                    Timber.i("position " + num, new Object[0]);
                    if (num != null) {
                        arrayList2.add(Math.min(num.intValue(), arrayList2.size()), new UPIApp(loadIcon, loadLabel.toString(), str, UpiType.SECONDARY));
                    }
                }
            }
            arrayList = new ArrayList();
            for (ResolveInfo resolveInfo : queryIntentActivities) {
                ActivityInfo activityInfo2 = resolveInfo.activityInfo;
                String str3 = activityInfo2 != null ? activityInfo2.packageName : null;
                if (str3 == null) {
                    str3 = "";
                }
                Timber.i("packageName " + str3, new Object[0]);
                if (!this.upiAppsUpi.containsKey(str3) && !this.excludedApps.containsKey(str3)) {
                    arrayList.add(new UPIApp(resolveInfo.loadIcon(packageManager), resolveInfo.loadLabel(packageManager).toString(), str3, UpiType.SECONDARY));
                }
            }
            this.upiAppAvailable = (arrayList2.isEmpty() ^ true) || (arrayList.isEmpty() ^ true);
        } catch (Exception e) {
            Activity activity = (Activity) this;
            String message = e.getMessage();
            if (message == null) {
                message = "Error";
            }
            ActivityExtKt.toast(activity, message);
        }
        if (!showAll && arrayList2.size() > 2) {
            if (!arrayList.isEmpty()) {
                arrayList2.add(new UPIApp(ContextCompat.getDrawable(getContext(), 2131231743), "Others", "", UpiType.OTHER));
            }
            return arrayList2;
        }
        arrayList2.addAll(arrayList);
        return arrayList2;
    }

    public static final int getUPIAppList$lambda$14(Function2 function2, Object obj, Object obj2) {
        Intrinsics.checkNotNullParameter(function2, "$tmp0");
        return ((Number) function2.invoke(obj, obj2)).intValue();
    }

    private final void getUpiApps() {
        this.upiAppsUpi.clear();
        this.upiAppsUpi.put("com.google.android.apps.nbu.paisa.user", 0);
        this.upiAppsUpi.put("com.phonepe.app", 1);
        this.upiAppsUpi.put("net.one97.paytm", 2);
        this.upiAppsUpi.put("com.dreamplug.androidapp", 3);
        this.upiAppsUpi.put("in.org.npci.upiapp", 4);
        this.upiAppsUpi.put("com.bharatpe.app", 5);
    }

    private final void getCards() {
        this.cardsMap.clear();
        this.cardsMap.put("VISA", 0);
        this.cardsMap.put("RUPAY", 1);
        this.cardsMap.put("MAESTRO", 2);
        this.cardsMap.put("MASTERCARD", 3);
        this.cardsMap.put("AMEX", 4);
        this.cardsMap.put("OTHER", 5);
    }

    public final void showSnackbar(String message, final Function0<Unit> function) {
        Snackbar make = Snackbar.make(getBinding().getRoot(), message, -2);
        Intrinsics.checkNotNullExpressionValue(make, "make(binding.root, messa…ackbar.LENGTH_INDEFINITE)");
        make.setAction("Retry", new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                PaymentDetailsActivity.showSnackbar$lambda$15(function, view);
            }
        });
        make.show();
    }

    public static final void showSnackbar$lambda$15(Function0 function0, View view) {
        Intrinsics.checkNotNullParameter(function0, "$function");
        function0.invoke();
    }

    private final void showCouponAddedDialog(int couponBonusAmount) {
        try {
            BuildersKt.launch$default(LifecycleOwnerKt.getLifecycleScope((LifecycleOwner) this), (CoroutineContext) null, (CoroutineStart) null, new PaymentDetailsActivity$showCouponAddedDialog$1(this, couponBonusAmount, null), 3, (Object) null);
        } catch (Exception e) {
            Timber.e(e);
        }
    }
}