柬埔寨通 v6.1.5版本的 MD5 值为:9b68581ac30883219d6a25858a099d6b
以下内容为反编译后的 ConfigService.java 源代码,内容仅作参考
package net.duohuo.magappx.common.service;
import android.text.TextUtils;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.iflytek.cloud.SpeechConstant;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import net.duohuo.cloudad.CloudAdUtil;
import net.duohuo.core.eventbus.EventBus;
import net.duohuo.core.ioc.Ioc;
import net.duohuo.core.net.Net;
import net.duohuo.core.net.Result;
import net.duohuo.core.net.Task;
import net.duohuo.core.net.cache.CacheManager;
import net.duohuo.core.net.cache.CachePolicy;
import net.duohuo.core.util.SafeJsonUtil;
import net.duohuo.magapp.BuildConfig;
import net.duohuo.magappx.API;
import net.duohuo.magappx.common.dataview.model.PicAd;
import net.duohuo.magappx.common.util.AppPreference;
import net.duohuo.magappx.common.util.MonitorCenter;
import net.duohuo.magappx.find.model.ToolItem;
public class ConfigService {
static int bankupUrlIndex = -1;
EventBus bus = (EventBus) Ioc.get(EventBus.class);
public void loadPage() {
loadPageTask(null);
}
static {
int i = ((AppPreference) Ioc.get(AppPreference.class)).bankupUrlIndex;
bankupUrlIndex = i;
if (i <= -1 || i >= BuildConfig.extra_url_base.length) {
return;
}
Net.setUrlChange(new Net.UrlChange() {
@Override
public String onChange(String str) {
return str.startsWith("https://app.jpztong.com/") ? str.replaceFirst("https://app.jpztong.com/", BuildConfig.extra_url_base[ConfigService.bankupUrlIndex]) : str;
}
});
}
public void loadPageTask(final Task task) {
Net url = Net.url(API.Common.page);
url.showProgress(false);
url.get(new Task<Result>() {
@Override
public void onUnKnowHostError() {
super.onUnKnowHostError();
ConfigService.bankupUrlIndex++;
if (ConfigService.bankupUrlIndex < BuildConfig.extra_url_base.length) {
API.Common.page = BuildConfig.extra_url_base[ConfigService.bankupUrlIndex] + "mag/index/v2/index/pages";
ConfigService.this.loadPage();
return;
}
API.Common.page = "https://app.jpztong.com/mag/index/v2/index/pages";
}
@Override
public void onError() {
super.onError();
ConfigService.this.loadPage();
Task task2 = task;
if (task2 != null) {
task2.onError();
}
}
@Override
public void onResult(Result result) {
if (result.success()) {
if (ConfigService.bankupUrlIndex > -1 && ConfigService.bankupUrlIndex < BuildConfig.extra_url_base.length) {
Net.setUrlChange(new Net.UrlChange() {
@Override
public String onChange(String str) {
return str.startsWith("https://app.jpztong.com/") ? str.replaceFirst("https://app.jpztong.com/", BuildConfig.extra_url_base[ConfigService.bankupUrlIndex]) : str;
}
});
}
CacheManager cacheManager = (CacheManager) Ioc.get(CacheManager.class);
JSONObject json = result.json();
json.keySet();
for (String str : json.keySet()) {
if (!str.equals("success") && !str.equals("fragment_key")) {
String string = json.getString(str);
if (!TextUtils.isEmpty(string)) {
if ("index_fragment".equals(str) || "option_list".equals(str)) {
if (!json.getString("fragment_key").equals(cacheManager.get("fragment_key", null)) || TextUtils.isEmpty(cacheManager.get("index_fragment", null)) || TextUtils.isEmpty(cacheManager.get("option_list", null))) {
if ("index_fragment".equals(str)) {
MonitorCenter.loadConfig = string;
}
cacheManager.create(str, null, string);
ConfigService.this.bus.fireEvent(str, new Object[0]);
}
} else {
cacheManager.create(str, null, string);
ConfigService.this.bus.fireEvent(str, new Object[0]);
}
}
}
}
cacheManager.create("fragment_key", null, json.getString("fragment_key"));
Task task2 = task;
if (task2 != null) {
task2.onResult(result);
}
}
}
});
}
public String loadPage(String str) {
return ((CacheManager) Ioc.get(CacheManager.class)).get(str, null);
}
public void loadAd(String str, Task<List<PicAd>> task) {
loadAd(str, true, task);
}
public void loadAd(String str, boolean z, final Task<List<PicAd>> task) {
Net url = Net.url("https://app.jpztong.com/mag/operative/v1/ad/listNotEndByPlace");
url.showProgress(false);
url.param("place", str);
if (z) {
url.cache();
}
url.get(new Task<List<PicAd>>() {
@Override
public Object buildResult(Result result) {
if (!result.success()) {
return null;
}
List<PicAd> parseArray = JSON.parseArray(result.getList().toString(), PicAd.class);
ArrayList arrayList = new ArrayList();
long currentTimeMillis = System.currentTimeMillis() / 1000;
for (PicAd picAd : parseArray) {
if (picAd.beginTime < currentTimeMillis && picAd.endTime > currentTimeMillis) {
arrayList.add(picAd);
}
}
return arrayList;
}
@Override
public void onResult(List<PicAd> list) {
Task task2 = task;
if (task2 != null) {
task2.onResult(list);
}
}
});
}
public void loadCloudAdIds() {
Net url = Net.url(BuildConfig.cjad.booleanValue() ? API.Common.getCJCloudAdIds : API.Common.getCloudAdIds);
url.showProgress(false);
url.get(new Task<Result>() {
@Override
public void onResult(Result result) {
if (result.success()) {
String loadCloudAdIdByType = ((ConfigService) Ioc.get(ConfigService.class)).loadCloudAdIdByType("media_id");
AppPreference appPreference = (AppPreference) Ioc.get(AppPreference.class);
appPreference.cloudAdConfig = SafeJsonUtil.getString(result.jo, "data");
appPreference.commit();
String string = SafeJsonUtil.getString(result.getData(), "media_id");
if (!TextUtils.isEmpty(loadCloudAdIdByType) || TextUtils.isEmpty(string)) {
return;
}
CloudAdUtil.init(Ioc.getApplicationContext(), string);
}
}
});
}
public String loadCloudAdIdByType(String str) {
return SafeJsonUtil.getString(SafeJsonUtil.parseJSONObject(((AppPreference) Ioc.get(AppPreference.class)).cloudAdConfig), str);
}
public List<PicAd> listAdFromCache(String str) {
CacheManager cacheManager = (CacheManager) Ioc.get(CacheManager.class);
HashMap hashMap = new HashMap();
hashMap.put("place", str);
String str2 = cacheManager.get("https://app.jpztong.com/mag/operative/v1/ad/listNotEndByPlace", hashMap);
if (TextUtils.isEmpty(str2)) {
return null;
}
return SafeJsonUtil.parseList(SafeJsonUtil.getJSONArray(SafeJsonUtil.parseJSONObject(str2), "list").toString(), PicAd.class);
}
public PicAd loadAdFromCache(String str) {
List<PicAd> listAdFromCache = listAdFromCache(str);
if (listAdFromCache == null || listAdFromCache.size() <= 0) {
return null;
}
return listAdFromCache.get(0);
}
public List<ToolItem> loadUserTools() {
String str = ((CacheManager) Ioc.get(CacheManager.class)).get("userstools", null);
if (!TextUtils.isEmpty(str)) {
return JSON.parseArray(str, ToolItem.class);
}
return new ArrayList();
}
public void saveUserTools(List<ToolItem> list) {
((CacheManager) Ioc.get(CacheManager.class)).create("userstools", null, JSON.toJSONString(list));
((EventBus) Ioc.get(EventBus.class)).fireEvent(API.Event.user_tools_change, new Object[0]);
}
public boolean isDefToolChange(JSONArray jSONArray) {
return !((CacheManager) Ioc.get(CacheManager.class)).get("default", null).equals(jSONArray.toJSONString());
}
public void loadUserTools(final Task<List<ToolItem>> task) {
Net url = Net.url(API.Common.tools);
url.cache(CachePolicy.POLICY_BEFORE_AND_AFTER_NET);
url.showProgress(false);
url.get(new Task<List<ToolItem>>() {
@Override
public Object buildResult(Result result) {
if (!result.success()) {
return null;
}
HashMap hashMap = new HashMap();
JSONArray jSONArray = result.getData().getJSONArray(SpeechConstant.PLUS_LOCAL_ALL);
int i = 0;
for (int i2 = 0; i2 < jSONArray.size(); i2++) {
JSONArray jSONArray2 = jSONArray.getJSONObject(i2).getJSONArray("items");
for (int i3 = 0; i3 < jSONArray2.size(); i3++) {
JSONObject jSONObject = jSONArray2.getJSONObject(i3);
hashMap.put(jSONObject.getString("marking"), jSONObject);
}
}
CacheManager cacheManager = (CacheManager) Ioc.get(CacheManager.class);
String str = cacheManager.get("userstools", null);
JSONArray jSONArray3 = new JSONArray();
if (TextUtils.isEmpty(str)) {
JSONArray jSONArray4 = result.getData().getJSONArray("default");
while (i < jSONArray4.size()) {
JSONObject jSONObject2 = (JSONObject) hashMap.get(jSONArray4.getJSONObject(i).getString("marking"));
if (jSONObject2 != null) {
jSONObject2.put("isAdd", (Object) true);
jSONArray3.add(jSONObject2);
}
i++;
}
} else if (ConfigService.this.isDefToolChange(result.getData().getJSONArray("default"))) {
List parseArray = JSON.parseArray(JSONArray.parseArray(str).toJSONString(), ToolItem.class);
List parseArray2 = JSON.parseArray(cacheManager.get("default", null), ToolItem.class);
if (parseArray2 == null) {
parseArray2 = new ArrayList();
}
List parseArray3 = JSON.parseArray(result.getData().getJSONArray("default").toJSONString(), ToolItem.class);
ArrayList arrayList = new ArrayList();
for (int i4 = 0; i4 < parseArray2.size(); i4++) {
ToolItem toolItem = (ToolItem) parseArray2.get(i4);
for (int i5 = 0; i5 < parseArray.size(); i5++) {
ToolItem toolItem2 = (ToolItem) parseArray.get(i5);
if (toolItem.picId.equals(toolItem2.picId)) {
arrayList.add(toolItem2);
}
}
}
parseArray.removeAll(arrayList);
arrayList.clear();
for (int i6 = 0; i6 < parseArray3.size(); i6++) {
ToolItem toolItem3 = (ToolItem) parseArray3.get(i6);
for (int i7 = 0; i7 < parseArray.size(); i7++) {
ToolItem toolItem4 = (ToolItem) parseArray.get(i7);
if (toolItem3.picId.equals(toolItem4.picId)) {
arrayList.add(toolItem4);
}
}
}
parseArray.removeAll(arrayList);
arrayList.clear();
parseArray.removeAll(parseArray3);
parseArray3.addAll(parseArray);
String jSONString = JSON.toJSONString(parseArray3);
cacheManager.create("userstools", null, jSONString);
jSONArray3 = JSON.parseArray(jSONString);
} else {
JSONArray parseArray4 = JSONArray.parseArray(str);
while (i < parseArray4.size()) {
JSONObject jSONObject3 = (JSONObject) hashMap.get(parseArray4.getJSONObject(i).getString("marking"));
if (jSONObject3 != null) {
jSONObject3.put("isAdd", (Object) true);
jSONArray3.add(jSONObject3);
}
i++;
}
}
cacheManager.create("default", null, result.getData().getJSONArray("default").toJSONString());
return JSON.parseArray(jSONArray3.toJSONString(), ToolItem.class);
}
@Override
public void onResult(List<ToolItem> list) {
task.onResult(list);
}
});
}
}