From 0bc8b79b73ab7cdd45e39c618279db0a3f6296e3 Mon Sep 17 00:00:00 2001 From: lixiaopeng Date: Fri, 3 Mar 2023 16:33:43 +0800 Subject: [PATCH 1/6] =?UTF-8?q?[dev=5Farch=5Fopt=5F3.0]=20=E5=8E=BB?= =?UTF-8?q?=E6=8E=89=E8=BF=90=E8=90=A5=E9=9D=A2=E6=9D=BF=E6=97=A0=E7=94=A8?= =?UTF-8?q?=E7=9A=84=E5=BC=80=E5=85=B3=E6=8E=A7=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../function/hmi/ui/setting/SOPSettingView.kt | 18 +++++---------- .../src/main/res/layout/view_sop_setting.xml | 22 +++++-------------- 2 files changed, 10 insertions(+), 30 deletions(-) diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/setting/SOPSettingView.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/setting/SOPSettingView.kt index 116662754b..8861936c58 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/setting/SOPSettingView.kt +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/setting/SOPSettingView.kt @@ -73,11 +73,11 @@ internal class SOPSettingView @JvmOverloads constructor( /** * obu弱势交通控制 */ - tbObuWeaknessTrafficSop.isChecked = HmiBuildConfig.isShowObuWeaknessTrafficView - tbObuWeaknessTrafficSop.setOnCheckedChangeListener { _, isChecked -> - // 默认开启 - HmiBuildConfig.isShowObuWeaknessTrafficView = !isChecked - } +// tbObuWeaknessTrafficSop.isChecked = HmiBuildConfig.isShowObuWeaknessTrafficView +// tbObuWeaknessTrafficSop.setOnCheckedChangeListener { _, isChecked -> +// // 默认开启 +// HmiBuildConfig.isShowObuWeaknessTrafficView = !isChecked +// } /** * 云端弱势交通控制 @@ -88,14 +88,6 @@ internal class SOPSettingView @JvmOverloads constructor( HmiBuildConfig.isShowCloudWeaknessTrafficView = isChecked } - /** - * 限速数据来源开关 - */ - tbRoadLimitSpeedSop.setOnCheckedChangeListener { _, isChecked -> - // 默认关闭 - HmiBuildConfig.isShowObuLimitSpeedView = isChecked - } - /** * obu V2V开关,默认打开 */ diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/layout/view_sop_setting.xml b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/view_sop_setting.xml index 4558cc99a4..38db5038ad 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/res/layout/view_sop_setting.xml +++ b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/view_sop_setting.xml @@ -163,11 +163,13 @@ app:layout_constraintRight_toRightOf="parent" /> + @@ -214,31 +216,17 @@ android:paddingBottom="25dp" android:scaleY="1.2" android:scaleX="1.2" - app:layout_constraintTop_toBottomOf="@id/tbObuToDcView" + app:layout_constraintTop_toBottomOf="@id/tbObuWeaknessTrafficSop" app:layout_constraintLeft_toRightOf="@id/verticalGuideLine" app:layout_constraintRight_toRightOf="parent" /> - - Date: Fri, 3 Mar 2023 16:37:31 +0800 Subject: [PATCH 2/6] =?UTF-8?q?[Opt3.0]=E8=A7=A3=E5=86=B3=E5=81=B6?= =?UTF-8?q?=E7=8E=B0=E8=BF=9E=E6=8E=A5=E4=B8=8D=E4=B8=8A=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gradle.properties | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/gradle.properties b/gradle.properties index 1ba44964a9..96971cae96 100644 --- a/gradle.properties +++ b/gradle.properties @@ -66,23 +66,23 @@ SERVICE_BIZ_VERSION=1.2.4 LOGLIB_VERSION=1.5.11 ######## MogoAiCloudSDK Version ######## # 网络请求LOGLIB_VERSION -MOGO_NETWORK_VERSION=1.4.5.6 +MOGO_NETWORK_VERSION=1.4.5.7 # 鉴权 -MOGO_PASSPORT_VERSION=1.4.5.6 +MOGO_PASSPORT_VERSION=1.4.5.7 # 常链接 -MOGO_SOCKET_VERSION=1.4.5.6 +MOGO_SOCKET_VERSION=1.4.5.7 # 数据采集 -MOGO_REALTIME_VERSION=1.4.5.6 +MOGO_REALTIME_VERSION=1.4.5.7 # 探路,道路事件发布,获取 -MOGO_TANLU_VERSION=1.4.5.6 +MOGO_TANLU_VERSION=1.4.5.7 # 直播推流 -MOGO_LIVE_VERSION=1.4.5.6 +MOGO_LIVE_VERSION=1.4.5.7 # 直播拉流 -MOGO_TRAFFICLIVE_VERSION=1.4.5.6 +MOGO_TRAFFICLIVE_VERSION=1.4.5.7 # 定位服务 -MOGO_LOCATION_VERSION=1.4.5.6 +MOGO_LOCATION_VERSION=1.4.5.7 # 远程通讯模块 -MOGO_TELEMATIC_VERSION=1.4.5.6 +MOGO_TELEMATIC_VERSION=1.4.5.7 ######## MogoAiCloudSDK Version ######## # 自研地图 MAP_SDK_VERSION=2.10.0.9 From cc7591f918bb3b512b5dc53b5ad193b1a5df60ee Mon Sep 17 00:00:00 2001 From: lixiaopeng Date: Fri, 3 Mar 2023 17:02:36 +0800 Subject: [PATCH 3/6] =?UTF-8?q?[dev=5Farch=5Fopt=5F3.0]=20=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../datacenter/obu/MoGoObuProvider.kt | 5 +- .../datacenter/obu/MogoObuDcCombineManager.kt | 67 ++++++++++--------- .../obu/MogoPrivateObuNewManager.kt | 3 +- 3 files changed, 38 insertions(+), 37 deletions(-) diff --git a/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/obu/MoGoObuProvider.kt b/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/obu/MoGoObuProvider.kt index 7a0b107842..6027695b0e 100644 --- a/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/obu/MoGoObuProvider.kt +++ b/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/obu/MoGoObuProvider.kt @@ -6,8 +6,6 @@ import com.mogo.eagle.core.data.constants.MoGoConfig import com.mogo.eagle.core.data.constants.MogoServicePaths import com.mogo.eagle.core.data.obu.MogoObuConst import com.mogo.eagle.core.function.api.datacenter.obu.IMoGoObuProvider -import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger -import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_OBU import com.mogo.eagle.core.utilcode.mogo.storage.SharedPrefsMgr import com.mogo.eagle.core.utilcode.util.CommonUtils @@ -24,13 +22,12 @@ class MoGoObuProvider : IMoGoObuProvider { get() = TAG override fun onDestroy() { - + MogoObuDcCombineManager.INSTANCE.destoryListener() } override fun init(context: Context) { //obu融合数据 MogoObuDcCombineManager.INSTANCE.init(context) - CallerLogger.d("$M_OBU$TAG", "初始化蘑菇自研OBU…… localIp = " + CommonUtils.getLocalIPAddress()) //bus乘客版本obu功能去掉,大理项目需要全部车辆接收,不再限制 mContext = context diff --git a/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/obu/MogoObuDcCombineManager.kt b/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/obu/MogoObuDcCombineManager.kt index dc894bbaf4..62b6e5d953 100644 --- a/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/obu/MogoObuDcCombineManager.kt +++ b/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/obu/MogoObuDcCombineManager.kt @@ -56,19 +56,27 @@ class MogoObuDcCombineManager private constructor() : IMoGoObuWarningRsiListener } override fun onMoGoObuRsiWarning(rsiWarningData: ObuScene.RsiWarningData) { - onMogoObuDcRsiWarning(rsiWarningData) + if (HmiBuildConfig.isShowObuV2iView) { + onMogoObuDcRsiWarning(rsiWarningData) + } } override fun onMoGoObuRsmWarning(rsmWarningData: ObuScene.RsmWarningData) { - onMogoObuDcRsmWarning(rsmWarningData) + if (HmiBuildConfig.isShowObuV2iView) { + onMogoObuDcRsmWarning(rsmWarningData) + } } override fun onMoGoObuSpatWarning(spatWarningData: ObuScene.SpatWarningData) { - onMogoObuDcSpatWarning(spatWarningData) + if (HmiBuildConfig.isShowObuV2iView) { + onMogoObuDcSpatWarning(spatWarningData) + } } override fun onMoGoObuMapMath(mapMatchData: ObuScene.MapMatchData) { - onMogoObuMapMath(mapMatchData) + if (HmiBuildConfig.isShowObuV2iView) { + onMogoObuMapMath(mapMatchData) + } } /** @@ -237,8 +245,7 @@ class MogoObuDcCombineManager private constructor() : IMoGoObuWarningRsiListener CallerLogger.d( "${M_OBU}${TAG}", - "MogoObuDcCombineManager ttsContent = $ttsContent --alertContent = $alertContent --appId = $appId ---direction = ${direction.direction} --distance = ${rsiWarningData.warningMsgList[0].distance} ---eventRadius = ${rsiWarningData.warningMsgList[0].eventRadius} --speedMaxLimit = ${rsiWarningData.warningMsgList[0].speedMaxLimit}" - ) + "MogoObuDcCombineManager ttsContent = $ttsContent --alertContent = $alertContent --appId = $appId ---direction = ${direction.direction} --distance = ${rsiWarningData.warningMsgList[0].distance} ---eventRadius = ${rsiWarningData.warningMsgList[0].eventRadius} --speedMaxLimit = ${rsiWarningData.warningMsgList[0].speedMaxLimit}") when (status) { // 添加 MogoObuConstants.STATUS.ADD -> { @@ -380,33 +387,31 @@ class MogoObuDcCombineManager private constructor() : IMoGoObuWarningRsiListener * 地图匹配 是OBU算法输出地图匹配结果,主车匹配道路哪条路或者哪条车道 */ fun onMogoObuMapMath(data: ObuScene.MapMatchData?) { - if (HmiBuildConfig.isShowObuLimitSpeedView) { - if (data != null) { - CallerLogger.d( - "${M_OBU}${TAG}", - "MogoObuDcCombineManager onMogoObuMapMath = ${data.status} --speedMaxLimit = ${ - Math.round( - (data.speedMaxLimit * 0.02 * 3.6) - ) - } --- data.speedMaxLimit = ${data.speedMaxLimit}" - ) - when (data.status) { - MogoObuConstants.STATUS.ADD -> { // 添加 - CallerLimitingVelocityListenerManager.invokeUnion( - (data.speedMaxLimit * 0.02 * 3.6).roundToInt().toInt(), - DataSourceType.OBU - ) - } + if (data != null) { + CallerLogger.d( + "${M_OBU}${TAG}", + "MogoObuDcCombineManager onMogoObuMapMath = ${data.status} --speedMaxLimit = ${ + Math.round( + (data.speedMaxLimit * 0.02 * 3.6) + ) + } --- data.speedMaxLimit = ${data.speedMaxLimit}" + ) + when (data.status) { + MogoObuConstants.STATUS.ADD -> { // 添加 + CallerLimitingVelocityListenerManager.invokeUnion( + (data.speedMaxLimit * 0.02 * 3.6).roundToInt().toInt(), + DataSourceType.OBU + ) + } - MogoObuConstants.STATUS.UPDATE -> { // 更新 - } + MogoObuConstants.STATUS.UPDATE -> { // 更新 + } - MogoObuConstants.STATUS.DELETE -> { // 删除 - CallerLimitingVelocityListenerManager.invokeUnion( - -1, - DataSourceType.OBU - ) - } + MogoObuConstants.STATUS.DELETE -> { // 删除 + CallerLimitingVelocityListenerManager.invokeUnion( + -1, + DataSourceType.OBU + ) } } } diff --git a/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/obu/MogoPrivateObuNewManager.kt b/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/obu/MogoPrivateObuNewManager.kt index 868498b8ac..3f7f908681 100644 --- a/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/obu/MogoPrivateObuNewManager.kt +++ b/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/obu/MogoPrivateObuNewManager.kt @@ -661,7 +661,7 @@ class MogoPrivateObuNewManager private constructor() : OnUpgradeListener { /** * 构造对应展示数据和场景 根据obu的场景,add change delete确定是否展示 - * @param appId 使用WarningTypeEnum获取icon、提示内容、tts内容 TODO 添加事件频繁播报拦截 + * @param appId 使用WarningTypeEnum获取icon、提示内容、tts内容 * @see com.mogo.module.common.enums.EventTypeEnumNew * EventTypeEnumNew在定义的id为了防止重复,和原始数据是不一样的,有对应关系 */ @@ -806,7 +806,6 @@ class MogoPrivateObuNewManager private constructor() : OnUpgradeListener { EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_EVW.poiType) v2xType = EventTypeEnumNew.TYPE_USECASE_ID_EVW.poiType } - } when (status) { From 525d1827df96c15519647c26c41f5581e933fe52 Mon Sep 17 00:00:00 2001 From: chenfufeng Date: Fri, 3 Mar 2023 17:02:51 +0800 Subject: [PATCH 4/6] =?UTF-8?q?[Opt3.0]=E6=80=9D=E5=BF=85=E9=A9=B0TTS?= =?UTF-8?q?=E5=85=BC=E5=AE=B9=E5=A4=9A=E8=AF=AD=E8=A8=80=E7=9A=84API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/mogo/tts/pad/PadTTS.java | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/tts/tts-pad/src/main/java/com/mogo/tts/pad/PadTTS.java b/tts/tts-pad/src/main/java/com/mogo/tts/pad/PadTTS.java index 382f00303a..707876c9b1 100644 --- a/tts/tts-pad/src/main/java/com/mogo/tts/pad/PadTTS.java +++ b/tts/tts-pad/src/main/java/com/mogo/tts/pad/PadTTS.java @@ -29,6 +29,8 @@ import com.mogo.eagle.core.utilcode.util.ThreadUtils; import com.mogo.eagle.core.utilcode.util.ToastUtils; import com.mogo.tts.base.IMogoTTS; import com.mogo.tts.base.IMogoTTSCallback; +import com.mogo.tts.base.LangTtsEntity; +import com.mogo.tts.base.LanguageType; import com.mogo.tts.base.MultiLangTtsEntity; import com.mogo.tts.base.PreemptType; import com.zhidao.auto.platform.voice.VoiceClient; @@ -443,9 +445,11 @@ public class PadTTS implements IMogoTTS, VoiceClient.VoiceCmdCallBack, OnTtsList @MainThread public void speakTTSVoiceWithLevel(String text, int ttsLevel, IMogoTTSCallback callBack) { if (mHasAuth && mEngine != null) { - mSpeakVoiceMap.put(text, callBack); + if (callBack != null) { + mSpeakVoiceMap.put(text, callBack); + } + speakTTSVoiceWithLevel(text, ttsLevel); } - speakTTSVoiceWithLevel(text, ttsLevel); } // 降序插入Tts(目前Level0、1可排队) @@ -508,7 +512,15 @@ public class PadTTS implements IMogoTTS, VoiceClient.VoiceCmdCallBack, OnTtsList @Override public void speakMultiLangTTSWithLevel(MultiLangTtsEntity ttsEntity, int level, IMogoTTSCallback callback) { - + if (mHasAuth && mEngine != null) { + LangTtsEntity entity; + if ((entity = ttsEntity.ttsNext()) != null && entity.getLanguage() == LanguageType.CHINESE) { + if (callback != null) { + mSpeakVoiceMap.put(entity.getTtsContent(), callback); + } + speakTTSVoiceWithLevel(entity.getTtsContent(), level); + } + } } /** From 835a547ad8907ad8ccd0d74969bc736f093049a6 Mon Sep 17 00:00:00 2001 From: zhongchao Date: Fri, 3 Mar 2023 15:02:29 +0800 Subject: [PATCH 5/6] [2.13.0-arch-opt] code opt --- .../eagle/core/function/msgbox/DataManager.kt | 183 +++++++++++------- .../DevaToolsProvider.kt | 3 - .../setting/WrapContentLinearLayoutManager.kt | 36 ---- .../function/hmi/ui/vehicle/PncActionsView.kt | 1 + .../function/hmi/ui/widget/BatteryView.kt | 21 +- .../function/hmi/ui/widget/CheckSystemView.kt | 2 + .../function/hmi/ui/widget/StatusBarView.kt | 9 +- .../function/main/MainMoGoApplication.java | 52 +---- .../api/devatools/IDevaToolsProvider.kt | 5 - .../call/devatools/CallerDevaToolsManager.kt | 7 - 10 files changed, 141 insertions(+), 178 deletions(-) delete mode 100644 core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/setting/WrapContentLinearLayoutManager.kt diff --git a/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/msgbox/DataManager.kt b/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/msgbox/DataManager.kt index 7c25c50613..50281064c0 100644 --- a/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/msgbox/DataManager.kt +++ b/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/msgbox/DataManager.kt @@ -1,26 +1,35 @@ package com.mogo.eagle.core.function.msgbox +import android.annotation.SuppressLint import android.content.Context import android.os.Looper +import com.mogo.eagle.core.data.deva.report.ReportEntity import com.mogo.eagle.core.data.enums.DataSourceType import com.mogo.eagle.core.data.msgbox.* -import com.mogo.eagle.core.data.deva.report.ReportEntity import com.mogo.eagle.core.function.call.msgbox.CallerMsgBoxListenerManager import com.mogo.eagle.core.function.msgbox.db.MsgBoxDb import com.mogo.eagle.core.function.msgbox.db.MsgBoxInfo import com.mogo.eagle.core.utilcode.kotlin.lifeCycleScope import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger +import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.e import com.mogo.eagle.core.utilcode.util.GsonUtils +import com.mogo.eagle.core.utilcode.util.ProcessUtils +import com.mogo.eagle.core.utilcode.util.SPUtils import com.mogo.eagle.core.utilcode.util.Utils import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.delay import kotlinx.coroutines.launch import kotlinx.coroutines.withContext +import java.io.File +import java.text.SimpleDateFormat +import java.util.* object DataManager { // private val msgBoxMap: EnumMap> = EnumMap(MsgBoxType::class.java) + const val TAG = "DataManager" + // 消失时间5000ms const val DISMISS_TIME = 5000L @@ -148,6 +157,10 @@ object DataManager { * 从本地数据库中查询数据 */ fun queryAllMessages(context: Context) { + if (!ProcessUtils.isMainProcess(context)) { + return + } + clearMessageBoxTable(context) scope.launch { initCache() try { @@ -158,6 +171,38 @@ object DataManager { } } + @SuppressLint("SimpleDateFormat") + private fun clearMessageBoxTable(context: Context) { + Thread { + val lastLaunchTimeStr = SPUtils.getInstance().getString("last_launch", "") + val format = SimpleDateFormat("yyyy-MM-dd") + val currDate = Date(System.currentTimeMillis()) + val currTimeStr = format.format(currDate) + try { + if (lastLaunchTimeStr != null && lastLaunchTimeStr.isNotEmpty()) { + val isSameDay = currTimeStr == lastLaunchTimeStr + // 超过一天需要清除消息盒子中的数据,并把时间戳存入SP + if (!isSameDay) { + val file: File = context.getDatabasePath(MsgBoxDb.INTERNAL_DB_NAME) + if (file != null && file.exists()) { + context.deleteDatabase(MsgBoxDb.INTERNAL_DB_NAME) + } + SPUtils.getInstance().put("last_launch", currTimeStr) + } + } else { + // 首次使用App或中途仅删除sp文件 + val file: File = context.getDatabasePath(MsgBoxDb.INTERNAL_DB_NAME) + if (file != null && file.exists()) { + context.deleteDatabase(MsgBoxDb.INTERNAL_DB_NAME) + } + SPUtils.getInstance().put("last_launch", currTimeStr) + } + } catch (e: Exception) { + e(TAG, e.message) + } + }.start() + } + private fun initCache() { if (cacheNotifyList.isNotEmpty()) { cacheNotifyList.clear() @@ -170,86 +215,87 @@ object DataManager { } } - private suspend fun getCacheMessages(context: Context): List = withContext(Dispatchers.IO) { - delay(2000) - return@withContext MsgBoxDb.getDb(context) - .monitorDao() - .getAllCachedMessages() - .map { msgInfo -> - val json = msgInfo.bean2Json - when (msgInfo.obj2JsonType) { - MsgBoxType.V2X.ordinal -> { - return@map MsgBoxBean( - MsgBoxType.V2X, - GsonUtils.fromJson(json, V2XMsg::class.java) - ).apply { - this.timestamp = msgInfo.timeStamp - withContext(Dispatchers.Main) { - cacheNotifyList.add(this@apply) + private suspend fun getCacheMessages(context: Context): List = + withContext(Dispatchers.IO) { + delay(2000) + return@withContext MsgBoxDb.getDb(context) + .monitorDao() + .getAllCachedMessages() + .map { msgInfo -> + val json = msgInfo.bean2Json + when (msgInfo.obj2JsonType) { + MsgBoxType.V2X.ordinal -> { + return@map MsgBoxBean( + MsgBoxType.V2X, + GsonUtils.fromJson(json, V2XMsg::class.java) + ).apply { + this.timestamp = msgInfo.timeStamp + withContext(Dispatchers.Main) { + cacheNotifyList.add(this@apply) + } } } - } - MsgBoxType.OBU.ordinal -> { - return@map MsgBoxBean( - MsgBoxType.OBU, - GsonUtils.fromJson(json, V2XMsg::class.java) - ).apply { - this.timestamp = msgInfo.timeStamp - withContext(Dispatchers.Main) { - cacheNotifyList.add(this@apply) + MsgBoxType.OBU.ordinal -> { + return@map MsgBoxBean( + MsgBoxType.OBU, + GsonUtils.fromJson(json, V2XMsg::class.java) + ).apply { + this.timestamp = msgInfo.timeStamp + withContext(Dispatchers.Main) { + cacheNotifyList.add(this@apply) + } } } - } - MsgBoxType.OPERATION.ordinal -> { - return@map MsgBoxBean( - MsgBoxType.OPERATION, - GsonUtils.fromJson(json, OperationMsg::class.java) - ).apply { - this.timestamp = msgInfo.timeStamp - withContext(Dispatchers.Main) { - cacheNotifyList.add(this@apply) + MsgBoxType.OPERATION.ordinal -> { + return@map MsgBoxBean( + MsgBoxType.OPERATION, + GsonUtils.fromJson(json, OperationMsg::class.java) + ).apply { + this.timestamp = msgInfo.timeStamp + withContext(Dispatchers.Main) { + cacheNotifyList.add(this@apply) + } } } - } - MsgBoxType.REPORT.ordinal -> { - return@map MsgBoxBean( - MsgBoxType.REPORT, - GsonUtils.fromJson(json, ReportEntity::class.java) - ).apply { - this.timestamp = msgInfo.timeStamp - withContext(Dispatchers.Main) { - cacheSysInfoList.add(this@apply) + MsgBoxType.REPORT.ordinal -> { + return@map MsgBoxBean( + MsgBoxType.REPORT, + GsonUtils.fromJson(json, ReportEntity::class.java) + ).apply { + this.timestamp = msgInfo.timeStamp + withContext(Dispatchers.Main) { + cacheSysInfoList.add(this@apply) + } } } - } - MsgBoxType.RECORD.ordinal -> { - return@map MsgBoxBean( - MsgBoxType.RECORD, - GsonUtils.fromJson(json, RecordBagMsg::class.java) - ).apply { - this.timestamp = msgInfo.timeStamp - withContext(Dispatchers.Main) { - cacheRecordList.add(this@apply) + MsgBoxType.RECORD.ordinal -> { + return@map MsgBoxBean( + MsgBoxType.RECORD, + GsonUtils.fromJson(json, RecordBagMsg::class.java) + ).apply { + this.timestamp = msgInfo.timeStamp + withContext(Dispatchers.Main) { + cacheRecordList.add(this@apply) + } } } - } - MsgBoxType.NOTICE.ordinal -> { - return@map MsgBoxBean( - MsgBoxType.NOTICE, - GsonUtils.fromJson(json, NoticeFrCloudMsg::class.java) - ).apply { - this.timestamp = msgInfo.timeStamp - withContext(Dispatchers.Main) { - cacheNotifyList.add(this@apply) + MsgBoxType.NOTICE.ordinal -> { + return@map MsgBoxBean( + MsgBoxType.NOTICE, + GsonUtils.fromJson(json, NoticeFrCloudMsg::class.java) + ).apply { + this.timestamp = msgInfo.timeStamp + withContext(Dispatchers.Main) { + cacheNotifyList.add(this@apply) + } } } - } - else -> { - return@map MsgBoxBean(MsgBoxType.V2X, V2XMsg()) + else -> { + return@map MsgBoxBean(MsgBoxType.V2X, V2XMsg()) + } } } - } - } + } /** * 存储到本地数据库 @@ -298,7 +344,8 @@ object DataManager { fun delMsgBoxBean(context: Context, msgBoxBean: MsgBoxBean) { scope.launch { withContext(Dispatchers.Default) { - val msgBoxInfo = MsgBoxInfo(msgBoxBean.bean2Json, msgBoxBean.type.ordinal, msgBoxBean.timestamp) + val msgBoxInfo = + MsgBoxInfo(msgBoxBean.bean2Json, msgBoxBean.type.ordinal, msgBoxBean.timestamp) MsgBoxDb.getDb(context) .monitorDao() .deleteMsg(msgBoxInfo) diff --git a/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/DevaToolsProvider.kt b/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/DevaToolsProvider.kt index 668c80ee3c..0e4b4aa983 100644 --- a/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/DevaToolsProvider.kt +++ b/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/DevaToolsProvider.kt @@ -173,9 +173,6 @@ class DevaToolsProvider : IDevaToolsProvider { override fun updateUpgradeProgress() { upgradeManager.updateUpgradeProgress(mContext!!) - } - - override fun updateObuUpgradeStatus() { upgradeManager.updateObuUpgradeStatus(mContext!!) } diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/setting/WrapContentLinearLayoutManager.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/setting/WrapContentLinearLayoutManager.kt deleted file mode 100644 index 75a93e3901..0000000000 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/setting/WrapContentLinearLayoutManager.kt +++ /dev/null @@ -1,36 +0,0 @@ -package com.mogo.eagle.core.function.hmi.ui.setting - -import android.content.Context -import android.util.AttributeSet -import androidx.recyclerview.widget.LinearLayoutManager -import androidx.recyclerview.widget.RecyclerView - -/** - * @author XuXinChao - * @description fix java.lang.IndexOutOfBoundsException:检测到不一致。视图持有者适配器positionViewHolder无效 - * @since: 2022/6/7 - */ -class WrapContentLinearLayoutManager : LinearLayoutManager { - constructor(context: Context?) : super(context) {} - - constructor(context: Context?, orientation: Int, reverseLayout: Boolean) : super( - context, - orientation, - reverseLayout - ) {} - - constructor( - context: Context?, - attrs: AttributeSet?, - defStyleAttr: Int, - defStyleRes: Int - ) : super(context, attrs, defStyleAttr, defStyleRes) {} - - override fun onLayoutChildren(recycler: RecyclerView.Recycler?, state: RecyclerView.State?) { - try { - super.onLayoutChildren(recycler, state) - } catch (e: IndexOutOfBoundsException) { - e.printStackTrace() - } - } -} \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/vehicle/PncActionsView.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/vehicle/PncActionsView.kt index 5d073ae54e..58bfe45c84 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/vehicle/PncActionsView.kt +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/vehicle/PncActionsView.kt @@ -40,6 +40,7 @@ class PncActionsView @JvmOverloads constructor( @Volatile private var mTrafficLightResult: TrafficLightResult? = null + @Volatile private var mAutoPilotStatusInfo: AutopilotStatusInfo? = null private val bgResources: Int diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/BatteryView.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/BatteryView.kt index c88cc7a1bb..18c0f70988 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/BatteryView.kt +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/BatteryView.kt @@ -11,6 +11,7 @@ import android.view.View import com.mogo.eagle.core.function.api.setting.IMoGoSkinModeChangeListener import com.mogo.eagle.core.function.call.setting.CallerSkinModeListenerManager import com.mogo.eagle.core.function.hmi.R +import com.mogo.eagle.core.utilcode.util.ThreadUtils import kotlin.math.abs @@ -139,17 +140,19 @@ class BatteryView : View , IMoGoSkinModeChangeListener { } override fun onSkinModeChange(skinMode: Int) { - when (skinMode) { - 0 -> { - batteryColor = resources.getColor(R.color.color_27FFFFFF) - powerColor = Color.WHITE - } - 1 -> { - batteryColor = resources.getColor(R.color.color_1E111111) - powerColor = resources.getColor(R.color.color_2C2E30) + ThreadUtils.runOnUiThread { + when (skinMode) { + 0 -> { + batteryColor = resources.getColor(R.color.color_27FFFFFF) + powerColor = Color.WHITE + } + 1 -> { + batteryColor = resources.getColor(R.color.color_1E111111) + powerColor = resources.getColor(R.color.color_2C2E30) + } } + invalidate() } - invalidate() } override fun onAttachedToWindow() { diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/CheckSystemView.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/CheckSystemView.kt index b07b0292b1..f6a1f0bd87 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/CheckSystemView.kt +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/CheckSystemView.kt @@ -29,7 +29,9 @@ class CheckSystemView @JvmOverloads constructor( const val TAG = "CheckSystemView" } + @Volatile private var connectStatus = false //是否连接工控机 + @Volatile private var autopilotStatus: Int? = null //自动驾驶状态 0代表不可自动驾驶,1代表可自动驾驶,2代表自动驾驶中 private var dockerRebootDialog: DockerRebootDialog? = null diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/StatusBarView.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/StatusBarView.kt index 1205cba30a..cc791d43cd 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/StatusBarView.kt +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/StatusBarView.kt @@ -14,6 +14,7 @@ import com.mogo.eagle.core.function.call.hmi.CallerHmiViewControlListenerManager import com.mogo.eagle.core.function.call.setting.CallerSkinModeListenerManager import com.mogo.eagle.core.function.hmi.R import com.mogo.eagle.core.utilcode.util.BarUtils +import com.mogo.eagle.core.utilcode.util.ThreadUtils import kotlinx.android.synthetic.main.view_status_bar.view.* import java.util.concurrent.CopyOnWriteArrayList @@ -55,9 +56,11 @@ class StatusBarView @JvmOverloads constructor( } override fun onSkinModeChange(skinMode: Int) { - when (skinMode) { - 0 -> setStatusBarDarkOrLight(false) - 1 -> setStatusBarDarkOrLight(true) + ThreadUtils.runOnUiThread { + when (skinMode) { + 0 -> setStatusBarDarkOrLight(false) + 1 -> setStatusBarDarkOrLight(true) + } } } diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/main/MainMoGoApplication.java b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/main/MainMoGoApplication.java index 1e80ca8ec3..26370c9ed6 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/main/MainMoGoApplication.java +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/main/MainMoGoApplication.java @@ -2,7 +2,6 @@ package com.mogo.eagle.core.function.main; import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_HMI; -import android.annotation.SuppressLint; import android.content.Context; import android.os.Process; @@ -18,20 +17,15 @@ import com.mogo.eagle.core.data.constants.MogoServicePaths; import com.mogo.eagle.core.function.api.chat.biz.ChatConsts; import com.mogo.eagle.core.function.call.devatools.CallerDevaToolsManager; import com.mogo.eagle.core.function.call.msgbox.CallerMsgBoxManager; -import com.mogo.eagle.core.function.msgbox.db.MsgBoxDb; import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils; import com.mogo.eagle.core.utilcode.mogo.AppLaunchTimeUtils; import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger; import com.mogo.eagle.core.utilcode.util.ProcessUtils; -import com.mogo.eagle.core.utilcode.util.SPUtils; -import java.io.File; import java.lang.reflect.Field; -import java.text.SimpleDateFormat; -import java.util.Date; /** - * 默认初始化一些基础服务配置 todo 分离 msgBox去自己的模块中 --- 扶风 + * 默认初始化一些基础服务配置 */ public abstract class MainMoGoApplication extends AbsMogoApplication { @@ -50,12 +44,8 @@ public abstract class MainMoGoApplication extends AbsMogoApplication { initLogConfig(); initTipToast(); initModules(); - if (ProcessUtils.isMainProcess(this)) { - clearMessageBoxTable(); - CallerMsgBoxManager.INSTANCE.queryAllMessages(this); - } + CallerMsgBoxManager.INSTANCE.queryAllMessages(this); CallerDevaToolsManager.INSTANCE.updateUpgradeProgress(); - CallerDevaToolsManager.INSTANCE.updateObuUpgradeStatus(); } @Override @@ -64,38 +54,6 @@ public abstract class MainMoGoApplication extends AbsMogoApplication { return true; } - @SuppressLint("SimpleDateFormat") - private void clearMessageBoxTable() { - new Thread(() -> { - String lastLaunchTimeStr = SPUtils.getInstance().getString("last_launch", ""); - SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); - Date currDate = new Date(System.currentTimeMillis()); - String currTimeStr = format.format(currDate); - try { - if (lastLaunchTimeStr != null && !lastLaunchTimeStr.isEmpty()) { - boolean isSameDay = currTimeStr.equals(lastLaunchTimeStr); - // 超过一天需要清除消息盒子中的数据,并把时间戳存入SP - if (!isSameDay) { - File file = this.getDatabasePath(MsgBoxDb.INTERNAL_DB_NAME); - if (file != null && file.exists()) { - this.deleteDatabase(MsgBoxDb.INTERNAL_DB_NAME); - } - SPUtils.getInstance().put("last_launch", currTimeStr); - } - } else { - // 首次使用App或中途仅删除sp文件 - File file = this.getDatabasePath(MsgBoxDb.INTERNAL_DB_NAME); - if (file != null && file.exists()) { - this.deleteDatabase(MsgBoxDb.INTERNAL_DB_NAME); - } - SPUtils.getInstance().put("last_launch", currTimeStr); - } - } catch (Exception e) { - CallerLogger.INSTANCE.e(TAG, e.getMessage()); - } - }).start(); - } - /** * 初始化异常采集配置 */ @@ -126,11 +84,11 @@ public abstract class MainMoGoApplication extends AbsMogoApplication { MogoModulePaths.addModuleFunctionServer(new MogoModule(MogoServicePaths.PATH_V2X_OBU_MOGO, "IMoGoObuProvider")); // BIZ MogoModulePaths.addModuleFunctionServer(new MogoModule(MogoServicePaths.PATH_FUNC_BIZ, "IMoGoNoticeProvider")); - // todo 后置 车聊聊,IM + // 后置 车聊聊,IM MogoModulePaths.addModuleFunctionServer(new MogoModule(ChatConsts.CHAT_PROVIDER_PATH, ChatConsts.CHAT_MODULE_NAME)); // 司机身份专属 if (AppIdentityModeUtils.isDriver(FunctionBuildConfig.appIdentityMode)) { - // todo 后置 地图数据收集模块 + // 后置 地图数据收集模块 MogoModulePaths.addModuleFunctionServer(new MogoModule(MogoServicePaths.PATH_MAP_DATA_COLLECT_PROVIDER, "MoGoMapDataCollector")); } CallerLogger.INSTANCE.i(M_HMI + TAG, "App launch timer cost " + (System.currentTimeMillis() - start) + "ms"); @@ -141,7 +99,7 @@ public abstract class MainMoGoApplication extends AbsMogoApplication { super.attachBaseContext(base); /*如果是主进程**/ // if (ProcessUtils.isMainProcess(this)) { - AppLaunchTimeUtils.beginTimeCalculate(AppLaunchTimeUtils.COLD_START); + AppLaunchTimeUtils.beginTimeCalculate(AppLaunchTimeUtils.COLD_START); // } BoostMultiDex.install(base); AbsMogoApplication.sApp = this; diff --git a/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/devatools/IDevaToolsProvider.kt b/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/devatools/IDevaToolsProvider.kt index 830f983b58..3a4835bb04 100644 --- a/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/devatools/IDevaToolsProvider.kt +++ b/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/devatools/IDevaToolsProvider.kt @@ -125,11 +125,6 @@ interface IDevaToolsProvider : IProvider { */ fun updateUpgradeProgress() - /** - * obu下载进度 - */ - fun updateObuUpgradeStatus() - /** * 展示状态栏 */ diff --git a/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/devatools/CallerDevaToolsManager.kt b/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/devatools/CallerDevaToolsManager.kt index c17d108ec6..0cc3944c46 100644 --- a/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/devatools/CallerDevaToolsManager.kt +++ b/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/devatools/CallerDevaToolsManager.kt @@ -169,13 +169,6 @@ object CallerDevaToolsManager { devaToolsProviderApi?.updateUpgradeProgress() } - /** - * obu下载状态 - */ - fun updateObuUpgradeStatus() { - devaToolsProviderApi?.updateObuUpgradeStatus() - } - /** * 展示状态栏 */ From 601892621146433095a7d740b09a89b36138e6da Mon Sep 17 00:00:00 2001 From: zhongchao Date: Fri, 3 Mar 2023 18:16:08 +0800 Subject: [PATCH 6/6] [2.13.0-arch-opt] thread change to main --- .../hmi/ui/tools/AutoPilotAndCheckView.kt | 1 + .../function/hmi/ui/widget/VersionNameView.kt | 1 + .../eagle/core/function/main/MainActivity.kt | 12 ++-- .../core/function/smp/view/SmallMapView.kt | 63 ++++++++++--------- 4 files changed, 42 insertions(+), 35 deletions(-) diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/tools/AutoPilotAndCheckView.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/tools/AutoPilotAndCheckView.kt index 1ad27de6c1..effcdf840c 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/tools/AutoPilotAndCheckView.kt +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/tools/AutoPilotAndCheckView.kt @@ -51,6 +51,7 @@ internal class AutoPilotAndCheckView @JvmOverloads constructor( private var clickListener: ClickListener? = null private var keyBoardUtil: KeyBoardUtil? = null + @Volatile private var connectStatus = false private var lastTime = 0L diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/VersionNameView.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/VersionNameView.kt index bc404b047d..383f583392 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/VersionNameView.kt +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/VersionNameView.kt @@ -31,6 +31,7 @@ class VersionNameView @JvmOverloads constructor( const val TAG = "VersionNameView" } + @Volatile private var dockerVersion: String? = null //工控机版本 init{ diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/main/MainActivity.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/main/MainActivity.kt index 814487cf90..c7d20aea1f 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/main/MainActivity.kt +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/main/MainActivity.kt @@ -293,11 +293,13 @@ open class MainActivity : MvpActivity(), MainView, } override fun onAutopilotStatusResponse(autoPilotStatusInfo: AutopilotStatusInfo) { - val status = autoPilotStatusInfo.ipcConnStatus - if (mLastStatus != status) { - val statusInfo = autoPilotStatusInfo.clone() - rvConnectInfo.post { updateConnectInfoView(statusInfo) } - mLastStatus = status + UiThreadHandler.post { + val status = autoPilotStatusInfo.ipcConnStatus + if (mLastStatus != status) { + val statusInfo = autoPilotStatusInfo.clone() + rvConnectInfo.post { updateConnectInfoView(statusInfo) } + mLastStatus = status + } } } diff --git a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/smp/view/SmallMapView.kt b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/smp/view/SmallMapView.kt index 823d45079c..aca9bd6ecd 100644 --- a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/smp/view/SmallMapView.kt +++ b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/smp/view/SmallMapView.kt @@ -4,7 +4,6 @@ import android.content.Context import android.graphics.Color import android.os.Bundle import android.util.AttributeSet -import android.util.Log import android.view.LayoutInflater import android.view.MotionEvent import android.widget.RelativeLayout @@ -52,6 +51,7 @@ class SmallMapView @JvmOverloads constructor( private var mContext: Context? = null private var mLocation: MogoLocation? = null + @Volatile private var autoPilotStatus = 0 companion object { @@ -216,7 +216,7 @@ class SmallMapView @JvmOverloads constructor( uiSettings?.setAllGesturesEnabled(false) // 所有手势 uiSettings?.isMyLocationButtonEnabled = false // 显示默认的定位按钮 uiSettings?.setLogoBottomMargin(-150) //设置Logo下边界距离屏幕底部的边距,设置为负值即可 - mAMap?.setOnMapLoadedListener(AMap.OnMapLoadedListener { + mAMap?.setOnMapLoadedListener { CallerLogger.d( SceneConstant.M_MAP + TAG, "smp---onMapLoaded" @@ -237,7 +237,7 @@ class SmallMapView @JvmOverloads constructor( mAMapNaviView!!.width / 2, mAMapNaviView!!.height / 2 ) - }) + } } private fun coordinateConverterFrom84(mContext: Context?, mogoLatLng: MogoLatLng): LatLng { @@ -283,36 +283,39 @@ class SmallMapView @JvmOverloads constructor( if (mCarMarker == null) { return } - val currentLatLng = LatLng(mLocation!!.latitude, mLocation!!.longitude) - val bearing = floor(mLocation!!.heading).toFloat() - //更新车辆位置 - mCarMarker!!.position = currentLatLng - if (mCoordinatesLatLng.size > 1) { - // 结束位置 - val endLatLng = mCoordinatesLatLng[mCoordinatesLatLng.size - 1] - val calculateDistance = CoordinateUtils.calculateLineDistance( - endLatLng.latitude, endLatLng.longitude, - currentLatLng.latitude, currentLatLng.longitude - ) - CallerLogger.d( - SceneConstant.M_MAP + TAG, - "calculateDistance=$calculateDistance" - ) - if (calculateDistance <= 5) { + UiThreadHandler.post { + val currentLatLng = LatLng(mLocation!!.latitude, mLocation!!.longitude) + val bearing = floor(mLocation!!.heading).toFloat() + //更新车辆位置 + mCarMarker!!.position = currentLatLng + if (mCoordinatesLatLng.size > 1) { + // 结束位置 + val endLatLng = mCoordinatesLatLng[mCoordinatesLatLng.size - 1] + val calculateDistance = CoordinateUtils.calculateLineDistance( + endLatLng.latitude, endLatLng.longitude, + currentLatLng.latitude, currentLatLng.longitude + ) CallerLogger.d( - SceneConstant.M_MAP + TAG, "onChassisLocationGCJ02 -----> calculateDistance <= 5 ") - clearPolyline() - mCoordinatesLatLng.clear() + SceneConstant.M_MAP + TAG, + "calculateDistance=$calculateDistance" + ) + if (calculateDistance <= 5) { + CallerLogger.d( + SceneConstant.M_MAP + TAG, "onChassisLocationGCJ02 -----> calculateDistance <= 5 ") + clearPolyline() + mCoordinatesLatLng.clear() + } } + val cameraPosition: CameraPosition = + CameraPosition.Builder() + .target(mCarMarker!!.position) + .tilt(0f) + .bearing(bearing) + .zoom(zoomLevel.toFloat()) + .build() + mAMap?.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition)) } - val cameraPosition: CameraPosition = - CameraPosition.Builder() - .target(mCarMarker!!.position) - .tilt(0f) - .bearing(bearing) - .zoom(zoomLevel.toFloat()) - .build() - mAMap?.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition)) + } override fun onAutopilotStatusResponse(autoPilotStatusInfo: AutopilotStatusInfo) {