OurPlay v5.5.9版本的 MD5 值为:d4e139798f4c2243a1145c8af5e21046

以下内容为反编译后的 f.java 源代码,内容仅作参考


package com.excelliance.kxqp.gs.ui.home;

import a.q;
import android.app.Activity;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.Looper;
import android.os.Message;
import android.text.TextUtils;
import android.util.Log;
import android.widget.Toast;
import androidx.lifecycle.Observer;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import androidx.work.WorkRequest;
import com.android.spush.PushItem;
import com.android.spush.SPushDBHelper;
import com.android.spush.util.WebActionRouter;
import com.excean.bytedancebi.bean.BiAppUploadInfo;
import com.excean.bytedancebi.bean.BiEventAppDownloadPause;
import com.excean.bytedancebi.manager.BiManager;
import com.excean.ggspace.main.R;
import com.excelliance.kxqp.GameUtil;
import com.excelliance.kxqp.SmtServService;
import com.excelliance.kxqp.VersionManager;
import com.excelliance.kxqp.api.ApiManager;
import com.excelliance.kxqp.api.request.GameAttrsRequest;
import com.excelliance.kxqp.api.response.NewYearGiftResponse;
import com.excelliance.kxqp.bean.AppBuyBean;
import com.excelliance.kxqp.bean.AppExtraBean;
import com.excelliance.kxqp.bean.AppStartedInfo;
import com.excelliance.kxqp.bean.CloudGameInfo;
import com.excelliance.kxqp.bean.LoginResponse;
import com.excelliance.kxqp.bean.OpenVipContentBean;
import com.excelliance.kxqp.bitmap.bean.RankingItem;
import com.excelliance.kxqp.bitmap.model.AppInfo;
import com.excelliance.kxqp.bitmap.ui.imp.j;
import com.excelliance.kxqp.gs.adapter.e;
import com.excelliance.kxqp.gs.bean.AppDownLoadInfoBean;
import com.excelliance.kxqp.gs.bean.AppDownLoadInfoChildBean;
import com.excelliance.kxqp.gs.bean.CityBean;
import com.excelliance.kxqp.gs.bean.GameChosenBean;
import com.excelliance.kxqp.gs.bean.GameCircleEntranceBean;
import com.excelliance.kxqp.gs.bean.ImportParams;
import com.excelliance.kxqp.gs.bean.InitialGameBean;
import com.excelliance.kxqp.gs.bean.ServerBroadcastInfo;
import com.excelliance.kxqp.gs.bean.ShareGameBean;
import com.excelliance.kxqp.gs.bean.TodayRecommend;
import com.excelliance.kxqp.gs.bean.UserParamInfoBean;
import com.excelliance.kxqp.gs.dialog.ad;
import com.excelliance.kxqp.gs.g.aa;
import com.excelliance.kxqp.gs.g.b;
import com.excelliance.kxqp.gs.g.t;
import com.excelliance.kxqp.gs.g.z;
import com.excelliance.kxqp.gs.l.i;
import com.excelliance.kxqp.gs.multi.down.model.DownBean;
import com.excelliance.kxqp.gs.multi.down.model.PatchDownBean;
import com.excelliance.kxqp.gs.service.CustomIntentService;
import com.excelliance.kxqp.gs.thpool.tp;
import com.excelliance.kxqp.gs.ui.combine_recomend.model.CombineRecommendBean;
import com.excelliance.kxqp.gs.ui.home.d;
import com.excelliance.kxqp.gs.ui.pay.VipFragment;
import com.excelliance.kxqp.gs.ui.search.SearchHotAndDiscover;
import com.excelliance.kxqp.gs.ui.share.core.config.SocializeMedia;
import com.excelliance.kxqp.gs.ui.share.core.helper.ShareHelper;
import com.excelliance.kxqp.gs.util.UserUtil;
import com.excelliance.kxqp.gs.util.ViewSwitcher;
import com.excelliance.kxqp.gs.util.ab;
import com.excelliance.kxqp.gs.util.ah;
import com.excelliance.kxqp.gs.util.an;
import com.excelliance.kxqp.gs.util.aq;
import com.excelliance.kxqp.gs.util.as;
import com.excelliance.kxqp.gs.util.au;
import com.excelliance.kxqp.gs.util.aw;
import com.excelliance.kxqp.gs.util.ay;
import com.excelliance.kxqp.gs.util.az;
import com.excelliance.kxqp.gs.util.bc;
import com.excelliance.kxqp.gs.util.bd;
import com.excelliance.kxqp.gs.util.bf;
import com.excelliance.kxqp.gs.util.bn;
import com.excelliance.kxqp.gs.util.bq;
import com.excelliance.kxqp.gs.util.bs;
import com.excelliance.kxqp.gs.util.bx;
import com.excelliance.kxqp.gs.util.by;
import com.excelliance.kxqp.gs.util.bz;
import com.excelliance.kxqp.gs.util.cd;
import com.excelliance.kxqp.gs.util.cg;
import com.excelliance.kxqp.gs.util.cn;
import com.excelliance.kxqp.gs.util.s;
import com.excelliance.kxqp.gs.util.w;
import com.excelliance.kxqp.gs.view.zmbanner.c;
import com.excelliance.kxqp.platforms.ExcellianceAppInfo;
import com.excelliance.kxqp.sdk.StatisticsGS;
import com.excelliance.kxqp.task.g.f;
import com.excelliance.kxqp.task.model.BuyGoogleAccountSupportPayResult;
import com.excelliance.kxqp.task.model.ResponseData;
import com.excelliance.kxqp.task.model.TaskShareDownloadParams;
import com.excelliance.kxqp.ui.InitialData;
import com.excelliance.staticslio.StatisticsManager;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.umeng.analytics.pro.am;
import com.zero.support.core.task.Response;
import java.io.File;
import java.net.URL;
import java.net.URLConnection;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import kotlinx.coroutines.DebugKt;
import org.apache.http.client.config.CookieSpecs;
import org.apache.http.cookie.ClientCookie;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

public class f implements d.a, ShareHelper.Callback {

    protected ShareHelper f10029a;

    private MainFragment f10030b;
    private Context c;
    private Context d;
    private List<InitialGameBean> e = new ArrayList();
    private List<DownBean> f = new ArrayList();
    private final Object g = new Object();
    private Thread h;
    private com.excelliance.kxqp.gs.appstore.keynote.b i;
    private a j;
    private com.excelliance.kxqp.gs.multi.down.a k;
    private Gson l;

    public void R() {
    }

    @Override
    public void onDismiss(SocializeMedia socializeMedia) {
    }

    @Override
    public void onShareStart(SocializeMedia socializeMedia) {
    }

    public com.excelliance.kxqp.gs.appstore.keynote.b p() {
        return null;
    }

    private Gson I() {
        if (this.l == null) {
            this.l = new Gson();
        }
        return this.l;
    }

    public class a extends Handler {
        public a(Looper looper) {
            super(looper);
        }

        @Override
        public void handleMessage(Message message) {
            switch (message.what) {
                case 0:
                    if (bf.a(f.this.d)) {
                        f.this.k.a(f.this.f);
                        return;
                    } else {
                        if (bf.b(f.this.d)) {
                            tp.i(new Runnable() {
                                @Override
                                public void run() {
                                    f.this.R();
                                }
                            });
                            return;
                        }
                        return;
                    }
                case 1:
                    Object obj = message.obj;
                    if (obj == null) {
                        return;
                    }
                    String obj2 = obj.toString();
                    Intent intent = new Intent(f.this.d.getPackageName() + VersionManager.q);
                    intent.putExtra(obj2 + "", true);
                    f.this.d.sendBroadcast(intent);
                    cg.a(f.this.d, w.e(f.this.d, "app_store_failure"));
                    return;
                default:
                    return;
            }
        }
    }

    public f(MainFragment mainFragment, Context context) {
        this.f10030b = mainFragment;
        this.c = context;
        this.d = this.c.getApplicationContext();
        this.k = com.excelliance.kxqp.gs.multi.down.a.a(context);
        HandlerThread handlerThread = new HandlerThread("HomePresenterWorker", 10);
        handlerThread.start();
        this.j = new a(handlerThread.getLooper());
        this.i = p();
        N();
    }

    @Override
    public void initData() {
        x();
        this.j.postDelayed(new Runnable() {
            @Override
            public void run() {
                if (com.excelliance.kxqp.gs.util.b.aa(f.this.c) && !bs.p(f.this.c) && (!com.excelliance.kxqp.gs.util.b.aN(f.this.c) || com.excelliance.kxqp.gs.ui.home.a.a(f.this.c, "flag_today_recommend_"))) {
                    f.this.b();
                }
                if (com.excean.ab_builder.c.a.F(f.this.c) && !bs.p(f.this.c)) {
                    f.this.c();
                }
                if (com.excelliance.kxqp.gs.util.b.bj(f.this.c) && !bs.p(f.this.c)) {
                    f.this.u();
                }
                if (com.excelliance.kxqp.gs.util.b.bl(f.this.c) && !bs.p(f.this.c)) {
                    f.this.v();
                }
                if (f.this.j == null) {
                }
            }
        }, 2000L);
        K();
        M();
        J();
        L();
    }

    private void J() {
        this.j.post(new Runnable() {
            @Override
            public void run() {
                HashMap hashMap = new HashMap();
                long a2 = by.a(f.this.c, "sp_total_info").a("sp_key_upload_last_pay_time", (Long) 0L);
                if (a2 > 0) {
                    hashMap.put(BiManager.LAST_PAYMENT_DATE, com.excean.bytedancebi.d.d.a(a2, "yyyy-MM-dd HH:mm:ss"));
                }
                hashMap.put(BiManager.PAYMENT_NUM, Long.valueOf(by.a(f.this.c, "sp_total_info").a("sp_key_upload_pay_count_total", (Long) 0L)));
                hashMap.put(BiManager.PAYMENT_AMOUNT, Float.valueOf(by.a(f.this.c, "sp_total_info").a("sp_key_upload_pay_money_total", Float.valueOf(0.0f)).floatValue()));
                hashMap.put(BiManager.ENTER_GAME_PAGE, Long.valueOf(by.a(f.this.c, "sp_total_info").a("sp_key_upload_enter_game_detail_count", (Long) 0L)));
                hashMap.put(BiManager.GAME_INSTALL_NUM, Long.valueOf(com.excelliance.kxqp.gs.g.c.a().f(f.this.c)));
                List<ExcellianceAppInfo> b2 = com.excelliance.kxqp.repository.a.a(f.this.c).b();
                Iterator<ExcellianceAppInfo> it = b2.iterator();
                while (it.hasNext()) {
                    ExcellianceAppInfo next = it.next();
                    if (bs.n(next.getAppPackageName()) || bs.r(next.getAppPackageName()) || bs.o(next.getAppPackageName())) {
                        if (!bs.s(next.getAppPackageName()) || !ViewSwitcher.a(f.this.c).a() || !ViewSwitcher.a(f.this.c).n()) {
                            it.remove();
                        }
                    }
                }
                hashMap.put(BiManager.NOW_GAME_NUM_INT, Integer.valueOf(b2.size()));
                BiManager.setPublicPresetParam(hashMap);
            }
        });
    }

    private void K() {
        if (com.excelliance.kxqp.gs.util.b.cz(this.c)) {
            this.j.post(new Runnable() {
                @Override
                public void run() {
                    as.f(f.this.c);
                }
            });
        }
    }

    private void L() {
        if (com.excean.ab_builder.c.a.M(this.c)) {
            this.j.post(new Runnable() {
                @Override
                public void run() {
                    ResponseData<BuyGoogleAccountSupportPayResult> e = com.excelliance.kxqp.task.store.b.a(f.this.d).e();
                    if (e.data != null) {
                        as.a(f.this.d, e.data);
                    }
                }
            });
        }
    }

    private void M() {
        this.j.post(new Runnable() {
            @Override
            public void run() {
                boolean z;
                q.a aVar = new q.a();
                by a2 = by.a(f.this.c, "sp_config");
                if (a2.c("sp_key_from_server_bought_google_account", 0) != 1) {
                    aVar.a("is_bought_google_acc", "2");
                    z = true;
                } else {
                    z = false;
                }
                if (a2.c("sp_key_from_server_bought_riot_account", 0) != 1) {
                    aVar.a(UserParamInfoBean.IS_BOUGHT_RIOT_ACCOUNT, "2");
                    z = true;
                }
                if (a2.c("sp_key_from_server_is_register", 0) != 1) {
                    aVar.a(UserParamInfoBean.IS_REGISTER, "2");
                    z = true;
                }
                if (a2.c("sp_key_from_server_first_ver", 0) == 0) {
                    aVar.a(UserParamInfoBean.FIRST_VER, "2");
                    z = true;
                }
                if (a2.c("sp_key_from_server_first_main_channel", 0) == 0) {
                    aVar.a(UserParamInfoBean.FIRST_MAIN_CHANNEL, "2");
                    z = true;
                }
                if (a2.c("sp_key_from_server_first_sub_channel", 0) == 0) {
                    aVar.a(UserParamInfoBean.FIRST_SUB_CHANNEL, "2");
                    z = true;
                }
                if (z) {
                    q a3 = aVar.a();
                    if (a3.c() > 0) {
                        for (int i = 0; i < a3.c(); i++) {
                            az.d("HomePresenter", "getUserParamInfo ket:" + a3.b(i) + " value:" + a3.d(i));
                        }
                    }
                    az.d("HomePresenter", "getUserParamInfo formBody:" + a3);
                    com.excelliance.kxqp.api.c cVar = new com.excelliance.kxqp.api.c(f.this.c);
                    cVar.a(ApiManager.getInstance().a(f.this.c, "https://api.ourplay.com.cn/").R(a3));
                    com.excelliance.kxqp.gs.appstore.model.ResponseData b2 = cVar.b();
                    az.d("HomePresenter", "getUserParamInfo responseData:" + b2);
                    if (b2 == null || b2.code != 1 || b2.data == 0) {
                        return;
                    }
                    UserParamInfoBean userParamInfoBean = (UserParamInfoBean) b2.data;
                    boolean booleanValue = by.a(f.this.c.getApplicationContext(), "sp_total_info").b("sp_key_bought_google_account_down", false).booleanValue();
                    boolean booleanValue2 = by.a(f.this.c.getApplicationContext(), "sp_total_info").b("sp_key_bought_google_account_down", false).booleanValue();
                    HashMap hashMap = new HashMap();
                    if (userParamInfoBean.is_bought_google_acc == 1) {
                        hashMap.put("is_bought_google_acc", "是");
                        a2.a("sp_key_from_server_bought_google_account", userParamInfoBean.is_bought_google_acc);
                        by.a(f.this.c.getApplicationContext(), "sp_total_info").a("sp_key_bought_google_account_down", true);
                    } else if (userParamInfoBean.is_bought_google_acc == 2) {
                        a2.a("sp_key_from_server_bought_google_account", userParamInfoBean.is_bought_google_acc);
                        hashMap.put("is_bought_google_acc", "否");
                    }
                    if (userParamInfoBean.is_bought_riot_acc == 1) {
                        a2.c("sp_key_from_server_bought_riot_account", userParamInfoBean.is_bought_riot_acc);
                        by.a(f.this.c.getApplicationContext(), "sp_total_info").a("sp_key_bought_ratio_account", true);
                    }
                    if (userParamInfoBean.is_register == 1) {
                        a2.a("sp_key_from_server_is_register", userParamInfoBean.is_register);
                        hashMap.put(BiManager.IS_REGISTER, "是");
                    } else if (userParamInfoBean.is_register == 2) {
                        a2.a("sp_key_from_server_is_register", userParamInfoBean.is_register);
                        hashMap.put(BiManager.IS_REGISTER, "否");
                    }
                    if (userParamInfoBean.first_ver != 0) {
                        a2.a("sp_key_from_server_first_ver", userParamInfoBean.first_ver);
                        BiManager.setUserPresetParam(BiManager.FIRST_VER, userParamInfoBean.first_ver + "");
                    }
                    if (userParamInfoBean.first_main_channel != 0) {
                        a2.a("sp_key_from_server_first_main_channel", userParamInfoBean.first_main_channel);
                        BiManager.setUserPresetParam(BiManager.MAIN_FIRST_CHANNEL, userParamInfoBean.first_main_channel + "");
                    }
                    if (userParamInfoBean.first_sub_channel != 0) {
                        a2.a("sp_key_from_server_first_sub_channel", userParamInfoBean.first_sub_channel);
                        BiManager.setUserPresetParam(BiManager.SUB_FIRST_CHANNEL, userParamInfoBean.first_sub_channel + "");
                    }
                    if (hashMap.size() > 0) {
                        BiManager.setPublicPresetParam(hashMap);
                    }
                    if (com.excean.ab_builder.c.a.f(f.this.c) || com.excean.ab_builder.c.a.O(f.this.c)) {
                        boolean booleanValue3 = by.a(f.this.c.getApplicationContext(), "sp_total_info").b("sp_key_bought_google_account_down", false).booleanValue();
                        boolean booleanValue4 = by.a(f.this.c.getApplicationContext(), "sp_total_info").b("sp_key_bought_google_account_down", false).booleanValue();
                        if (booleanValue != booleanValue3) {
                            com.excelliance.kxqp.bitmap.ui.b.a().a(new t.e(booleanValue3 ? 1 : 0, 1));
                        } else if (booleanValue2 != booleanValue4) {
                            com.excelliance.kxqp.bitmap.ui.b.a().a(new t.e(booleanValue4 ? 1 : 0, 2));
                        }
                    }
                }
            }
        });
    }

    public void a() {
        az.d("HomePresenter", "checkLoginStatus()");
        this.j.post(new Runnable() {
            @Override
            public void run() {
                String str;
                int i;
                boolean z;
                SharedPreferences sharedPreferences = f.this.c.getSharedPreferences("USERINFO", Build.VERSION.SDK_INT < 11 ? 0 : 4);
                boolean b2 = bx.a().b(f.this.c);
                UserUtil.getInstance().getRequestParams(sharedPreferences, f.this.c);
                com.excelliance.kxqp.gs.g.c.a().a(BiManager.IS_LOGIN, b2);
                if (!b2 && com.excelliance.kxqp.gs.util.b.bh(f.this.c)) {
                    com.excelliance.kxqp.gs.newappstore.b.a.a().a(null, f.this.c.getApplicationContext(), 2);
                }
                String a2 = bx.a().a(sharedPreferences, "USER_NAME", CookieSpecs.DEFAULT);
                long currentTimeMillis = System.currentTimeMillis();
                String a3 = com.excelliance.kxqp.gs.util.c.a(currentTimeMillis + "");
                az.d("HomePresenter", "tryLogin/currentTimeSecret:" + a3 + " currentTime:" + currentTimeMillis);
                int u = bx.a().u(f.this.c);
                boolean a4 = bx.a().a(u);
                q a5 = new q.a().a("username", a2).a("veriStr", a3).a();
                com.excelliance.kxqp.api.c cVar = new com.excelliance.kxqp.api.c(f.this.c);
                cVar.a(ApiManager.getInstance().a(f.this.c, WorkRequest.DEFAULT_BACKOFF_DELAY_MILLIS, WorkRequest.DEFAULT_BACKOFF_DELAY_MILLIS, "https://gapi.ourplay.com.cn/").b(a5));
                com.excelliance.kxqp.gs.appstore.model.ResponseData b3 = cVar.b();
                if (b3 != null) {
                    az.d("HomePresenter", "checkLoginStatus/rawResponse:" + ((String) b3.data));
                    str = ab.b((String) b3.data, "utf-8");
                    i = f.this.a(str, currentTimeMillis);
                } else {
                    str = null;
                    i = 0;
                }
                az.d("HomePresenter", "checkLoginStatus/response:" + str);
                com.excelliance.user.account.f.e.a("getVip", "homedifflogin: " + str);
                f.this.c(str);
                if (i == 1) {
                    UserUtil.getInstance().clearLocalUserInfo(sharedPreferences, f.this.c);
                    if (com.excelliance.kxqp.gs.util.b.bh(f.this.c)) {
                        com.excelliance.kxqp.gs.newappstore.b.a.a().a(null, f.this.c.getApplicationContext(), 2);
                        return;
                    }
                    return;
                }
                try {
                    JSONObject optJSONObject = new JSONObject(str).optJSONObject("uinfo");
                    if (optJSONObject != null) {
                        int optInt = optJSONObject.optInt("flag");
                        Log.d("HomePresenter", "flag = " + optInt);
                        int optInt2 = optJSONObject.optInt("vip");
                        Log.d("HomePresenter", "v_p_" + optInt2);
                        if (optInt == 1) {
                            long optInt3 = optJSONObject.optInt("endtime", 0);
                            long optInt4 = optJSONObject.optInt("current", 0);
                            f.this.a(sharedPreferences, optInt4, optInt3, optInt2);
                            com.excelliance.user.account.f.e.a("getVip", "saveVipInfoToLocal: endTime " + optInt3 + " currentTime " + currentTimeMillis);
                            Log.d("HomePresenter", "无其他设备登录该账号");
                            String a6 = bx.a().a(f.this.c);
                            if (optInt2 != 4) {
                                if (bx.a().n(f.this.c)) {
                                    int a7 = f.this.a(optInt4 + "", optInt3 + "");
                                    Log.d("HomePresenter", "lastTime = " + a7);
                                    if (a7 > 0 && a7 <= 3) {
                                        int i2 = sharedPreferences.getInt("HASEXPIRATION" + a6, 0);
                                        if ((i2 <= 0 || i2 > 3) && f.this.f10030b != null) {
                                            if (by.a(f.this.c, "sp_config").b("sp_key_just_buy_one_day_vip", false).booleanValue()) {
                                                by.a(f.this.c, "sp_config").a("sp_key_just_buy_one_day_vip", false);
                                            } else {
                                                f.this.f10030b.a(a7);
                                            }
                                        }
                                    } else {
                                        sharedPreferences.edit().putInt("HASEXPIRATION" + a6, 0).apply();
                                    }
                                }
                            } else {
                                int i3 = sharedPreferences.getInt("HASEXPIRATION" + a6, 0);
                                f.this.d(u);
                                if (i3 != 4 && f.this.f10030b != null && !com.excean.ab_builder.c.a.u(f.this.c) && !com.excean.ab_builder.c.a.v(f.this.c)) {
                                    f.this.f10030b.a(4);
                                }
                            }
                            if (com.excelliance.kxqp.gs.util.b.bh(f.this.c)) {
                                f.this.t();
                            }
                            z = a4;
                        } else {
                            z = a4;
                            if (optInt == 10) {
                                long optInt5 = optJSONObject.optInt("endtime", 0);
                                long optInt6 = optJSONObject.optInt("current", 0);
                                f.this.a(sharedPreferences, optInt6, optInt5, optInt2);
                                String e = com.excelliance.kxqp.info.a.e(f.this.c);
                                if (optInt2 != 4) {
                                    if (bx.a().n(f.this.c)) {
                                        int a8 = f.this.a(optInt6 + "", optInt5 + "");
                                        Log.d("HomePresenter", "lastTime = " + a8);
                                        if (a8 > 0 && a8 <= 3) {
                                            int i4 = sharedPreferences.getInt("HASEXPIRATION" + e, 0);
                                            if ((i4 <= 0 || i4 > 3) && f.this.f10030b != null) {
                                                if (by.a(f.this.c, "sp_config").b("sp_key_just_buy_one_day_vip", false).booleanValue()) {
                                                    by.a(f.this.c, "sp_config").a("sp_key_just_buy_one_day_vip", false);
                                                } else {
                                                    f.this.f10030b.a(a8);
                                                }
                                            }
                                        } else {
                                            sharedPreferences.edit().putInt("HASEXPIRATION" + e, 0).apply();
                                        }
                                    }
                                } else {
                                    int i5 = sharedPreferences.getInt("HASEXPIRATION" + e, 0);
                                    f.this.d(u);
                                    if (i5 != 4 && f.this.f10030b != null && !com.excean.ab_builder.c.a.u(f.this.c) && !com.excean.ab_builder.c.a.v(f.this.c)) {
                                        f.this.f10030b.a(4);
                                    }
                                }
                            } else if (optInt != 11) {
                                UserUtil.getInstance().clearLocalUserInfo(sharedPreferences, f.this.c);
                                if (b2) {
                                    if (com.excelliance.kxqp.gs.util.b.bh(f.this.c)) {
                                        com.excelliance.kxqp.gs.newappstore.b.a.a().a(null, f.this.c.getApplicationContext(), 2);
                                    }
                                    if (f.this.f10030b != null) {
                                        f.this.f10030b.a(-1);
                                    }
                                }
                            } else {
                                f.this.a(sharedPreferences, optJSONObject.optInt("current", 0), optJSONObject.optInt("endtime", 0), optInt2);
                                if (optInt2 == 4) {
                                    f.this.d(u);
                                    if (sharedPreferences.getBoolean("HAS_EXPIRATION_BY_SPECIAL_VIP", true) && f.this.f10030b != null && !com.excean.ab_builder.c.a.u(f.this.c) && !com.excean.ab_builder.c.a.v(f.this.c)) {
                                        f.this.f10030b.a(4);
                                        sharedPreferences.edit().putBoolean("HAS_EXPIRATION_BY_SPECIAL_VIP", false).apply();
                                    }
                                }
                                if (com.excelliance.kxqp.gs.util.b.bh(f.this.c)) {
                                    f.this.t();
                                }
                            }
                        }
                        if (com.excelliance.kxqp.gs.util.b.cf(f.this.c)) {
                            z.a(f.this.c).b();
                        }
                        boolean n = bx.a().n(f.this.c);
                        com.excelliance.kxqp.gs.g.c.a().a(BiManager.IS_VIP, n);
                        if (n != z) {
                            VersionManager.getInstance().j(f.this.c.getApplicationContext());
                            if (com.excean.ab_builder.c.a.f(f.this.c) || com.excean.ab_builder.c.a.O(f.this.c)) {
                                com.excelliance.kxqp.bitmap.ui.b.a().a(new t.e(n ? 1 : 0, 0));
                            }
                        }
                        Intent intent = new Intent();
                        intent.setAction("com.excelliance.after.diff.login");
                        f.this.c.sendBroadcast(intent);
                    }
                } catch (Exception e2) {
                    e2.printStackTrace();
                    Log.d("HomePresenter", "json exception");
                }
            }
        });
    }

    public void d(int i) {
        if (i != 4) {
            if (com.excean.ab_builder.c.a.u(this.c) && com.excean.ab_builder.c.a.v(this.c)) {
                return;
            }
            by.a(this.c, "sp_total_info").a("sp_key_vip_expire_notice_optimize_remove_original_dialog_start_app_notice_every_time_select_not_again", false);
            by.a(this.c, "sp_total_info").a("sp_key_vip_expire_notice_optimize_retain_original_dialog_start_app_notice_one_time_is_notice", false);
            by.a(this.c, "sp_total_info").a("sp_key_vip_expire_notice_optimize_remove_original_dialog_start_app_notice_one_time_is_notice", false);
        }
    }

    public void a(SharedPreferences sharedPreferences, long j, long j2, int i) {
        bx.a().b(sharedPreferences, "END_TIME", j2 + "");
        bx.a().b(sharedPreferences, "CUR_TIME", j + "");
        aa.a(this.c).a(i);
        tp.i(new Runnable() {
            @Override
            public void run() {
                if (f.this.f10030b != null) {
                    com.excelliance.kxqp.bitmap.ui.b.a().a(new VipFragment.c("refresh_accelerate_ui"));
                }
            }
        });
    }

    public void c(String str) {
        if (str != null) {
            try {
                JSONObject optJSONObject = new JSONObject(str).optJSONObject("uinfo");
                if (optJSONObject != null) {
                    int optInt = optJSONObject.optInt(BiManager.IS_BOUGHT_VIP);
                    int optInt2 = optJSONObject.optInt(BiManager.IS_WECHAT_LOGIN);
                    String optString = optJSONObject.optString(BiManager.CURRENT_VIP_TYPE);
                    HashMap hashMap = new HashMap();
                    hashMap.put(BiManager.IS_BOUGHT_VIP, optInt == 1 ? "是" : "否");
                    hashMap.put(BiManager.IS_WECHAT_LOGIN, optInt2 == 1 ? "是" : "否");
                    hashMap.put(BiManager.CURRENT_VIP_TYPE, optString);
                    BiManager.setPublicPresetParam(hashMap);
                }
            } catch (Exception unused) {
            }
        }
    }

    public void b() {
        final com.excelliance.kxqp.gs.ui.nyactivitys.b bVar = new com.excelliance.kxqp.gs.ui.nyactivitys.b();
        if (this.j == null) {
            return;
        }
        this.j.post(new Runnable() {
            @Override
            public void run() {
                final com.excelliance.kxqp.gs.discover.model.ResponseData<TodayRecommend> a2 = i.a().a(f.this.c);
                if (a2 == null || a2.data == null) {
                    return;
                }
                bVar.execute(new Runnable() {
                    @Override
                    public void run() {
                        if (f.this.f10030b != null) {
                            if (a2 == null || a2.data == 0) {
                                f.this.f10030b.b((List<ExcellianceAppInfo>) null);
                            } else {
                                f.this.f10030b.b(j.a(f.this.c).a(((TodayRecommend) a2.data).list));
                            }
                        }
                    }
                });
            }
        });
    }

    public void c() {
        final com.excelliance.kxqp.gs.ui.nyactivitys.b bVar = new com.excelliance.kxqp.gs.ui.nyactivitys.b();
        Log.d("HomePresenter", "fetchCloudGame " + this.j);
        if (this.j == null) {
            return;
        }
        this.j.post(new Runnable() {
            @Override
            public void run() {
                final List<CloudGameInfo> f = as.f(f.this.c, 0);
                az.d("HomePresenter", "fetchCloudGame gameList = " + f);
                if (f == null || f.size() == 0) {
                    Log.d("HomePresenter", "fetchCloudGame no games = " + f);
                    return;
                }
                bVar.execute(new Runnable() {
                    @Override
                    public void run() {
                        if (f.this.f10030b != null) {
                            if (f == null || f.size() == 0) {
                                f.this.f10030b.c((List<CloudGameInfo>) null);
                            } else {
                                f.this.f10030b.c(f);
                            }
                        }
                    }
                });
            }
        });
    }

    @Override
    public void a(final int i, final com.excelliance.kxqp.gs.discover.a.b<List<CloudGameInfo>> bVar) {
        final com.excelliance.kxqp.gs.ui.nyactivitys.b bVar2 = new com.excelliance.kxqp.gs.ui.nyactivitys.b();
        az.d("HomePresenter", "getMoreCloudGame " + this.j);
        if (this.j == null) {
            return;
        }
        this.j.post(new Runnable() {
            @Override
            public void run() {
                final List<CloudGameInfo> f = as.f(f.this.c, i);
                az.d("HomePresenter", "getMoreCloudGame gameList = " + f);
                bVar2.execute(new Runnable() {
                    @Override
                    public void run() {
                        if (bVar != null) {
                            if (f != null && f.size() != 0) {
                                bVar.a(f, new Object[0]);
                            } else {
                                bVar.a(f, new Object[0]);
                            }
                        }
                    }
                });
            }
        });
    }

    public void d() {
        if (this.j == null) {
            return;
        }
        this.j.post(new Runnable() {
            @Override
            public void run() {
                List<GameCircleEntranceBean> b2 = com.excelliance.kxqp.gs.l.d.a(f.this.c).b(f.this.c);
                if (f.this.f10030b != null) {
                    f.this.f10030b.h(b2);
                }
            }
        });
    }

    private void N() {
        this.j.post(new Runnable() {
            @Override
            public void run() {
                long a2 = com.excelliance.kxqp.bitmap.ui.a.e.a();
                Log.d("HomePresenter", "initOther:  dangerSize = 104857600, sdCardSize = " + a2);
                if (a2 < 104857600) {
                    tp.i(new Runnable() {
                        @Override
                        public void run() {
                            if (f.this.f10030b != null) {
                                f.this.f10030b.r();
                            }
                        }
                    });
                }
            }
        });
    }

    public void a(final ExcellianceAppInfo excellianceAppInfo, final String str) {
        az.d("HomePresenter", String.format("HomePresenter/checkIncompatible:thread(%s)", Thread.currentThread().getName()));
        tp.f(new Runnable() {
            @Override
            public void run() {
                final String b2 = f.this.b(excellianceAppInfo, str);
                Log.d("HomePresenter", "run: incompatibleAppNames = " + b2);
                tp.i(new Runnable() {
                    @Override
                    public void run() {
                        if (f.this.f10030b != null) {
                            f.this.f10030b.a(excellianceAppInfo, b2);
                        }
                    }
                });
            }
        });
    }

    public void a(final List<String> list) {
        this.j.post(new Runnable() {
            @Override
            public void run() {
                JSONObject i = cn.i(f.this.c);
                try {
                    JSONArray jSONArray = new JSONArray();
                    Iterator it = list.iterator();
                    while (it.hasNext()) {
                        jSONArray.put((String) it.next());
                    }
                    i.put("pkgname", jSONArray);
                } catch (JSONException e) {
                    e.printStackTrace();
                }
                String b2 = bd.b("https://api.ourplay.com.cn/rank/fix", i.toString(), 3000, 3000);
                try {
                    if (TextUtils.isEmpty(b2)) {
                        return;
                    }
                    JSONObject jSONObject = new JSONObject(cn.a(b2));
                    if (jSONObject.optInt("code") == 0) {
                        final HashMap hashMap = new HashMap();
                        JSONArray optJSONArray = jSONObject.optJSONArray("data");
                        for (int i2 = 0; i2 < optJSONArray.length(); i2++) {
                            JSONObject jSONObject2 = optJSONArray.getJSONObject(i2);
                            String optString = jSONObject2.optString(WebActionRouter.KEY_PKG);
                            boolean z = true;
                            boolean z2 = jSONObject2.optInt("needFix") != 0;
                            if (jSONObject2.optInt("isSubscribe") == 0) {
                                z = false;
                            }
                            hashMap.put(optString, new com.excelliance.kxqp.ui.detail.c(z2, z));
                        }
                        tp.i(new Runnable() {
                            @Override
                            public void run() {
                                if (f.this.f10030b != null) {
                                    f.this.f10030b.b(hashMap);
                                }
                            }
                        });
                    }
                } catch (Exception e2) {
                    e2.printStackTrace();
                }
            }
        });
    }

    public String b(ExcellianceAppInfo excellianceAppInfo, String str) {
        try {
            if (TextUtils.isEmpty(str)) {
                return null;
            }
            ArrayList arrayList = new ArrayList();
            if (arrayList.contains(StatisticsManager.COMMA)) {
                String[] split = str.split(StatisticsManager.COMMA);
                if (split.length > 0) {
                    arrayList.addAll(Arrays.asList(split));
                }
            } else {
                arrayList.add(str);
            }
            PackageManager packageManager = this.c.getPackageManager();
            Log.d("HomePresenter", "checkIncompatible: appName = " + excellianceAppInfo.appName + ", incompatibleListString = " + str);
            ArrayList arrayList2 = new ArrayList();
            Iterator it = arrayList.iterator();
            while (it.hasNext()) {
                PackageInfo packageInfo = packageManager.getPackageInfo((String) it.next(), 0);
                if (packageInfo != null) {
                    String charSequence = packageInfo.applicationInfo.loadLabel(packageManager).toString();
                    Log.d("HomePresenter", "checkIncompatible: incompatibleAppName = " + charSequence);
                    arrayList2.add(charSequence);
                }
            }
            if (arrayList2.size() == 0) {
                return null;
            }
            StringBuilder sb = new StringBuilder();
            int size = arrayList2.size();
            String e = w.e(this.c, "high_light_app_name");
            if (e == null) {
                e = "【%s】";
            }
            for (int i = 0; i < size; i++) {
                sb.append(String.format(e, arrayList2.get(i)));
                if (size != 1 && i < size - 1) {
                    sb.append("、");
                }
            }
            return sb.toString();
        } catch (Exception e2) {
            Log.e("HomePresenter", "hasInstalledIncompatibleApp: ", e2);
            return null;
        }
    }

    public void e() {
        this.j.post(new Runnable() {
            @Override
            public void run() {
                if (as.a(true).booleanValue()) {
                    return;
                }
                tp.i(new Runnable() {
                    @Override
                    public void run() {
                        Boolean b2 = by.a(f.this.c, "sp_total_info").b("sp_disconnectioin", false);
                        if (f.this.f10030b == null || b2.booleanValue()) {
                            return;
                        }
                        f.this.f10030b.b(true);
                    }
                });
            }
        });
    }

    public int a(String str, String str2) throws Exception {
        Log.d("HomePresenter", "current = " + str + "  endTime = " + str2);
        if (TextUtils.isEmpty(str) || TextUtils.isEmpty(str2) || TextUtils.equals(str, "0") || TextUtils.equals(str2, "0")) {
            Log.d("HomePresenter", "参数有问题");
            return -1;
        }
        int ceil = (int) Math.ceil(((Long.parseLong(str2) - Long.parseLong(str)) * 1.0d) / 86400.0d);
        if (ceil >= 0) {
            return ceil;
        }
        Log.d("HomePresenter", "参数有问题");
        return -1;
    }

    public void f() {
        if (ViewSwitcher.a(this.c).a()) {
            this.j.post(new Runnable() {
                @Override
                public void run() {
                    String b2 = by.a(f.this.c, "global_config").b("sp_key_banner_list_cache", "");
                    if (!TextUtils.isEmpty(b2)) {
                        com.excelliance.kxqp.gs.discover.model.ResponseData<List<c.a>> a2 = com.excelliance.kxqp.gs.view.zmbanner.c.a(b2);
                        az.d("HomePresenter", "banner cache:" + a2);
                        if (a2 != null) {
                            f.this.a(a2.data, a2.code == 0);
                        }
                    }
                    com.excelliance.kxqp.gs.discover.bbs.c cVar = new com.excelliance.kxqp.gs.discover.bbs.c(f.this.c);
                    JSONObject i = cn.i(f.this.c);
                    try {
                        i.put("banner_ver", 1);
                        i.put("abtest", com.excelliance.kxqp.gs.util.b.a(f.this.c));
                        i.put("controlapi", 1);
                        i.put("hasActive", by.a(f.this.c, "sp_statistics_info").b("sp_kye_statistics_start_app_success", false).booleanValue() ? 1 : 0);
                    } catch (JSONException e) {
                        e.printStackTrace();
                    }
                    com.excelliance.kxqp.gs.discover.model.ResponseData a3 = cVar.a(i.toString(), bc.e, new com.excelliance.kxqp.gs.discover.a.c<List<c.a>>() {
                        @Override
                        public com.excelliance.kxqp.gs.discover.model.ResponseData<List<c.a>> a(String str) {
                            by.a(f.this.c, "global_config").a("sp_key_banner_list_cache", str);
                            return com.excelliance.kxqp.gs.view.zmbanner.c.a(str);
                        }
                    });
                    f.this.a((List<c.a>) a3.data, a3.code == 0);
                }
            });
        }
    }

    public void a(final List<c.a> list, final boolean z) {
        tp.c(new Runnable() {
            @Override
            public void run() {
                new com.excelliance.kxqp.gs.ui.banner.a(f.this.c).a(list);
                tp.i(new Runnable() {
                    @Override
                    public void run() {
                        if (f.this.f10030b != null) {
                            boolean booleanValue = by.a(f.this.c, "sp_config").b("sp_key_switch_get_activity_icon", true).booleanValue();
                            if (z && !booleanValue) {
                                Iterator it = list.iterator();
                                while (it.hasNext()) {
                                    if (TextUtils.equals("270", ((c.a) it.next()).f12386a)) {
                                        it.remove();
                                    }
                                }
                            }
                            f.this.f10030b.a(z, list);
                        }
                    }
                });
            }
        });
    }

    public String a(Context context, String str) {
        String k = bn.k(context, str);
        bs.a(context, k, bs.h(str));
        return k;
    }

    public void g() {
        this.j.post(new Runnable() {
            @Override
            public void run() {
                Intent intent = new Intent("com.excelliance.kxqp.action.check.lost");
                intent.setComponent(new ComponentName(f.this.d.getPackageName(), "com.excelliance.kxqp.SmtServService"));
                try {
                    f.this.d.startService(intent);
                } catch (Exception unused) {
                }
            }
        });
    }

    public void h() {
        Log.d("HomePresenter", String.format("HomePresenter/checkWaitForImportFgoPkgs:thread(%s)", Thread.currentThread().getName()));
        this.j.post(new Runnable() {
            @Override
            public void run() {
                List<String> i = au.a().i(f.this.d);
                if (i == null || i.size() <= 0) {
                    return;
                }
                StringBuilder sb = new StringBuilder();
                for (int i2 = 0; i2 < i.size(); i2++) {
                    String str = i.get(i2);
                    if (i2 == i.size() - 1) {
                        sb.append(str);
                    } else {
                        sb.append(str);
                        sb.append(com.alipay.sdk.util.i.f491b);
                    }
                }
                Intent intent = new Intent("com.excelliance.kxqp.action.addApps");
                intent.setComponent(new ComponentName(f.this.d.getPackageName(), "com.excelliance.kxqp.SmtServService"));
                az.d("HomePresenter", "addApps(): " + sb.toString());
                ImportParams importParams = new ImportParams();
                importParams.setPkgs(sb.toString());
                importParams.setAutoImport(true);
                importParams.setAntPlugin(true);
                intent.putExtra(ImportParams.INTENT_KEY, importParams);
                try {
                    f.this.d.startService(intent);
                } catch (Exception unused) {
                }
            }
        });
    }

    @Override
    public void onShareComplete(SocializeMedia socializeMedia, int i, Bundle bundle) {
        if (i == 200) {
            Toast.makeText(this.c, w.e(this.c, "share_sdk_share_success"), 0).show();
        } else if (i == 202) {
            Toast.makeText(this.c, w.e(this.c, "share_sdk_share_failed"), 0).show();
        }
    }

    public void a(String str, Context context) {
        boolean booleanValue = by.a(context, "sp_share_info").b(str, false).booleanValue();
        if (TextUtils.isEmpty(str) || context == null || booleanValue) {
            return;
        }
        Intent intent = new Intent();
        intent.setAction(context.getPackageName() + ".pre.get.share.info");
        intent.putExtra("shareLibName", str);
        intent.setComponent(new ComponentName(context.getPackageName(), "com.excelliance.kxqp.gs.service.CustomIntentService"));
        try {
            context.startService(intent);
        } catch (Exception unused) {
        }
    }

    public void a(boolean z) {
        try {
            Intent intent = new Intent();
            intent.setComponent(new ComponentName(this.d.getPackageName(), "com.excelliance.kxqp.gs.service.CustomIntentService"));
            intent.putExtra(DebugKt.DEBUG_PROPERTY_VALUE_AUTO, z);
            intent.setAction(this.d.getPackageName() + ".refresh.proxy.config");
            this.d.startService(intent);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public boolean a(String str, ExcellianceAppInfo excellianceAppInfo) {
        az.d("HomePresenter", "checkPlayDownloadLegal pkg: " + str);
        if (cd.a(str)) {
            return false;
        }
        az.d("HomePresenter", "checkPlayDownloadLegal downloadManager: " + this.k);
        boolean z = this.k != null ? !this.k.e(str) : true;
        az.d("HomePresenter", "checkPlayDownloadLegal isLegal1: " + z);
        if (excellianceAppInfo == null) {
            return z;
        }
        if (!com.excelliance.kxqp.bitmap.a.a.b(this.c, str).update) {
            az.d("HomePresenter", "checkPlayDownloadLegal isLegal2: " + str);
            z = false;
        }
        return z ? !bs.d(str) : z;
    }

    public DownBean a(String str, String str2, int i) {
        return a(str, str2, i, "");
    }

    public DownBean a(String str, String str2, int i, String str3) {
        DownBean downBean = new DownBean();
        downBean.appName = str;
        downBean.downloadUrl = "";
        downBean.name = str2;
        downBean.packageName = str2;
        downBean.index = 0;
        downBean.type = i;
        downBean.filePath = bn.k(this.d, str2);
        downBean.size = 0L;
        downBean.md5 = "";
        downBean.threadNum = 1;
        downBean.downloadSource = str3;
        downBean.startPos = new long[]{0};
        downBean.endPos = new long[]{downBean.size - 1};
        return downBean;
    }

    public DownBean a(String str, String str2, int i, String str3, boolean z, String str4, int i2) {
        DownBean downBean = new DownBean();
        downBean.appName = str;
        downBean.downloadUrl = "";
        downBean.name = str2;
        downBean.packageName = str2;
        downBean.index = 0;
        downBean.type = i;
        if (z) {
            downBean.filePath = bn.k(this.d, str2);
        } else {
            downBean.filePath = str4;
        }
        downBean.size = 0L;
        downBean.md5 = "";
        downBean.threadNum = 1;
        downBean.downloadSource = str3;
        downBean.startPos = new long[]{0};
        downBean.endPos = new long[]{downBean.size - 1};
        downBean.download_special_source = i2;
        return downBean;
    }

    public DownBean a(String str, String str2, String str3, int i) {
        DownBean downBean = new DownBean();
        downBean.downloadUrl = "";
        downBean.name = str2;
        downBean.appName = str;
        downBean.packageName = str3;
        downBean.type = 4;
        downBean.filePath = bn.k(this.d, str3);
        String c = bn.c(this.d, str3);
        if (!new File(c).exists()) {
            new File(c).mkdirs();
        }
        downBean.filePath = bn.a(this.c, str3, downBean.name);
        downBean.size = 0L;
        downBean.md5 = "";
        downBean.threadNum = 1;
        downBean.startPos = new long[]{0};
        downBean.endPos = new long[]{downBean.size - 1};
        downBean.versionCode = i;
        return downBean;
    }

    public void a(ExcellianceAppInfo excellianceAppInfo) {
        com.excelliance.kxqp.gs.m.a.f fVar;
        if (this.k != null) {
            String appPackageName = excellianceAppInfo.getAppPackageName();
            String mainObb = excellianceAppInfo.getMainObb();
            String patchObb = excellianceAppInfo.getPatchObb();
            az.d("HomePresenter", "FUCK clearDownloadInfo libName: " + appPackageName + " mainObb: " + mainObb + " patchObb: " + patchObb);
            this.k.f(appPackageName);
            this.k.f(mainObb);
            this.k.f(patchObb);
            this.k.f(mainObb + PatchDownBean.KEY_SUFFIX);
            this.k.f(patchObb + PatchDownBean.KEY_SUFFIX);
            if (com.excelliance.kxqp.gs.util.b.S(this.c)) {
                AppDownLoadInfoBean appDownLoadInfoBean = null;
                if (!com.excelliance.kxqp.gs.util.b.U(this.c) || excellianceAppInfo.appId == 0) {
                    fVar = null;
                } else {
                    fVar = com.excelliance.kxqp.gs.m.d.a.a().b(this.c, "appId", excellianceAppInfo.appId + "");
                    if (fVar != null && !fVar.e()) {
                        for (com.excelliance.kxqp.gs.m.a.e eVar : fVar.r) {
                            this.k.f(eVar.i + ":" + fVar.f + ":" + fVar.c + ":split");
                        }
                    }
                }
                if (com.excelliance.kxqp.util.d.b.c && excellianceAppInfo.appId == 0 && (appDownLoadInfoBean = com.excelliance.kxqp.gs.d.a.a().a(this.c, excellianceAppInfo.getAppPackageName())) != null && !appDownLoadInfoBean.splitInfoIsEmpty()) {
                    for (AppDownLoadInfoChildBean appDownLoadInfoChildBean : appDownLoadInfoBean.mSplits) {
                        this.k.f(appDownLoadInfoChildBean.name + ":" + appDownLoadInfoChildBean.versionCode + ":" + appDownLoadInfoChildBean.pkg + ":split");
                    }
                }
                com.excelliance.kxqp.gs.m.d.a.a().a(this.c, am.o, excellianceAppInfo.getAppPackageName());
                com.excelliance.kxqp.gs.m.d.a.a().delete(this.c, am.o, excellianceAppInfo.getAppPackageName());
                if (com.excelliance.kxqp.util.d.b.c) {
                    com.excelliance.kxqp.gs.d.a.a().delete(this.c, am.o, excellianceAppInfo.getAppPackageName());
                }
                as.a(this.c, excellianceAppInfo.getAppPackageName(), fVar, appDownLoadInfoBean);
                if (excellianceAppInfo.appId != 0) {
                    com.excelliance.kxqp.bitmap.a.a.d(this.c, excellianceAppInfo.getAppPackageName());
                }
            }
        }
    }

    public void i() {
        Runnable runnable = new Runnable() {
            @Override
            public void run() {
                if (aq.v()) {
                    return;
                }
                String str = com.excelliance.kxqp.gs.ui.flow.b.a((String) null).d;
                az.d("HomePresenter", "queryFlowInfo 更新流量信息" + str);
                if (cd.a(str)) {
                    str = f.this.O();
                }
                az.d("HomePresenter", "queryFlowInfo 新的infoId" + str);
                JSONObject i = cn.i(f.this.c);
                try {
                    i.put("infoid", str);
                    i.put("rid", bx.a().a(f.this.c));
                    i.put("account", bx.a().r(f.this.c));
                    i.put("fflag", aq.x());
                    az.d("HomePresenter", "queryFlowInfo requestParams:" + i.toString());
                    az.d("HomePresenter", "queryFlowInfo encry requestParams:" + cn.b(i.toString()));
                    String a2 = bd.a("https://sdk.ourplay.com.cn/flow/flowReal.php", i.toString());
                    az.d("HomePresenter", "queryFlowInfo encry response:" + a2);
                    String a3 = cn.a(a2);
                    az.d("HomePresenter", "queryFlowInfo response:" + a3);
                    if (cd.a(a3)) {
                        return;
                    }
                    JSONObject jSONObject = new JSONObject(a3).getJSONObject("data");
                    com.excelliance.kxqp.gs.ui.flow.b.INSTANCE.a(f.this.c, "markTotalCommonFlow", jSONObject.getString("totalCommonFlow"), "markTotalFastFlow", jSONObject.getString("totalFastFlow"), "markTotalUseFlow", jSONObject.optString("totalUseFlow"));
                } catch (Exception e) {
                    az.d("HomePresenter", e.getMessage());
                    e.printStackTrace();
                }
            }
        };
        if (this.j != null) {
            this.j.post(runnable);
        }
    }

    public String O() {
        JSONObject i = cn.i(this.c);
        String a2 = aq.a(this.c, i);
        az.d("HomePresenter", "initFlowData 初始化流量相关信息");
        SharedPreferences sharedPreferences = this.c.getSharedPreferences("sp_flow_info", Build.VERSION.SDK_INT < 11 ? 0 : 4);
        try {
            i.put("rid", bx.a().a(this.c));
            i.put("account", bx.a().r(this.c));
            az.d("HomePresenter", "initFlowData requestParams:" + cn.b(i.toString()));
            String a3 = bd.a("https://sdk.ourplay.com.cn/flow/flowIndex.php", i.toString());
            az.d("HomePresenter", "initFlowData encry response:" + a3);
            String a4 = cn.a(a3);
            az.d("HomePresenter", "initFlowData response:" + a4);
            if (!cd.a(a4)) {
                JSONObject jSONObject = new JSONObject(a4);
                int optInt = jSONObject.optInt("valve");
                int optInt2 = jSONObject.optInt("code");
                JSONObject jSONObject2 = jSONObject.getJSONObject("data");
                bx a5 = bx.a();
                a5.a(sharedPreferences, "markFlowReportValve", optInt);
                com.excelliance.kxqp.gs.ui.flow.b.f9061b = optInt;
                com.excelliance.kxqp.gs.ui.flow.b a6 = com.excelliance.kxqp.gs.ui.flow.b.a(jSONObject2.toString());
                List<com.excelliance.kxqp.gs.ui.account.c> f = as.f();
                az.d("HomePresenter", "initFlowData list:" + f);
                if (f != null && f.size() > 0 && a6.r.f9063b == 0) {
                    StatisticsGS.getInstance().uploadUserAction(this.c, 117);
                    a6.r.f9063b = 1;
                }
                if (optInt2 != 0 && !cd.a(a2)) {
                    cn.c(this.c, 0);
                }
                a6.a();
                a5.b(sharedPreferences, "markFlowConfig", jSONObject2.toString());
            } else {
                az.d("HomePresenter", "initFlowData 初始化流量信息失败!");
            }
        } catch (Exception e) {
            az.d("HomePresenter", e.getMessage());
            e.printStackTrace();
        }
        return com.excelliance.kxqp.gs.ui.flow.b.a((String) null).d;
    }

    public void j() {
        az.d("HomePresenter", "enter queryMoneyInfo()");
        this.j.post(new Runnable() {
            @Override
            public void run() {
                String str = com.excelliance.kxqp.task.g.f.a((String) null).h;
                az.d("HomePresenter", "更新任务信息" + str);
                f.this.P();
                az.d("HomePresenter", "新的taskId" + str);
                JSONObject i = cn.i(f.this.c);
                try {
                    i.put("rid", bx.a().a(f.this.c));
                    i.put("account", bx.a().r(f.this.c));
                    az.d("HomePresenter", "requestParams:" + i.toString());
                    az.d("HomePresenter", "encry requestParams:" + cn.b(i.toString()));
                    String a2 = bd.a("http://api.ourplay.com.cn/task/index", i.toString());
                    az.d("HomePresenter", "encry response:" + a2);
                    String a3 = cn.a(a2);
                    az.d("HomePresenter", "response:" + a3);
                    if (!cd.a(a3)) {
                        JSONObject jSONObject = new JSONObject(a3);
                        JSONObject jSONObject2 = jSONObject.getJSONObject("data");
                        int optInt = jSONObject.optInt("code");
                        az.d("HomePresenter", "code:" + optInt);
                        if (optInt == 1 && jSONObject2 != null) {
                            com.excelliance.kxqp.task.g.f a4 = com.excelliance.kxqp.task.g.f.a(jSONObject2.toString());
                            List<com.excelliance.kxqp.gs.ui.account.c> f = as.f();
                            az.d("HomePresenter", "list:" + f);
                            if (f != null && f.size() > 0 && com.excelliance.kxqp.task.g.f.INSTANCE.G.d == 0) {
                                com.excelliance.kxqp.task.g.f.INSTANCE.G.d = 1;
                            }
                            a4.a();
                            JSONObject optJSONObject = jSONObject2.optJSONObject("userdata");
                            f.a aVar = new f.a();
                            aVar.c = optJSONObject.optLong("totalmoneyk");
                            aVar.d = optJSONObject.optLong("totalusemoneyk");
                            aVar.e = optJSONObject.optLong("totaldiamond");
                            aVar.f = optJSONObject.optLong("totalusediamond");
                            aVar.f13239a = optJSONObject.optString("rank");
                            aVar.f13240b = optJSONObject.optString("ranknickname");
                            com.excelliance.kxqp.task.g.f.INSTANCE.a(f.this.c, aVar);
                            az.d("HomePresenter", "初始任务信息成功!");
                            return;
                        }
                        az.d("HomePresenter", "初始化任务信息失败!");
                        return;
                    }
                    az.d("HomePresenter", "初始化任务信息失败!");
                } catch (Exception e) {
                    az.d("HomePresenter", e.getMessage());
                    e.printStackTrace();
                }
            }
        });
    }

    public void P() {
        az.d("HomePresenter", "enter postPKGInfo  ");
        boolean booleanValue = by.a(this.c, "sp_total_info").b("goldminer2", false).booleanValue();
        az.d("HomePresenter", "gold_miner2 = " + booleanValue);
        if (booleanValue) {
            return;
        }
        if (com.excelliance.kxqp.task.g.f.INSTANCE != null && com.excelliance.kxqp.task.g.f.INSTANCE.y != null && com.excelliance.kxqp.task.g.f.INSTANCE.y.d == 2) {
            az.d("HomePresenter", "enter postPKGInfo1  ");
            return;
        }
        JSONObject i = cn.i(this.c);
        TaskShareDownloadParams a2 = com.excelliance.kxqp.task.g.g.a(this.c, i);
        try {
            i.put("tasktype", a2.getTasktype());
            i.put("taskinfoid", a2.getTaskinfoid());
            i.put("catid", a2.getCatid());
            az.d("HomePresenter", "request:" + i.toString());
            String a3 = bd.a("http://api.ourplay.com.cn/task/sharedown", i.toString());
            if (cd.a(a3)) {
                az.d("HomePresenter", "respone is empty");
                return;
            }
            az.d("HomePresenter", "encry response:" + a3);
            String a4 = cn.a(a3);
            az.d("HomePresenter", "response:" + a4);
            JSONObject jSONObject = new JSONObject(a4);
            int optInt = jSONObject.optInt("code");
            jSONObject.optJSONObject("data");
            if (optInt == 1) {
                if (!cd.a(a2.getTaskinfoid())) {
                    cn.c(this.c, 1);
                }
                by.a(this.c, "sp_total_info").a("goldminer2", true);
                return;
            }
            az.d("HomePresenter", "post gold miner2 fail");
        } catch (Exception e) {
            az.d("HomePresenter", "post gold miner2 fail");
            az.d("HomePresenter", e.getMessage());
            e.printStackTrace();
        }
    }

    public void b(ExcellianceAppInfo excellianceAppInfo) {
        if (this.k != null) {
            this.k.a(excellianceAppInfo);
        }
    }

    public boolean a(int i) {
        ExcellianceAppInfo b2;
        if (this.k == null) {
            return false;
        }
        Map<String, DownBean> c = this.k.c();
        boolean z = false;
        for (String str : c.keySet()) {
            DownBean downBean = c.get(str);
            if (downBean != null && bs.a(downBean.packageName) == -1 && downBean.downloadState != i && (i != 2 || downBean.downloadState != 4 || downBean.downloadSubState != 1 || (b2 = com.excelliance.kxqp.repository.a.a(this.d).b(str)) == null || !b2.isMainLandGame())) {
                downBean.downloadErrorCount = 0;
                d(downBean.packageName);
                this.k.a(downBean.name, i, 0);
                Intent intent = new Intent();
                intent.setAction(this.d.getPackageName() + ".download.notify.state");
                Bundle bundle = new Bundle();
                bundle.putInt("state", i);
                bundle.putString(WebActionRouter.KEY_PKG, downBean.packageName);
                intent.putExtra("bundle", bundle);
                LocalBroadcastManager.getInstance(this.c).sendBroadcast(intent);
                z = true;
            }
        }
        return z;
    }

    private void d(final String str) {
        tp.f(new Runnable() {
            @Override
            public void run() {
                ExcellianceAppInfo b2 = com.excelliance.kxqp.repository.a.a(f.this.d).b(str);
                if (b2 != null) {
                    int downloadStatus = b2.getDownloadStatus();
                    if (downloadStatus == 2) {
                        com.excelliance.kxqp.gs.g.c.a().a(f.this.c.getApplicationContext(), b2, BiEventAppDownloadPause.Reason.REASON_NET_PAUSE);
                    } else {
                        if (downloadStatus != 4) {
                            return;
                        }
                        com.excelliance.kxqp.gs.g.c.a().a(f.this.c.getApplicationContext(), b2, BiEventAppDownloadPause.Reason.REASON_NET_CONTINUE);
                    }
                }
            }
        });
    }

    public boolean a(Context context, Bundle bundle) {
        if (bundle == null) {
            return false;
        }
        try {
            ArrayList arrayList = new ArrayList();
            int i = bundle.getInt("obbSize");
            bundle.getLong(ClientCookie.VERSION_ATTR);
            bundle.getString("libName");
            for (int i2 = 0; i2 < i; i2++) {
                DownBean downBean = (DownBean) bundle.getSerializable("obb" + i2);
                if (downBean != null) {
                    arrayList.add(downBean);
                }
            }
            Log.e("HomePresenter", "Obb size:" + arrayList.size());
            Iterator it = arrayList.iterator();
            while (it.hasNext()) {
                az.d("HomePresenter", "downloadObb downBean: " + ((DownBean) it.next()));
            }
            if (arrayList.size() > 0) {
                if (this.k == null) {
                    return true;
                }
                this.k.a(arrayList);
                return true;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return false;
    }

    public boolean b(Context context, Bundle bundle) {
        if (bundle == null) {
            return false;
        }
        try {
            ArrayList arrayList = new ArrayList();
            int i = bundle.getInt("splitSize");
            for (int i2 = 0; i2 < i; i2++) {
                DownBean downBean = (DownBean) bundle.getSerializable("split" + i2);
                if (downBean != null) {
                    arrayList.add(downBean);
                }
            }
            Log.e("HomePresenter", "split size:" + arrayList.size());
            Iterator it = arrayList.iterator();
            while (it.hasNext()) {
                az.d("HomePresenter", "downloadSplit downBean: " + ((DownBean) it.next()));
            }
            if (arrayList.size() > 0) {
                if (this.k == null) {
                    return true;
                }
                this.k.a(arrayList);
                return true;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return false;
    }

    public void k() {
        if (this.k != null) {
            this.j.post(new Runnable() {
                @Override
                public void run() {
                    synchronized (f.this.g) {
                        try {
                            Map<String, DownBean> c = f.this.k.c();
                            Iterator<String> it = c.keySet().iterator();
                            while (it.hasNext()) {
                                DownBean downBean = c.get(it.next());
                                int i = downBean.downloadState;
                                if (downBean.type == 3 || downBean.type == 4) {
                                    if (i == 2) {
                                        f.this.k.b(downBean.name, 0);
                                        Intent intent = new Intent();
                                        intent.setAction(f.this.d.getPackageName() + ".download.notify.state");
                                        Bundle bundle = new Bundle();
                                        bundle.putInt("state", 4);
                                        bundle.putString(WebActionRouter.KEY_PKG, downBean.packageName);
                                        intent.putExtra("bundle", bundle);
                                        LocalBroadcastManager.getInstance(f.this.c).sendBroadcast(intent);
                                    }
                                }
                            }
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    }
                }
            });
        }
    }

    public void a(final List<DownBean> list, final HashMap<String, List<DownBean>> hashMap) {
        if (this.j != null) {
            this.j.post(new Runnable() {
                @Override
                public void run() {
                    f.this.b((List<DownBean>) list, (HashMap<String, List<DownBean>>) hashMap);
                }
            });
        }
    }

    public void l() {
        if (this.j != null) {
            this.j.post(new Runnable() {
                @Override
                public void run() {
                    f.this.Q();
                }
            });
        }
    }

    public void Q() {
        if (this.k != null) {
            Map<String, DownBean> c = this.k.c();
            for (String str : c.keySet()) {
                DownBean downBean = c.get(str);
                if (downBean != null && bs.a(downBean.packageName) >= 0) {
                    this.k.a(str, 0);
                }
            }
        }
    }

    public void b(List<DownBean> list, HashMap<String, List<DownBean>> hashMap) {
        int i;
        String a2;
        if (list != null) {
            if (list.size() == 0 && hashMap.size() == 0) {
                return;
            }
            long j = 0;
            if (com.excelliance.kxqp.gs.util.b.S(this.c)) {
                ArrayList arrayList = new ArrayList();
                Iterator<DownBean> it = list.iterator();
                while (it.hasNext()) {
                    DownBean next = it.next();
                    if (next.yalp_type > 0 && next.size == 0) {
                        Log.d("HomePresenter", " yalp DownBean0: " + next);
                        com.excelliance.kxqp.gs.m.a.f b2 = com.excelliance.kxqp.gs.m.d.a.a().b(this.c, "appId", String.valueOf(next.appId));
                        if (b2 != null) {
                            Log.d("HomePresenter", "yalp DownBean1: " + next);
                            if (next.yalp_type == 4) {
                                Log.d("HomePresenter", "APK yalp DownBean: " + next);
                                arrayList.add(com.excelliance.kxqp.gs.m.b.a.b(b2, this.c));
                            } else if (next.yalp_type == 3) {
                                Log.d("HomePresenter", "DELTA yalp DownBean: " + next);
                                arrayList.add(com.excelliance.kxqp.gs.m.b.a.c(b2, this.c));
                            }
                            it.remove();
                        }
                    } else if (next.yalp_type > 0 && next.size > 0) {
                        Log.d("HomePresenter", " yalp DownBean2: " + next);
                        arrayList.add(next);
                        it.remove();
                    }
                }
                if (arrayList.size() > 0) {
                    Iterator it2 = arrayList.iterator();
                    while (it2.hasNext()) {
                        az.d("HomePresenter", "yalp prepareTouristPlayApp downBean: " + ((DownBean) it2.next()));
                    }
                    ah.a(this.d, arrayList);
                    Iterator it3 = arrayList.iterator();
                    while (it3.hasNext()) {
                        az.d("HomePresenter", "yalp inflate prepareTouristPlayApp downBean: " + ((DownBean) it3.next()));
                    }
                    this.k.a(arrayList);
                }
                if (list == null || (list.size() == 0 && hashMap.size() == 0)) {
                    az.d("HomePresenter", "yalp prepareTouristPlayApp or obbMap is null ");
                    return;
                }
            }
            ArrayList arrayList2 = new ArrayList();
            ArrayList<DownBean> arrayList3 = new ArrayList();
            ah.a(this.d, list);
            String str = "";
            JSONArray jSONArray = new JSONArray();
            Iterator<DownBean> it4 = list.iterator();
            while (true) {
                i = 0;
                if (!it4.hasNext()) {
                    break;
                }
                DownBean next2 = it4.next();
                if (next2.size == 0 && !cd.a(next2.packageName)) {
                    JSONObject jSONObject = new JSONObject();
                    ExcellianceAppInfo a3 = InitialData.a(this.d).a(-1, 0, next2.packageName);
                    try {
                        jSONObject.put(WebActionRouter.KEY_PKG, a3.getAppPackageName());
                        jSONObject.put(RankingItem.KEY_VER, a3.getVersionCode());
                        AppExtraBean d = com.excelliance.kxqp.util.master.e.d(this.d, a3.getAppPackageName(), a3.getUid());
                        int cpu = d.getCpu();
                        if (cpu != -1) {
                            i = cpu;
                        }
                        jSONObject.put("cpu", i);
                        jSONObject.put("pos", d.getInstallPosition());
                        jSONArray.put(jSONObject);
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                    String str2 = str + next2.packageName + "||";
                    arrayList3.add(next2);
                    str = str2;
                } else {
                    arrayList2.add(next2);
                }
            }
            if (!cd.a(str) && this.d != null && bf.e(this.d)) {
                String trim = str.substring(0, str.length() - "||".length()).trim();
                AppDownLoadInfoBean appDownLoadInfoBean = new AppDownLoadInfoBean();
                if (com.excelliance.kxqp.util.d.b.f15028b) {
                    a2 = as.a(this.c, trim, jSONArray, false, appDownLoadInfoBean, true);
                } else {
                    a2 = as.a(this.c, trim, jSONArray);
                }
                Log.d("HomePresenter", String.format("HomePresenter/prepareTouristPlayApp:thread(%s) touristPlayAppInfo(%s)", Thread.currentThread().getName(), a2));
                try {
                    if (com.excelliance.kxqp.util.d.b.f15028b) {
                        AppDownLoadInfoBean a4 = ay.a(a2, arrayList3, this.d);
                        if (a4 != null) {
                            a4.isAssistance = appDownLoadInfoBean.isAssistance;
                            com.excelliance.kxqp.gs.d.a.a().a(this.c, a4);
                        }
                    } else {
                        ay.a(a2, arrayList3);
                    }
                    ArrayList arrayList4 = new ArrayList();
                    for (DownBean downBean : arrayList3) {
                        if (downBean.packageName != null && bs.a(downBean.packageName) == -1) {
                            arrayList4.add(downBean.packageName);
                        }
                        az.d("HomePresenter", "prepareTouristPlayApp2: " + downBean);
                    }
                    List<ExcellianceAppInfo> n = as.n(this.d);
                    Iterator it5 = arrayList3.iterator();
                    while (it5.hasNext()) {
                        DownBean downBean2 = (DownBean) it5.next();
                        for (ExcellianceAppInfo excellianceAppInfo : n) {
                            if (excellianceAppInfo.getAppPackageName().equals(downBean2.packageName) && excellianceAppInfo.getDownloadStatus() == 1 && !downBean2.packageName.equals("com.open.netacc")) {
                                it5.remove();
                            }
                        }
                        a(this.c, downBean2.packageName, downBean2.mBiAppUploadInfo);
                    }
                    arrayList2.addAll(arrayList3);
                } catch (Exception e2) {
                    Log.e("HomePresenter", "prepareTouristPlayApp/ex:" + e2);
                    az.d("HomePresenter", "prepareTouristPlayApp/ packageName" + trim);
                    String trim2 = trim.trim();
                    e2.printStackTrace();
                    if (this.j != null) {
                        az.d("HomePresenter", "prepareTouristPlayApp/ex: split[0]:" + trim2);
                        this.j.sendMessage(this.j.obtainMessage(1, trim2));
                        return;
                    }
                    return;
                }
            }
            arrayList3.clear();
            if (hashMap.size() > 0 && this.d != null && bf.e(this.d)) {
                long j2 = 0;
                for (String str3 : hashMap.keySet()) {
                    List<DownBean> list2 = hashMap.get(str3);
                    if (list2 != null && list2.size() != 0) {
                        ah.a(this.d, list2);
                        Iterator<DownBean> it6 = list2.iterator();
                        while (it6.hasNext()) {
                            DownBean next3 = it6.next();
                            long j3 = next3.versionCode;
                            Iterator<DownBean> it7 = it6;
                            if (next3.size == j || TextUtils.isEmpty(next3.downloadUrl) || TextUtils.isEmpty(next3.filePath)) {
                                j2 = j3;
                                i = 1;
                                break;
                            } else {
                                it6 = it7;
                                j2 = j3;
                            }
                        }
                        if (i != 0) {
                            String a5 = as.a(this.d, str3, j2);
                            az.d("HomePresenter", "prepareTouristPlayApp libName: " + str3 + " versionCode:  obbInfo: " + a5);
                            if (!TextUtils.isEmpty(a5)) {
                                ArrayList arrayList5 = new ArrayList();
                                boolean a6 = ay.a(this.d, a5, arrayList5);
                                az.d("HomePresenter", "prepareTouristPlayApp needDownloadObb: " + a6);
                                if (a6) {
                                    arrayList3.addAll(arrayList5);
                                }
                            }
                        }
                        arrayList3.addAll(list2);
                    }
                    j = 0;
                }
                if (arrayList3.size() > 0) {
                    arrayList2.addAll(arrayList3);
                }
            }
            arrayList3.clear();
            Iterator it8 = arrayList2.iterator();
            while (it8.hasNext()) {
                az.d("HomePresenter", "prepareTouristPlayApp downBean: " + ((DownBean) it8.next()));
            }
            this.k.a(arrayList2);
        }
    }

    public static void a(final Context context, final String str, final BiAppUploadInfo biAppUploadInfo) {
        com.excelliance.kxqp.repository.a.a(context).a().runInTransaction(new Runnable() {
            @Override
            public void run() {
                ExcellianceAppInfo b2 = com.excelliance.kxqp.repository.a.a(context).b(str);
                if (b2 != null) {
                    if (biAppUploadInfo != null && biAppUploadInfo.serverVc > 0) {
                        b2.serverVc = biAppUploadInfo.serverVc;
                    }
                    if (biAppUploadInfo != null && !TextUtils.isEmpty(biAppUploadInfo.appUpdateTime)) {
                        b2.appUpdateTime = biAppUploadInfo.appUpdateTime;
                    }
                    b2.lastDownloadTime = System.currentTimeMillis();
                    az.d("HomePresenter", "prepareTouristPlayApp updateAppInfo appInfo: " + b2);
                    com.excelliance.kxqp.repository.a.a(context).b(b2);
                }
            }
        });
        tp.f(new Runnable() {
            @Override
            public void run() {
                ExcellianceAppInfo b2 = com.excelliance.kxqp.repository.a.a(context).b(str);
                if (b2 != null) {
                    com.excelliance.kxqp.gs.g.c.a().a(b2);
                }
            }
        });
    }

    public static void a(final Context context, final String str, final int i, final String str2, final int i2, final e.c cVar) {
        tp.f(new Runnable() {
            @Override
            public void run() {
                try {
                    if (as.a(context, str, i, str2, i2)) {
                        cVar.a();
                    } else {
                        cVar.b();
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
    }

    public void m() {
        if (this.h != null) {
            this.h.interrupt();
            this.h = null;
        }
        this.f10030b = null;
        if (this.i != null) {
            this.i.a();
        }
        if (this.j != null) {
            this.j.removeCallbacksAndMessages(null);
            this.j.getLooper().quit();
        }
    }

    public void a(final String str, final Context context, final SocializeMedia socializeMedia, final ad.a aVar) {
        this.j.post(new Runnable() {
            @Override
            public void run() {
                ShareGameBean shareGameBean;
                String a2 = as.a(str, context);
                if (TextUtils.isEmpty(a2)) {
                    shareGameBean = null;
                } else {
                    shareGameBean = ay.e(a2);
                    if (shareGameBean != null && !shareGameBean.beanIsNull()) {
                        by.a(context, "sp_share_info").a(str, true);
                    }
                }
                aVar.a(shareGameBean, socializeMedia);
            }
        });
    }

    public void a(SocializeMedia socializeMedia, ShareGameBean shareGameBean) {
        this.f10029a = ShareHelper.instance((Activity) this.c);
        this.f10029a.setCallBack(this);
        this.f10029a.shareTo(socializeMedia, shareGameBean);
    }

    public void b(final List<ExcellianceAppInfo> list) {
        if (this.j == null) {
            return;
        }
        this.j.post(new Runnable() {
            @Override
            public void run() {
                JSONArray jSONArray = new JSONArray();
                try {
                    int i = 0;
                    for (ExcellianceAppInfo excellianceAppInfo : list) {
                        String iconPath = excellianceAppInfo.getIconPath();
                        String path = excellianceAppInfo.getPath();
                        JSONObject jSONObject = new JSONObject();
                        try {
                            jSONObject.put(RankingItem.KEY_ICON, iconPath);
                            jSONObject.put("apk", path);
                            int i2 = i + 1;
                            try {
                                jSONArray.put(i, jSONObject);
                                i = i2;
                            } catch (JSONException e) {
                                e = e;
                                i = i2;
                                e.printStackTrace();
                            }
                        } catch (JSONException e2) {
                            e = e2;
                        }
                    }
                    Intent intent = new Intent();
                    intent.setComponent(new ComponentName(f.this.d.getPackageName(), "com.excelliance.kxqp.gs.service.CustomIntentService"));
                    intent.setAction(f.this.d.getPackageName() + ".check.game.icon.dismiss");
                    intent.putExtra("checkdata", jSONArray.toString());
                    Log.d("HomePresenter", "checkGameIcon1: ");
                    f.this.d.startService(intent);
                } catch (Exception e3) {
                    e3.printStackTrace();
                    Log.d("HomePresenter", "checkGameIconDismiss: Exception ");
                }
            }
        });
    }

    public boolean n() {
        if (this.k == null) {
            return false;
        }
        Map<String, DownBean> c = this.k.c();
        Iterator<String> it = c.keySet().iterator();
        while (it.hasNext()) {
            if (bs.a(c.get(it.next()).packageName) != -1) {
                return true;
            }
        }
        return false;
    }

    public void a(final String str) {
        this.j.post(new Runnable() {
            @Override
            public void run() {
                if (TextUtils.isEmpty(str)) {
                    return;
                }
                String[] split = str.split(com.alipay.sdk.util.i.f491b);
                JSONArray jSONArray = new JSONArray();
                for (String str2 : split) {
                    jSONArray.put(str2);
                }
                JSONObject i = cn.i(f.this.c);
                try {
                    i.put("pkglist", jSONArray);
                } catch (JSONException e) {
                    e.printStackTrace();
                }
                final com.excelliance.kxqp.gs.discover.model.ResponseData a2 = new com.excelliance.kxqp.gs.discover.bbs.c(f.this.c).a(i.toString(), "https://api.ourplay.com.cn/goneload/getdlownremain", new com.excelliance.kxqp.gs.discover.a.c<List<AppInfo>>() {
                    @Override
                    public com.excelliance.kxqp.gs.discover.model.ResponseData<List<AppInfo>> a(String str3) {
                        try {
                            return (com.excelliance.kxqp.gs.discover.model.ResponseData) new Gson().a(str3, new TypeToken<com.excelliance.kxqp.gs.discover.model.ResponseData<List<AppInfo>>>() {
                            }.getType());
                        } catch (Exception e2) {
                            az.e("HomePresenter", "requestGuideDownloadList/ex:" + e2);
                            return null;
                        }
                    }
                });
                az.d("HomePresenter", "requestGuideDownloadList/run: " + a2);
                if (a2 == null || s.a((Collection) a2.data) || f.this.f10030b == null) {
                    return;
                }
                tp.i(new Runnable() {
                    @Override
                    public void run() {
                        f.this.f10030b.g(j.a(f.this.c).a((List<AppInfo>) a2.data));
                    }
                });
            }
        });
    }

    public static void a(Context context) {
        if (context == null) {
            return;
        }
        GameUtil.c(false);
        Intent intent = new Intent();
        intent.setComponent(new ComponentName(context.getPackageName(), "com.excelliance.kxqp.gs.service.CustomIntentService"));
        intent.setAction(context.getPackageName() + ".start.register.proxy");
        intent.putExtra("connect", 1);
        try {
            context.startService(intent);
        } catch (Exception unused) {
        }
    }

    public void o() {
        this.f10030b = null;
    }

    public void b(final String str) {
        this.j.post(new Runnable() {
            @Override
            public void run() {
                JSONObject i = cn.i(f.this.c);
                try {
                    i.put("pkgname", str);
                    if (com.excelliance.kxqp.gs.util.b.bh(f.this.c)) {
                        i.put("isFromDomestic", "1");
                    }
                } catch (JSONException e) {
                    e.printStackTrace();
                }
                com.excelliance.kxqp.gs.discover.model.ResponseData a2 = new com.excelliance.kxqp.gs.discover.bbs.c(f.this.c).a(i.toString(), "https://api.ourplay.com.cn/rank/getrelation", new com.excelliance.kxqp.gs.discover.a.c<AppInfo>() {
                    @Override
                    public com.excelliance.kxqp.gs.discover.model.ResponseData<AppInfo> a(String str2) {
                        az.d("HomePresenter", "response:" + str2);
                        try {
                            return (com.excelliance.kxqp.gs.discover.model.ResponseData) new Gson().a(str2, new TypeToken<com.excelliance.kxqp.gs.discover.model.ResponseData<AppInfo>>() {
                            }.getType());
                        } catch (Exception unused) {
                            return null;
                        }
                    }
                });
                az.d("HomePresenter", "responseResult:" + a2);
                if (a2 == null || a2.data == 0) {
                    return;
                }
                AppInfo appInfo = (AppInfo) a2.data;
                if (appInfo.isEmpty()) {
                    return;
                }
                ArrayList arrayList = new ArrayList();
                arrayList.add(appInfo);
                au.b(f.this.c, arrayList);
                j.a(f.this.c);
                final List<ExcellianceAppInfo> list = j.a(f.this.c, arrayList).data;
                tp.i(new Runnable() {
                    @Override
                    public void run() {
                        if (f.this.f10030b != null) {
                            f.this.f10030b.a(str, list);
                        }
                    }
                });
            }
        });
    }

    public void b(Context context) {
        try {
            Intent intent = new Intent();
            intent.setClass(context, CustomIntentService.class);
            intent.setAction(context.getPackageName() + "REPORT_INNER_GOOGLE_ACCOUNT_LOGIN");
            context.startService(intent);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public DownBean a(String str, String str2, int i, int i2, int i3) {
        DownBean downBean = new DownBean();
        downBean.appName = str;
        downBean.downloadUrl = "";
        downBean.name = str2;
        downBean.packageName = str2;
        downBean.type = i;
        downBean.size = 0L;
        downBean.yalp_type = i2;
        downBean.appId = i3;
        return downBean;
    }

    public void a(com.excelliance.kxqp.gs.m.a.f fVar, AppDownLoadInfoBean appDownLoadInfoBean, String str) {
        boolean z = fVar != null;
        if (this.k != null) {
            this.k.g(fVar.c);
            if (z) {
                if (!fVar.e()) {
                    Iterator<com.excelliance.kxqp.gs.m.a.e> it = fVar.r.iterator();
                    while (it.hasNext()) {
                        this.k.g(it.next().i);
                    }
                }
            } else if (!appDownLoadInfoBean.splitInfoIsEmpty()) {
                Iterator<AppDownLoadInfoChildBean> it2 = appDownLoadInfoBean.mSplits.iterator();
                while (it2.hasNext()) {
                    this.k.g(it2.next().name);
                }
            }
        }
        File file = new File(str);
        if (file.exists()) {
            File parentFile = file.getParentFile();
            if (parentFile.exists()) {
                File[] listFiles = parentFile.listFiles();
                HashMap hashMap = new HashMap();
                for (File file2 : listFiles) {
                    hashMap.put(file2.getName(), file2);
                }
                if (z) {
                    Iterator<com.excelliance.kxqp.gs.m.a.e> it3 = fVar.r.iterator();
                    while (it3.hasNext()) {
                        String str2 = fVar.c + "." + String.valueOf(fVar.f) + ".split." + it3.next().i + ".apk";
                        if (hashMap.containsKey(str2)) {
                            ((File) hashMap.get(str2)).delete();
                        }
                    }
                    return;
                }
                if (com.excelliance.kxqp.util.d.b.c) {
                    Iterator<AppDownLoadInfoChildBean> it4 = appDownLoadInfoBean.mSplits.iterator();
                    while (it4.hasNext()) {
                        String str3 = appDownLoadInfoBean.pkg + "." + appDownLoadInfoBean.versionCode + ".split." + it4.next().name + ".apk";
                        if (hashMap.containsKey(str3)) {
                            ((File) hashMap.get(str3)).delete();
                        }
                    }
                }
            }
        }
    }

    public void q() {
        this.j.post(new Runnable() {
            @Override
            public void run() {
                File file;
                try {
                    file = Environment.getExternalStorageDirectory().getAbsoluteFile();
                } catch (Exception e) {
                    e.printStackTrace();
                    file = null;
                }
                if (file == null) {
                    return;
                }
                File file2 = new File(file, ".assistant");
                if (file2.exists()) {
                    File file3 = new File(file2, ".assistant.json");
                    if (file3.exists()) {
                        String a2 = an.a(f.this.c, file3);
                        if (cd.a(a2)) {
                            return;
                        }
                        file3.delete();
                        ArrayList arrayList = new ArrayList();
                        try {
                            JSONArray jSONArray = new JSONArray(a2);
                            for (int i = 0; i < jSONArray.length(); i++) {
                                JSONObject jSONObject = jSONArray.getJSONObject(i);
                                DownBean downBean = new DownBean();
                                downBean.filePath = jSONObject.getString("image");
                                downBean.name = jSONObject.getString("name");
                                downBean.packageName = jSONObject.getString(WebActionRouter.KEY_PKG);
                                arrayList.add(downBean);
                            }
                        } catch (JSONException e2) {
                            e2.printStackTrace();
                        }
                        az.d("HomePresenter", "downBean size:" + arrayList.size());
                        Intent intent = new Intent();
                        intent.setAction(f.this.c.getPackageName() + ".download_game_from_assistant");
                        intent.putExtra("gameBeans", arrayList);
                        f.this.c.sendBroadcast(intent);
                    }
                }
            }
        });
    }

    public void b(final int i) {
        az.d("HomePresenter", "getMarketOfferVip enter");
        tp.f(new Runnable() {
            @Override
            public void run() {
                SharedPreferences sharedPreferences = f.this.c.getSharedPreferences("USERINFO", Build.VERSION.SDK_INT < 11 ? 0 : 4);
                String requestParams = UserUtil.getInstance().getRequestParams(sharedPreferences, f.this.c);
                try {
                    JSONObject jSONObject = new JSONObject(requestParams);
                    jSONObject.put("isquit", i);
                    requestParams = jSONObject.toString();
                } catch (JSONException e) {
                    az.d("HomePresenter", "getMarketOfferVip put josn fail");
                    e.printStackTrace();
                }
                az.d("HomePresenter", "getMarketOfferVip requestParams:" + requestParams.toString());
                String a2 = bd.a("https://api.ourplay.com.cn/activity/appget", requestParams);
                if (!cd.a(a2)) {
                    String a3 = cn.a(a2);
                    az.d("HomePresenter", " getMarketOfferVip result: " + a3);
                    try {
                        JSONObject jSONObject2 = new JSONObject(a3);
                        int optInt = jSONObject2.optInt("code");
                        az.d("HomePresenter", "getMarketOfferVipData code" + optInt);
                        if (optInt == 0) {
                            JSONObject optJSONObject = jSONObject2.optJSONObject("data");
                            if (optJSONObject != null) {
                                if (i == 0) {
                                    az.d("HomePresenter", "getMarketOfferVip start sendBroadcast");
                                    int optInt2 = optJSONObject.optInt("is_vip");
                                    String optString = optJSONObject.optString("endtime", "0");
                                    String optString2 = optJSONObject.optString("current", "0");
                                    bx.a().b(sharedPreferences, "END_TIME", optString);
                                    bx.a().b(sharedPreferences, "CUR_TIME", optString2);
                                    bx.a().a(sharedPreferences, "USER_V001", optInt2);
                                    f.this.c.sendBroadcast(new Intent(f.this.c.getPackageName() + ".action.accounts.MARKET_VIP_INFO_UPDATE"));
                                }
                            } else {
                                az.d("HomePresenter", "getMarketOfferVipData data is null ");
                            }
                            String a4 = bx.a().a(f.this.c);
                            by a5 = by.a(f.this.c, "market_action");
                            a5.a("market_offer_vip_dialog_show" + a4, true);
                            a5.a("market_offer_vip_is_show_vip_tab", true);
                            if (f.this.f10030b != null) {
                                az.d("HomePresenter", "getMarketOfferVipData show vip tab");
                                f.this.f10030b.s();
                                return;
                            }
                            return;
                        }
                        return;
                    } catch (JSONException e2) {
                        az.d("HomePresenter", "getMarketOfferVipData json fail" + e2);
                        e2.printStackTrace();
                        return;
                    }
                }
                az.d("HomePresenter", "getMarketOfferVipData is null");
            }
        });
    }

    public void r() {
        az.d("HomePresenter", "getMarketOfferVipData enter");
        this.j.post(new Runnable() {
            @Override
            public void run() {
                boolean b2 = bx.a().b(f.this.c);
                if (b2) {
                    String a2 = bx.a().a(f.this.c);
                    boolean booleanValue = by.a(f.this.c, "market_action").b("market_offer_vip_dialog_show" + a2, false).booleanValue();
                    if (!b2 || booleanValue) {
                        return;
                    }
                    az.d("HomePresenter", "getMarketOfferVipData start");
                    String requestParams = UserUtil.getInstance().getRequestParams(f.this.c.getSharedPreferences("USERINFO", Build.VERSION.SDK_INT >= 11 ? 4 : 0), f.this.c);
                    az.d("HomePresenter", "getMarketOfferVipData requestParams:" + requestParams.toString());
                    String a3 = bd.a("https://api.ourplay.com.cn/activity/appfind", requestParams);
                    if (!cd.a(a3)) {
                        String a4 = cn.a(a3);
                        az.d("HomePresenter", " getMarketOfferVipData result: " + a4);
                        if (TextUtils.isEmpty(a4)) {
                            return;
                        }
                        try {
                            JSONObject jSONObject = new JSONObject(a4);
                            int optInt = jSONObject.optInt("code");
                            az.d("HomePresenter", "getMarketOfferVipData code" + optInt);
                            if (optInt == 0) {
                                JSONObject optJSONObject = jSONObject.optJSONObject("data");
                                if (optJSONObject != null) {
                                    int optInt2 = optJSONObject.optInt("value");
                                    az.d("HomePresenter", "getMarketOfferVipData day" + optInt2);
                                    if (optInt2 > 0 && f.this.f10030b != null) {
                                        az.d("HomePresenter", "getMarketOfferVipData start show");
                                        f.this.f10030b.b(optInt2);
                                    }
                                } else {
                                    az.d("HomePresenter", "getMarketOfferVipData data is null ");
                                }
                            }
                            return;
                        } catch (JSONException e) {
                            az.d("HomePresenter", "getMarketOfferVipData json fail" + e);
                            e.printStackTrace();
                            return;
                        }
                    }
                    az.d("HomePresenter", "getMarketOfferVipData is null");
                    return;
                }
                az.d("HomePresenter", "getMarketOfferVipData() not login");
            }
        });
    }

    public void s() {
        this.f10030b.d();
    }

    public void t() {
        if (bx.a().b(this.c) && bf.e(this.c)) {
            tp.f(new Runnable() {
                @Override
                public void run() {
                    JSONArray optJSONArray;
                    JSONObject i = cn.i(f.this.c);
                    az.d("HomePresenter", " getAppBuyList requestParams: " + i);
                    String a2 = bd.a("https://api.ourplay.com.cn/rank/paidapp", i.toString());
                    if (!cd.a(a2)) {
                        String a3 = cn.a(a2);
                        az.d("HomePresenter", " getAppBuyList result: " + a3);
                        if (TextUtils.isEmpty(a3)) {
                            return;
                        }
                        try {
                            JSONObject jSONObject = new JSONObject(a3);
                            int optInt = jSONObject.optInt("code");
                            az.d("HomePresenter", "getAppBuyList code" + optInt);
                            if (optInt != 0 || (optJSONArray = jSONObject.optJSONArray("data")) == null) {
                                return;
                            }
                            ArrayList arrayList = new ArrayList();
                            for (int i2 = 0; i2 < optJSONArray.length(); i2++) {
                                JSONObject optJSONObject = optJSONArray.optJSONObject(i2);
                                if (optJSONObject != null) {
                                    String optString = optJSONObject.optString(WebActionRouter.KEY_PKG);
                                    String optString2 = optJSONObject.optString("rid");
                                    String optString3 = optJSONObject.optString("name");
                                    JSONObject jSONObject2 = new JSONObject();
                                    jSONObject2.put(WebActionRouter.KEY_PKG, optString);
                                    jSONObject2.put("name", optString3);
                                    jSONObject2.put("rid", optString2);
                                    if (optString != null && optString2 != null) {
                                        AppBuyBean appBuyBean = new AppBuyBean();
                                        appBuyBean.packageName = optString;
                                        appBuyBean.detail = ab.c(jSONObject2.toString(), "keics_e21p3kds8s");
                                        arrayList.add(appBuyBean);
                                    }
                                }
                            }
                            if (com.excelliance.kxqp.gs.util.b.bh(f.this.c)) {
                                com.excelliance.kxqp.gs.newappstore.b.a.a().a(arrayList, f.this.c.getApplicationContext(), 3);
                                return;
                            }
                            return;
                        } catch (JSONException e) {
                            az.d("HomePresenter", "getAppBuyList json fail" + e);
                            e.printStackTrace();
                            return;
                        }
                    }
                    az.d("HomePresenter", "getAppBuyList is null");
                }
            });
        }
    }

    public void a(final ExcellianceAppInfo excellianceAppInfo, final Runnable runnable) {
        if (this.j != null) {
            this.j.post(new Runnable() {
                @Override
                public void run() {
                    au.a().a(f.this.c, GameAttrsRequest.Factory.create(f.this.c, excellianceAppInfo.getAppPackageName()));
                    tp.i(new Runnable() {
                        @Override
                        public void run() {
                            runnable.run();
                        }
                    });
                }
            });
        }
    }

    public void u() {
        final com.excelliance.kxqp.gs.ui.nyactivitys.b bVar = new com.excelliance.kxqp.gs.ui.nyactivitys.b();
        if (this.j == null) {
            return;
        }
        this.j.post(new Runnable() {
            @Override
            public void run() {
                final List<AppInfo> a2 = com.excelliance.kxqp.gs.l.g.a(f.this.c).a(0, 20, "3", true);
                bVar.execute(new Runnable() {
                    @Override
                    public void run() {
                        if (f.this.f10030b != null) {
                            if (a2 == null || a2.size() <= 0) {
                                f.this.f10030b.e((List<AppInfo>) null);
                            } else {
                                f.this.f10030b.e(a2);
                            }
                        }
                    }
                });
            }
        });
    }

    public void v() {
        final com.excelliance.kxqp.gs.ui.nyactivitys.b bVar = new com.excelliance.kxqp.gs.ui.nyactivitys.b();
        if (this.j == null) {
            return;
        }
        this.j.post(new Runnable() {
            @Override
            public void run() {
                final List<GameChosenBean> b2 = com.excelliance.kxqp.gs.l.c.a().b(f.this.c.getApplicationContext());
                bVar.execute(new Runnable() {
                    @Override
                    public void run() {
                        if (f.this.f10030b != null) {
                            if (b2 == null || b2.size() <= 0) {
                                f.this.f10030b.f((List<GameChosenBean>) null);
                            } else {
                                f.this.f10030b.f(b2);
                            }
                        }
                    }
                });
            }
        });
    }

    public void w() {
        az.d("HomePresenter", "installWebjar enter: ");
        tp.d(new Runnable() {
            @Override
            public void run() {
                ExcellianceAppInfo b2 = com.excelliance.kxqp.repository.a.a(f.this.c).b("com.excean.web");
                boolean z = true;
                if (b2 == null) {
                    az.d("HomePresenter", "no exit reInstall: true");
                } else {
                    com.excelliance.kxqp.wr.a a2 = com.excelliance.kxqp.wr.a.a();
                    String appPackageName = b2.getAppPackageName();
                    String path = b2.getPath();
                    if (!TextUtils.isEmpty(path)) {
                        boolean a3 = bs.a(a2, appPackageName, 0);
                        az.d("HomePresenter", "installWebjar libName: " + appPackageName + " gameInstalled: " + a3);
                        if (new File(path).exists() && a3) {
                            z = false;
                        }
                    }
                    if (!z) {
                        z = bs.a("com.excean.web", b2.getPath(), f.this.c, false);
                    }
                }
                if (z) {
                    f.this.S();
                }
            }
        });
    }

    public void x() {
        Log.d("HomePresenter", "initCombineGameDialog: ");
        tp.f(new Runnable() {
            @Override
            public void run() {
                boolean booleanValue = by.a(f.this.c, "sp_statistics_info").b("sp_kye_statistics_start_app_success", false).booleanValue();
                final CombineRecommendBean.SubBean b2 = com.excelliance.kxqp.task.g.a.a().b(f.this.c);
                if (b2 != null) {
                    by a2 = by.a(f.this.c, "sp_combine_recommend");
                    long a3 = a2.a("sp_key_last_show_dialog_advertisement_time", (Long) 0L);
                    long currentTimeMillis = System.currentTimeMillis();
                    if (!(booleanValue || b2.isShow == 1) || com.excelliance.kxqp.gs.appstore.recommend.e.b.a(f.this.c, b2.packageName)) {
                        return;
                    }
                    long j = currentTimeMillis - a3;
                    Log.d("HomePresenter", "initCombineGameDialog: diffTime = " + j);
                    if (j > b2.interval * 1000.0d) {
                        a2.a("sp_key_last_show_dialog_advertisement_time", currentTimeMillis);
                        tp.i(new Runnable() {
                            @Override
                            public void run() {
                                if (f.this.f10030b != null) {
                                    f.this.f10030b.a(b2);
                                }
                            }
                        });
                    }
                }
            }
        });
    }

    public void S() {
        az.d("HomePresenter", "installWebApk enter: ");
        String a2 = a(this.c, "com.excean.web");
        Intent intent = new Intent(this.c, (Class<?>) SmtServService.class);
        intent.setAction("com.excelliance.kxqp.action.installDownApps");
        Bundle bundle = new Bundle();
        bundle.putString(WebActionRouter.KEY_PKG, "com.excean.web");
        bundle.putString("apkPath", a2);
        bundle.putInt("installType", 1);
        bundle.putInt("sourceType", 0);
        intent.putExtra("bundle", bundle);
        try {
            this.c.startService(intent);
        } catch (Exception e) {
            az.d("HomePresenter", "installWebApk  error appName:");
            e.printStackTrace();
        }
    }

    public void y() {
        new com.excelliance.kxqp.gs.ui.nyactivitys.b();
        if (this.j == null) {
            return;
        }
        this.j.post(new Runnable() {
            @Override
            public void run() {
                List<AppStartedInfo> y = com.excelliance.kxqp.repository.a.a(f.this.c).y();
                int min = Math.min(y.size(), 3);
                JSONArray jSONArray = new JSONArray();
                if (min > 0) {
                    for (int i = 0; i < min; i++) {
                        AppStartedInfo appStartedInfo = y.get(i);
                        if (appStartedInfo != null && !TextUtils.isEmpty(appStartedInfo.packageName)) {
                            jSONArray.put(appStartedInfo.packageName);
                        }
                    }
                }
                com.excelliance.kxqp.gs.discover.bbs.c cVar = new com.excelliance.kxqp.gs.discover.bbs.c(f.this.c);
                JSONObject i2 = cn.i(f.this.c);
                try {
                    i2.put("controlapi", 1);
                    i2.put("isFromDomestic", 1);
                    i2.put("isnew", 1);
                    i2.put("startover_pkglist", jSONArray);
                } catch (JSONException e) {
                    e.printStackTrace();
                }
                com.excelliance.kxqp.gs.discover.model.ResponseData a2 = cVar.a(i2.toString(), "https://api.ourplay.com.cn/goneload/searchrecomd", new com.excelliance.kxqp.gs.discover.a.c<SearchHotAndDiscover>() {
                    @Override
                    public com.excelliance.kxqp.gs.discover.model.ResponseData<SearchHotAndDiscover> a(String str) {
                        try {
                            return (com.excelliance.kxqp.gs.discover.model.ResponseData) new Gson().a(str, new TypeToken<com.excelliance.kxqp.gs.discover.model.ResponseData<SearchHotAndDiscover>>() {
                            }.getType());
                        } catch (Exception e2) {
                            Log.e("HomePresenter", "getHotLabel/ex:" + e2);
                            return null;
                        }
                    }
                });
                Log.d("HomePresenter", "getHotLabel/ResponseData:" + a2);
                if (a2 == null || a2.data == 0) {
                    return;
                }
                if (!s.a(((SearchHotAndDiscover) a2.data).find_list)) {
                    if (f.this.f10030b != null) {
                        f.this.f10030b.d(((SearchHotAndDiscover) a2.data).find_list);
                    }
                } else {
                    if (s.a(((SearchHotAndDiscover) a2.data).hot_search) || f.this.f10030b == null) {
                        return;
                    }
                    f.this.f10030b.d(((SearchHotAndDiscover) a2.data).hot_search);
                }
            }
        });
    }

    public int a(String str, long j) {
        LoginResponse loginResponse;
        az.d("HomePresenter", "verification data: " + str + " time:" + j);
        int i = 0;
        if (!TextUtils.isEmpty(str)) {
            try {
                loginResponse = (LoginResponse) I().a(str, new TypeToken<LoginResponse>() {
                }.getType());
            } catch (Exception e) {
                e.printStackTrace();
                az.d("HomePresenter", "verification ex: " + e.getMessage());
                loginResponse = null;
            }
            if (loginResponse != null && loginResponse.mLoginUserInfo != null && loginResponse.mLoginUserInfo.vip > 0 && loginResponse.mLoginUserInfo.veriStr - j > 60000) {
                i = 1;
            }
            if (loginResponse != null && loginResponse.mLoginUserInfo != null) {
                UserUtil.getInstance().updateHeadStuAndNickStu(this.c, loginResponse.mLoginUserInfo);
            }
        }
        return i;
    }

    public void a(final Context context, final String str, final String str2) {
        this.j.post(new Runnable() {
            @Override
            public void run() {
                aw.a(context, str2, str, "HomePresenter");
            }
        });
    }

    public void z() {
        if (com.excelliance.kxqp.gs.ui.nyactivitys.e.b(this.c)) {
            this.j.post(new Runnable() {
                @Override
                public void run() {
                    JSONObject jSONObject = new JSONObject();
                    GameUtil intance = GameUtil.getIntance();
                    intance.q(f.this.c);
                    try {
                        jSONObject.put(BiManager.UQID, intance.F(f.this.c));
                    } catch (JSONException e) {
                        e.printStackTrace();
                    }
                    az.d("HomePresenter", "getNewYearActionGift request: " + jSONObject.toString());
                    com.excelliance.kxqp.api.c cVar = new com.excelliance.kxqp.api.c(f.this.c);
                    cVar.a(ApiManager.getInstance().c(f.this.c, 15000L, 15000L, "https://api.ourplay.com.cn/").b(jSONObject));
                    final com.excelliance.kxqp.gs.appstore.model.ResponseData b2 = cVar.b();
                    az.d("HomePresenter", "getNewYearActionGift responseData: " + b2);
                    if (b2.data == 0 || b2.code != 0) {
                        return;
                    }
                    by.a(f.this.c, "sp_total_info").a("sp_key_newyear_action_open", ((NewYearGiftResponse) b2.data).actionOpenState);
                    if (((NewYearGiftResponse) b2.data).actionOpenState && ((NewYearGiftResponse) b2.data).giftValueShow && !com.excelliance.kxqp.gs.ui.nyactivitys.e.d(f.this.c) && com.excelliance.kxqp.gs.ui.nyactivitys.e.a(f.this.c)) {
                        tp.i(new Runnable() {
                            @Override
                            public void run() {
                                if (f.this.f10030b != null) {
                                    f.this.f10030b.a((NewYearGiftResponse) b2.data);
                                }
                            }
                        });
                    }
                }
            });
        }
    }

    public void A() {
        this.j.post(new Runnable() {
            @Override
            public void run() {
                long j;
                Runnable runnable;
                final com.excelliance.kxqp.gs.discover.model.ResponseData<b.C0235b> a2 = com.excelliance.kxqp.gs.g.b.a(f.this.c).a(f.this.c, "nextDayVip");
                if (a2 == null) {
                    cg.a(f.this.c, f.this.c.getString(R.string.server_busy));
                    return;
                }
                tp.i(new Runnable() {
                    @Override
                    public void run() {
                        if (f.this.f10030b != null) {
                            f.this.f10030b.x();
                        }
                    }
                });
                switch (a2.code) {
                    case 1:
                        if (a2.data != null) {
                            bx a3 = bx.a();
                            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                            long parseLong = Long.parseLong(a3.t(f.this.c)) * 1000;
                            Calendar calendar = Calendar.getInstance();
                            try {
                                URLConnection openConnection = new URL("http://ourplay.com.cn/").openConnection();
                                openConnection.connect();
                                calendar.setTimeInMillis(openConnection.getDate());
                                j = calendar.getTimeInMillis();
                                try {
                                    try {
                                        az.d("HomePresenter", "网络时间:" + simpleDateFormat.format(calendar.getTime()));
                                        az.d("HomePresenter", "currentEndTime:" + parseLong + " netTime:" + j);
                                        if (parseLong > j) {
                                            az.d("HomePresenter", "还没过期,则直接延续");
                                            calendar.clear();
                                            calendar.setTimeInMillis(parseLong);
                                        }
                                        calendar.add(5, 1);
                                        aa.a(f.this.c).a(a2.data.f6157a);
                                        az.d("HomePresenter", "calendar.getTimeInMillis()" + calendar.getTimeInMillis());
                                        a3.a(f.this.c, calendar.getTimeInMillis() / 1000);
                                        runnable = new Runnable() {
                                            @Override
                                            public void run() {
                                                if (f.this.f10030b != null) {
                                                    f.this.f10030b.c(((b.C0235b) a2.data).f6157a);
                                                }
                                            }
                                        };
                                    } catch (Exception e) {
                                        e = e;
                                        e.printStackTrace();
                                        az.d("HomePresenter", "本地时间:" + simpleDateFormat.format(calendar.getTime()));
                                        long currentTimeMillis = System.currentTimeMillis();
                                        az.d("HomePresenter", "currentEndTime:" + parseLong + " netTime:" + currentTimeMillis);
                                        if (parseLong > currentTimeMillis) {
                                            az.d("HomePresenter", "还没过期,则直接延续");
                                            calendar.clear();
                                            calendar.setTimeInMillis(parseLong);
                                        }
                                        calendar.add(5, 1);
                                        aa.a(f.this.c).a(a2.data.f6157a);
                                        az.d("HomePresenter", "calendar.getTimeInMillis()" + calendar.getTimeInMillis());
                                        a3.a(f.this.c, calendar.getTimeInMillis() / 1000);
                                        runnable = new Runnable() {
                                            @Override
                                            public void run() {
                                                if (f.this.f10030b != null) {
                                                    f.this.f10030b.c(((b.C0235b) a2.data).f6157a);
                                                }
                                            }
                                        };
                                        tp.i(runnable);
                                        bz.a().a(f.this.c, 149000, 3, "第二日礼包领取成功数");
                                        return;
                                    }
                                } catch (Throwable th) {
                                    th = th;
                                    az.d("HomePresenter", "currentEndTime:" + parseLong + " netTime:" + j);
                                    if (parseLong > j) {
                                        az.d("HomePresenter", "还没过期,则直接延续");
                                        calendar.clear();
                                        calendar.setTimeInMillis(parseLong);
                                    }
                                    calendar.add(5, 1);
                                    aa.a(f.this.c).a(a2.data.f6157a);
                                    az.d("HomePresenter", "calendar.getTimeInMillis()" + calendar.getTimeInMillis());
                                    a3.a(f.this.c, calendar.getTimeInMillis() / 1000);
                                    tp.i(new Runnable() {
                                        @Override
                                        public void run() {
                                            if (f.this.f10030b != null) {
                                                f.this.f10030b.c(((b.C0235b) a2.data).f6157a);
                                            }
                                        }
                                    });
                                    bz.a().a(f.this.c, 149000, 3, "第二日礼包领取成功数");
                                    throw th;
                                }
                            } catch (Exception e2) {
                                e = e2;
                                j = 0;
                            } catch (Throwable th2) {
                                th = th2;
                                j = 0;
                                az.d("HomePresenter", "currentEndTime:" + parseLong + " netTime:" + j);
                                if (parseLong > j) {
                                }
                                calendar.add(5, 1);
                                aa.a(f.this.c).a(a2.data.f6157a);
                                az.d("HomePresenter", "calendar.getTimeInMillis()" + calendar.getTimeInMillis());
                                a3.a(f.this.c, calendar.getTimeInMillis() / 1000);
                                tp.i(new Runnable() {
                                    @Override
                                    public void run() {
                                        if (f.this.f10030b != null) {
                                            f.this.f10030b.c(((b.C0235b) a2.data).f6157a);
                                        }
                                    }
                                });
                                bz.a().a(f.this.c, 149000, 3, "第二日礼包领取成功数");
                                throw th;
                            }
                            tp.i(runnable);
                            bz.a().a(f.this.c, 149000, 3, "第二日礼包领取成功数");
                            return;
                        }
                        return;
                    case 2:
                        tp.i(new Runnable() {
                            @Override
                            public void run() {
                                if (f.this.f10030b != null) {
                                    f.this.f10030b.y();
                                }
                            }
                        });
                        break;
                }
                cg.a(f.this.c, a2.msg);
            }
        });
    }

    public void a(final int i, final CityBean cityBean, final int i2) {
        this.j.post(new Runnable() {
            @Override
            public void run() {
                if (!bf.e(f.this.c)) {
                    if (f.this.f10030b != null) {
                        if (com.excelliance.kxqp.gs.util.b.cq(f.this.c)) {
                            f.this.f10030b.a((OpenVipContentBean) null);
                            return;
                        } else {
                            f.this.f10030b.a(i, cityBean, i2, (OpenVipContentBean) null);
                            return;
                        }
                    }
                    return;
                }
                final com.excelliance.kxqp.gs.discover.model.ResponseData<OpenVipContentBean> B = f.this.B();
                tp.i(new Runnable() {
                    @Override
                    public void run() {
                        if (f.this.f10030b == null || B == null) {
                            return;
                        }
                        if (com.excelliance.kxqp.gs.util.b.cq(f.this.c)) {
                            f.this.f10030b.a((OpenVipContentBean) B.data);
                        } else {
                            f.this.f10030b.a(i, cityBean, i2, (OpenVipContentBean) B.data);
                        }
                    }
                });
            }
        });
    }

    public void c(final int i) {
        if (!bf.e(this.c)) {
            if (this.f10030b != null) {
                this.f10030b.a(i, (OpenVipContentBean) null);
            }
        } else {
            if (this.f10030b != null) {
                this.f10030b.a("加载中");
            }
            this.j.post(new Runnable() {
                @Override
                public void run() {
                    final com.excelliance.kxqp.gs.discover.model.ResponseData<OpenVipContentBean> B = f.this.B();
                    tp.i(new Runnable() {
                        @Override
                        public void run() {
                            if (f.this.f10030b == null || B == null) {
                                return;
                            }
                            f.this.f10030b.a(i, (OpenVipContentBean) B.data);
                        }
                    });
                }
            });
        }
    }

    public com.excelliance.kxqp.gs.discover.model.ResponseData<OpenVipContentBean> B() {
        try {
            return new com.excelliance.kxqp.gs.discover.bbs.c(this.c).a(cn.i(this.c).toString(), "https://api.ourplay.com.cn/goneload/getviptext", new com.excelliance.kxqp.gs.discover.a.c<OpenVipContentBean>() {
                @Override
                public com.excelliance.kxqp.gs.discover.model.ResponseData<OpenVipContentBean> a(String str) {
                    return (com.excelliance.kxqp.gs.discover.model.ResponseData) new Gson().a(str, new TypeToken<com.excelliance.kxqp.gs.discover.model.ResponseData<OpenVipContentBean>>() {
                    }.getType());
                }
            });
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }

    public void C() {
        az.d("HomePresenter", "installVendingAppV2 enter: ");
        tp.d(new Runnable() {
            @Override
            public void run() {
                f.this.T();
                ExcellianceAppInfo b2 = com.excelliance.kxqp.repository.a.a(f.this.c).b("com.excean.android.browser");
                boolean z = true;
                if (b2 == null) {
                    az.d("HomePresenter", "no exit reInstall: true");
                } else {
                    com.excelliance.kxqp.wr.a a2 = com.excelliance.kxqp.wr.a.a();
                    String appPackageName = b2.getAppPackageName();
                    String path = b2.getPath();
                    if (!TextUtils.isEmpty(path)) {
                        boolean a3 = bs.a(a2, appPackageName, 0);
                        az.d("HomePresenter", "installWebjar libName: " + appPackageName + " gameInstalled: " + a3);
                        if (new File(path).exists() && a3) {
                            z = false;
                        }
                    }
                    if (!z) {
                        z = bs.a("com.excean.android.browser", b2.getPath(), f.this.c, false);
                    }
                }
                if (z) {
                    f.this.U();
                }
            }
        });
    }

    public void T() {
        ExcellianceAppInfo b2 = com.excelliance.kxqp.repository.a.a(this.c).b("com.excean.android.unrestricted_inner_browser");
        Log.d("HomePresenter", "initWork: " + b2);
        if (b2 != null) {
            com.excelliance.kxqp.wr.a a2 = com.excelliance.kxqp.wr.a.a();
            String appPackageName = b2.getAppPackageName();
            boolean a3 = bs.a(a2, appPackageName, 0);
            Log.d("HomePresenter", "initWork: gameInstalled::" + a3);
            if (a3) {
                a2.d(0, appPackageName);
                a2.c(0, appPackageName, 0);
                com.excelliance.kxqp.repository.a.a(this.c).a(appPackageName);
            }
        }
    }

    public void U() {
        az.d("HomePresenter", "installWebApk enter: ");
        String a2 = a(this.c, "com.excean.android.browser");
        Intent intent = new Intent(this.c, (Class<?>) SmtServService.class);
        intent.setAction("com.excelliance.kxqp.action.installDownApps");
        Bundle bundle = new Bundle();
        bundle.putString(WebActionRouter.KEY_PKG, "com.excean.android.browser");
        bundle.putString("apkPath", a2);
        bundle.putInt("installType", 1);
        bundle.putInt("sourceType", 0);
        intent.putExtra("bundle", bundle);
        try {
            this.c.startService(intent);
        } catch (Exception e) {
            az.d("HomePresenter", "installWebApk  error appName:");
            e.printStackTrace();
        }
    }

    public void D() {
        this.j.post(new Runnable() {
            @Override
            public void run() {
                JSONObject optJSONObject;
                try {
                    az.d("HomePresenter", String.format("InitObserver/showProtocolDialog:thread(%s)", Thread.currentThread().getName()));
                    String b2 = by.a(f.this.c, "sp_config").b("sp_key_privacy_vc", "");
                    JSONObject i = cn.i(f.this.c);
                    i.put("privacy_vc", b2);
                    String a2 = bd.a("https://api.ourplay.com.cn/switch/get-privacy-policy-update", i.toString());
                    Log.d("HomePresenter", "run: rawResponse::" + a2);
                    if (TextUtils.isEmpty(a2)) {
                        return;
                    }
                    String a3 = cn.a(a2);
                    az.d("HomePresenter", "showProtocolDialog:" + a3);
                    if (TextUtils.isEmpty(a3)) {
                        return;
                    }
                    JSONObject jSONObject = new JSONObject(a3);
                    if (jSONObject.optInt("code") != 0 || (optJSONObject = jSONObject.optJSONObject("data")) == null) {
                        return;
                    }
                    final String optString = optJSONObject.optString("privacy_vc");
                    final String optString2 = optJSONObject.optString("content");
                    if (TextUtils.isEmpty(optString2) || TextUtils.isEmpty(optString)) {
                        return;
                    }
                    tp.i(new Runnable() {
                        @Override
                        public void run() {
                            if (f.this.f10030b != null) {
                                f.this.f10030b.a(optString2, optString);
                            }
                        }
                    });
                } catch (Exception e) {
                    e.printStackTrace();
                    Log.d("HomePresenter", "run: Exception::" + e.toString());
                }
            }
        });
    }

    public void E() {
        this.j.post(new Runnable() {
            @Override
            public void run() {
                final com.excelliance.kxqp.gs.discover.model.ResponseData<b.C0235b> a2 = com.excelliance.kxqp.gs.g.b.a(f.this.c).a(f.this.c, "startupGame");
                if (a2 == null) {
                    cg.a(f.this.c, f.this.c.getString(R.string.server_busy));
                    return;
                }
                tp.i(new Runnable() {
                    @Override
                    public void run() {
                        if (f.this.f10030b != null) {
                            f.this.f10030b.x();
                        }
                    }
                });
                if (a2.code != 1) {
                    cg.a(f.this.c, a2.msg);
                } else if (a2.data != null) {
                    aa.a(f.this.c).a(a2.data.f6157a);
                    bx.a().b(f.this.c.getSharedPreferences("USERINFO", Build.VERSION.SDK_INT < 11 ? 0 : 4), "END_TIME", String.valueOf(a2.data.f6158b));
                    tp.i(new Runnable() {
                        @Override
                        public void run() {
                            if (f.this.f10030b != null) {
                                f.this.f10030b.d(((b.C0235b) a2.data).f6157a);
                            }
                        }
                    });
                }
            }
        });
    }

    public void F() {
        ((com.excelliance.kxqp.api.b) com.zero.support.core.api.a.a(com.excelliance.kxqp.api.b.class)).c().d().observe(this.f10030b, new Observer<Response<ServerBroadcastInfo>>() {
            @Override
            public void onChanged(Response<ServerBroadcastInfo> response) {
                if (response.d() == null) {
                    f.this.f10030b.a((ServerBroadcastInfo) null, true);
                } else {
                    f.this.a(response);
                    f.this.f10030b.a(response.d(), true);
                }
            }
        });
    }

    public void G() {
        tp.f(new Runnable() {
            @Override
            public void run() {
                List<PushItem> queryNotDeletedItems = SPushDBHelper.getInstance(f.this.c).queryNotDeletedItems();
                ArrayList arrayList = new ArrayList();
                if (queryNotDeletedItems != null) {
                    for (int i = 0; i < queryNotDeletedItems.size(); i++) {
                        if (queryNotDeletedItems.get(i).showPosition.homePage == 1 && f.this.a(queryNotDeletedItems.get(i).id)) {
                            arrayList.add(queryNotDeletedItems.get(i));
                        }
                    }
                }
                final ServerBroadcastInfo pushItemsToServerBroadcastInfo = ServerBroadcastInfo.pushItemsToServerBroadcastInfo(arrayList);
                tp.i(new Runnable() {
                    @Override
                    public void run() {
                        if (f.this.f10030b != null) {
                            f.this.f10030b.a(pushItemsToServerBroadcastInfo, false);
                        }
                    }
                });
            }
        });
    }

    public boolean a(long j) {
        Long valueOf = Long.valueOf(by.a(this.c, "sp_config").a("sp_key_tz_dismiss_time_pre_" + j, (Long) 0L));
        return valueOf.longValue() == 0 || Long.valueOf(Calendar.getInstance().getTimeInMillis()).longValue() <= valueOf.longValue();
    }

    public void H() {
        boolean i = bq.i(this.c);
        com.excelliance.user.account.f.e.a("HomePresenter", "HomePresenter.java/checkGetInstallAppPermission: []need request  " + i);
        if (i) {
            String format = com.excelliance.kxqp.gs.ui.medal.a.i.a().format(new Date());
            Set<String> b2 = by.a(this.c, "sp_config").b("sp_key_request_install_app_show_day_time", new HashSet());
            com.excelliance.user.account.f.e.a("HomePresenter", "HomePresenter.java/checkGetInstallAppPermission: dateSet " + new Gson().a(b2));
            if (b2.contains(format) || b2.size() == 2) {
                return;
            }
            this.f10030b.L();
        }
    }

    public void a(Response<ServerBroadcastInfo> response) {
        List<ExcellianceAppInfo> b2 = com.excelliance.kxqp.repository.a.a(this.c).b();
        HashMap hashMap = new HashMap();
        for (ExcellianceAppInfo excellianceAppInfo : b2) {
            hashMap.put(excellianceAppInfo.appPackageName, excellianceAppInfo);
        }
        long currentTimeMillis = System.currentTimeMillis();
        List<ServerBroadcastInfo.BroadcastItem> list = response.d().broadcastList;
        ArrayList arrayList = new ArrayList();
        if (list != null && list.size() > 0) {
            for (int i = 0; i < list.size(); i++) {
                ServerBroadcastInfo.BroadcastItem broadcastItem = list.get(i);
                String str = broadcastItem.matchPkgs;
                broadcastItem.receiveTime = Long.valueOf(i + currentTimeMillis);
                if (!cd.a(str)) {
                    String[] split = str.split(StatisticsManager.COMMA);
                    int i2 = 0;
                    while (true) {
                        if (i2 >= split.length) {
                            break;
                        }
                        if (hashMap.get(split[i2]) != null) {
                            arrayList.add(broadcastItem);
                            break;
                        }
                        i2++;
                    }
                } else {
                    arrayList.add(broadcastItem);
                }
            }
        }
        response.d().broadcastList = arrayList;
    }
}