[add] 解决不释放导致内存泄露问题
This commit is contained in:
@@ -5,6 +5,8 @@ import android.content.Intent
|
||||
import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.mogo.eagle.core.function.api.check.ICheckProvider
|
||||
import com.mogo.eagle.core.function.api.check.IMogoCheckListener
|
||||
import com.mogo.eagle.core.function.check.api.ICheckResultCallBack
|
||||
import com.mogo.eagle.core.function.check.net.CheckNetWork
|
||||
import com.mogo.eagle.core.function.check.view.CheckActivity
|
||||
import com.mogo.eagle.core.function.check.view.CheckDialog
|
||||
import com.mogo.eagle.core.utilcode.util.ActivityUtils
|
||||
@@ -36,9 +38,9 @@ class VehicleMonitoringManager : ICheckProvider, IMogoStatusChangedListener {
|
||||
LogUtils.dTag(TAG, "初始化 CheckProvider 模块")
|
||||
mContext = context
|
||||
MogoApisHandler.getInstance().apis.statusManagerApi.registerStatusChangedListener(
|
||||
TAG,
|
||||
StatusDescriptor.MAIN_PAGE_RESUME,
|
||||
this
|
||||
TAG,
|
||||
StatusDescriptor.MAIN_PAGE_RESUME,
|
||||
this
|
||||
)
|
||||
}
|
||||
|
||||
@@ -61,9 +63,9 @@ class VehicleMonitoringManager : ICheckProvider, IMogoStatusChangedListener {
|
||||
}
|
||||
|
||||
override fun checkMonitor(context: Context) {
|
||||
CheckActivity.checkMonitor(context) { state ->
|
||||
updateMonitoringStatus(MogoReceiver.ACTION_CHECK_VEHICLE_MONITORING, state)
|
||||
if (state == 1) {
|
||||
CheckNetWork.checkNetWork(context, ICheckResultCallBack { state ->
|
||||
updateMonitoringStatus(MogoReceiver.ACTION_CHECK_VEHICLE_MONITORING, state.data.vehicle.state)
|
||||
if (state.data.vehicle.state == 1) {
|
||||
hasTipShow = false
|
||||
} else {
|
||||
if (!hasTipShow) {
|
||||
@@ -71,7 +73,7 @@ class VehicleMonitoringManager : ICheckProvider, IMogoStatusChangedListener {
|
||||
hasTipShow = true //已弹框
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -80,8 +82,8 @@ class VehicleMonitoringManager : ICheckProvider, IMogoStatusChangedListener {
|
||||
private fun showDialog(context: Context) {
|
||||
try {
|
||||
if (ActivityLifecycleManager.getInstance().isAppActive && AppUtils.isAppRunning(
|
||||
AppUtils.getAppPackageName()
|
||||
) && ActivityUtils.getTopActivity() !is CheckActivity
|
||||
AppUtils.getAppPackageName()
|
||||
) && ActivityUtils.getTopActivity() !is CheckActivity
|
||||
) {
|
||||
if (dialog != null) {
|
||||
dialog!!.dismiss()
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
package com.mogo.eagle.core.function.check.api;
|
||||
|
||||
import com.mogo.eagle.core.function.check.net.CheckResultData;
|
||||
|
||||
/**
|
||||
* @author liujing
|
||||
* @description 自车检测结果回调
|
||||
* @since: 9/28/21
|
||||
*/
|
||||
public interface ICheckResultCallBack {
|
||||
void callBackWithErrorState(Integer state);
|
||||
void callBackWithCheckData(CheckResultData data);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.mogo.eagle.core.function.check.net
|
||||
|
||||
import android.content.Context
|
||||
import android.util.Log
|
||||
import com.elegant.network.ParamsBuilder
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClientConfig
|
||||
import com.mogo.commons.network.SubscribeImpl
|
||||
import com.mogo.eagle.core.function.check.api.ICheckResultCallBack
|
||||
import com.mogo.eagle.core.function.check.view.CheckActivity
|
||||
import com.mogo.eagle.core.utilcode.util.ThreadUtils
|
||||
import com.mogo.utils.network.RequestOptions
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
|
||||
/**
|
||||
* @author liujing
|
||||
* @description 自测检测网络请求类
|
||||
* @since: 10/12/21
|
||||
*/
|
||||
|
||||
object CheckNetWork {
|
||||
//网络请求,获取自车检测结果(工控机上报云端)
|
||||
fun checkNetWork(context: Context, callbackFlow: ICheckResultCallBack) {
|
||||
val params = ParamsBuilder.of(false)
|
||||
.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) }
|
||||
}
|
||||
|
||||
override fun onError(message: String, code: Int) {
|
||||
super.onError(message, code)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
@@ -23,6 +23,7 @@ import com.mogo.commons.network.SubscribeImpl;
|
||||
import com.mogo.eagle.core.function.check.R;
|
||||
import com.mogo.eagle.core.function.check.api.ICheckResultCallBack;
|
||||
import com.mogo.eagle.core.function.check.net.CheckApiServiceFactory;
|
||||
import com.mogo.eagle.core.function.check.net.CheckNetWork;
|
||||
import com.mogo.eagle.core.function.check.net.CheckResultData;
|
||||
import com.mogo.eagle.core.utilcode.util.ThreadUtils;
|
||||
import com.mogo.module.common.view.ImageViewClipBounds;
|
||||
@@ -43,10 +44,8 @@ import io.reactivex.schedulers.Schedulers;
|
||||
*/
|
||||
public class CheckActivity extends AppCompatActivity {
|
||||
|
||||
private static final String TAG = "CheckActivity";
|
||||
private RecyclerView mRecyclerView;
|
||||
private static CheckResultData sCheckResultData;
|
||||
private static NetworkStatusUtil.NetWorkStatus sNetWorkStatus;
|
||||
private ImageView mImageView;
|
||||
//车模
|
||||
private ImageView scanBottomCarImage;
|
||||
@@ -63,7 +62,7 @@ public class CheckActivity extends AppCompatActivity {
|
||||
//进度条
|
||||
private ProgressBar mProgressBar;
|
||||
private final static long DURATION_TIME = 1000;
|
||||
private static CheckAdapter mCheckAdapter;
|
||||
private CheckAdapter mCheckAdapter;
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
@@ -76,8 +75,9 @@ public class CheckActivity extends AppCompatActivity {
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
animation();
|
||||
loadDetail(this.getApplicationContext(), null);
|
||||
checkAction();
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表View初始化
|
||||
*/
|
||||
@@ -102,47 +102,22 @@ public class CheckActivity extends AppCompatActivity {
|
||||
mRecyclerView.setAdapter(mCheckAdapter);
|
||||
}
|
||||
|
||||
/**
|
||||
* 自动驾驶状态下指标监测
|
||||
*/
|
||||
public static void checkMonitor(Context context, ICheckResultCallBack checkResultCallBack) {
|
||||
Log.d(TAG, "checkMonitor");
|
||||
loadDetail(context.getApplicationContext(), checkResultCallBack);
|
||||
}
|
||||
|
||||
//网络请求,获取自车检测结果(工控机上报云端)
|
||||
public static void loadDetail(Context context, ICheckResultCallBack checkResultCallBack) {
|
||||
final Map<String, Object> params = ParamsBuilder.of(false)
|
||||
.append("sn", MoGoAiCloudClientConfig.getInstance().getSn())
|
||||
.build();
|
||||
CheckApiServiceFactory.getDataApiService(context).loadMonitorDetail(params)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new SubscribeImpl<CheckResultData>(RequestOptions.create(context)) {
|
||||
private void checkAction() {
|
||||
CheckNetWork.INSTANCE.checkNetWork(this.getApplicationContext(), new ICheckResultCallBack() {
|
||||
@Override
|
||||
public void callBackWithCheckData(CheckResultData data) {
|
||||
Log.d("CheckActivity", "车辆自检结果是:" + data.toString());
|
||||
ThreadUtils.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void onSuccess(CheckResultData o) {
|
||||
super.onSuccess(o);
|
||||
Log.d(TAG, "车辆自检结果是:" + o.toString());
|
||||
ThreadUtils.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (o != null && mCheckAdapter != null) {
|
||||
mCheckAdapter.mCheckResultData = o;
|
||||
mCheckAdapter.notifyDataSetChanged();
|
||||
}
|
||||
if (checkResultCallBack != null) {
|
||||
checkResultCallBack.callBackWithErrorState(o.getData().getVehicle().getState());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String message, int code) {
|
||||
super.onError(message, code);
|
||||
public void run() {
|
||||
if (data != null && mCheckAdapter != null) {
|
||||
mCheckAdapter.mCheckResultData = data;
|
||||
mCheckAdapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -236,7 +211,7 @@ public class CheckActivity extends AppCompatActivity {
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
if (mCheckAdapter!=null){
|
||||
if (mCheckAdapter != null) {
|
||||
mCheckAdapter.dismissDialog();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user