From 601892621146433095a7d740b09a89b36138e6da Mon Sep 17 00:00:00 2001 From: zhongchao Date: Fri, 3 Mar 2023 18:16:08 +0800 Subject: [PATCH] [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) {