[6.5.0][Fix]解决上个订单信息未清除的问题
This commit is contained in:
@@ -12,6 +12,7 @@ import android.os.Message
|
||||
import android.util.AttributeSet
|
||||
import android.util.Log
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import com.amap.api.maps.AMap
|
||||
import com.amap.api.maps.CameraUpdate
|
||||
@@ -45,7 +46,6 @@ import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager
|
||||
import com.mogo.eagle.core.function.map.R
|
||||
import com.mogo.eagle.core.utilcode.mogo.MapAssetStyleUtils
|
||||
import com.mogo.eagle.core.utilcode.util.LocationUtils
|
||||
import com.mogo.eagle.core.utilcode.util.ThreadUtils
|
||||
import me.jessyan.autosize.utils.AutoSizeUtils
|
||||
import mogo.telematics.pad.MessagePad
|
||||
|
||||
@@ -76,12 +76,12 @@ class TravelRealityView @JvmOverloads constructor(
|
||||
private const val DRAW_END_MARKER = 10
|
||||
private const val UPDATE_VIDEO_MARKER = 11
|
||||
|
||||
private const val maxRoadRange = 68f
|
||||
private const val minRoadRange = 52f
|
||||
private const val maxRoadWidth = 32f
|
||||
private const val minRoadWidth = 14f
|
||||
private const val maxGlobalWidth = 30f
|
||||
private const val minGlobalWidth = 13f
|
||||
// private const val CLEAR_POLY_LINE = 12
|
||||
private const val CLEAR_ROAD_EVENT = 13
|
||||
private const val CLEAR_CROSS_DEVICE = 14
|
||||
// private const val CLEAR_ROAD_TRAJECTORY = 15
|
||||
private const val CLEAR_END_MARKER = 16
|
||||
private const val CLEAR_VIDEO_MARKER = 17
|
||||
}
|
||||
|
||||
private var mContext: Context? = null
|
||||
@@ -115,6 +115,7 @@ class TravelRealityView @JvmOverloads constructor(
|
||||
|
||||
@Volatile
|
||||
private var isMapLoaded = false
|
||||
|
||||
@Volatile
|
||||
private var isMapDestroyed = false
|
||||
|
||||
@@ -174,6 +175,8 @@ class TravelRealityView @JvmOverloads constructor(
|
||||
|
||||
@Volatile
|
||||
private var reqData: List<Point>? = null
|
||||
|
||||
@Volatile
|
||||
private var retryCount = 0
|
||||
|
||||
@Volatile
|
||||
@@ -191,21 +194,11 @@ class TravelRealityView @JvmOverloads constructor(
|
||||
@Volatile
|
||||
private var isRoadTrackReq = false
|
||||
|
||||
/**
|
||||
* 在轨迹点附近的道路事件
|
||||
*/
|
||||
private val roadEventList by lazy {
|
||||
ArrayList<EventBean>()
|
||||
}
|
||||
private val ipPointMap by lazy {
|
||||
HashMap<String, VideoMarkerEntity>()
|
||||
}
|
||||
private val eventPointMap by lazy {
|
||||
HashMap<String, Int>()
|
||||
}
|
||||
private val devicePointMap by lazy {
|
||||
HashMap<String, Int>()
|
||||
}
|
||||
@Volatile
|
||||
private var isRoadEventReq = false
|
||||
|
||||
@Volatile
|
||||
private var isCrossDeviceReq = false
|
||||
|
||||
private var testTime = 0L
|
||||
|
||||
@@ -357,6 +350,17 @@ class TravelRealityView @JvmOverloads constructor(
|
||||
}
|
||||
}
|
||||
|
||||
override fun onVisibilityChanged(changedView: View, visibility: Int) {
|
||||
super.onVisibilityChanged(changedView, visibility)
|
||||
if (visibility == VISIBLE) {
|
||||
Log.d(TAG, "onVisibilityChanged:VISIBLE!")
|
||||
val globalPath: List<Point>? = reqData
|
||||
if (!globalPath.isNullOrEmpty()) {
|
||||
requestData(globalPath as ArrayList<Point>)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onAttachedToWindow() {
|
||||
super.onAttachedToWindow()
|
||||
Log.d(TAG, "onAttachedToWindow")
|
||||
@@ -479,15 +483,17 @@ class TravelRealityView @JvmOverloads constructor(
|
||||
testTime = System.currentTimeMillis()
|
||||
if (eventList.isEmpty()) {
|
||||
listener?.onDraw(emptyList(), true)
|
||||
// 事件不足3个则用路口设备补齐
|
||||
completeQuantity()
|
||||
// 绘制道路事件
|
||||
// 没有事件则全部用路口设备补齐
|
||||
retryGetCrossDevice(ArrayList<String>(), HashMap<String, VideoMarkerEntity>())
|
||||
// 清除道路事件
|
||||
drawMarkers(DRAW_ROAD_EVENT, ArrayList<MarkerOptions>())
|
||||
} else {
|
||||
val eventDrawMap = HashMap<String, EventDrawBean>()
|
||||
val eventOptionsList = ArrayList<MarkerOptions>()
|
||||
var distance = 0.0
|
||||
var key = ""
|
||||
val roadEvents = ArrayList<EventBean>()
|
||||
val eventPointMap = HashMap<String, Int>()
|
||||
globalList.forEachIndexed { index, globalPoint ->
|
||||
if (index >= 0 && index < globalList.size - 1) {
|
||||
eventList.forEach { eventBean ->
|
||||
@@ -500,8 +506,11 @@ class TravelRealityView @JvmOverloads constructor(
|
||||
eventBean.lat
|
||||
)
|
||||
key = "${eventBean.lon},${eventBean.lat}"
|
||||
if (distance >= 10 || eventPointMap.contains(key)) {
|
||||
Log.d(TAG, "道路事件:点(${key})到线段${index}-${index+1}的距离为:${distance}米")
|
||||
if (distance >= 10 || eventPointMap.contains(key)) {
|
||||
Log.d(
|
||||
TAG,
|
||||
"道路事件:点(${key})到线段${index}-${index + 1}的距离为:${distance}米"
|
||||
)
|
||||
return@forEach
|
||||
}
|
||||
eventPointMap[key] = 1
|
||||
@@ -509,30 +518,29 @@ class TravelRealityView @JvmOverloads constructor(
|
||||
eventBean.lon, eventBean.lat, globalPoint.lon,
|
||||
globalPoint.lat, globalList[index + 1].lon, globalList[index + 1].lat,
|
||||
)
|
||||
filterEventWithType(eventBean, eventOptionsList, eventDrawMap)
|
||||
filterEventWithType(eventBean, eventOptionsList, eventDrawMap, roadEvents)
|
||||
}
|
||||
}
|
||||
}
|
||||
listener?.onDraw(eventDrawMap.values.toList(), true)
|
||||
Log.d(TAG, "过滤掉的事件个数为:${eventList.size - eventOptionsList.size}")
|
||||
// 事件不足3个则用路口设备补齐
|
||||
completeQuantity()
|
||||
completeQuantity(roadEvents)
|
||||
// 绘制道路事件
|
||||
drawMarkers(DRAW_ROAD_EVENT, eventOptionsList)
|
||||
eventPointMap.clear()
|
||||
}
|
||||
}
|
||||
|
||||
private fun completeQuantity() {
|
||||
ipPointMap.clear()
|
||||
private fun completeQuantity(roadEvents: ArrayList<EventBean>) {
|
||||
val ipPointEntityMap = HashMap<String, VideoMarkerEntity>()
|
||||
// 全部展示事件,事件数不足则用路口设备补齐
|
||||
Log.d(TAG, "待绘制的道路事件的个数为:${roadEventList.size}")
|
||||
if (roadEventList.size >= 3) {
|
||||
Log.d(TAG, "已绘制的道路事件个数为:${roadEvents.size}")
|
||||
if (roadEvents.size >= 3) {
|
||||
val ipList = mutableListOf<String>()
|
||||
roadEventList[0].let {
|
||||
roadEvents[0].let {
|
||||
it.ip?.also { ip ->
|
||||
if (ip.isEmpty()) return@also
|
||||
ipPointMap[ip] = VideoMarkerEntity(
|
||||
ipPointEntityMap[ip] = VideoMarkerEntity(
|
||||
coordinateConverterWgsToGcj(it.lat, it.lon),
|
||||
it.title,
|
||||
it.orientation
|
||||
@@ -540,10 +548,10 @@ class TravelRealityView @JvmOverloads constructor(
|
||||
ipList.add(ip)
|
||||
}
|
||||
}
|
||||
roadEventList[(roadEventList.size - 1) / 2].let {
|
||||
roadEvents[(roadEvents.size - 1) / 2].let {
|
||||
it.ip?.also { ip ->
|
||||
if (ip.isEmpty()) return@also
|
||||
ipPointMap[ip] = VideoMarkerEntity(
|
||||
ipPointEntityMap[ip] = VideoMarkerEntity(
|
||||
coordinateConverterWgsToGcj(it.lat, it.lon),
|
||||
it.title,
|
||||
it.orientation
|
||||
@@ -551,10 +559,10 @@ class TravelRealityView @JvmOverloads constructor(
|
||||
ipList.add(ip)
|
||||
}
|
||||
}
|
||||
roadEventList[roadEventList.size - 1].let {
|
||||
roadEvents[roadEvents.size - 1].let {
|
||||
it.ip?.also { ip ->
|
||||
if (ip.isEmpty()) return@also
|
||||
ipPointMap[ip] = VideoMarkerEntity(
|
||||
ipPointEntityMap[ip] = VideoMarkerEntity(
|
||||
coordinateConverterWgsToGcj(it.lat, it.lon),
|
||||
it.title,
|
||||
it.orientation
|
||||
@@ -562,18 +570,30 @@ class TravelRealityView @JvmOverloads constructor(
|
||||
ipList.add(ip)
|
||||
}
|
||||
}
|
||||
reqCrossLive(ipList)
|
||||
reqCrossLive(ipList, ipPointEntityMap)
|
||||
} else {
|
||||
retryGetCrossDevice()
|
||||
val ipList = mutableListOf<String>()
|
||||
roadEvents.forEach {
|
||||
it.ip?.let { ip ->
|
||||
if (ip.isEmpty()) return@let
|
||||
ipPointEntityMap[ip] = VideoMarkerEntity(
|
||||
coordinateConverterWgsToGcj(it.lat, it.lon),
|
||||
it.title,
|
||||
it.orientation
|
||||
)
|
||||
ipList.add(ip)
|
||||
}
|
||||
}
|
||||
retryGetCrossDevice(ipList, ipPointEntityMap)
|
||||
}
|
||||
}
|
||||
|
||||
private fun filterEventWithType(
|
||||
eventBean: EventBean,
|
||||
eventOptionsList: ArrayList<MarkerOptions>,
|
||||
eventDrawMap: HashMap<String, EventDrawBean>
|
||||
eventDrawMap: HashMap<String, EventDrawBean>,
|
||||
roadEvents: ArrayList<EventBean>
|
||||
) {
|
||||
roadEventList.clear()
|
||||
when (eventBean.poiType) {
|
||||
"800003" -> {// 交通事故
|
||||
eventOptionsList.add(MarkerOptions().apply {
|
||||
@@ -584,7 +604,7 @@ class TravelRealityView @JvmOverloads constructor(
|
||||
})
|
||||
eventBean.resId = R.drawable.mogo_shigu_nor
|
||||
eventBean.title = "交通事故"
|
||||
roadEventList.add(eventBean)
|
||||
roadEvents.add(eventBean)
|
||||
if (!eventDrawMap.containsKey("800003")) {
|
||||
eventDrawMap["800003"] = EventDrawBean(R.drawable.mogo_shigu_nor, "交通事故")
|
||||
}
|
||||
@@ -599,7 +619,7 @@ class TravelRealityView @JvmOverloads constructor(
|
||||
})
|
||||
eventBean.resId = R.drawable.mogo_shigong_image
|
||||
eventBean.title = "道路施工"
|
||||
roadEventList.add(eventBean)
|
||||
roadEvents.add(eventBean)
|
||||
if (!eventDrawMap.containsKey("800002")) {
|
||||
eventDrawMap["800002"] =
|
||||
EventDrawBean(R.drawable.mogo_shigong_image, "道路施工")
|
||||
@@ -624,7 +644,7 @@ class TravelRealityView @JvmOverloads constructor(
|
||||
})
|
||||
eventBean.resId = R.drawable.mogo_jingzhi_nor
|
||||
eventBean.title = "静止事件"
|
||||
roadEventList.add(eventBean)
|
||||
roadEvents.add(eventBean)
|
||||
if (!eventDrawMap.containsKey("800004")) {
|
||||
eventDrawMap["800004"] = EventDrawBean(R.drawable.mogo_jingzhi_nor, "静止事件")
|
||||
}
|
||||
@@ -641,35 +661,32 @@ class TravelRealityView @JvmOverloads constructor(
|
||||
* handleRoadEvent -> 计算Marker方向 -> completeQuantity -> retryGetCrossDevice(等待缓存deviceInPathList结束) -> 获取deviceInPathList -> 获取Marker方向
|
||||
* handleCrossDevices -> 计算Marker方向 -> 缓存deviceInPathList
|
||||
*/
|
||||
private fun retryGetCrossDevice() {
|
||||
private fun retryGetCrossDevice(
|
||||
ipList: MutableList<String>,
|
||||
ipPointEntityMap: HashMap<String, VideoMarkerEntity>
|
||||
) {
|
||||
Log.d(TAG, "retryGetCrossDevice")
|
||||
val crossDeviceListTmp = deviceInPathList
|
||||
if (crossDeviceListTmp.isNullOrEmpty()) {
|
||||
if (retryCount >= 5) return
|
||||
retryCount++
|
||||
ThreadUtils.runOnUiThreadDelayed({
|
||||
retryGetCrossDevice()
|
||||
}, 100)
|
||||
} else {
|
||||
var maxSize = 3 - roadEventList.size
|
||||
if (maxSize <= 0) return
|
||||
val ipList = mutableListOf<String>()
|
||||
roadEventList.forEach {
|
||||
it.ip?.let { ip ->
|
||||
if (ip.isEmpty()) return@let
|
||||
ipPointMap[ip] = VideoMarkerEntity(
|
||||
coordinateConverterWgsToGcj(it.lat, it.lon),
|
||||
it.title,
|
||||
it.orientation
|
||||
)
|
||||
ipList.add(ip)
|
||||
}
|
||||
while (crossDeviceListTmp.isNullOrEmpty()) {
|
||||
if (retryCount >= 5) {
|
||||
Log.d(TAG, "尝试多次后仍无法获取到路口设备数据!")
|
||||
break
|
||||
}
|
||||
Thread.sleep(150)
|
||||
retryCount++
|
||||
}
|
||||
var maxSize = 3 - ipList.size
|
||||
if (maxSize <= 0) {
|
||||
Log.d(TAG, "全息路口个数计算有误则返回!")
|
||||
return
|
||||
}
|
||||
Log.d(TAG, "待查询的事件个数为:${ipList.size}")
|
||||
if (!crossDeviceListTmp.isNullOrEmpty()) {
|
||||
// 轨迹线附近的路口设备取几个进行卡片展示
|
||||
for (i in crossDeviceListTmp.indices) {
|
||||
if (maxSize > 0 && !crossDeviceListTmp[i].deviceInfoList.isNullOrEmpty()) {
|
||||
crossDeviceListTmp[i].deviceInfoList!![0].deviceIp?.let {
|
||||
ipPointMap[it] = VideoMarkerEntity(
|
||||
ipPointEntityMap[it] = VideoMarkerEntity(
|
||||
coordinateConverterWgsToGcj(
|
||||
crossDeviceListTmp[i].deviceInfoList!![0].lat,
|
||||
crossDeviceListTmp[i].deviceInfoList!![0].lon
|
||||
@@ -680,8 +697,8 @@ class TravelRealityView @JvmOverloads constructor(
|
||||
}
|
||||
}
|
||||
}
|
||||
reqCrossLive(ipList)
|
||||
}
|
||||
reqCrossLive(ipList, ipPointEntityMap)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -701,8 +718,11 @@ class TravelRealityView @JvmOverloads constructor(
|
||||
})
|
||||
}
|
||||
|
||||
private fun reqCrossLive(ipList: MutableList<String>) {
|
||||
Log.d(TAG, "请求获取缩略图!")
|
||||
private fun reqCrossLive(
|
||||
ipList: MutableList<String>,
|
||||
ipPointEntityMap: HashMap<String, VideoMarkerEntity>
|
||||
) {
|
||||
Log.d(TAG, "请求获取缩略图,个数为:${ipList.size}!")
|
||||
travelNetWorkModel.batchRequestCrossLive(ipList, onSuccess = {
|
||||
val liveOptionsList = ArrayList<MarkerOptions>()
|
||||
var markerOption: MarkerOptions
|
||||
@@ -713,17 +733,18 @@ class TravelRealityView @JvmOverloads constructor(
|
||||
markerOption.zIndex(0.9f)
|
||||
if (roadCamera.imageUrl.isNullOrEmpty()) {
|
||||
var view: EventVideoView
|
||||
if (ipPointMap[ip] != null) {
|
||||
markerOption.position(ipPointMap[ip]?.latLng)
|
||||
if (ipPointEntityMap[ip] != null) {
|
||||
markerOption.position(ipPointEntityMap[ip]?.latLng)
|
||||
view = EventVideoView(
|
||||
context,
|
||||
title = ipPointMap[ip]!!.title,
|
||||
orientation = ipPointMap[ip]!!.orientation
|
||||
title = ipPointEntityMap[ip]!!.title,
|
||||
orientation = ipPointEntityMap[ip]!!.orientation
|
||||
)
|
||||
pair = travelNetWorkModel.calculateAnchor(ipPointMap[ip]!!.orientation)
|
||||
pair =
|
||||
travelNetWorkModel.calculateAnchor(ipPointEntityMap[ip]!!.orientation)
|
||||
Log.d(
|
||||
TAG,
|
||||
"绘制时位置为:${ipPointMap[ip]?.latLng},标题为:${ipPointMap[ip]!!.title},方向为:${ipPointMap[ip]!!.orientation},锚点为:${pair}"
|
||||
"绘制时位置为:${ipPointEntityMap[ip]?.latLng},标题为:${ipPointEntityMap[ip]!!.title},方向为:${ipPointEntityMap[ip]!!.orientation},锚点为:${pair}"
|
||||
)
|
||||
markerOption.anchor(pair.first, pair.second)
|
||||
view.setPlaceHolder()
|
||||
@@ -734,14 +755,16 @@ class TravelRealityView @JvmOverloads constructor(
|
||||
} else {
|
||||
// 需要下载缩略图
|
||||
markerOption.icon(null)
|
||||
markerOption.position(ipPointMap[ip]?.latLng)
|
||||
pair = travelNetWorkModel.calculateAnchor(ipPointMap[ip]?.orientation ?: 0)
|
||||
markerOption.position(ipPointEntityMap[ip]?.latLng)
|
||||
pair = travelNetWorkModel.calculateAnchor(
|
||||
ipPointEntityMap[ip]?.orientation ?: 0
|
||||
)
|
||||
markerOption.anchor(pair.first, pair.second)
|
||||
downloadImage(
|
||||
roadCamera.imageUrl!!,
|
||||
ipPointMap[ip]?.latLng,
|
||||
ipPointMap[ip]?.title,
|
||||
ipPointMap[ip]?.orientation ?: 0
|
||||
ipPointEntityMap[ip]?.latLng,
|
||||
ipPointEntityMap[ip]?.title,
|
||||
ipPointEntityMap[ip]?.orientation ?: 0
|
||||
)
|
||||
}
|
||||
liveOptionsList.add(markerOption)
|
||||
@@ -762,6 +785,7 @@ class TravelRealityView @JvmOverloads constructor(
|
||||
var distance = 0.0
|
||||
var key = ""
|
||||
val deviceInPaths = ArrayList<DeviceInfoBean>()
|
||||
val devicePointMap = HashMap<String, Int>()
|
||||
globalList?.forEachIndexed { index, globalPoint ->
|
||||
if (index >= 0 && index < globalList.size - 1) {
|
||||
crossDeviceList.forEach {
|
||||
@@ -775,8 +799,11 @@ class TravelRealityView @JvmOverloads constructor(
|
||||
deviceBean.lat
|
||||
)
|
||||
key = "${deviceBean.lon},${deviceBean.lat}"
|
||||
if (distance >= 10 || devicePointMap.contains(key)) {
|
||||
Log.d(TAG, "路口设备:点(${key})到线段${index}-${index+1}的距离为:${distance}米")
|
||||
if (distance >= 10 || devicePointMap.contains(key)) {
|
||||
Log.d(
|
||||
TAG,
|
||||
"路口设备:点(${key})到线段${index}-${index + 1}的距离为:${distance}米"
|
||||
)
|
||||
return@loop
|
||||
}
|
||||
devicePointMap[key] = 1
|
||||
@@ -804,7 +831,6 @@ class TravelRealityView @JvmOverloads constructor(
|
||||
}
|
||||
}
|
||||
}
|
||||
devicePointMap.clear()
|
||||
if (deviceInPaths.isNotEmpty()) {
|
||||
listener?.onDraw(
|
||||
arrayListOf(EventDrawBean(R.drawable.mogo_quanxi_lukou, "全息路口")),
|
||||
@@ -916,54 +942,6 @@ class TravelRealityView @JvmOverloads constructor(
|
||||
if (distanceTmp < 50) {
|
||||
Log.d(TAG, "智慧道路内点索引为:$i")
|
||||
globalIndexSet.add(i)
|
||||
// if (lastIndex < 0 || index - lastIndex > 1) {
|
||||
// // 绘制新的智慧路段轨迹
|
||||
// polylineOptionTmp = PolylineOptions()
|
||||
// polylineOptionTmp?.let { optionTmp ->
|
||||
// buildPolylineOption(
|
||||
// optionTmp,
|
||||
// roadRange,
|
||||
// roadRangeBitmap
|
||||
// )
|
||||
// optionTmp.add(
|
||||
// coordinateConverterWgsToGcj(
|
||||
// trajPointList[1],
|
||||
// trajPointList[0]
|
||||
// )
|
||||
// )
|
||||
// optionTmp.add(
|
||||
// coordinateConverterWgsToGcj(
|
||||
// trajectoryList[index + 1]!![1],
|
||||
// trajectoryList[index + 1]!![0]
|
||||
// )
|
||||
// )
|
||||
// // 待绘制多段智慧道路的轨迹线
|
||||
// roadTrajectoryOptionsList.add(optionTmp)
|
||||
// }
|
||||
// lastIndex = index + 1
|
||||
// } else if (index == lastIndex) {
|
||||
// polylineOptionTmp?.add(
|
||||
// coordinateConverterWgsToGcj(
|
||||
// trajectoryList[index + 1]!![1],
|
||||
// trajectoryList[index + 1]!![0]
|
||||
// )
|
||||
// )
|
||||
// lastIndex = index + 1
|
||||
// } else if (index - lastIndex == 1) {
|
||||
// polylineOptionTmp?.add(
|
||||
// coordinateConverterWgsToGcj(
|
||||
// trajPointList[1],
|
||||
// trajPointList[0]
|
||||
// )
|
||||
// )
|
||||
// polylineOptionTmp?.add(
|
||||
// coordinateConverterWgsToGcj(
|
||||
// trajectoryList[index + 1]!![1],
|
||||
// trajectoryList[index + 1]!![0]
|
||||
// )
|
||||
// )
|
||||
// lastIndex = index + 1
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1123,41 +1101,76 @@ class TravelRealityView @JvmOverloads constructor(
|
||||
// nonFrequentHandler?.removeCallbacksAndMessages(null)
|
||||
Log.d(TAG, "取消之前的网络请求!")
|
||||
travelNetWorkModel.cancelAllRequest()
|
||||
// 清除之前的所有Marker
|
||||
clearAllMarkers()
|
||||
|
||||
val pointList = ArrayList<Point>()
|
||||
globalPath.wayPointsList.forEach { loc ->
|
||||
pointList.add(Point(loc.longitude, loc.latitude))
|
||||
}
|
||||
Log.d(TAG, "轨迹点个数为:${pointList.size}")
|
||||
reqData = pointList
|
||||
handleGlobalPath(pointList)
|
||||
|
||||
requestData(pointList)
|
||||
if (!isRoadTrackReq) {
|
||||
Log.d(TAG, "请求智慧道路轨迹!")
|
||||
handleRoadTrajectories(roadTrackList)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun clearAllMarkers() {
|
||||
Message.obtain().apply {
|
||||
what = CLEAR_ROAD_EVENT
|
||||
nonFrequentHandler?.sendMessage(this)
|
||||
}
|
||||
Message.obtain().apply {
|
||||
what = CLEAR_CROSS_DEVICE
|
||||
nonFrequentHandler?.sendMessage(this)
|
||||
}
|
||||
Message.obtain().apply {
|
||||
what = CLEAR_VIDEO_MARKER
|
||||
nonFrequentHandler?.sendMessage(this)
|
||||
}
|
||||
}
|
||||
|
||||
private fun requestData(pointList: ArrayList<Point>) {
|
||||
if (!isCrossDeviceReq) {
|
||||
Log.d(TAG, "请求获取路口设备!")
|
||||
isCrossDeviceReq = true
|
||||
// 获取路口设备
|
||||
travelNetWorkModel.getCrossDevice(onSuccess = {
|
||||
Log.d(TAG, "Cross device result is:$it")
|
||||
isCrossDeviceReq = false
|
||||
deviceList = it
|
||||
handleCrossDevices(it)
|
||||
}, onError = {
|
||||
isCrossDeviceReq = false
|
||||
Log.d(TAG, "Cross device error is:$it")
|
||||
})
|
||||
}
|
||||
if (!isRoadEventReq) {
|
||||
Log.d(TAG, "请求获取道路事件!")
|
||||
// 获取道路事件
|
||||
var cityCode = CallerMapUIServiceManager.getCityCode() ?: "0734"
|
||||
if (cityCode.isEmpty()) {
|
||||
cityCode = "0734"
|
||||
}
|
||||
isRoadEventReq = true
|
||||
travelNetWorkModel.getEventsWithTrajRequest(
|
||||
EventReqEntity(pointList, cityCode),
|
||||
onSuccess = {
|
||||
isRoadEventReq = false
|
||||
retryCount = 0
|
||||
Log.d(TAG, "Events result is:$it")
|
||||
handleRoadEvent(it)
|
||||
},
|
||||
onError = {
|
||||
isRoadEventReq = false
|
||||
retryCount = 0
|
||||
Log.d(TAG, "Events error is:$it")
|
||||
})
|
||||
if (!isRoadTrackReq) {
|
||||
handleRoadTrajectories(roadTrackList)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1189,6 +1202,7 @@ class TravelRealityView @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
DRAW_ROAD_EVENT -> {
|
||||
removeMessages(CLEAR_ROAD_EVENT)
|
||||
removeMessages(DRAW_ROAD_EVENT)
|
||||
if (isMapDestroyed) return
|
||||
(msg.obj as ArrayList<MarkerOptions>).apply {
|
||||
@@ -1196,7 +1210,14 @@ class TravelRealityView @JvmOverloads constructor(
|
||||
}
|
||||
}
|
||||
|
||||
CLEAR_ROAD_EVENT -> {
|
||||
removeMessages(CLEAR_ROAD_EVENT)
|
||||
if (isMapDestroyed) return
|
||||
realClearEventMarkers()
|
||||
}
|
||||
|
||||
DRAW_CROSS_DEVICE -> {
|
||||
removeMessages(CLEAR_CROSS_DEVICE)
|
||||
removeMessages(DRAW_CROSS_DEVICE)
|
||||
if (isMapDestroyed) return
|
||||
(msg.obj as ArrayList<MarkerOptions>).apply {
|
||||
@@ -1204,6 +1225,12 @@ class TravelRealityView @JvmOverloads constructor(
|
||||
}
|
||||
}
|
||||
|
||||
CLEAR_CROSS_DEVICE -> {
|
||||
removeMessages(CLEAR_CROSS_DEVICE)
|
||||
if (isMapDestroyed) return
|
||||
realClearCrossDeviceMarkers()
|
||||
}
|
||||
|
||||
DRAW_ROAD_RANGE -> {
|
||||
removeMessages(DRAW_ROAD_RANGE)
|
||||
if (isMapDestroyed) return
|
||||
@@ -1213,6 +1240,7 @@ class TravelRealityView @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
DRAW_ROAD_TRAJECTORY -> {
|
||||
// removeMessages(CLEAR_ROAD_TRAJECTORY)
|
||||
removeMessages(DRAW_ROAD_TRAJECTORY)
|
||||
if (isMapDestroyed) return
|
||||
(msg.obj as ArrayList<PolylineOptions>).apply {
|
||||
@@ -1220,6 +1248,12 @@ class TravelRealityView @JvmOverloads constructor(
|
||||
}
|
||||
}
|
||||
|
||||
// CLEAR_ROAD_TRAJECTORY -> {
|
||||
// removeMessages(CLEAR_ROAD_TRAJECTORY)
|
||||
// if (isMapDestroyed) return
|
||||
// realClearRoadTrajectory()
|
||||
// }
|
||||
|
||||
DRAW_GLOBAL_TRAJECTORY -> {
|
||||
removeMessages(DRAW_GLOBAL_TRAJECTORY)
|
||||
if (isMapDestroyed) return
|
||||
@@ -1234,6 +1268,7 @@ class TravelRealityView @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
DRAW_LIVE_DETAIL -> {
|
||||
removeMessages(CLEAR_VIDEO_MARKER)
|
||||
removeMessages(DRAW_LIVE_DETAIL)
|
||||
if (isMapDestroyed) return
|
||||
(msg.obj as ArrayList<MarkerOptions>).apply {
|
||||
@@ -1241,6 +1276,12 @@ class TravelRealityView @JvmOverloads constructor(
|
||||
}
|
||||
}
|
||||
|
||||
CLEAR_VIDEO_MARKER -> {
|
||||
removeMessages(CLEAR_VIDEO_MARKER)
|
||||
if (isMapDestroyed) return
|
||||
realClearLiveMarkers()
|
||||
}
|
||||
|
||||
DRAW_END_MARKER -> {
|
||||
removeMessages(DRAW_END_MARKER)
|
||||
if (isMapDestroyed) return
|
||||
@@ -1248,6 +1289,7 @@ class TravelRealityView @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
UPDATE_VIDEO_MARKER -> {
|
||||
removeMessages(UPDATE_VIDEO_MARKER)
|
||||
if (isMapDestroyed) return
|
||||
realUpdateVideoMarker(msg.obj as MarkerOptions)
|
||||
}
|
||||
@@ -1314,6 +1356,14 @@ class TravelRealityView @JvmOverloads constructor(
|
||||
Log.d(TAG, "计算到绘制事件耗时为:${System.currentTimeMillis() - testTime}")
|
||||
}
|
||||
|
||||
private fun realClearEventMarkers() {
|
||||
Log.d(TAG, "realClearEventMarkers")
|
||||
eventMarkerList.forEach {
|
||||
it.destroy()
|
||||
}
|
||||
eventMarkerList.clear()
|
||||
}
|
||||
|
||||
private fun realDrawCrossDeviceMarkers(eventMarkerList: ArrayList<MarkerOptions>) {
|
||||
Log.d(TAG, "realDrawCrossDeviceMarkers")
|
||||
deviceMarkerList.forEach {
|
||||
@@ -1328,6 +1378,14 @@ class TravelRealityView @JvmOverloads constructor(
|
||||
}
|
||||
}
|
||||
|
||||
private fun realClearCrossDeviceMarkers() {
|
||||
Log.d(TAG, "realClearCrossDeviceMarkers")
|
||||
deviceMarkerList.forEach {
|
||||
it.destroy()
|
||||
}
|
||||
deviceMarkerList.clear()
|
||||
}
|
||||
|
||||
private fun realDrawGlobalTrajectory(polylineOptionsList: ArrayList<PolylineOptions>) {
|
||||
Log.d(TAG, "realDrawGlobalTrajectory")
|
||||
if (globalPolylineList.isNotEmpty() && globalPolylineList.size != polylineOptionsList.size) {
|
||||
@@ -1393,6 +1451,14 @@ class TravelRealityView @JvmOverloads constructor(
|
||||
}
|
||||
}
|
||||
|
||||
private fun realClearLiveMarkers() {
|
||||
Log.d(TAG, "realClearLiveMarkers")
|
||||
liveMarkerList.forEach {
|
||||
it.destroy()
|
||||
}
|
||||
liveMarkerList.clear()
|
||||
}
|
||||
|
||||
private fun realUpdateVideoMarker(options: MarkerOptions) {
|
||||
Log.d(TAG, "realUpdateVideoMarker")
|
||||
liveMarkerList.forEach {
|
||||
|
||||
Reference in New Issue
Block a user