优化检查模块

Signed-off-by: 董宏宇 <martindhy@gmail.com>
This commit is contained in:
董宏宇
2021-10-09 18:37:44 +08:00
parent 19d2fd45a6
commit c13ca6e7b1
25 changed files with 254 additions and 268 deletions

View File

@@ -1,8 +1,10 @@
apply plugin: 'com.android.library'
apply plugin: 'com.alibaba.arouter'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
plugins {
id 'com.android.library'
id 'kotlin-android'
id 'kotlin-android-extensions'
id 'kotlin-kapt'
id 'com.alibaba.arouter'
}
android {
compileSdkVersion rootProject.ext.android.compileSdkVersion
defaultConfig {
@@ -11,14 +13,16 @@ android {
versionCode Integer.valueOf(VERSION_CODE)
versionName getValueFromRootProperties("${project.name.replace("-", "_").toUpperCase()}_VERSION")
javaCompileOptions {
annotationProcessorOptions {
arguments = [AROUTER_MODULE_NAME: project.getName()]
}
}
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles 'consumer-rules.pro'
//ARouter apt 参数
kapt {
useBuildCache = false
arguments {
arg("AROUTER_MODULE_NAME", project.getName())
}
}
}
buildTypes {
release {
@@ -45,11 +49,9 @@ dependencies {
implementation rootProject.ext.dependencies.coroutinescore
implementation rootProject.ext.dependencies.rxandroid
implementation rootProject.ext.dependencies.kotlinstdlibjdk7
implementation 'com.google.android.material:material:1.2.1'
implementation project(':modules:mogo-module-common')
implementation project(path: ':modules:mogo-module-service')
implementation rootProject.ext.dependencies.material
annotationProcessor rootProject.ext.dependencies.aroutercompiler
kapt rootProject.ext.dependencies.aroutercompiler
if (Boolean.valueOf(RELEASE)) {
implementation rootProject.ext.dependencies.mogocommons
@@ -58,13 +60,12 @@ dependencies {
implementation project(":foudations:mogo-commons")
implementation project(':services:mogo-service-api')
implementation project(':modules:mogo-module-common')
implementation project(':modules:mogo-module-service')
implementation project(':core:mogo-core-utils')
implementation project(':core:mogo-core-function-call')
}
implementation 'com.tencent.bugly:crashreport_upgrade:latest.release'
//其中latest.release指代最新Bugly SDK版本号也可以指定明确的版本号例如2.1.9
implementation 'com.tencent.bugly:nativecrashreport:latest.release'
//其中latest.release指代最新Bugly NDK版本号也可以指定明确的版本号例如3.0
}

View File

@@ -1,158 +0,0 @@
package com.mogo.eagle.core.function.check;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.util.Log;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.elegant.network.ParamsBuilder;
import com.mogo.cloud.passport.MoGoAiCloudClientConfig;
import com.mogo.commons.network.SubscribeImpl;
import com.mogo.eagle.core.function.call.check.CallerCheckManager;
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.CheckResultData;
import com.mogo.eagle.core.function.check.view.CheckDialog;
import com.mogo.eagle.core.utilcode.util.ActivityUtils;
import com.mogo.eagle.core.utilcode.util.AppUtils;
import com.mogo.eagle.core.utilcode.util.LogUtils;
import com.mogo.eagle.core.function.api.check.IMogoCheckListener;
import com.mogo.eagle.core.function.check.view.CheckActivity;
import com.mogo.eagle.core.utilcode.util.ThreadUtils;
import com.mogo.module.service.receiver.MogoReceiver;
import com.mogo.service.MogoServicePaths;
import com.mogo.eagle.core.function.api.check.ICheckProvider;
import com.mogo.utils.ActivityLifecycleManager;
import com.mogo.utils.network.RequestOptions;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;
/**
* 鹰眼系统、自动驾驶系统 检测模块
*
* @date 4/21/21 3:39 PM
* 需求地址
* wikihttp://wiki.zhidaohulian.com/pages/viewpage.action?pageId=58204952
*/
@Route(path = MogoServicePaths.PATH_CHECK)
public class VehicleMonitoringManager implements ICheckProvider {
private static final String TAG = "VehicleMonitoringManager";
private Context mContext;
private final Map<String, CopyOnWriteArrayList> mListeners = new ConcurrentHashMap<>();
private boolean hasTipShow = false;//是否已经弹框提示
CheckDialog dialog;
@Override
public void init(Context context) {
LogUtils.dTag(TAG, "初始化 CheckProvider 模块");
mContext = context;
}
@Override
public void registerVehicleMonitoringListener(String module, IMogoCheckListener listener) {
if (listener == null || module == null) {
LogUtils.dTag(TAG, "listener == null || intent == null");
return;
}
if (!mListeners.containsKey(module)) {
LogUtils.dTag(TAG, "intent==" + module + "listener" + listener);
mListeners.put(module, new CopyOnWriteArrayList<>());
}
mListeners.get(module).add(listener);
}
@Override
public void unregisterListener(String module, IMogoCheckListener listener) {
if (mListeners.containsKey(module)) {
mListeners.get(module).remove(listener);
}
}
@Override
public void startCheckActivity(Context context) {
Intent starter = new Intent(context, CheckActivity.class);
starter.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(starter);
}
@Override
public void showCheckDialog(Context context) {
showDialog(context);
}
@Override
public void checkMonitor(Context context) {
if (context != null) {
CheckActivity.checkMonitor(context, new ICheckResultCallBack() {
@Override
public void callBackWithErrorState(Integer state) {
updateMonitoringStatus(MogoReceiver.ACTION_CHECK_VEHICLE_MONITORING, state);
if (state == 1) {
hasTipShow = false;
} else {
if (hasTipShow == false) {
showDialog(context);
hasTipShow = true;//已弹框
}
}
}
});
}
}
/**
* 指标异常弹框
*/
public void showDialog(Context context) {
try {
if (ActivityLifecycleManager.getInstance().isAppActive() == true &&
AppUtils.isAppRunning(getPackageName(context)) &&
ActivityUtils.getTopActivity() instanceof CheckActivity == false) {
if (dialog != null) {
dialog.dismiss();
}
dialog = new CheckDialog(context, true);
dialog.show();
}
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* @param context
* @return 当前应用的版本名称
*/
public static synchronized String getPackageName(Context context) {
try {
PackageManager packageManager = context.getPackageManager();
PackageInfo packageInfo = packageManager.getPackageInfo(
context.getPackageName(), 0);
return packageInfo.packageName;
} catch (Exception e) {
e.printStackTrace();
}
return "com.mogo.launcher.f";
}
@Override
public void updateMonitoringStatus(String module, Integer state) {
List<IMogoCheckListener> listeners = mListeners.get(module);
if (listeners != null && !listeners.isEmpty()) {
for (IMogoCheckListener listener : listeners) {
if (listener != null) {
listener.updateMonitoringStatus(state);
}
}
}
}
}

View File

@@ -0,0 +1,99 @@
package com.mogo.eagle.core.function.check
import android.content.Context
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.view.CheckActivity
import com.mogo.eagle.core.function.check.view.CheckDialog
import com.mogo.eagle.core.utilcode.util.ActivityUtils
import com.mogo.eagle.core.utilcode.util.AppUtils
import com.mogo.eagle.core.utilcode.util.LogUtils
import com.mogo.module.service.receiver.MogoReceiver
import com.mogo.service.MogoServicePaths
import com.mogo.utils.ActivityLifecycleManager
import java.util.concurrent.ConcurrentHashMap
/**
* 鹰眼系统、自动驾驶系统 检测模块
*
* @date 4/21/21 3:39 PM
* 需求地址
* wikihttp://wiki.zhidaohulian.com/pages/viewpage.action?pageId=58204952
*/
@Route(path = MogoServicePaths.PATH_CHECK)
class VehicleMonitoringManager : ICheckProvider {
private val TAG = "VehicleMonitoringManager"
private var mContext: Context? = null
private val mListeners: ConcurrentHashMap<String, IMogoCheckListener> = ConcurrentHashMap()
private var hasTipShow = false //是否已经弹框提示
var dialog: CheckDialog? = null
override fun init(context: Context) {
LogUtils.dTag(TAG, "初始化 CheckProvider 模块")
mContext = context
}
override fun registerVehicleMonitoringListener(module: String, listener: IMogoCheckListener) {
mListeners[module] = listener
}
override fun unregisterListener(module: String) {
if (mListeners.containsKey(module)) {
mListeners.remove(module)
}
}
override fun startCheckActivity(context: Context) {
val starter = Intent(context, CheckActivity::class.java)
starter.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
context.startActivity(starter)
}
override fun showCheckDialog(context: Context) {
showDialog(context)
}
override fun checkMonitor(context: Context) {
CheckActivity.checkMonitor(context) { state ->
updateMonitoringStatus(MogoReceiver.ACTION_CHECK_VEHICLE_MONITORING, state)
if (state == 1) {
hasTipShow = false
} else {
if (!hasTipShow) {
showDialog(context)
hasTipShow = true //已弹框
}
}
}
}
/**
* 指标异常弹框
*/
private fun showDialog(context: Context) {
try {
if (ActivityLifecycleManager.getInstance().isAppActive &&
AppUtils.isAppRunning(
AppUtils.getAppPackageName()
) && ActivityUtils.getTopActivity() !is CheckActivity
) {
if (dialog != null) {
dialog!!.dismiss()
}
dialog = CheckDialog(context, true)
dialog!!.show()
}
} catch (e: Exception) {
e.printStackTrace()
}
}
override fun updateMonitoringStatus(module: String, state: Int) {
for (listener in mListeners) {
listener.value.updateMonitoringStatus(state)
}
}
}

View File

@@ -1,7 +1,5 @@
package com.mogo.eagle.core.function.check.api;
import com.mogo.service.adas.IMogoAdasDataCallback;
/**
* @author liujing
* @description 自车检测结果回调

View File

@@ -1,11 +1,9 @@
package com.mogo.eagle.core.function.check.net;
import java.util.Map;
import retrofit2.http.FieldMap;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.POST;
import io.reactivex.Observable;
import retrofit2.http.GET;
import retrofit2.http.QueryMap;
/**

View File

@@ -6,9 +6,6 @@ import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.graphics.Rect;
import android.os.Bundle;
import android.util.Log;
@@ -23,17 +20,13 @@ import androidx.recyclerview.widget.RecyclerView;
import com.elegant.network.ParamsBuilder;
import com.mogo.cloud.passport.MoGoAiCloudClientConfig;
import com.mogo.commons.network.SubscribeImpl;
import com.mogo.eagle.core.function.call.check.CallerCheckManager;
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.CheckResultData;
import com.mogo.eagle.core.utilcode.util.ActivityUtils;
import com.mogo.eagle.core.utilcode.util.AppUtils;
import com.mogo.eagle.core.utilcode.util.ThreadUtils;
import com.mogo.module.common.view.ImageViewClipBounds;
import com.mogo.module.common.view.SpacesItemDecoration;
import com.mogo.module.service.receiver.MogoReceiver;
import com.mogo.utils.network.RequestOptions;
import com.mogo.utils.network.utils.NetworkStatusUtil;

View File

@@ -8,7 +8,6 @@ import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.CheckResult;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
@@ -16,8 +15,6 @@ import com.mogo.eagle.core.function.check.R;
import com.mogo.eagle.core.function.check.model.CheckItemInfo;
import com.mogo.eagle.core.function.check.net.CheckResultData;
import java.util.ArrayList;
/**
* @author liujing

View File

@@ -1,7 +1,6 @@
package com.mogo.eagle.core.function.check.view;
import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

View File

@@ -1,8 +1,6 @@
package com.mogo.eagle.core.function.check.view;
import android.content.Context;
import android.text.TextPaint;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -15,7 +13,6 @@ import androidx.recyclerview.widget.RecyclerView;
import com.mogo.eagle.core.function.check.R;
import com.mogo.eagle.core.function.check.net.CheckResultData;
import java.util.ArrayList;
import java.util.List;
/**

View File

@@ -3,8 +3,6 @@ package com.mogo.eagle.core.function.check.view;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.GradientDrawable;

View File

@@ -1,15 +1,10 @@
package com.mogo.eagle.core.function.check.view;
import android.content.Context;
import android.graphics.Color;
import android.util.AttributeSet;
import android.util.Log;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.mogo.eagle.core.function.check.R;
import com.mogo.eagle.core.function.check.model.CheckItemInfo;

View File

@@ -0,0 +1,66 @@
package com.mogo.eagle.core.function.hmi.ui.widget
import android.content.Context
import android.util.AttributeSet
import android.view.LayoutInflater
import android.view.View
import androidx.constraintlayout.widget.ConstraintLayout
import com.mogo.eagle.core.function.api.check.IMogoCheckListener
import com.mogo.eagle.core.function.call.check.CallerCheckManager
import com.mogo.eagle.core.function.hmi.R
import com.mogo.eagle.core.utilcode.mogo.logger.Logger
import kotlinx.android.synthetic.main.view_check_status.view.*
/**
*@author xiaoyuzhou
*@date 2021/8/6 12:25 下午
*/
class CheckStatusView @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0
) : ConstraintLayout(context, attrs, defStyleAttr), IMogoCheckListener {
private val TAG = "CheckStatusView"
init {
LayoutInflater.from(context).inflate(R.layout.view_check_status, this, true)
setOnClickListener {
// 启动检测页面
CallerCheckManager.startCheckActivity(getContext())
}
}
private fun showErrorIcon() {
errorTipImage.visibility = View.VISIBLE
}
private fun dismissErrorIcon() {
errorTipImage.visibility = View.GONE
}
override fun updateMonitoringStatus(state: Int?) {
Logger.d(TAG, "updateCheckStatus")
if (state == 1) {
dismissErrorIcon()
} else {
showErrorIcon()
}
}
override fun onAttachedToWindow() {
super.onAttachedToWindow()
Logger.d(TAG, "onAttachedToWindow")
//车辆监控
CallerCheckManager.registerVehicleMonitoringListener(TAG, this)
}
override fun onDetachedFromWindow() {
super.onDetachedFromWindow()
Logger.d(TAG, "onDetachedFromWindow")
//车辆监控
CallerCheckManager.unregisterListener(TAG)
}
}

View File

@@ -63,5 +63,13 @@
app:layout_goneMarginTop="40px"
tools:visibility="visible" />
<com.mogo.eagle.core.function.hmi.ui.widget.CheckStatusView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="40px"
android:layout_marginBottom="@dimen/dp_490"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/clAutopilotStatus"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<!--车辆检测入口-->
<TextView
android:id="@+id/moduleHmiCheck"
android:layout_width="@dimen/dp_128"
android:layout_height="@dimen/dp_128"
android:background="@drawable/module_ext_check"
android:gravity="center"
android:text="检测"
android:textColor="#fff"
android:textSize="@dimen/module_hmi_btn_text_size"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toRightOf="parent" />
<ImageView
android:id="@+id/errorTipImage"
android:layout_width="@dimen/dp_40"
android:layout_height="@dimen/dp_40"
android:src="@drawable/check_error_image"
android:visibility="invisible"
app:layout_constraintRight_toRightOf="@+id/moduleHmiCheck"
app:layout_constraintTop_toTopOf="@+id/moduleHmiCheck" />
</androidx.constraintlayout.widget.ConstraintLayout>