This commit is contained in:
zhongchao
2022-03-22 10:07:10 +08:00
parent 3a14b5e37d
commit a39f310331
42 changed files with 1317 additions and 201 deletions

View File

@@ -60,7 +60,7 @@ class VehicleMonitoringManager : ICheckProvider, IMogoStatusChangedListener {
}
override fun checkMonitor(context: Context) {
checkNetWork(context, object : ICheckResultCallBack {
checkNetWork( context, object : ICheckResultCallBack {
override fun callBackWithCheckData(data: CheckResultData) {
updateMonitoringStatus(MogoReceiver.ACTION_CHECK_VEHICLE_MONITORING, data.data.vehicle.state)
if (data.data.vehicle.state == 1) {

View File

@@ -1,11 +1,7 @@
package com.mogo.eagle.core.function.check.net;
import android.content.Context;
import com.alibaba.android.arouter.launcher.ARouter;
import com.mogo.eagle.core.data.constants.MogoServicePaths;
import com.mogo.eagle.core.network.MoGoRetrofitFactory;
import com.mogo.module.common.constants.HostConst;
import com.mogo.service.network.IMogoNetwork;
/**
* @author liujing
@@ -18,18 +14,15 @@ public class CheckApiServiceFactory {
/**
* 获取指定域名下的 API 服务
*/
public static CheckApiServices getApiService(Context context, String netHost) {
IMogoNetwork network = (IMogoNetwork) ARouter.getInstance()
.build(MogoServicePaths.PATH_SERVICES_NETWORK)
.navigation(context);
return network.create(CheckApiServices.class, netHost);
public static CheckApiServices getApiService(String netHost) {
return MoGoRetrofitFactory.getInstance(netHost).create(CheckApiServices.class);
}
public static CheckApiServices getDataApiService(Context context) {
public static CheckApiServices getDataApiService() {
if (mDataApiService == null) {
synchronized (CheckApiServiceFactory.class) {
if (mDataApiService == null) {
mDataApiService = getApiService(context, HostConst.DATA_SERVICE_HOST);
mDataApiService = getApiService(HostConst.DATA_SERVICE_HOST);
}
}
}

View File

@@ -21,23 +21,23 @@ object CheckNetWork {
//网络请求,获取自车检测结果(工控机上报云端)
fun checkNetWork(context: Context, callbackFlow: ICheckResultCallBack) {
val params = ParamsBuilder.of(false)
.append("sn", MoGoAiCloudClientConfig.getInstance().sn)
.build()
.append("sn", MoGoAiCloudClientConfig.getInstance().sn)
.build()
CheckApiServiceFactory.getDataApiService(context).loadMonitorDetail(params)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(object : SubscribeImpl<CheckResultData>(RequestOptions.create(context)) {
override fun onSuccess(o: CheckResultData) {
super.onSuccess(o)
ThreadUtils.runOnUiThread { callbackFlow?.callBackWithCheckData(o) }
}
CheckApiServiceFactory.getDataApiService().loadMonitorDetail(params)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(object : SubscribeImpl<CheckResultData>(RequestOptions.create(context)) {
override fun onSuccess(o: CheckResultData) {
super.onSuccess(o)
ThreadUtils.runOnUiThread { callbackFlow?.callBackWithCheckData(o) }
}
override fun onError(message: String, code: Int) {
super.onError(message, code)
ThreadUtils.runOnUiThread { callbackFlow?.callBackWithError(message,code) }
}
})
override fun onError(message: String, code: Int) {
super.onError(message, code)
ThreadUtils.runOnUiThread { callbackFlow?.callBackWithError(message, code) }
}
})
}
}