version:1.9
fix: add:接口缓存
This commit is contained in:
@@ -10,25 +10,17 @@ import android.util.Log;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.amap.api.location.AMapLocation;
|
||||
import com.amap.api.location.AMapLocationClient;
|
||||
import com.amap.api.location.AMapLocationListener;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.trello.rxlifecycle4.RxLifecycle;
|
||||
import com.trello.rxlifecycle4.android.ActivityEvent;
|
||||
import com.uiui.sn.bean.AppInfo;
|
||||
import com.uiui.sn.bean.AppStart;
|
||||
import com.uiui.sn.bean.BaseResponse;
|
||||
import com.uiui.sn.bean.Label;
|
||||
import com.uiui.sn.bean.UserAvatarInfo;
|
||||
import com.uiui.sn.bean.SnInfo;
|
||||
import com.uiui.sn.bean.browser.BrowserApiData;
|
||||
import com.uiui.sn.bean.browser.BrowserBean;
|
||||
import com.uiui.sn.config.CommonConfig;
|
||||
import com.uiui.sn.manager.AmapManager;
|
||||
import com.uiui.sn.manager.ControlManager;
|
||||
import com.uiui.sn.network.HTTPInterface;
|
||||
import com.uiui.sn.network.NetInterfaceManager;
|
||||
import com.uiui.sn.service.ManagerService;
|
||||
import com.uiui.sn.utils.ApkUtils;
|
||||
@@ -87,7 +79,7 @@ public class MainSPresenter implements MainSContact.Presenter {
|
||||
@Override
|
||||
public void getSnInfo() {
|
||||
NetInterfaceManager.getInstance()
|
||||
.getSnInfo(lifecycle, new NetInterfaceManager.ObserverCallback() {
|
||||
.getSnInfo(true, getLifecycle(), new NetInterfaceManager.ObserverCallback() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
|
||||
@@ -118,7 +110,12 @@ public class MainSPresenter implements MainSContact.Presenter {
|
||||
|
||||
@Override
|
||||
public void checkUpdate() {
|
||||
mView.checkUpdateFinish();
|
||||
NetInterfaceManager.getInstance().checkAllAppUpdate(true, getLifecycle(), new NetInterfaceManager.onCompleteCallback() {
|
||||
@Override
|
||||
public void onComplete() {
|
||||
mView.checkUpdateFinish();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -126,7 +123,7 @@ public class MainSPresenter implements MainSContact.Presenter {
|
||||
public void getAllApp() {
|
||||
NetInterfaceManager.getInstance()
|
||||
.getQueryAllAppControl()
|
||||
.compose(RxLifecycle.bindUntilEvent(lifecycle, ActivityEvent.DESTROY))
|
||||
.compose(RxLifecycle.bindUntilEvent(getLifecycle(), ActivityEvent.DESTROY))
|
||||
.subscribe(new Observer<BaseResponse<List<AppInfo>>>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
@@ -150,7 +147,7 @@ public class MainSPresenter implements MainSContact.Presenter {
|
||||
Settings.System.putString(mContext.getContentResolver(), CommonConfig.ONLY_SHORTCUT_LIST, allPkgString);
|
||||
Log.e("getAllApp", "onNext: " + allPkgString);
|
||||
ApkUtils.writeAppPackageList(mContext, allPkgString);
|
||||
HTTPInterface.getAppStart(mContext, appInfoList);
|
||||
NetInterfaceManager.getInstance().getAppStart(appInfoList);
|
||||
}
|
||||
JGYUtils.getInstance().deleteOtherApp();
|
||||
}
|
||||
@@ -174,7 +171,7 @@ public class MainSPresenter implements MainSContact.Presenter {
|
||||
public void getAppInside() {
|
||||
NetInterfaceManager.getInstance()
|
||||
.getAppInsideControl()
|
||||
.compose(RxLifecycle.bindUntilEvent(lifecycle, ActivityEvent.DESTROY))
|
||||
.compose(RxLifecycle.bindUntilEvent(getLifecycle(), ActivityEvent.DESTROY))
|
||||
.subscribe(new Observer<BaseResponse>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
@@ -215,7 +212,7 @@ public class MainSPresenter implements MainSContact.Presenter {
|
||||
public void getForceInstall() {
|
||||
NetInterfaceManager.getInstance()
|
||||
.getForceInstallControl()
|
||||
.compose(RxLifecycle.bindUntilEvent(lifecycle, ActivityEvent.DESTROY))
|
||||
.compose(RxLifecycle.bindUntilEvent(getLifecycle(), ActivityEvent.DESTROY))
|
||||
.subscribe(new Observer<BaseResponse<List<AppInfo>>>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
@@ -229,7 +226,7 @@ public class MainSPresenter implements MainSContact.Presenter {
|
||||
if (code == 200) {
|
||||
List<AppInfo> appInfos = listBaseResponse.data;
|
||||
if (null != appInfos && appInfos.size() != 0) {
|
||||
HTTPInterface.getForceInstallState(mContext, appInfos);
|
||||
NetInterfaceManager.getInstance().getForceInstallState(appInfos);
|
||||
}
|
||||
} else {
|
||||
boolean qch_force_app = JGYUtils.putString(mContext.getContentResolver(), "qch_force_app", "invalid");
|
||||
@@ -255,7 +252,7 @@ public class MainSPresenter implements MainSContact.Presenter {
|
||||
public void getSystemSettings() {
|
||||
NetInterfaceManager.getInstance()
|
||||
.getsettingControl()
|
||||
.compose(RxLifecycle.bindUntilEvent(lifecycle, ActivityEvent.DESTROY))
|
||||
.compose(RxLifecycle.bindUntilEvent(getLifecycle(), ActivityEvent.DESTROY))
|
||||
.subscribe(new Observer<BaseResponse>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
@@ -296,7 +293,7 @@ public class MainSPresenter implements MainSContact.Presenter {
|
||||
@Override
|
||||
public void getBrowserLabel() {
|
||||
NetInterfaceManager.getInstance().getLabelControl()
|
||||
.compose(RxLifecycle.bindUntilEvent(lifecycle, ActivityEvent.DESTROY))
|
||||
.compose(RxLifecycle.bindUntilEvent(getLifecycle(), ActivityEvent.DESTROY))
|
||||
.subscribe(new Observer<BaseResponse<Label>>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
@@ -373,7 +370,7 @@ public class MainSPresenter implements MainSContact.Presenter {
|
||||
@Override
|
||||
public void getBrowserWhiteList() {
|
||||
NetInterfaceManager.getInstance().getBrowserControl()
|
||||
.compose(RxLifecycle.bindUntilEvent(lifecycle, ActivityEvent.DESTROY))
|
||||
.compose(RxLifecycle.bindUntilEvent(getLifecycle(), ActivityEvent.DESTROY))
|
||||
.subscribe(new Observer<BaseResponse<BrowserApiData>>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
@@ -427,7 +424,7 @@ public class MainSPresenter implements MainSContact.Presenter {
|
||||
public void getAppStart() {
|
||||
NetInterfaceManager.getInstance()
|
||||
.getAppStartControl()
|
||||
.compose(RxLifecycle.bindUntilEvent(lifecycle, ActivityEvent.DESTROY))
|
||||
.compose(RxLifecycle.bindUntilEvent(getLifecycle(), ActivityEvent.DESTROY))
|
||||
.subscribe(new Observer<BaseResponse<List<AppStart>>>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
@@ -440,9 +437,9 @@ public class MainSPresenter implements MainSContact.Presenter {
|
||||
int code = listBaseResponse.code;
|
||||
if (code == 200) {
|
||||
List<AppStart> list = listBaseResponse.data;
|
||||
HTTPInterface.setAppState(mContext, list);
|
||||
NetInterfaceManager.getInstance().setAppState(list);
|
||||
} else {
|
||||
HTTPInterface.setInvalid(mContext);
|
||||
NetInterfaceManager.getInstance().setInvalid();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -463,17 +460,17 @@ public class MainSPresenter implements MainSContact.Presenter {
|
||||
@Override
|
||||
public void getTimeControl() {
|
||||
NetInterfaceManager.getInstance()
|
||||
.getTimeControl()
|
||||
.compose(RxLifecycle.bindUntilEvent(lifecycle, ActivityEvent.DESTROY))
|
||||
.getTimeControlObservable()
|
||||
.compose(RxLifecycle.bindUntilEvent(getLifecycle(), ActivityEvent.DESTROY))
|
||||
.subscribe(new Observer<BaseResponse>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
Log.e("getTimeControl", "onSubscribe: ");
|
||||
Log.e("getTimeControlControl", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(BaseResponse baseResponse) {
|
||||
Log.e("getTimeControl", "onNext: ");
|
||||
Log.e("getTimeControlControl", "onNext: ");
|
||||
int code = baseResponse.code;
|
||||
if (code == 200) {
|
||||
JSONObject jsonObject = (JSONObject) JSON.toJSON(baseResponse.data);
|
||||
@@ -486,32 +483,32 @@ public class MainSPresenter implements MainSContact.Presenter {
|
||||
TimeUtils.ContralTime workingTime = TimeUtils.String2WorkingTime(mContext, work_start_time + "-" + work_end_time);
|
||||
TimeUtils.ContralTime weekTime = TimeUtils.String2WeekTime(mContext, rest_start_time + "-" + rest_end_time);
|
||||
if (null != workingTime) {
|
||||
Log.e("getTimeControl", "200:" + workingTime.toString());
|
||||
Log.e("getTimeControlControl", "200:" + workingTime.toString());
|
||||
}
|
||||
if (null != weekTime) {
|
||||
Log.e("getTimeControl", "200:" + weekTime.toString());
|
||||
Log.e("getTimeControlControl", "200:" + weekTime.toString());
|
||||
}
|
||||
} else {
|
||||
TimeUtils.setEmpty(mContext);
|
||||
TimeUtils.ContralTime workingTime = TimeUtils.getWorkingDayContralTime(mContext);
|
||||
if (null != workingTime) {
|
||||
Log.e("getTimeControl", workingTime.toString());
|
||||
Log.e("getTimeControlControl", workingTime.toString());
|
||||
}
|
||||
TimeUtils.ContralTime weekTime = TimeUtils.getWeekDayContralTime(mContext);
|
||||
if (null != weekTime) {
|
||||
Log.e("getTimeControl", weekTime.toString());
|
||||
Log.e("getTimeControlControl", weekTime.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
Log.e("getTimeControl", "onError: " + e.getMessage());
|
||||
Log.e("getTimeControlControl", "onError: " + e.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("getTimeControl", "onComplete: ");
|
||||
Log.e("getTimeControlControl", "onComplete: ");
|
||||
Intent intent = new Intent();
|
||||
intent.setAction(ManagerService.ACTION_UPDATE);
|
||||
mContext.sendBroadcast(intent);
|
||||
@@ -527,7 +524,7 @@ public class MainSPresenter implements MainSContact.Presenter {
|
||||
.getScreenshot(Utils.getSerial())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.compose(RxLifecycle.bindUntilEvent(lifecycle, ActivityEvent.DESTROY))
|
||||
.compose(RxLifecycle.bindUntilEvent(getLifecycle(), ActivityEvent.DESTROY))
|
||||
.subscribe(new Observer<BaseResponse>() {
|
||||
|
||||
@Override
|
||||
|
||||
@@ -107,7 +107,7 @@ public class MainService extends Service implements MainSContact.MainView, Netwo
|
||||
start.onstar(WiFiAlias);
|
||||
}
|
||||
}
|
||||
NetInterfaceManager.getInstance().checkAllAppUpdate();
|
||||
mPresenter.checkUpdate();
|
||||
TimeTask task = new TimeTask();
|
||||
task.execute("ntp.aliyun.com");
|
||||
}
|
||||
@@ -124,22 +124,7 @@ public class MainService extends Service implements MainSContact.MainView, Netwo
|
||||
AlarmManager am = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
|
||||
am.setTime(aLong);
|
||||
tPushInit();
|
||||
NetInterfaceManager.getInstance().setPushTags(lifecycleSubject, new NetInterfaceManager.ObserverCallback() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
Log.e("TimeTask", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(BaseResponse response) {
|
||||
Log.e("TimeTask", "onNext: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
Log.e("TimeTask", "onError: " + e.getMessage());
|
||||
}
|
||||
|
||||
NetInterfaceManager.getInstance().setPushTags(true, lifecycleSubject, new NetInterfaceManager.onCompleteCallback() {
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("TimeTask", "onComplete: ");
|
||||
@@ -351,7 +336,7 @@ public class MainService extends Service implements MainSContact.MainView, Netwo
|
||||
@Override
|
||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||
Log.e(TAG, "onStartCommand: " + System.currentTimeMillis());
|
||||
NetInterfaceManager.getInstance().checkAllAppUpdate();
|
||||
mPresenter.checkUpdate();
|
||||
return START_STICKY;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user