导航菜单

页面标题

页面副标题

Mint v5.7.3 - CountryWorker.java 源代码

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

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


package com.htmedia.mint.ui.workmanager;

import android.content.Context;
import android.text.TextUtils;
import androidx.annotation.NonNull;
import androidx.work.ListenableWorker;
import androidx.work.Worker;
import androidx.work.WorkerParameters;
import com.google.firebase.perf.network.FirebasePerfUrlConnection;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.htmedia.mint.AppController;
import com.htmedia.mint.marketRevamp.marketUtils.MarketUtils;
import com.htmedia.mint.mymint.pojo.MyMintConfig;
import com.htmedia.mint.piano.PianoResponseSingleTon;
import com.htmedia.mint.pojo.config.Config;
import com.htmedia.mint.pojo.giftingarticle.CouponPojo;
import com.htmedia.mint.pojo.giftingarticle.GiftingArticleListPojo;
import com.htmedia.mint.pojo.giftingarticle.GiftingArticleUserInfoPojo;
import com.htmedia.mint.pojo.marketRevamp.MarketRevampConfig;
import com.htmedia.mint.pojo.mintpiller.MintPillarWidgetStoryDetailResponse;
import com.htmedia.mint.pojo.newsletterwidget.NewsLetterConfigResponse;
import com.htmedia.mint.pojo.newsletterwidget.NewsLetterConfigSingleton;
import com.htmedia.mint.pojo.storydetail.AffiliateKeysResponse;
import com.htmedia.mint.storydatailpage.viewholder.s;
import com.htmedia.mint.utils.f0;
import com.htmedia.mint.utils.g1;
import com.htmedia.mint.utils.h1;
import com.htmedia.mint.utils.o0;
import com.htmedia.mint.utils.o1;
import com.snowplowanalytics.snowplow.tracker.constants.Parameters;
import com.thoughtbot.expandablerecyclerview.BuildConfig;
import g7.i;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.ProtocolException;
import java.net.URL;
import java.net.URLConnection;
import java.util.HashMap;
import javax.net.ssl.HttpsURLConnection;
import k6.b0;
import k6.c0;
import k6.u0;
import k6.x0;
import org.json.JSONObject;
import p6.e;
import p6.f;

public class CountryWorker extends Worker implements c0, u0 {
    private final String a;
    private Context b;
    private String c;
    private final String d;
    private String e;
    Config f;
    private String g;
    private final String h;
    private String i;
    c j;

    class a implements f {
        a() {
        }

        @Override
        public void getCouponCode(CouponPojo couponPojo) {
        }

        @Override
        public void getCouponData(GiftingArticleUserInfoPojo giftingArticleUserInfoPojo) {
        }

        @Override
        public void getGiftedArticleListCouponData(GiftingArticleListPojo giftingArticleListPojo) {
            if (giftingArticleListPojo == null || giftingArticleListPojo.getData() == null || giftingArticleListPojo.getData().getRedeemedArticles() == null || giftingArticleListPojo.getData().getRedeemedArticles().size() <= 0) {
                return;
            }
            g1.b().c(giftingArticleListPojo.getData().getRedeemedArticles());
        }

        @Override
        public void onError(String str, String str2) {
        }
    }

    class b extends TypeToken<MyMintConfig> {
        b() {
        }
    }

    public enum c {
        US,
        India,
        Other
    }

    public CountryWorker(@NonNull Context context, @NonNull WorkerParameters workerParameters) {
        super(context, workerParameters);
        this.a = "CountryWorker";
        this.c = BuildConfig.FLAVOR;
        this.d = BuildConfig.FLAVOR;
        this.e = BuildConfig.FLAVOR;
        this.g = BuildConfig.FLAVOR;
        this.h = BuildConfig.FLAVOR;
        this.i = BuildConfig.FLAVOR;
        this.b = context == null ? AppController.j() : context;
        this.f = AppController.j().g();
    }

    private void b() {
        Config config = this.f;
        String domainUrl = (config == null || config.getAffiliateAdUrls() == null || TextUtils.isEmpty(this.f.getAffiliateAdUrls().getDomainUrl())) ? BuildConfig.FLAVOR : this.f.getAffiliateAdUrls().getDomainUrl();
        this.e = domainUrl;
        if (TextUtils.isEmpty(domainUrl)) {
            return;
        }
        new HashMap();
        x0 x0Var = new x0(this.b, this);
        String str = this.e;
        x0Var.a(0, str, str, null, null, false, false);
    }

    private void c(Context context) {
        if (f0.n2(context)) {
            d6.b.a.a(context, false);
        }
    }

    private c d() {
        URL url = null;
        String locationUrl = (AppController.j().g() == null || TextUtils.isEmpty(AppController.j().g().getLocationUrl())) ? null : AppController.j().g().getLocationUrl();
        if (locationUrl != null) {
            try {
                url = new URL(locationUrl);
            } catch (MalformedURLException e) {
                e.printStackTrace();
                o0.h(e, locationUrl, e.getMessage());
            }
            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)) {
                        headerField = BuildConfig.FLAVOR;
                    }
                    if (!TextUtils.isEmpty(headerField)) {
                        if (!headerField.startsWith("us") && !headerField.startsWith("US")) {
                            if (headerField.startsWith("in") || headerField.startsWith("IN")) {
                                return c.India;
                            }
                        }
                        return c.US;
                    }
                }
            } catch (ProtocolException e2) {
                e2.printStackTrace();
                o0.h(e2, locationUrl, e2.getMessage());
            } catch (IOException e3) {
                e3.printStackTrace();
                o0.h(e3, locationUrl, e3.getMessage());
            } catch (Exception e4) {
                e4.printStackTrace();
                o0.h(e4, locationUrl, e4.getMessage());
            }
        }
        return c.Other;
    }

    private void e() {
        e eVar = new e(this.b, new a());
        String G1 = f0.G1(this.b, "userClient");
        if (G1 != null) {
            Config r0 = f0.r0();
            eVar.a(0, s.i, ((r0 == null || r0.getGiftArticleConfig() == null || TextUtils.isEmpty(r0.getGiftArticleConfig().getGiftedList())) ? "https://apigw.livemint.com/ss/api/v1/subscription/gift/{clientId}/redeemedArticle" : r0.getGiftArticleConfig().getGiftedList()).replace("{clientId}", G1) + "?productId=" + h1.b(this.b), null, null, false, false);
        }
    }

    private void f() {
        Config g = AppController.j().g();
        String android_url = (g == null || g.getMarketWidgetHome() == null || TextUtils.isEmpty(g.getMarketWidgetHome().getAndroid_url())) ? "https://images.livemint.com/apps/v3/stockdetailconfig.json" : g.getMarketWidgetHome().getAndroid_url();
        this.i = android_url;
        if (TextUtils.isEmpty(android_url)) {
            return;
        }
        x0 x0Var = new x0(this.b, this);
        String str = this.i;
        x0Var.a(0, str, str, null, null, false, false);
    }

    private void g() {
        Config g = AppController.j().g();
        String mintPillarWidgetStoryDetailUrl = (g == null || TextUtils.isEmpty(g.getMintPillarWidgetStoryDetailUrl())) ? BuildConfig.FLAVOR : g.getMintPillarWidgetStoryDetailUrl();
        this.g = mintPillarWidgetStoryDetailUrl;
        if (TextUtils.isEmpty(mintPillarWidgetStoryDetailUrl)) {
            return;
        }
        x0 x0Var = new x0(this.b, this);
        String str = this.g;
        x0Var.a(0, str, str, null, null, false, false);
    }

    private void h() {
        Config config = this.f;
        String androidUrl = (config == null || config.getMyMint() == null || TextUtils.isEmpty(this.f.getMyMint().getAndroidUrl())) ? BuildConfig.FLAVOR : this.f.getMyMint().getAndroidUrl();
        if (TextUtils.isEmpty(androidUrl)) {
            return;
        }
        new HashMap();
        new x0(this.b, this).a(0, androidUrl, androidUrl, null, null, false, false);
    }

    public void a(Context context) {
        Config g = AppController.j().g();
        if (g == null || g.getStockRecos() == null || TextUtils.isEmpty(g.getStockRecos().getGetMarketStatusByTime())) {
            return;
        }
        new b0(context, this).a(0, "FetchIsMarketOpen", g.getStockRecos().getGetMarketStatusByTime(), null, null, false, false);
    }

    @NonNull
    public ListenableWorker.Result doWork() {
        if (this.b == null) {
            this.b = AppController.j();
        }
        c(this.b);
        c d = d();
        this.j = d;
        f0.e3(this.b, d.name());
        Context context = this.b;
        if (context != null) {
            new i7.a(context).d(this.b, this.j);
        }
        i();
        h();
        b();
        g();
        if (h1.e(this.b) && f0.G1(this.b, "userName") != null) {
            e();
        }
        f();
        Context context2 = this.b;
        if (context2 != null) {
            a(context2);
        }
        return ListenableWorker.Result.success();
    }

    @Override
    public void getResponse(JSONObject jSONObject, String str) {
        if (jSONObject != null) {
            try {
                Gson gson = new Gson();
                if (this.c.equalsIgnoreCase(str)) {
                    NewsLetterConfigSingleton.getInstance().setNewsLetterConfigResponse((NewsLetterConfigResponse) gson.fromJson(jSONObject.toString(), NewsLetterConfigResponse.class));
                } else if (BuildConfig.FLAVOR.equalsIgnoreCase(str)) {
                    w5.a.a().c((MyMintConfig) gson.fromJson(jSONObject.toString(), new b().getType()));
                } else if (TextUtils.isEmpty(this.g) && this.g.equalsIgnoreCase(str)) {
                    i.a().d((MintPillarWidgetStoryDetailResponse) gson.fromJson(jSONObject.toString(), MintPillarWidgetStoryDetailResponse.class));
                } else if (this.e.equalsIgnoreCase(str)) {
                    g7.e.c().d((AffiliateKeysResponse) gson.fromJson(jSONObject.toString(), AffiliateKeysResponse.class));
                } else if (this.i.equalsIgnoreCase(str)) {
                    MarketUtils.INSTANCE.initialize((MarketRevampConfig) gson.fromJson(jSONObject.toString(), MarketRevampConfig.class));
                }
            } catch (Exception e) {
                e.printStackTrace();
                o0.h(e, str, e.getMessage());
            }
        }
    }

    @Override
    public void getResponseFromServer(String str, String str2, JSONObject jSONObject) {
        if (jSONObject != null) {
            if (jSONObject.optBoolean("success")) {
                String optString = jSONObject.optString(Parameters.DATA, BuildConfig.FLAVOR);
                o1.a("CountryWorker", "**URL**" + str2);
                o1.a("CountryWorker", "**UserResponse**" + jSONObject);
                PianoResponseSingleTon.getInstance().setUserScopeData(optString);
            }
            if (jSONObject.has("marketOpen")) {
                f0.f = jSONObject.optBoolean("marketOpen");
            }
        }
    }

    public void i() {
        Config config = this.f;
        this.c = (config == null || TextUtils.isEmpty(config.getNewsletter_authors_url())) ? BuildConfig.FLAVOR : this.f.getNewsletter_authors_url();
        new HashMap();
        x0 x0Var = new x0(this.b, this);
        String str = this.c;
        x0Var.a(0, str, str, null, null, false, false);
    }

    @Override
    public void onError(String str) {
    }

    @Override
    public void onError(String str, String str2, String str3) {
    }
}