[add] 解决不释放导致内存泄露问题
This commit is contained in:
3
.idea/gradle.xml
generated
3
.idea/gradle.xml
generated
@@ -4,7 +4,7 @@
|
|||||||
<component name="GradleSettings">
|
<component name="GradleSettings">
|
||||||
<option name="linkedExternalProjectsSettings">
|
<option name="linkedExternalProjectsSettings">
|
||||||
<GradleProjectSettings>
|
<GradleProjectSettings>
|
||||||
<option name="testRunner" value="GRADLE" />
|
<option name="testRunner" value="PLATFORM" />
|
||||||
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
||||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||||
<option name="modules">
|
<option name="modules">
|
||||||
@@ -81,6 +81,7 @@
|
|||||||
</set>
|
</set>
|
||||||
</option>
|
</option>
|
||||||
<option name="resolveModulePerSourceSet" value="false" />
|
<option name="resolveModulePerSourceSet" value="false" />
|
||||||
|
<option name="useQualifiedModuleNames" value="true" />
|
||||||
</GradleProjectSettings>
|
</GradleProjectSettings>
|
||||||
</option>
|
</option>
|
||||||
</component>
|
</component>
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ import android.content.Intent
|
|||||||
import com.alibaba.android.arouter.facade.annotation.Route
|
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.ICheckProvider
|
||||||
import com.mogo.eagle.core.function.api.check.IMogoCheckListener
|
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.CheckActivity
|
||||||
import com.mogo.eagle.core.function.check.view.CheckDialog
|
import com.mogo.eagle.core.function.check.view.CheckDialog
|
||||||
import com.mogo.eagle.core.utilcode.util.ActivityUtils
|
import com.mogo.eagle.core.utilcode.util.ActivityUtils
|
||||||
@@ -36,9 +38,9 @@ class VehicleMonitoringManager : ICheckProvider, IMogoStatusChangedListener {
|
|||||||
LogUtils.dTag(TAG, "初始化 CheckProvider 模块")
|
LogUtils.dTag(TAG, "初始化 CheckProvider 模块")
|
||||||
mContext = context
|
mContext = context
|
||||||
MogoApisHandler.getInstance().apis.statusManagerApi.registerStatusChangedListener(
|
MogoApisHandler.getInstance().apis.statusManagerApi.registerStatusChangedListener(
|
||||||
TAG,
|
TAG,
|
||||||
StatusDescriptor.MAIN_PAGE_RESUME,
|
StatusDescriptor.MAIN_PAGE_RESUME,
|
||||||
this
|
this
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,9 +63,9 @@ class VehicleMonitoringManager : ICheckProvider, IMogoStatusChangedListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun checkMonitor(context: Context) {
|
override fun checkMonitor(context: Context) {
|
||||||
CheckActivity.checkMonitor(context) { state ->
|
CheckNetWork.checkNetWork(context, ICheckResultCallBack { state ->
|
||||||
updateMonitoringStatus(MogoReceiver.ACTION_CHECK_VEHICLE_MONITORING, state)
|
updateMonitoringStatus(MogoReceiver.ACTION_CHECK_VEHICLE_MONITORING, state.data.vehicle.state)
|
||||||
if (state == 1) {
|
if (state.data.vehicle.state == 1) {
|
||||||
hasTipShow = false
|
hasTipShow = false
|
||||||
} else {
|
} else {
|
||||||
if (!hasTipShow) {
|
if (!hasTipShow) {
|
||||||
@@ -71,7 +73,7 @@ class VehicleMonitoringManager : ICheckProvider, IMogoStatusChangedListener {
|
|||||||
hasTipShow = true //已弹框
|
hasTipShow = true //已弹框
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -80,8 +82,8 @@ class VehicleMonitoringManager : ICheckProvider, IMogoStatusChangedListener {
|
|||||||
private fun showDialog(context: Context) {
|
private fun showDialog(context: Context) {
|
||||||
try {
|
try {
|
||||||
if (ActivityLifecycleManager.getInstance().isAppActive && AppUtils.isAppRunning(
|
if (ActivityLifecycleManager.getInstance().isAppActive && AppUtils.isAppRunning(
|
||||||
AppUtils.getAppPackageName()
|
AppUtils.getAppPackageName()
|
||||||
) && ActivityUtils.getTopActivity() !is CheckActivity
|
) && ActivityUtils.getTopActivity() !is CheckActivity
|
||||||
) {
|
) {
|
||||||
if (dialog != null) {
|
if (dialog != null) {
|
||||||
dialog!!.dismiss()
|
dialog!!.dismiss()
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
package com.mogo.eagle.core.function.check.api;
|
package com.mogo.eagle.core.function.check.api;
|
||||||
|
|
||||||
|
import com.mogo.eagle.core.function.check.net.CheckResultData;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author liujing
|
* @author liujing
|
||||||
* @description 自车检测结果回调
|
* @description 自车检测结果回调
|
||||||
* @since: 9/28/21
|
* @since: 9/28/21
|
||||||
*/
|
*/
|
||||||
public interface ICheckResultCallBack {
|
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.R;
|
||||||
import com.mogo.eagle.core.function.check.api.ICheckResultCallBack;
|
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.CheckApiServiceFactory;
|
||||||
|
import com.mogo.eagle.core.function.check.net.CheckNetWork;
|
||||||
import com.mogo.eagle.core.function.check.net.CheckResultData;
|
import com.mogo.eagle.core.function.check.net.CheckResultData;
|
||||||
import com.mogo.eagle.core.utilcode.util.ThreadUtils;
|
import com.mogo.eagle.core.utilcode.util.ThreadUtils;
|
||||||
import com.mogo.module.common.view.ImageViewClipBounds;
|
import com.mogo.module.common.view.ImageViewClipBounds;
|
||||||
@@ -43,10 +44,8 @@ import io.reactivex.schedulers.Schedulers;
|
|||||||
*/
|
*/
|
||||||
public class CheckActivity extends AppCompatActivity {
|
public class CheckActivity extends AppCompatActivity {
|
||||||
|
|
||||||
private static final String TAG = "CheckActivity";
|
|
||||||
private RecyclerView mRecyclerView;
|
private RecyclerView mRecyclerView;
|
||||||
private static CheckResultData sCheckResultData;
|
private static CheckResultData sCheckResultData;
|
||||||
private static NetworkStatusUtil.NetWorkStatus sNetWorkStatus;
|
|
||||||
private ImageView mImageView;
|
private ImageView mImageView;
|
||||||
//车模
|
//车模
|
||||||
private ImageView scanBottomCarImage;
|
private ImageView scanBottomCarImage;
|
||||||
@@ -63,7 +62,7 @@ public class CheckActivity extends AppCompatActivity {
|
|||||||
//进度条
|
//进度条
|
||||||
private ProgressBar mProgressBar;
|
private ProgressBar mProgressBar;
|
||||||
private final static long DURATION_TIME = 1000;
|
private final static long DURATION_TIME = 1000;
|
||||||
private static CheckAdapter mCheckAdapter;
|
private CheckAdapter mCheckAdapter;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
@@ -76,8 +75,9 @@ public class CheckActivity extends AppCompatActivity {
|
|||||||
protected void onStart() {
|
protected void onStart() {
|
||||||
super.onStart();
|
super.onStart();
|
||||||
animation();
|
animation();
|
||||||
loadDetail(this.getApplicationContext(), null);
|
checkAction();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 列表View初始化
|
* 列表View初始化
|
||||||
*/
|
*/
|
||||||
@@ -102,47 +102,22 @@ public class CheckActivity extends AppCompatActivity {
|
|||||||
mRecyclerView.setAdapter(mCheckAdapter);
|
mRecyclerView.setAdapter(mCheckAdapter);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private void checkAction() {
|
||||||
* 自动驾驶状态下指标监测
|
CheckNetWork.INSTANCE.checkNetWork(this.getApplicationContext(), new ICheckResultCallBack() {
|
||||||
*/
|
@Override
|
||||||
public static void checkMonitor(Context context, ICheckResultCallBack checkResultCallBack) {
|
public void callBackWithCheckData(CheckResultData data) {
|
||||||
Log.d(TAG, "checkMonitor");
|
Log.d("CheckActivity", "车辆自检结果是:" + data.toString());
|
||||||
loadDetail(context.getApplicationContext(), checkResultCallBack);
|
ThreadUtils.runOnUiThread(new Runnable() {
|
||||||
}
|
|
||||||
|
|
||||||
//网络请求,获取自车检测结果(工控机上报云端)
|
|
||||||
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)) {
|
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(CheckResultData o) {
|
public void run() {
|
||||||
super.onSuccess(o);
|
if (data != null && mCheckAdapter != null) {
|
||||||
Log.d(TAG, "车辆自检结果是:" + o.toString());
|
mCheckAdapter.mCheckResultData = data;
|
||||||
ThreadUtils.runOnUiThread(new Runnable() {
|
mCheckAdapter.notifyDataSetChanged();
|
||||||
@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);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -236,7 +211,7 @@ public class CheckActivity extends AppCompatActivity {
|
|||||||
@Override
|
@Override
|
||||||
protected void onPause() {
|
protected void onPause() {
|
||||||
super.onPause();
|
super.onPause();
|
||||||
if (mCheckAdapter!=null){
|
if (mCheckAdapter != null) {
|
||||||
mCheckAdapter.dismissDialog();
|
mCheckAdapter.dismissDialog();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,11 @@ import android.content.Context;
|
|||||||
|
|
||||||
import com.alibaba.android.arouter.facade.template.IProvider;
|
import com.alibaba.android.arouter.facade.template.IProvider;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import kotlin.Unit;
|
||||||
|
import kotlin.jvm.functions.Function0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 检测接口
|
* 检测接口
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,5 +1,10 @@
|
|||||||
package com.mogo.service.statusmanager;
|
package com.mogo.service.statusmanager;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import kotlin.Unit;
|
||||||
|
import kotlin.jvm.functions.Function0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author congtaowang
|
* @author congtaowang
|
||||||
* @since 2020-01-04
|
* @since 2020-01-04
|
||||||
@@ -13,4 +18,5 @@ public interface IMogoStatusChangedListener {
|
|||||||
* @param isTrue true - accOn、adas ui show、voice ui show、push ui show、v2x ui show
|
* @param isTrue true - accOn、adas ui show、voice ui show、push ui show、v2x ui show
|
||||||
*/
|
*/
|
||||||
void onStatusChanged( StatusDescriptor descriptor, boolean isTrue );
|
void onStatusChanged( StatusDescriptor descriptor, boolean isTrue );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user