[3.2.0][Fix]解决多次下发全局轨迹导致卡顿的问题
This commit is contained in:
@@ -130,16 +130,16 @@ object MarkerDrawerManager {
|
||||
heading
|
||||
) >= 90
|
||||
) {
|
||||
currentIndex = if (i < lastArrivedIndex) {
|
||||
lastArrivedIndex
|
||||
} else {
|
||||
lastArrivedIndex = i
|
||||
i
|
||||
}
|
||||
Log.d("MarkerDrawerManager", "已走过的点的索引为:$currentIndex")
|
||||
currentIndex = i
|
||||
}
|
||||
}
|
||||
}
|
||||
Log.d("MarkerDrawerManager", "当次计算已走过的点的索引为:$currentIndex,存储的上次索引为:$lastArrivedIndex")
|
||||
if (currentIndex < lastArrivedIndex) {
|
||||
currentIndex = lastArrivedIndex
|
||||
} else {
|
||||
lastArrivedIndex = currentIndex
|
||||
}
|
||||
newPoints.addAll(routePoints)
|
||||
newPoints.add(currentIndex + 1, LatLng(realLat, realLon))
|
||||
return currentIndex + 1
|
||||
|
||||
@@ -20,7 +20,6 @@ import com.amap.api.maps.CameraUpdate
|
||||
import com.amap.api.maps.CameraUpdateFactory
|
||||
import com.amap.api.maps.TextureMapView
|
||||
import com.amap.api.maps.model.*
|
||||
import com.mogo.eagle.core.data.config.FunctionBuildConfig
|
||||
import com.mogo.eagle.core.data.map.Infrastructure
|
||||
import com.mogo.eagle.core.data.map.MogoLocation
|
||||
import com.mogo.eagle.core.data.v2x.Center
|
||||
@@ -49,9 +48,12 @@ import com.mogo.eagle.core.function.smp.V2XMarkerView
|
||||
import com.mogo.eagle.core.utilcode.mogo.MapAssetStyleUtils
|
||||
import com.mogo.eagle.core.utilcode.util.ThreadUtils
|
||||
import com.mogo.eagle.core.utilcode.util.UiThreadHandler
|
||||
import com.zhidaoauto.map.sdk.open.tools.ThreadPoolUtils
|
||||
import me.jessyan.autosize.utils.AutoSizeUtils
|
||||
import mogo.telematics.pad.MessagePad
|
||||
import mogo.v2x.MogoV2X
|
||||
import java.util.concurrent.ExecutorService
|
||||
import java.util.concurrent.Executors
|
||||
import kotlin.math.pow
|
||||
|
||||
/**
|
||||
@@ -126,6 +128,10 @@ class OverMapView @JvmOverloads constructor(
|
||||
@Volatile
|
||||
private var isInit = false
|
||||
|
||||
private val singlePool by lazy {
|
||||
Executors.newSingleThreadExecutor()
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val TAG = "OverMapView"
|
||||
}
|
||||
@@ -468,38 +474,36 @@ class OverMapView @JvmOverloads constructor(
|
||||
return
|
||||
}
|
||||
val list: List<MessagePad.Location> = locationList
|
||||
ThreadUtils.getSinglePool().submit {
|
||||
lastArrivedIndex = -1
|
||||
// 转成高德坐标系并存储
|
||||
updateRoutePoints(list, mContext!!)
|
||||
val planningPointList: List<LatLng> = planningPoints
|
||||
UiThreadHandler.post {
|
||||
displayCustomOverView()
|
||||
drawStartAndEndMarker(planningPointList)
|
||||
|
||||
if (geoHashInfMap.isNullOrEmpty()) {
|
||||
UiThreadHandler.postDelayed({
|
||||
drawInfrastructureMarkers(locationList)
|
||||
}, 1000)
|
||||
} else {
|
||||
drawInfrastructureMarkers(locationList)
|
||||
}
|
||||
}
|
||||
}
|
||||
// 转成高德坐标系并存储
|
||||
updateRoutePoints(list, mContext!!)
|
||||
val planningPointList: List<LatLng> = planningPoints
|
||||
UiThreadHandler.post ({
|
||||
displayCustomOverView()
|
||||
drawStartAndEndMarker(planningPointList)
|
||||
}, UiThreadHandler.MODE.QUEUE)
|
||||
if (!isInit) {
|
||||
callback = object : MarkerDrawerManager.Callback {
|
||||
override fun onLocationChanged(planningPoints: List<LatLng>, locIndex: Int) {
|
||||
// 每1s刷新一下轨迹线
|
||||
UiThreadHandler.post {
|
||||
UiThreadHandler.post ({
|
||||
if (planningPoints.isNotEmpty()) {
|
||||
drawPolyline(planningPoints, locIndex)
|
||||
}
|
||||
}
|
||||
}, UiThreadHandler.MODE.QUEUE)
|
||||
}
|
||||
}
|
||||
startLoopCalCarLocation()
|
||||
isInit = true
|
||||
}
|
||||
UiThreadHandler.post({
|
||||
if (geoHashInfMap.isNullOrEmpty()) {
|
||||
UiThreadHandler.postDelayed({
|
||||
drawInfrastructureMarkers(locationList)
|
||||
}, 1000, UiThreadHandler.MODE.QUEUE)
|
||||
} else {
|
||||
drawInfrastructureMarkers(locationList)
|
||||
}
|
||||
}, UiThreadHandler.MODE.QUEUE)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -884,7 +888,9 @@ class OverMapView @JvmOverloads constructor(
|
||||
*/
|
||||
override fun onAutopilotRotting(globalPathResp: MessagePad.GlobalPathResp?) {
|
||||
globalPathResp?.let {
|
||||
handlePlanningData(it.wayPointsList)
|
||||
singlePool.execute {
|
||||
handlePlanningData(it.wayPointsList)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -948,8 +954,8 @@ class OverMapView @JvmOverloads constructor(
|
||||
)
|
||||
}
|
||||
}
|
||||
UiThreadHandler.post {
|
||||
UiThreadHandler.post({
|
||||
showV2XEventMarkers(list)
|
||||
}
|
||||
}, UiThreadHandler.MODE.QUEUE)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user