导航菜单

页面标题

页面副标题

Mint v5.7.3 - SubscriptionActivity.java 源代码

正在查看: Mint v5.7.3 应用的 SubscriptionActivity.java JAVA 源代码文件

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


package com.htmedia.mint.ui.activity;

import android.annotation.SuppressLint;
import android.app.ActivityOptions;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.text.Html;
import android.text.Spannable;
import android.text.TextUtils;
import android.util.DisplayMetrics;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.AppCompatTextView;
import androidx.appcompat.widget.Toolbar;
import androidx.core.content.res.ResourcesCompat;
import androidx.databinding.DataBindingUtil;
import androidx.recyclerview.widget.DefaultItemAnimator;
import androidx.recyclerview.widget.LinearLayoutManager;
import com.google.android.material.tabs.TabLayout;
import com.google.firebase.perf.network.FirebasePerfUrlConnection;
import com.htmedia.mint.AppController;
import com.htmedia.mint.htsubscription.CheckSubscriptionFromLocal;
import com.htmedia.mint.htsubscription.ConvertMintPlanIntoZSPlan;
import com.htmedia.mint.htsubscription.FilterPlanWRTDuration;
import com.htmedia.mint.htsubscription.GetSubscriptionIntent;
import com.htmedia.mint.htsubscription.GetUserSubscriptionDetail;
import com.htmedia.mint.htsubscription.PlanPageHeading;
import com.htmedia.mint.htsubscription.SnowplowSubscriptionAnalytices;
import com.htmedia.mint.htsubscription.SubscriptionConverter;
import com.htmedia.mint.htsubscription.SubscriptionPlanSingleton;
import com.htmedia.mint.htsubscription.SyncPurchaseWithSession;
import com.htmedia.mint.htsubscription.WebEngageAnalytices;
import com.htmedia.mint.htsubscription.ZSErrorCodeHandling;
import com.htmedia.mint.htsubscription.ZohoInAppConfig;
import com.htmedia.mint.piano.PianoCallbackListener;
import com.htmedia.mint.piano.PianoCallbacks;
import com.htmedia.mint.piano.PianoResponse;
import com.htmedia.mint.piano.PianoResponseSingleTon;
import com.htmedia.mint.pojo.Answer;
import com.htmedia.mint.pojo.Content;
import com.htmedia.mint.pojo.ForyouPojo;
import com.htmedia.mint.pojo.config.Config;
import com.htmedia.mint.pojo.config.FrequentlyQuestion;
import com.htmedia.mint.pojo.config.Section;
import com.htmedia.mint.pojo.mintsubscribenowmodel.SubscribeNowPerant;
import com.htmedia.mint.pojo.planpage.PaymentMethod;
import com.htmedia.mint.pojo.planpage.PianoPlan;
import com.htmedia.mint.pojo.planpage.PlanPageExperience;
import com.htmedia.mint.pojo.subscription.ErrorCode;
import com.htmedia.mint.pojo.subscription.PlanInterval;
import com.htmedia.mint.pojo.subscription.SubscriptionError;
import com.htmedia.mint.pojo.subscription.SubscriptionSource;
import com.htmedia.mint.pojo.subscription.SubscriptionStatus;
import com.htmedia.mint.pojo.subscription.plandetail.htapi.MintPlan;
import com.htmedia.mint.pojo.subscription.plandetail.htapi.MintPlanWithZSPlan;
import com.htmedia.mint.pojo.subscription.plandetail.htapi.MintServerPlan;
import com.htmedia.mint.pojo.subscription.plandetail.htapi.PlanDiscount;
import com.htmedia.mint.pojo.subscription.plandetail.htapi.Plans;
import com.htmedia.mint.pojo.subscription.plandetail.htapi.SubsPlans;
import com.htmedia.mint.pojo.subscription.userdetail.MintSubscriptionDetail;
import com.htmedia.mint.razorpay.coupon.CouponModule;
import com.htmedia.mint.razorpay.ui.SubscriptionCheckOutPage;
import com.htmedia.mint.razorpay.utils.RazorPayCheckout;
import com.htmedia.mint.ui.viewholders.QuestionAnswerGroup;
import com.htmedia.mint.utils.q;
import com.htmedia.sso.activities.LoginRegisterActivity;
import com.htmedia.sso.helpers.WebEngageNewSSOEvents;
import com.razorpay.PaymentData;
import com.razorpay.PaymentResultWithDataListener;
import com.thoughtbot.expandablerecyclerview.BuildConfig;
import com.zoho.zsm.inapppurchase.core.ZSInAppPurchaseKit;
import com.zoho.zsm.inapppurchase.interfaces.PlanDetailsListener;
import com.zoho.zsm.inapppurchase.interfaces.PurchaseUpdationListener;
import com.zoho.zsm.inapppurchase.model.ZSCustomField;
import com.zoho.zsm.inapppurchase.model.ZSError;
import com.zoho.zsm.inapppurchase.model.ZSErrorCode;
import com.zoho.zsm.inapppurchase.model.ZSPlan;
import com.zoho.zsm.inapppurchase.model.ZSSuscriptionDetail;
import java.io.IOException;
import java.math.RoundingMode;
import java.net.MalformedURLException;
import java.net.ProtocolException;
import java.net.URL;
import java.net.URLConnection;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Set;
import javax.net.ssl.HttpsURLConnection;
import q7.g0;
import q7.j7;
import x4.mq0;

public class SubscriptionActivity extends com.htmedia.mint.ui.activity.a implements View.OnClickListener, j7.b, PurchaseUpdationListener, PlanDetailsListener, GetUserSubscriptionDetail.OnSubscriptionDetail, k6.s, k6.d1, g0.a, PianoCallbackListener, PaymentResultWithDataListener {
    private Config A;
    private CouponModule B;
    private boolean C;
    private NumberFormat D;
    private PlanPageExperience G;
    private RazorPayCheckout H;
    private g I;
    private TabLayout a;
    mq0 b;
    private ZSPlan d;
    public MintPlanWithZSPlan e;
    private ProgressDialog f;
    private j7 h;
    private k6.r i;
    private MintPlan o;
    private q7.g0 p;
    private boolean q;
    private boolean r;
    private boolean s;
    private String u;
    private String v;
    private String w;
    public String x;
    public boolean y;
    private boolean z;
    private HashMap<String, ArrayList<MintPlanWithZSPlan>> c = new HashMap<>();
    private final boolean g = false;
    private ArrayList<MintPlanWithZSPlan> j = new ArrayList<>();
    private String t = BuildConfig.FLAVOR;
    private Content E = null;
    public String F = BuildConfig.FLAVOR;

    class a extends com.htmedia.mint.utils.a3 {
        a() {
        }

        @Override
        public void onLinkClick(String str) {
            WebEngageNewSSOEvents.trackSSOLinkClicked("Login", "Subscription Funnel");
            SubscriptionActivity.this.openLoginPage("plans_page");
        }
    }

    class b implements TabLayout.BaseOnTabSelectedListener {
        final boolean a;

        b(boolean z) {
            this.a = z;
        }

        public void onTabReselected(TabLayout.Tab tab) {
        }

        public void onTabSelected(TabLayout.Tab tab) {
            SubscriptionActivity.this.W(this.a, true, tab.getCustomView());
            if (tab.getPosition() == 1) {
                SubscriptionActivity.this.y0(false);
                SubscriptionActivity.this.X(FilterPlanWRTDuration.PlanFilter.PLAN_WSJ);
            } else {
                SubscriptionActivity.this.y0(true);
                SubscriptionActivity.this.X(FilterPlanWRTDuration.PlanFilter.PLAN_MINT);
            }
        }

        public void onTabUnselected(TabLayout.Tab tab) {
            SubscriptionActivity.this.W(this.a, false, tab.getCustomView());
        }
    }

    class c implements View.OnClickListener {
        c() {
        }

        @Override
        public void onClick(View view) {
            SubscriptionActivity.this.goBack();
        }
    }

    class d implements View.OnClickListener {
        final List a;

        d(List list) {
            this.a = list;
        }

        @Override
        public void onClick(View view) {
            int size = this.a.size();
            ArrayList arrayList = new ArrayList();
            for (int i = 0; i < size; i++) {
                ArrayList arrayList2 = new ArrayList();
                Answer answer = new Answer();
                answer.setAnswer(((FrequentlyQuestion) this.a.get(i)).getAnswer());
                arrayList2.add(answer);
                arrayList.add(i, new QuestionAnswerGroup(((FrequentlyQuestion) this.a.get(i)).getQuestion(), arrayList2));
            }
            ?? r62 = SubscriptionActivity.this;
            ((SubscriptionActivity) r62).p = new q7.g0(arrayList, r62, r62);
            SubscriptionActivity subscriptionActivity = SubscriptionActivity.this;
            subscriptionActivity.b.v.setAdapter(subscriptionActivity.p);
            SubscriptionActivity.this.b.G.setVisibility(8);
        }
    }

    static class e {
        static final int[] a;

        static {
            int[] iArr = new int[q.v.values().length];
            a = iArr;
            try {
                iArr[q.v.UPI.ordinal()] = 1;
            } catch (NoSuchFieldError unused) {
            }
            try {
                a[q.v.WALLET.ordinal()] = 2;
            } catch (NoSuchFieldError unused2) {
            }
            try {
                a[q.v.NETBANKING.ordinal()] = 3;
            } catch (NoSuchFieldError unused3) {
            }
            try {
                a[q.v.CREDIT_CARD.ordinal()] = 4;
            } catch (NoSuchFieldError unused4) {
            }
        }
    }

    @SuppressLint({"StaticFieldLeak"})
    private class f extends AsyncTask<Void, Void, g> {
        private f() {
        }

        f(SubscriptionActivity subscriptionActivity, a aVar) {
            this();
        }

        @Override
        public g doInBackground(Void... voidArr) {
            URL url = null;
            String locationUrl = (AppController.j().g() == null || TextUtils.isEmpty(AppController.j().g().getLocationUrl())) ? null : AppController.j().g().getLocationUrl();
            try {
            } catch (MalformedURLException e) {
                e.printStackTrace();
                com.htmedia.mint.utils.o0.h(e, locationUrl, e.getMessage());
            }
            if (locationUrl == null) {
                return g.Other;
            }
            url = new URL(locationUrl);
            try {
                HttpsURLConnection httpsURLConnection = (HttpsURLConnection) ((URLConnection) FirebasePerfUrlConnection.instrument(url.openConnection()));
                httpsURLConnection.setRequestMethod("GET");
                httpsURLConnection.setRequestProperty("charset", "utf-8");
                httpsURLConnection.connect();
                if (httpsURLConnection.getResponseCode() == 200) {
                    String headerField = httpsURLConnection.getHeaderField("meta-geo");
                    if (!TextUtils.isEmpty(headerField)) {
                        if (!headerField.startsWith("us") && !headerField.startsWith("US")) {
                            if (headerField.startsWith("in") || headerField.startsWith("IN")) {
                                return g.India;
                            }
                        }
                        return g.US;
                    }
                }
            } catch (ProtocolException e2) {
                e2.printStackTrace();
                com.htmedia.mint.utils.o0.h(e2, locationUrl, e2.getMessage());
            } catch (IOException e3) {
                e3.printStackTrace();
                com.htmedia.mint.utils.o0.h(e3, locationUrl, e3.getMessage());
            } catch (Exception e4) {
                e4.printStackTrace();
                com.htmedia.mint.utils.o0.h(e4, locationUrl, e4.getMessage());
            }
            return g.Other;
        }

        @Override
        public void onPostExecute(g gVar) {
            super.onPostExecute(gVar);
            SubscriptionActivity.this.I = gVar;
            SubscriptionActivity.this.j0(gVar != g.US);
            SubscriptionActivity.this.U(gVar);
            SubscriptionActivity.this.B.fetchCouponData();
        }
    }

    enum g {
        US,
        India,
        Other
    }

    public void U(g gVar) {
        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
        LinearLayoutManager linearLayoutManager2 = new LinearLayoutManager(this);
        List<FrequentlyQuestion> frequentlyQuestion = AppController.j().g().getFrequentlyQuestion();
        T(AppController.j().g().getBenefitQuestion(), linearLayoutManager2, gVar);
        V(frequentlyQuestion, linearLayoutManager);
        this.b.G.setOnClickListener(new d(frequentlyQuestion));
    }

    public void W(boolean z, boolean z2, View view) {
        LinearLayout linearLayout = (LinearLayout) view.findViewById(2131429329);
        if (z2) {
            linearLayout.setBackgroundResource(h0(z, true));
        } else {
            linearLayout.setBackgroundResource(h0(z, false));
        }
    }

    public void X(FilterPlanWRTDuration.PlanFilter planFilter) {
        ArrayList<MintPlanWithZSPlan> arrayList = this.c.get(planFilter.getPlanFilter());
        this.j = arrayList;
        if (arrayList == null) {
            this.j = new ArrayList<>();
        }
        if (this.j.size() > 0) {
            this.b.a.setVisibility(0);
        } else {
            this.b.a.setVisibility(8);
        }
        this.h.setPlansList(this.j);
        this.h.notifyDataSetChanged();
    }

    private void Z() {
        this.a.addOnTabSelectedListener(new b(AppController.j().E()));
    }

    private View a0(LayoutInflater layoutInflater, boolean z, boolean z2) {
        View inflate = layoutInflater.inflate(2131624641, (ViewGroup) null, false);
        LinearLayout linearLayout = (LinearLayout) inflate.findViewById(2131429329);
        ImageView imageView = (ImageView) inflate.findViewById(2131428852);
        boolean E = AppController.j().E();
        if (z) {
            linearLayout.setBackgroundResource(h0(E, z2));
            if (E) {
                imageView.setImageResource(2131233472);
            } else {
                imageView.setImageResource(2131233472);
            }
        } else {
            linearLayout.setBackgroundResource(h0(E, z2));
            if (E) {
                imageView.setImageResource(2131233471);
            } else {
                imageView.setImageResource(2131233470);
            }
        }
        return inflate;
    }

    private ArrayList<ZSPlan> c0(ArrayList<ZSPlan> arrayList) {
        ArrayList<ZSPlan> arrayList2 = new ArrayList<>();
        MintPlan mintPlan = this.o;
        Plans plans = mintPlan != null ? mintPlan.getPlans() : null;
        Iterator<ZSPlan> it = arrayList.iterator();
        while (it.hasNext()) {
            ZSPlan next = it.next();
            if (next.getStatus().equalsIgnoreCase("active")) {
                if (plans != null) {
                    List<SubsPlans> mintOnly = plans.getMintOnly();
                    List<SubsPlans> mintWsj = plans.getMintWsj();
                    String code = next.getCode();
                    boolean l0 = l0(code, mintOnly);
                    if (!l0) {
                        l0 = l0(code, mintWsj);
                    }
                    if (l0) {
                        arrayList2.add(next);
                    }
                } else {
                    arrayList2.add(next);
                }
            }
        }
        return arrayList2;
    }

    private void checkConfig() {
        boolean z;
        boolean z2;
        Config g2 = getApplication().g();
        this.A = g2;
        if (g2 == null) {
            k6.r rVar = new k6.r(this, this);
            this.i = rVar;
            rVar.e(0, "SubscriptionActivity", "https://images.livemint.com/apps/v3/deviceconfig.json", true, false);
            return;
        }
        if (g2.getSubscription() != null) {
            z = this.A.getSubscription().isSubscriptionEnable();
            z2 = this.A.getSubscription().isTrialEnabled();
            this.z = this.A.getSubscription().isRazorPayEnabled();
        } else {
            z = false;
            z2 = false;
        }
        this.b.e(Boolean.valueOf(z2));
        if (z) {
            initSubscription(this.A);
        } else {
            goBack();
        }
    }

    private void checkZSUserSubscriptionDetail() {
        new SyncPurchaseWithSession.SyncPaymentFailureAsyncTask(this).execute(this.d);
        new GetUserSubscriptionDetail(this, this).fetchUserSubscriptionDetail("subscribenowbutton", q.f0.HT_SUBSCRIPTION, true);
    }

    private Section f0(String str, String str2) {
        List<Section> settings = AppController.j().g().getSettings();
        if (str2.equalsIgnoreCase("others")) {
            settings = AppController.j().g().getOthers();
        }
        for (Section section : settings) {
            if (!TextUtils.isEmpty(section.getId()) && section.getId().equalsIgnoreCase(str)) {
                return section;
            }
        }
        return null;
    }

    private int getHeightOfScreen() {
        DisplayMetrics displayMetrics = new DisplayMetrics();
        getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
        return displayMetrics.heightPixels;
    }

    private MintSubscriptionDetail getUpdatedSubscriptionDetail(Intent intent) {
        MintSubscriptionDetail l = AppController.j().l();
        if (l == null) {
            Bundle extras = intent != null ? intent.getExtras() : null;
            if (extras != null) {
                l = (MintSubscriptionDetail) extras.getParcelable("Subscription");
                if (l.getStatus() == null) {
                    l.setStatus((SubscriptionStatus) extras.getSerializable("Status"));
                }
                if (l.getSource() == null) {
                    l.setSource((SubscriptionSource) extras.getSerializable("Source"));
                }
                if (l.getIntervalUnit() == null) {
                    l.setIntervalUnit((PlanInterval) extras.getSerializable("PlanIntervalUnit"));
                }
            }
        }
        return l;
    }

    public void goBack() {
        if (getIntent().getExtras() != null && getIntent().getExtras().containsKey("isNotification") && getIntent().getExtras().getInt("isNotification") > q.m.SPLASH.ordinal()) {
            startActivity(new Intent((Context) this, (Class<?>) HomeActivity.class));
        }
        setSubscriptionIntent();
        finish();
    }

    private int h0(boolean z, boolean z2) {
        return z ? z2 ? 2131234165 : 2131234168 : z2 ? 2131234163 : 2131234166;
    }

    private boolean handleDeeplink(Bundle bundle) {
        if (bundle != null && bundle.containsKey("urlPlankey")) {
            String string = bundle.getString("urlPlankey", BuildConfig.FLAVOR);
            if (!TextUtils.isEmpty(string)) {
                Uri parse = Uri.parse(string);
                parse.getHost();
                parse.getScheme();
                if (parse.getPath().equalsIgnoreCase(com.htmedia.mint.utils.s0.AUTO_APPLY_COUPON.b())) {
                    this.y = true;
                    Set<String> queryParameterNames = parse.getQueryParameterNames();
                    if (queryParameterNames == null || queryParameterNames.isEmpty()) {
                        goBack();
                        return false;
                    }
                    this.x = parse.getQueryParameter("coupon");
                    this.B.setAutoCouponApplied(this.y);
                    this.B.setPartenrCouponCode(this.x);
                    if (TextUtils.isEmpty(this.x)) {
                        goBack();
                        return false;
                    }
                }
            }
        }
        return true;
    }

    private void i0(PianoResponse pianoResponse) {
        com.htmedia.mint.utils.n.A(this, com.htmedia.mint.utils.n.f1, "plan_page", com.htmedia.mint.utils.n.s0, this.E, null);
        PlanPageHeading planPageHeading = new PlanPageHeading(this, this.b);
        planPageHeading.setPianoResponse(pianoResponse);
        planPageHeading.initPlanHeader();
    }

    private void initCountryAndPlans() {
        new f(this, null).execute(new Void[0]);
    }

    private void initNumberFormat() {
        if (this.D == null) {
            NumberFormat numberInstance = NumberFormat.getNumberInstance(new Locale("en"));
            this.D = numberInstance;
            numberInstance.setRoundingMode(RoundingMode.CEILING);
            this.D.setMaximumFractionDigits(2);
        }
    }

    private void initPianoExp() {
        new PianoCallbacks(this, this).checkUserScope("subscriptionplanpage", (List) null, "https://accounts.hindustantimes.com/lm/userplan", new HashMap(), this.E);
    }

    private void initProgressDialogAndShow() {
        ProgressDialog progressDialog = this.f;
        if (progressDialog != null && !progressDialog.isShowing()) {
            this.f.show();
            return;
        }
        if (this.f == null) {
            ProgressDialog progressDialog2 = new ProgressDialog(this);
            this.f = progressDialog2;
            progressDialog2.setMessage("Please wait...!");
            this.f.setCancelable(false);
            if (this.f.isShowing()) {
                return;
            }
            this.f.show();
        }
    }

    private void initSubscription(Config config) {
        x0(config);
        this.u = config.getSso() != null ? config.getAdFreeSubscription().getAdFreeValue() : BuildConfig.FLAVOR;
        ProgressDialog progressDialog = new ProgressDialog(this);
        this.f = progressDialog;
        progressDialog.setMessage("Please wait...!");
        boolean z = false;
        this.f.setCancelable(false);
        this.b.w.setLayoutManager(new LinearLayoutManager(this));
        DefaultItemAnimator itemAnimator = this.b.v.getItemAnimator();
        if (itemAnimator instanceof DefaultItemAnimator) {
            itemAnimator.setSupportsChangeAnimations(false);
        }
        j7 j7Var = new j7(this, this, this.j, this);
        this.h = j7Var;
        this.b.w.setAdapter(j7Var);
        this.b.a.setOnClickListener(this);
        this.b.K.setOnClickListener(this);
        this.b.M.setOnClickListener(this);
        if (config.getPiano() != null && config.getPiano().isPlanPageExperience()) {
            z = true;
        }
        if (z) {
            initPianoExp();
        } else {
            initCountryAndPlans();
        }
        showProgressDialog();
    }

    private void initiatePayment(MintSubscriptionDetail mintSubscriptionDetail) {
        SubscriptionPlanSingleton subscriptionPlanSingleton = SubscriptionPlanSingleton.getInstance();
        WebEngageAnalytices.PAYMENTSTORE paymentstore = WebEngageAnalytices.PAYMENTSTORE.PLAY_STORE;
        subscriptionPlanSingleton.setPaymentMethod(paymentstore.getStore());
        WebEngageAnalytices.trackPaymentStatus("Subscribe Now Click", (ZSSuscriptionDetail) null, this.e, (ZSError) null, this.t, (String) null, paymentstore.getStore(), true);
        this.q = false;
        ArrayList<MintPlanWithZSPlan> arrayList = this.j;
        if (arrayList == null || arrayList.size() <= 0 || this.d == null) {
            return;
        }
        SnowplowSubscriptionAnalytices.trackSubscribeNowButtonClick(this.b.u.getSelectedTabPosition() == 1, this.d);
        String storeOrderId = (mintSubscriptionDetail == null || mintSubscriptionDetail.getSource() == null || mintSubscriptionDetail.getSource() != SubscriptionSource.playstore) ? BuildConfig.FLAVOR : mintSubscriptionDetail.getStoreOrderId();
        String str = TextUtils.isEmpty(storeOrderId) ? BuildConfig.FLAVOR : storeOrderId;
        if (str.equalsIgnoreCase("unknown")) {
            return;
        }
        ArrayList<ZSCustomField> arrayList2 = new ArrayList<>();
        arrayList2.add(new ZSCustomField("cf_localized_currency", this.d.getSkuDetails().d()));
        arrayList2.add(new ZSCustomField("cf_eco_new_app", "yes"));
        ZSInAppPurchaseKit.getInstance().initiateNewPurchase(this, this.d, str, arrayList2, this);
    }

    public void j0(boolean z) {
        Config g2 = AppController.j().g();
        int defaultTabSelected = (g2 == null || g2.getSubscription() == null) ? 0 : g2.getSubscription().getDefaultTabSelected();
        if (!z) {
            defaultTabSelected = 0;
        }
        TabLayout findViewById = findViewById(2131430119);
        this.a = findViewById;
        if (findViewById.getTabCount() < 1) {
            LayoutInflater from = LayoutInflater.from(this);
            LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(-1, -1);
            TabLayout tabLayout = this.a;
            tabLayout.addTab(tabLayout.newTab().setCustomView(a0(from, true, defaultTabSelected == 0)), 0);
            this.a.getTabAt(0).getCustomView().setLayoutParams(layoutParams);
            this.a.getTabAt(0).setTag(FilterPlanWRTDuration.PlanFilter.PLAN_MINT.getPlanFilter());
            if (z) {
                TabLayout tabLayout2 = this.a;
                tabLayout2.addTab(tabLayout2.newTab().setCustomView(a0(from, false, defaultTabSelected == 1)), 1);
                this.a.getTabAt(1).getCustomView().setLayoutParams(layoutParams);
                this.a.getTabAt(1).setTag(FilterPlanWRTDuration.PlanFilter.PLAN_WSJ.getPlanFilter());
            }
            this.a.getTabAt(defaultTabSelected).select();
            y0(defaultTabSelected == 0);
            Z();
        }
    }

    private boolean l0(String str, List<SubsPlans> list) {
        if (list == null || list.size() <= 0) {
            return false;
        }
        for (SubsPlans subsPlans : list) {
            if (str.equalsIgnoreCase(subsPlans.getPlanCode()) && "active".equalsIgnoreCase(subsPlans.getStatus())) {
                return true;
            }
        }
        return false;
    }

    private boolean m0() {
        if (this.a.getTabCount() == 2) {
            return this.b.u.getSelectedTabPosition() == 1;
        }
        if (this.a.getTabCount() == 1) {
            return ((String) this.a.getTabAt(0).getTag()).equalsIgnoreCase(FilterPlanWRTDuration.PlanFilter.PLAN_WSJ.getPlanFilter());
        }
        return false;
    }

    public void n0(View view) {
        this.b.O.scrollBy(0, view.getHeight() + 50);
    }

    private void newSubscriptionPage(MintSubscriptionDetail mintSubscriptionDetail) {
        SyncPurchaseWithSession.syncPurchaseWithSession(this, mintSubscriptionDetail);
        Intent intent = new Intent();
        intent.putExtra("Subscription", mintSubscriptionDetail);
        intent.putExtra("Status", mintSubscriptionDetail.getStatus());
        intent.putExtra("Source", mintSubscriptionDetail.getSource());
        intent.putExtra("PlanIntervalUnit", mintSubscriptionDetail.getIntervalUnit());
        Intent intent2 = getIntent();
        if (intent2 != null && intent2.getExtras() != null && intent2.getExtras().containsKey("isNotification") && intent2.getExtras().getInt("isNotification") > q.m.SPLASH.ordinal()) {
            startActivity(new Intent((Context) this, (Class<?>) HomeActivity.class));
        }
        setResult(-1, intent);
        finish();
    }

    public void o0(int i) {
        this.b.O.scrollBy(0, i);
    }

    private void openCheckoutPage(MintSubscriptionDetail mintSubscriptionDetail) {
        this.q = false;
        SubscriptionPlanSingleton.getInstance().setPaywallReason(this.F);
        WebEngageAnalytices.trackPaymentStatus("Subscribe Now Click", (ZSSuscriptionDetail) null, this.e, (ZSError) null, this.t, this.F, WebEngageAnalytices.PAYMENTSTORE.UNKOWN.getStore(), false);
        ArrayList<MintPlanWithZSPlan> arrayList = this.j;
        if (arrayList == null || arrayList.size() <= 0 || this.e == null || this.d == null) {
            return;
        }
        SnowplowSubscriptionAnalytices.trackSubscribeNowButtonClick(this.b.u.getSelectedTabPosition() == 1, this.d);
        SubscriptionPlanSingleton subscriptionPlanSingleton = SubscriptionPlanSingleton.getInstance();
        MintPlanWithZSPlan mintPlanWithZSPlan = this.e;
        if (mintPlanWithZSPlan != null && mintPlanWithZSPlan.getZsPlan() == null) {
            this.e.setZsPlan(this.d);
        }
        subscriptionPlanSingleton.setMintPlanWithZSPlan(this.e);
        subscriptionPlanSingleton.setSubsscreen(q.g0.NEW_PLAN_PAGE);
        subscriptionPlanSingleton.setFunnelName(this.t);
        subscriptionPlanSingleton.setPremiumStory(this.v);
        subscriptionPlanSingleton.setPaywallReason(this.F);
        com.htmedia.mint.utils.o1.a("SubscriptionActivity", "***PaywallReason***" + this.F);
        subscriptionPlanSingleton.setLastAccessUrl(this.w);
        subscriptionPlanSingleton.setmNeedToSetPassword(this.r);
        subscriptionPlanSingleton.setToShowAdFreeText(this.s);
        subscriptionPlanSingleton.setMintSubscriptionDetail(mintSubscriptionDetail);
        openRazorPayCheckout(mintSubscriptionDetail, this.e);
    }

    private void openOnboardingFlow() {
        Intent intent = new Intent((Context) this, (Class<?>) OnBoardingActivity.class);
        intent.putExtra(com.htmedia.mint.utils.n.X, "subscription");
        startActivityForResult(intent, 1004, ActivityOptions.makeCustomAnimation(this, 2130772024, 2130772030).toBundle());
    }

    private void openRazorPayCheckout(MintSubscriptionDetail mintSubscriptionDetail, MintPlanWithZSPlan mintPlanWithZSPlan) {
        PianoPlan pianoPlan = mintPlanWithZSPlan.getPianoPlan();
        if (pianoPlan == null) {
            r0(null);
            return;
        }
        List<PaymentMethod> paymentMethod = pianoPlan.getPaymentMethod();
        if (paymentMethod == null || paymentMethod.isEmpty()) {
            r0(paymentMethod);
            return;
        }
        if (paymentMethod.size() != 1) {
            r0(paymentMethod);
            return;
        }
        PaymentMethod paymentMethod2 = paymentMethod.get(0);
        String type = paymentMethod2.getType();
        if (TextUtils.isEmpty(type)) {
            r0(paymentMethod);
            return;
        }
        q.v valueOf = q.v.valueOf(type);
        String autoRecurring = paymentMethod2.getAutoRecurring();
        boolean z = !TextUtils.isEmpty(autoRecurring) && ("1".equalsIgnoreCase(autoRecurring.trim()) || "true".equalsIgnoreCase(autoRecurring.trim()));
        int i = e.a[valueOf.ordinal()];
        if (i == 1) {
            SubsPlans subsPlans = mintPlanWithZSPlan.getSubsPlans();
            this.H = new RazorPayCheckout(this, valueOf, (subsPlans == null || subsPlans.getRecurringPrice() < 5000.0d) ? z : false);
        } else if (i == 2 || i == 3) {
            this.H = new RazorPayCheckout(this, valueOf, false);
        } else if (i != 4) {
            r0(paymentMethod);
        } else {
            this.H = new RazorPayCheckout(this, valueOf, z);
        }
    }

    private ArrayList<MintPlanWithZSPlan> p0(MintPlan mintPlan, ArrayList<ZSPlan> arrayList) {
        ArrayList<MintPlanWithZSPlan> arrayList2 = new ArrayList<>();
        Plans plans = (mintPlan == null || mintPlan.getPlans() == null) ? null : mintPlan.getPlans();
        PlanPageExperience e0 = e0();
        List<PianoPlan> arrayList3 = (e0 == null || e0.getMintPlans() == null) ? new ArrayList<>() : e0.getMintPlans().getPlanList();
        List<PianoPlan> arrayList4 = (e0 == null || e0.getWsjPlans() == null) ? new ArrayList<>() : e0.getWsjPlans().getPlanList();
        if (arrayList3 == null) {
            arrayList3 = new ArrayList<>();
        }
        if (arrayList4 == null) {
            arrayList4 = new ArrayList<>();
        }
        boolean z = arrayList3.isEmpty() && arrayList4.isEmpty();
        if (arrayList != null && !arrayList.isEmpty()) {
            if (z) {
                Iterator<ZSPlan> it = arrayList.iterator();
                while (it.hasNext()) {
                    ZSPlan next = it.next();
                    String code = next.getCode();
                    MintPlanWithZSPlan mintPlanWithZSPlan = new MintPlanWithZSPlan();
                    mintPlanWithZSPlan.setZsPlan(next);
                    if (plans != null) {
                        List<SubsPlans> mintOnly = plans.getMintOnly();
                        List<SubsPlans> mintWsj = plans.getMintWsj();
                        boolean u0 = u0(code, mintOnly, mintPlanWithZSPlan);
                        if (!u0) {
                            u0 = u0(code, mintWsj, mintPlanWithZSPlan);
                        }
                        if (u0) {
                            arrayList2.add(mintPlanWithZSPlan);
                        }
                    } else {
                        arrayList2.add(mintPlanWithZSPlan);
                    }
                }
            } else {
                Iterator<ZSPlan> it2 = arrayList.iterator();
                while (it2.hasNext()) {
                    ZSPlan next2 = it2.next();
                    String code2 = next2.getCode();
                    PianoPlan paymentOptionWRTPlan = SubscriptionConverter.getPaymentOptionWRTPlan(code2, arrayList3);
                    if (paymentOptionWRTPlan == null) {
                        paymentOptionWRTPlan = SubscriptionConverter.getPaymentOptionWRTPlan(code2, arrayList4);
                    }
                    if (paymentOptionWRTPlan != null) {
                        MintPlanWithZSPlan mintPlanWithZSPlan2 = new MintPlanWithZSPlan();
                        mintPlanWithZSPlan2.setZsPlan(next2);
                        mintPlanWithZSPlan2.setPianoPlan(paymentOptionWRTPlan);
                        if (plans != null) {
                            List<SubsPlans> mintOnly2 = plans.getMintOnly();
                            List<SubsPlans> mintWsj2 = plans.getMintWsj();
                            boolean u02 = u0(code2, mintOnly2, mintPlanWithZSPlan2);
                            if (!u02) {
                                u02 = u0(code2, mintWsj2, mintPlanWithZSPlan2);
                            }
                            if (u02) {
                                arrayList2.add(mintPlanWithZSPlan2);
                            }
                        } else {
                            arrayList2.add(mintPlanWithZSPlan2);
                        }
                    }
                }
            }
        }
        if (this.z && plans != null) {
            MintPlanWithZSPlan convertMintPlanIntoZSPlan = ConvertMintPlanIntoZSPlan.convertMintPlanIntoZSPlan(this.u, ConvertMintPlanIntoZSPlan.MINT_PLAN_CODES.LM_BI.getPlan(), plans.getMintOnly());
            if (convertMintPlanIntoZSPlan != null) {
                String planCode = convertMintPlanIntoZSPlan.getSubsPlans().getPlanCode();
                if (!TextUtils.isEmpty(planCode)) {
                    PianoPlan paymentOptionWRTPlan2 = !arrayList3.isEmpty() ? SubscriptionConverter.getPaymentOptionWRTPlan(planCode, arrayList3) : null;
                    if (paymentOptionWRTPlan2 != null) {
                        convertMintPlanIntoZSPlan.setPianoPlan(paymentOptionWRTPlan2);
                        arrayList2.add(convertMintPlanIntoZSPlan);
                    } else if (arrayList3.isEmpty() && arrayList4.isEmpty()) {
                        arrayList2.add(convertMintPlanIntoZSPlan);
                    }
                }
            }
            MintPlanWithZSPlan convertMintPlanIntoZSPlan2 = ConvertMintPlanIntoZSPlan.convertMintPlanIntoZSPlan(this.u, ConvertMintPlanIntoZSPlan.MINT_PLAN_CODES.WSJ_BI.getPlan(), plans.getMintWsj());
            if (convertMintPlanIntoZSPlan2 != null) {
                String planCode2 = convertMintPlanIntoZSPlan2.getSubsPlans().getPlanCode();
                if (!TextUtils.isEmpty(planCode2)) {
                    PianoPlan paymentOptionWRTPlan3 = arrayList4.isEmpty() ? null : SubscriptionConverter.getPaymentOptionWRTPlan(planCode2, arrayList4);
                    if (paymentOptionWRTPlan3 != null) {
                        convertMintPlanIntoZSPlan2.setPianoPlan(paymentOptionWRTPlan3);
                        arrayList2.add(convertMintPlanIntoZSPlan2);
                    } else if (arrayList3.isEmpty() && arrayList4.isEmpty()) {
                        arrayList2.add(convertMintPlanIntoZSPlan2);
                    }
                }
            }
        }
        return arrayList2;
    }

    private void q0(String str) {
        boolean isEmpty = TextUtils.isEmpty(str);
        String str2 = BuildConfig.FLAVOR;
        if (isEmpty) {
            str = BuildConfig.FLAVOR;
        }
        Config g2 = AppController.j().g();
        if (g2 != null && g2.getEpaper() != null) {
            str2 = g2.getEpaper().getUrl();
        }
        if (TextUtils.isEmpty(str2)) {
            return;
        }
        if (!str2.startsWith("http")) {
            str2 = AppController.j().g().getServerUrl() + str2;
        }
        com.htmedia.mint.utils.f0.e = "Header";
        com.htmedia.mint.utils.f0.A2(this, str2 + str);
    }

    private void r0(List<PaymentMethod> list) {
        if (list != null) {
            ArrayList arrayList = new ArrayList();
            Iterator<PaymentMethod> it = list.iterator();
            while (it.hasNext()) {
                arrayList.add(it.next().getType());
            }
            SubscriptionPlanSingleton.getInstance().setPaymentOptions(arrayList);
        }
        Intent intent = new Intent((Context) this, (Class<?>) SubscriptionCheckOutPage.class);
        intent.putExtras(getIntent());
        getIntent().putExtra("needSetPassword", this.r);
        startActivityForResult(intent, 20524);
    }

    private void s0(String str, String str2) {
        Section f0;
        if (TextUtils.isEmpty(str) || (f0 = f0(str, str2)) == null) {
            return;
        }
        String url = f0.getUrl();
        if (AppController.j().E()) {
            url = f0.getNightmodeurl();
        }
        if (TextUtils.isEmpty(url)) {
            return;
        }
        Intent intent = new Intent((Context) this, (Class<?>) WebViewActivityWithHeader.class);
        intent.putExtra("url", url);
        intent.putExtra("Title", f0.getDisplayName());
        startActivity(intent);
    }

    private void setSubscriptionIntent() {
        if (GetSubscriptionIntent.getSubscriptionIntent() != null) {
            setResult(-1, GetSubscriptionIntent.getSubscriptionIntent());
        } else {
            setResult(-1);
        }
    }

    private void setToolbar() {
        Toolbar findViewById = findViewById(2131430942);
        findViewById.setContentInsetStartWithNavigation(0);
        findViewById.setTitle("Back");
        findViewById.setTitleTextColor(ResourcesCompat.getColor(getResources(), 2131101008, (Resources.Theme) null));
        findViewById.setNavigationIcon(2131231330);
        setSupportActionBar(findViewById);
        getSupportActionBar().setDisplayShowTitleEnabled(true);
        if (findViewById.getTitle() != null) {
            String charSequence = findViewById.getTitle().toString();
            for (int i = 0; i < findViewById.getChildCount(); i++) {
                AppCompatTextView childAt = findViewById.getChildAt(i);
                if ("androidx.appcompat.widget.AppCompatTextView".equals(childAt.getClass().getName())) {
                    AppCompatTextView appCompatTextView = childAt;
                    if (appCompatTextView.getText().equals(charSequence)) {
                        appCompatTextView.setTypeface(ResourcesCompat.getFont(this, 2131296270));
                        childAt.setOnClickListener(new c());
                    }
                }
            }
        }
    }

    private void t0(FilterPlanWRTDuration.PlanFilter planFilter) {
        if (this.a.getTabCount() == 2) {
            if (planFilter == FilterPlanWRTDuration.PlanFilter.PLAN_MINT) {
                this.a.getTabAt(0).select();
            } else if (planFilter == FilterPlanWRTDuration.PlanFilter.PLAN_WSJ && this.a.getTabCount() == 2) {
                this.a.getTabAt(1).select();
            }
        }
        X(planFilter);
    }

    private boolean u0(String str, List<SubsPlans> list, MintPlanWithZSPlan mintPlanWithZSPlan) {
        if (list == null) {
            return false;
        }
        for (SubsPlans subsPlans : list) {
            if (str.equalsIgnoreCase(subsPlans.getPlanCode())) {
                mintPlanWithZSPlan.setSubsPlans(subsPlans);
                PlanDiscount planDiscount = subsPlans.getPlanDiscount();
                if (subsPlans.getAd_version() != null && !TextUtils.isEmpty(subsPlans.getAd_version().getLm_d()) && subsPlans.getAd_version().getLm_d().equals(this.u)) {
                    mintPlanWithZSPlan.setAdFreePlan(true);
                }
                if (planDiscount != null) {
                    double actualPrice = planDiscount.getActualPrice();
                    double discountValue = planDiscount.getDiscountValue();
                    mintPlanWithZSPlan.setActualPrice(actualPrice);
                    mintPlanWithZSPlan.setDiscountPercent(discountValue);
                }
                return true;
            }
        }
        return false;
    }

    private void v0(AppCompatActivity appCompatActivity, TextView textView) {
        textView.setMovementMethod(new a());
    }

    private void validateUserSubscriptionAndInitatePayment(MintSubscriptionDetail mintSubscriptionDetail) {
        SubscriptionPlanSingleton.getInstance().setSelectedPlan(this.d);
        if (mintSubscriptionDetail != null && mintSubscriptionDetail.isSubscriptionActive()) {
            AppController.j().V(mintSubscriptionDetail);
            com.htmedia.mint.utils.f0.c4(this, mintSubscriptionDetail);
            this.q = false;
            goBack();
            return;
        }
        if (this.q) {
            if (!this.z) {
                initiatePayment(mintSubscriptionDetail);
                return;
            }
            MintPlanWithZSPlan mintPlanWithZSPlan = this.e;
            if (mintPlanWithZSPlan == null || mintPlanWithZSPlan.getSubsPlans() == null) {
                initiatePayment(mintSubscriptionDetail);
            } else {
                openCheckoutPage(mintSubscriptionDetail);
            }
        }
    }

    private void w0() {
        if (!TextUtils.isEmpty(com.htmedia.mint.utils.f0.G1(this, "userName"))) {
            this.b.I.setVisibility(8);
            return;
        }
        this.b.I.setVisibility(0);
        this.b.I.setText(u7.q.p0(Spannable.Factory.getInstance().newSpannable(Html.fromHtml("Already Subscribed? <b><a href=\"Signin\">Sign In</a></b>"))));
        v0(this, this.b.I);
    }

    private void x0(Config config) {
        AppController.j().l();
        this.b.d(getResources().getString(2131952403));
    }

    public void T(List<FrequentlyQuestion> list, LinearLayoutManager linearLayoutManager, g gVar) {
        if (list == null || list.size() <= 0) {
            this.b.x.setVisibility(8);
            this.b.B.setVisibility(8);
            return;
        }
        int size = list.size();
        ArrayList arrayList = new ArrayList();
        int i = 0;
        for (int i2 = 0; i2 < size; i2++) {
            FrequentlyQuestion frequentlyQuestion = list.get(i2);
            String question = frequentlyQuestion.getQuestion();
            if (!question.trim().equalsIgnoreCase("The Wall Street Journal Subscription") || gVar != g.US) {
                ArrayList arrayList2 = new ArrayList();
                Answer answer = new Answer();
                answer.setAnswer(frequentlyQuestion.getAnswer());
                arrayList2.add(answer);
                arrayList.add(i, new QuestionAnswerGroup(question, arrayList2));
                i++;
            }
        }
        this.b.x.setLayoutManager(linearLayoutManager);
        q7.g0 g0Var = new q7.g0(arrayList, this, this);
        this.p = g0Var;
        this.b.x.setAdapter(g0Var);
        this.b.x.setVisibility(0);
        this.b.B.setVisibility(0);
    }

    public void V(List<FrequentlyQuestion> list, LinearLayoutManager linearLayoutManager) {
        if (list == null || list.size() <= 0) {
            this.b.v.setVisibility(8);
            this.b.G.setVisibility(8);
            this.b.D.setVisibility(8);
            return;
        }
        ArrayList arrayList = new ArrayList();
        int i = 4;
        if (list.size() < 4) {
            i = list.size();
            this.b.G.setVisibility(8);
        } else {
            this.b.G.setVisibility(0);
        }
        for (int i2 = 0; i2 < i; i2++) {
            ArrayList arrayList2 = new ArrayList();
            Answer answer = new Answer();
            answer.setAnswer(list.get(i2).getAnswer());
            arrayList2.add(answer);
            arrayList.add(i2, new QuestionAnswerGroup(list.get(i2).getQuestion(), arrayList2));
        }
        this.b.v.setLayoutManager(linearLayoutManager);
        q7.g0 g0Var = new q7.g0(arrayList, this, this);
        this.p = g0Var;
        this.b.v.setAdapter(g0Var);
        this.b.v.setVisibility(0);
    }

    public void Y() {
        boolean E = AppController.j().E();
        this.b.c(Boolean.valueOf(E));
        if (E) {
            this.b.y.setBackgroundColor(getResources().getColor(2131099901));
            this.b.A.setBackgroundColor(getResources().getColor(2131100008));
            this.b.v.setBackgroundColor(getResources().getColor(2131100950));
            this.b.B.setTextColor(getResources().getColor(2131099809));
            this.b.D.setTextColor(getResources().getColor(2131099809));
            this.b.b.setCardBackgroundColor(getResources().getColor(2131100598));
            this.b.J.setTextColor(getResources().getColor(2131100905));
            this.b.L.setTextColor(getResources().getColor(2131100906));
            return;
        }
        this.b.y.setBackgroundColor(getResources().getColor(2131099809));
        this.b.A.setBackgroundColor(getResources().getColor(2131099809));
        this.b.v.setBackgroundColor(getResources().getColor(2131100951));
        this.b.B.setTextColor(getResources().getColor(2131100683));
        this.b.D.setTextColor(getResources().getColor(2131100683));
        this.b.b.setCardBackgroundColor(getResources().getColor(2131099809));
        this.b.J.setTextColor(getResources().getColor(2131100905));
        this.b.L.setTextColor(getResources().getColor(2131100905));
    }

    public void b0() {
        Config g2 = AppController.j().g();
        String str = (g2.getSso() != null ? g2.getSso().getPlanFetch() : BuildConfig.FLAVOR) + "?device=android&country=IN";
        HashMap<String, String> hashMap = new HashMap<>();
        hashMap.put("ProductId", getResources().getString(2131952728));
        new k6.c1(this, this).a(0, "FetchPlan", str, hashMap, null, false, false, false, BuildConfig.FLAVOR);
    }

    public HashMap<String, ArrayList<MintPlanWithZSPlan>> d0() {
        return this.c;
    }

    public void dismissProgressDialog() {
        try {
            ProgressDialog progressDialog = this.f;
            if (progressDialog != null && progressDialog.isShowing()) {
                this.f.dismiss();
            }
        } catch (IllegalArgumentException unused) {
        } catch (Throwable th) {
            this.f = null;
            throw th;
        }
        this.f = null;
    }

    public PlanPageExperience e0() {
        PianoResponse pianoResponse;
        if (this.G == null && (pianoResponse = PianoResponseSingleTon.getInstance().getPianoResponse()) != null) {
            this.G = pianoResponse.getPlanPageExperience();
        }
        return this.G;
    }

    public j7 g0() {
        return this.h;
    }

    @Override
    public void getConfig(Config config) {
        boolean z;
        boolean z2;
        this.A = config;
        getApplication().L(config);
        if (config.getSubscription() != null) {
            z = config.getSubscription().isSubscriptionEnable();
            z2 = config.getSubscription().isTrialEnabled();
            this.z = config.getSubscription().isRazorPayEnabled();
        } else {
            z = false;
            z2 = false;
        }
        this.b.e(Boolean.valueOf(z2));
        if (z) {
            initSubscription(config);
        } else {
            goBack();
        }
    }

    @Override
    public void getMintPlan(MintPlan mintPlan) {
        this.o = mintPlan;
        ZohoInAppConfig.getInAppPurchaseKit().getPlans(this);
    }

    @Override
    public void getMintServerPlan(MintServerPlan mintServerPlan) {
    }

    public void getPianoResponse(String str, ForyouPojo foryouPojo, PianoResponse pianoResponse) {
        initCountryAndPlans();
        j7 j7Var = this.h;
        if (j7Var != null) {
            j7Var.l();
        }
        if (pianoResponse != null) {
            PlanPageExperience planPageExperience = pianoResponse.getPlanPageExperience();
            this.G = planPageExperience;
            if (planPageExperience != null && planPageExperience.getPlanUI() != null) {
                String androidCouponCode = planPageExperience.getPlanUI().getAndroidCouponCode();
                if (!TextUtils.isEmpty(androidCouponCode)) {
                    this.x = androidCouponCode;
                    this.y = true;
                    CouponModule couponModule = this.B;
                    if (couponModule != null) {
                        couponModule.setAutoCouponApplied(true);
                    }
                }
            }
        }
        WebEngageAnalytices.trackActivityLandEvent("Plan Detail View", this.t, this.E, this.F);
        i0(pianoResponse);
    }

    @Override
    public void getPremiumPlan(SubscribeNowPerant subscribeNowPerant) {
    }

    public void getUserSubscriptionDetail(MintSubscriptionDetail mintSubscriptionDetail) {
        validateUserSubscriptionAndInitatePayment(mintSubscriptionDetail);
    }

    public boolean k0() {
        return this.C;
    }

    protected void onActivityResult(int i, int i2, @Nullable Intent intent) {
        super/*androidx.fragment.app.FragmentActivity*/.onActivityResult(i, i2, intent);
        boolean z = false;
        if (i == 1001 && i2 == -1) {
            if (intent != null && intent.hasExtra("isSignUp")) {
                this.r = intent.getBooleanExtra("isSignUp", false);
            }
            w0();
            HashMap hashMap = new HashMap();
            String F1 = com.htmedia.mint.utils.f0.F1(this);
            if (F1 != null) {
                hashMap.put("userEmail", F1);
            }
            if (com.htmedia.mint.utils.f0.G1(this, "userName") != null) {
                hashMap.put("userName", com.htmedia.mint.utils.f0.G1(this, "userName"));
            }
            if (!hashMap.isEmpty()) {
                com.htmedia.mint.utils.o0.i(hashMap);
            }
            x0(AppController.j().g());
            y0(this.C);
            checkZSUserSubscriptionDetail();
            return;
        }
        if (i != 1003 || i2 != -1) {
            if (i == 1002 && i2 == -1) {
                openOnboardingFlow();
                return;
            }
            if (i == 20524 && i2 == -1) {
                newSubscriptionPage(getUpdatedSubscriptionDetail(intent));
                return;
            } else if (i != 1004 || i2 != -1) {
                this.q = false;
                return;
            } else {
                setSubscriptionIntent();
                finish();
                return;
            }
        }
        Intent intent2 = getIntent();
        if (intent2 != null && intent2.getExtras() != null && intent2.getExtras().containsKey("needSetPassword")) {
            z = intent2.getExtras().getBoolean("needSetPassword");
        }
        if (z) {
            Intent intent3 = new Intent((Context) this, (Class<?>) LoginRegisterActivity.class);
            intent3.putExtra("origin", "Subscription After");
            intent3.setFlags(603979776);
            startActivityForResult(intent3, 1002);
            return;
        }
        if (com.htmedia.mint.utils.f0.R0(this) == q.n.BOTH) {
            openOnboardingFlow();
            return;
        }
        Intent intent4 = new Intent((Context) this, (Class<?>) LoginRegisterActivity.class);
        intent4.putExtra("origin", "Linking");
        intent4.putExtra("linkingType", com.htmedia.mint.utils.f0.R0(this).ordinal());
        intent4.setFlags(603979776);
        startActivityForResult(intent4, 1002);
    }

    public void onBackPressed() {
        goBack();
    }

    @Override
    public void onClick(View view) {
        int id2 = view.getId();
        if (id2 != 2131427752) {
            if (id2 == 2131431690) {
                s0("153450746261", "settingarray");
                return;
            } else {
                if (id2 != 2131431728) {
                    return;
                }
                s0("153450634735", "settingarray");
                return;
            }
        }
        if (this.q) {
            return;
        }
        SubscriptionPlanSingleton.getInstance().setFunnelName(this.t);
        Content content = this.t.equalsIgnoreCase("Paywall") ? SubscriptionPlanSingleton.getInstance().getContent() : null;
        SubscriptionPlanSingleton.getInstance().setSelectedPlan(this.d);
        Content content2 = content;
        com.htmedia.mint.utils.n.A(this, com.htmedia.mint.utils.n.g1, "plan_page", com.htmedia.mint.utils.n.s0, content2, null);
        f5.a.e(this, "plan_detail_page_subscribe_button_click", f5.a.d, f5.a.e, content2, (String) null);
        this.q = true;
        if (com.htmedia.mint.utils.f0.G1(this, "userName") != null) {
            checkZSUserSubscriptionDetail();
        } else {
            WebEngageAnalytices.trackClickEvents("Subscribe Now", (String) null, "Sign In Initiate", (Content) null, "Subscription Funnel", BuildConfig.FLAVOR, BuildConfig.FLAVOR);
            openLoginPage("Subscription Funnel");
        }
    }

    public void onConfigurationChanged(@NonNull Configuration configuration) {
        super.onConfigurationChanged(configuration);
        AppController.e(getIntent(), this);
    }

    protected void onCreate(@Nullable Bundle bundle) {
        super/*androidx.fragment.app.FragmentActivity*/.onCreate(bundle);
        getWindow().setSoftInputMode(32);
        mq0 contentView = DataBindingUtil.setContentView(this, 2131625242);
        this.b = contentView;
        this.B = new CouponModule(this, contentView);
        checkConfig();
        Bundle extras = getIntent().getExtras();
        if (extras != null) {
            if (!handleDeeplink(extras)) {
                return;
            }
            String str = BuildConfig.FLAVOR;
            this.t = extras.getString("funnelName", BuildConfig.FLAVOR);
            if (extras.containsKey("paywallReason")) {
                str = extras.getString("paywallReason");
            }
            this.F = str;
            SubscriptionPlanSingleton.getInstance().setFunnelName(this.t);
            SubscriptionPlanSingleton.getInstance().setPaywallReason(this.F);
            if (this.t.equalsIgnoreCase("Paywall")) {
                this.E = SubscriptionPlanSingleton.getInstance().getContent();
            }
            if (extras.containsKey("keyPremiumStrory")) {
                this.v = extras.getString("keyPremiumStrory");
            }
            if (TextUtils.isEmpty(this.v)) {
                this.v = this.F;
            }
            if (extras.containsKey("lastAceessUrl")) {
                this.w = extras.getString("lastAceessUrl");
            }
            SnowplowSubscriptionAnalytices.trackLinkClick(extras);
        }
        com.htmedia.mint.utils.f0.b = false;
        w0();
        setToolbar();
        Y();
        com.htmedia.mint.utils.k1.x(com.htmedia.mint.utils.k1.l(this), "/subscribe");
    }

    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(2131689480, menu);
        return true;
    }

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

    @Override
    public void onError(ZSError zSError) {
        dismissProgressDialog();
        com.htmedia.mint.utils.o1.a("SubscriptionActivity", "-->" + zSError.getCode() + "<-->" + zSError.getMessage());
        com.htmedia.mint.utils.o0.e(zSError.getCode().getDescription(), zSError.getMessage(), getClass().getName());
        WebEngageAnalytices.trackPaymentStatus("Payment Failed", (ZSSuscriptionDetail) null, this.e, zSError, this.t, this.v, WebEngageAnalytices.PAYMENTSTORE.PLAY_STORE.getStore(), true);
        if (zSError.getCode() == ZSErrorCode.PLAY_STORE_PROBLEM) {
            this.b.r.setVisibility(8);
            this.b.L.setVisibility(8);
            this.b.a.setText(getResources().getString(2131952583));
        }
        com.htmedia.mint.utils.f0.M(this);
        ZSErrorCodeHandling.zsErrorCodeHandling(this, zSError.getCode());
    }

    @Override
    public void onError(String str) {
    }

    @Override
    public void onError(String str, String str2) {
        this.b.r.setVisibility(8);
        this.b.L.setVisibility(8);
        this.b.a.setText(getResources().getString(2131952583));
        ZohoInAppConfig.getInAppPurchaseKit().getPlans(this);
    }

    public boolean onOptionsItemSelected(MenuItem menuItem) {
        int itemId = menuItem.getItemId();
        if (itemId == 16908332) {
            goBack();
            return true;
        }
        if (itemId != 2131427416) {
            return super/*android.app.Activity*/.onOptionsItemSelected(menuItem);
        }
        q0("?utm_source=androidapp&utm_medium=topnav&utm_campaign=promo");
        return true;
    }

    @Override
    public void onPaymentError(int i, String str, PaymentData paymentData) {
        this.H.onPaymentError(i, str, paymentData);
    }

    @Override
    public void onPaymentSuccess(String str, PaymentData paymentData) {
        this.H.onPaymentSuccess(str, paymentData);
    }

    @Override
    public void onPlanDetailsFetched(ArrayList<ZSPlan> arrayList) {
        CouponModule couponModule;
        dismissProgressDialog();
        if (arrayList == null || arrayList.size() <= 0) {
            this.b.a.setVisibility(8);
        } else {
            ArrayList<MintPlanWithZSPlan> p0 = p0(this.o, SubscriptionConverter.getFilterPlanByCustomField(c0(arrayList)));
            boolean z = false;
            if (p0 != null && p0.isEmpty()) {
                Toast.makeText((Context) this, (CharSequence) "There is no plan for this user.", 0).show();
            }
            this.c = FilterPlanWRTDuration.filterPlan(p0);
            FilterPlanWRTDuration.PlanFilter planFilter = FilterPlanWRTDuration.PlanFilter.PLAN_WSJ;
            String planFilter2 = planFilter.getPlanFilter();
            FilterPlanWRTDuration.PlanFilter planFilter3 = FilterPlanWRTDuration.PlanFilter.PLAN_MINT;
            String planFilter4 = planFilter3.getPlanFilter();
            boolean z2 = (this.c.get(planFilter2) == null || this.c.get(planFilter2).isEmpty()) ? false : true;
            if (this.c.get(planFilter4) != null && !this.c.get(planFilter4).isEmpty()) {
                z = true;
            }
            if (!(z2 && z) && (z2 || z)) {
                if (z2 && m0()) {
                    t0(planFilter);
                } else if (z) {
                    t0(planFilter3);
                }
            } else if (m0()) {
                X(planFilter);
            } else {
                X(planFilter3);
            }
        }
        if (!this.y || TextUtils.isEmpty(this.x) || (couponModule = this.B) == null) {
            return;
        }
        couponModule.autoApplyCoupon(this.x);
    }

    public boolean onPrepareOptionsMenu(Menu menu) {
        MenuItem findItem = menu.findItem(2131427416);
        if (AppController.j().E()) {
            findItem.setIcon(getResources().getDrawable(2131232446));
        } else {
            findItem.setIcon(getResources().getDrawable(2131232444));
        }
        return super/*android.app.Activity*/.onPrepareOptionsMenu(menu);
    }

    @Override
    public void onPurchaseSyncedWithServer(ZSSuscriptionDetail zSSuscriptionDetail) {
        dismissProgressDialog();
        MintSubscriptionDetail convertZSSubsDetailWithMintSubs = GetUserSubscriptionDetail.convertZSSubsDetailWithMintSubs(zSSuscriptionDetail);
        SyncPurchaseWithSession.syncPurchaseWithSession(this, convertZSSubsDetailWithMintSubs);
        Content content = this.t.equalsIgnoreCase("Paywall") ? SubscriptionPlanSingleton.getInstance().getContent() : null;
        com.htmedia.mint.utils.n.A(this, com.htmedia.mint.utils.n.h1, "plan_page", com.htmedia.mint.utils.n.t0, content, null);
        f5.a.e(this, "payment_success", f5.a.d, f5.a.f, content, (String) null);
        WebEngageAnalytices.trackPaymentStatus("Payment Success", zSSuscriptionDetail, this.e, (ZSError) null, this.t, this.v, WebEngageAnalytices.PAYMENTSTORE.PLAY_STORE.getStore(), true);
        getIntent().putExtra("needSetPassword", this.r);
        GetUserSubscriptionDetail.SyncSubscriptionAsyncTask syncSubscriptionAsyncTask = new GetUserSubscriptionDetail.SyncSubscriptionAsyncTask(this);
        if (!TextUtils.isEmpty(this.v)) {
            syncSubscriptionAsyncTask.setPremiumStory(this.v);
        }
        if (!TextUtils.isEmpty(this.t)) {
            syncSubscriptionAsyncTask.setFunnelEntry(this.t);
        }
        syncSubscriptionAsyncTask.setPianoExp(SubscriptionPlanSingleton.getInstance().getPianoExpName());
        syncSubscriptionAsyncTask.setZsPlan(this.d);
        syncSubscriptionAsyncTask.setUserSubscriptionStatus("New");
        syncSubscriptionAsyncTask.execute(convertZSSubsDetailWithMintSubs);
    }

    protected void onResume() {
        super/*androidx.fragment.app.FragmentActivity*/.onResume();
        if (AppController.j().E()) {
            getWindow().setStatusBarColor(-16777216);
            getWindow().getDecorView().setSystemUiVisibility(0);
            this.b.A.setBackgroundColor(getResources().getColor(2131100008));
            this.b.A.setTitleTextColor(ResourcesCompat.getColor(getResources(), 2131101009, (Resources.Theme) null));
            this.b.A.setNavigationIcon(2131231333);
            if (AppController.j().l() == null || !AppController.j().l().isSubscriptionActive()) {
                this.b.d.setImageDrawable(getResources().getDrawable(2131233472));
            } else {
                this.b.d.setImageDrawable(getResources().getDrawable(2131232639));
            }
        } else {
            getWindow().setStatusBarColor(-1);
            getWindow().getDecorView().setSystemUiVisibility(8192);
            this.b.A.setBackgroundColor(getResources().getColor(2131101002));
            this.b.A.setTitleTextColor(ResourcesCompat.getColor(getResources(), 2131101008, (Resources.Theme) null));
            this.b.A.setNavigationIcon(2131231330);
            if (AppController.j().l() == null || !AppController.j().l().isSubscriptionActive()) {
                this.b.d.setImageDrawable(getResources().getDrawable(2131233472));
            } else {
                this.b.d.setImageDrawable(getResources().getDrawable(2131232638));
            }
        }
        com.htmedia.mint.utils.n.q0(this, "Plan Detail View");
    }

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

    @Override
    public void onStorePurchaseCompleted() {
        com.htmedia.mint.utils.f0.w3(this, "issubscribedmint", true);
        Toast.makeText((Context) this, (CharSequence) "Purchase Completed Successfully.", 0).show();
        initProgressDialogAndShow();
    }

    public void onSubscriptionError(SubscriptionError subscriptionError) {
        if (subscriptionError.getErrorCode() == ErrorCode.TOKEN_API_FAILED || subscriptionError.getErrorCode() == ErrorCode.UNKNOWN_ERROR) {
            Toast.makeText((Context) this, (CharSequence) "Something went wrong. Please try later.", 0).show();
        } else if (subscriptionError.getErrorCode() == ErrorCode.TOKEN_EXPIRE) {
            WebEngageAnalytices.trackClickEvents("Sign In", (String) null, "Sign In Initiate", (Content) null, "Subscription Funnel", BuildConfig.FLAVOR, BuildConfig.FLAVOR);
            openLoginPage("Subscription Funnel");
        } else if (subscriptionError.getErrorCode() == ErrorCode.ITEM_ALREADY_PURCHASED) {
            Toast.makeText((Context) this, (CharSequence) "You are already subscribed with your existing Playstore ID.", 1).show();
        }
        this.q = false;
        com.htmedia.mint.utils.o0.e(subscriptionError.getErrorCode().name(), subscriptionError.getMessage(), getClass().getName());
        if (CheckSubscriptionFromLocal.isSubscribedUser(this)) {
            setSubscriptionIntent();
            finish();
        }
    }

    public void openLoginPage(String str) {
        Intent intent = new Intent((Context) this, (Class<?>) LoginRegisterActivity.class);
        intent.putExtra("origin", str);
        intent.putExtra("ssoReason", "plans_page");
        if (!TextUtils.isEmpty(this.v) && this.v.equalsIgnoreCase("premium")) {
            intent.putExtra("premiumStory", true);
        }
        intent.setFlags(603979776);
        if (str.equals("Subscription After")) {
            startActivityForResult(intent, 1002);
        } else {
            startActivityForResult(intent, 1001);
        }
    }

    public void pianoError(String str, ForyouPojo foryouPojo, PianoResponse pianoResponse) {
        WebEngageAnalytices.trackActivityLandEvent("Plan Detail View", this.t, this.E, this.F);
        initCountryAndPlans();
        i0(null);
    }

    @Override
    public void setSelectedIndex(int i) {
        if (i <= -1 || this.j.size() <= 0) {
            return;
        }
        this.d = this.j.get(i).getZsPlan();
        this.e = this.j.get(i);
        y0(this.C);
        CouponModule couponModule = this.B;
        if (couponModule != null) {
            couponModule.checkCouponForEligibility(this.e);
        }
    }

    public void showProgressDialog() {
        ProgressDialog progressDialog = this.f;
        if (progressDialog == null || progressDialog.isShowing()) {
            return;
        }
        this.f.show();
    }

    @Override
    public void u(int i) {
        try {
            int heightOfScreen = (getHeightOfScreen() * 3) / 4;
            int height = this.b.v.getHeight();
            int scrollY = this.b.O.getScrollY();
            int height2 = this.b.O.getHeight();
            int[] iArr = new int[2];
            if (i != this.p.getItemCount() - 1) {
                final View childAt = this.b.v.getChildAt(i);
                childAt.getLocationInWindow(iArr);
                if (heightOfScreen <= iArr[1]) {
                    this.b.O.post(new Runnable() {
                        @Override
                        public final void run() {
                            SubscriptionActivity.this.n0(childAt);
                        }
                    });
                } else {
                    this.b.v.scrollToPosition(i);
                }
            } else {
                final int i2 = scrollY + height2 + height;
                this.b.O.post(new Runnable() {
                    @Override
                    public final void run() {
                        SubscriptionActivity.this.o0(i2);
                    }
                });
            }
        } catch (Exception e2) {
            e2.printStackTrace();
        }
    }

    public void y0(boolean z) {
        String string;
        this.C = z;
        initNumberFormat();
        if (!this.z) {
            this.b.a.setText(getResources().getString(2131952583));
            this.b.L.setVisibility(8);
            return;
        }
        Config config = this.A;
        if (!((config == null || config.getSubscription() == null || !this.A.getSubscription().isTrialEnabled()) ? false : true) || !z) {
            MintPlanWithZSPlan mintPlanWithZSPlan = this.e;
            if (!(mintPlanWithZSPlan != null && mintPlanWithZSPlan.isCouponApplied()) || this.e.getSubsPlans() == null) {
                this.b.a.setText(getResources().getString(2131952583));
            } else {
                String str = this.e.getSubsPlans().getCurrencySymbol() + this.D.format(this.e.getDiscountPrice());
                this.e.setFormatedDiscountPrice(str);
                this.b.a.setText("Pay " + str);
            }
            this.b.L.setVisibility(8);
            return;
        }
        MintPlanWithZSPlan mintPlanWithZSPlan2 = this.e;
        if ((mintPlanWithZSPlan2 != null && mintPlanWithZSPlan2.isCouponApplied()) && this.e.getSubsPlans() != null) {
            StringBuilder sb2 = new StringBuilder();
            sb2.append(this.e.getSubsPlans().getCurrencySymbol());
            sb2.append(this.e.isTrialCoupon() ? "1" : this.D.format(this.e.getDiscountPrice()));
            String sb3 = sb2.toString();
            this.e.setFormatedDiscountPrice(sb3);
            this.b.a.setText("Pay " + sb3);
            return;
        }
        MintPlanWithZSPlan mintPlanWithZSPlan3 = this.e;
        long trialPeriod = (mintPlanWithZSPlan3 == null || mintPlanWithZSPlan3.getSubsPlans() == null) ? 0L : this.e.getSubsPlans().getTrialPeriod();
        if (trialPeriod > 0) {
            string = String.format(getResources().getString(2131952563), trialPeriod + BuildConfig.FLAVOR);
        } else {
            Config config2 = this.A;
            if (config2 == null) {
                string = getResources().getString(2131952583);
            } else if (config2.getSubscription() == null || this.A.getSubscription().getSubscriptionTrialDays() == 0) {
                string = getResources().getString(2131952583);
            } else {
                string = String.format(getResources().getString(2131952563), this.A.getSubscription().getSubscriptionTrialDays() + BuildConfig.FLAVOR);
            }
        }
        this.b.a.setText(string);
        if (trialPeriod <= 0) {
            this.b.L.setVisibility(8);
            return;
        }
        this.b.L.setText("Full refund on cancellation within " + trialPeriod + " days \n(Not applicable on renewal)");
        this.b.L.setVisibility(0);
    }
}