From 6b982a9d719dd46bfc204f36fc091847be06c695 Mon Sep 17 00:00:00 2001 From: donghongyu Date: Wed, 16 Feb 2022 15:49:34 +0800 Subject: [PATCH] =?UTF-8?q?[Change]=20=E6=9B=B4=E6=96=B0=E8=B0=83=E8=AF=95?= =?UTF-8?q?=E9=9D=A2=E6=9D=BF=E7=9A=84=E6=B8=B2=E6=9F=93=E6=96=B9=E5=BC=8F?= =?UTF-8?q?=E4=B8=BA=E5=AE=9A=E6=97=B6=E6=9F=A5=E8=AF=A2=EF=BC=8C=E8=A7=A3?= =?UTF-8?q?=E5=86=B3anr=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: donghongyu --- .../hmi/ui/setting/DebugSettingView.kt | 59 ++++++++++++------- .../mogo/eagle/core/data/app/AppConfigInfo.kt | 4 -- 2 files changed, 37 insertions(+), 26 deletions(-) diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/setting/DebugSettingView.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/setting/DebugSettingView.kt index faf450483d..396cbaf9ef 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/setting/DebugSettingView.kt +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/setting/DebugSettingView.kt @@ -43,6 +43,7 @@ import com.mogo.eagle.core.utilcode.mogo.storage.SharedPrefsMgr import com.mogo.eagle.core.utilcode.util.* import com.mogo.map.MogoMap import kotlinx.android.synthetic.main.view_debug_setting.view.* +import java.util.* /** * @author xiaoyuzhou @@ -63,11 +64,26 @@ class DebugSettingView @JvmOverloads constructor( private var logInfoView: LogInfoView? = null private var logViewAttach = false + private var mAutoPilotStatusInfo: AutopilotStatusInfo?=null + private var mAutoPilotCarStateInfo: AutopilotCarStateInfo?=null + init { LayoutInflater.from(context).inflate(R.layout.view_debug_setting, this, true) initView() } + /** + * 定时刷新视图数据,防止因为过快更新导致anr异常 + */ + private val timerTaskRefresh = object : TimerTask() { + override fun run() { + UiThreadHandler.post { + // 绘制应用基本信息 + drawAppInfo() + } + } + } + override fun onAttachedToWindow() { super.onAttachedToWindow() // 添加 OBU状态 监听 @@ -83,6 +99,8 @@ class DebugSettingView @JvmOverloads constructor( if (logInfoView != null) { logInfoView!!.onEnterForeground() } + // 开启定时查询速度 + Timer().schedule(timerTaskRefresh, Date(), 100) } override fun onDetachedFromWindow() { @@ -100,6 +118,11 @@ class DebugSettingView @JvmOverloads constructor( if (logInfoView != null) { logInfoView!!.onEnterBackground() } + try { + timerTaskRefresh.cancel() + } catch (e: Exception) { + e.printStackTrace() + } } private fun initView() { @@ -372,35 +395,33 @@ class DebugSettingView @JvmOverloads constructor( AppConfigInfo.isConnectSocket = DebugConfig.isDownloadSnapshot() // 将数据绘制 - tvAppInfo.text =Html.fromHtml( AppConfigInfo.toString()) + tvAppInfo.text = Html.fromHtml(AppConfigInfo.toString()) + + tvAutopilotInfo.text = GsonUtils.toJson(mAutoPilotStatusInfo) + + tvCarInfo.text = + "GPS时间:${mAutoPilotCarStateInfo?.values?.satelliteTime}\n" + + "自车经纬度:\n${mAutoPilotCarStateInfo?.values?.lon}\n${mAutoPilotCarStateInfo?.values?.lat}\n" } /** * OBU状态回调 */ override fun onObuStatusResponse(obuStatusInfo: ObuStatusInfo) { - UiThreadHandler.post { - tvObuInfo.text = GsonUtils.toJson(obuStatusInfo) + tvObuInfo.text = GsonUtils.toJson(obuStatusInfo) - AppConfigInfo.obuSdkVersion = obuStatusInfo.obuSdkVersion - AppConfigInfo.isConnectObu = obuStatusInfo.obuStatus - drawAppInfo() - } + AppConfigInfo.obuSdkVersion = obuStatusInfo.obuSdkVersion + AppConfigInfo.isConnectObu = obuStatusInfo.obuStatus } /** * 自动驾驶状态回调 */ override fun onAutopilotStatusResponse(autoPilotStatusInfo: AutopilotStatusInfo) { - UiThreadHandler.post { - tvAutopilotInfo.post { - tvAutopilotInfo.text = GsonUtils.toJson(autoPilotStatusInfo) + mAutoPilotStatusInfo = autoPilotStatusInfo - AppConfigInfo.adasSdkVersion = autoPilotStatusInfo.version - AppConfigInfo.isConnectAutopilot = autoPilotStatusInfo.connectStatus - drawAppInfo() - } - } + AppConfigInfo.adasSdkVersion = autoPilotStatusInfo.version + AppConfigInfo.isConnectAutopilot = autoPilotStatusInfo.connectStatus } override fun onAutopilotArriveAtStation(autopilotWayArrive: AutopilotStationInfo?) { @@ -409,13 +430,7 @@ class DebugSettingView @JvmOverloads constructor( override fun onAutopilotCarStateData(autoPilotCarStateInfo: AutopilotCarStateInfo?) { //Logger.d(TAG, "autoPilotCarStateInfo:$autoPilotCarStateInfo") - UiThreadHandler.post { - tvAutopilotInfo.post { - tvCarInfo.text = - "GPS时间:${autoPilotCarStateInfo?.values?.satelliteTime}\n" + - "自车经纬度:\n${autoPilotCarStateInfo?.values?.lon}\n${autoPilotCarStateInfo?.values?.lat}\n" - } - } + mAutoPilotCarStateInfo = autoPilotCarStateInfo } override fun onAutopilotSNRequest() { diff --git a/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/app/AppConfigInfo.kt b/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/app/AppConfigInfo.kt index 0e05f8996e..a0c12bee4b 100644 --- a/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/app/AppConfigInfo.kt +++ b/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/app/AppConfigInfo.kt @@ -44,10 +44,6 @@ object AppConfigInfo { // 是否OBU var isConnectObu: Boolean = false - /*应用配置信息,这里的配置将影响功能,用来替换productFlavors配置的那种编译渠道*/ - // GPS数据提供源: 0-Android系统,1-工控机,2-OBU - var GPS_PROVIDER = 1 - override fun toString(): String { return "-------------------应用信息--------------------
" +