[6.5.0][Fix]解决订单结束后卡片未清除的问题
This commit is contained in:
@@ -2,6 +2,7 @@ package com.mogo.eagle.core.function.business.travelreality
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Bitmap
|
||||
import android.graphics.Point
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.util.Log
|
||||
import com.amap.api.maps.model.LatLng
|
||||
@@ -35,10 +36,13 @@ class TravelRealityModel private constructor() {
|
||||
|
||||
@Volatile
|
||||
private var eventKey = ""
|
||||
|
||||
@Volatile
|
||||
private var deviceKey = ""
|
||||
|
||||
@Volatile
|
||||
private var trackKey = ""
|
||||
|
||||
@Volatile
|
||||
private var liveKey = ""
|
||||
|
||||
@@ -56,22 +60,28 @@ class TravelRealityModel private constructor() {
|
||||
/**
|
||||
* 查询道路事件
|
||||
*/
|
||||
fun getEventsWithTrajRequest(reqData: EventReqEntity,
|
||||
onSuccess: ((List<EventBean>) -> Unit), onError: ((String) -> Unit)){
|
||||
fun getEventsWithTrajRequest(
|
||||
reqData: EventReqEntity,
|
||||
onSuccess: ((List<EventBean>) -> Unit), onError: ((String) -> Unit)
|
||||
) {
|
||||
eventKey = "getEvents_${System.currentTimeMillis()}"
|
||||
request<Response<List<EventBean>?>>(eventKey) {
|
||||
loader {
|
||||
apiResponseCall{
|
||||
apiResponseCall {
|
||||
val time = System.currentTimeMillis().toString()
|
||||
val md5String = "${ROAD_EVENT_TRAJECTORY.uppercase(Locale.getDefault())}$time"
|
||||
Log.d("TravelRealityModel", "查询道路事件轨迹点个数为:${reqData.points.size}")
|
||||
getNetWorkApi(HostConst.getNDEHost()).getEventsWithTrajRequest(Md5Util.getMD5Result(md5String), time, reqData)
|
||||
getNetWorkApi(HostConst.getNDEHost()).getEventsWithTrajRequest(
|
||||
Md5Util.getMD5Result(
|
||||
md5String
|
||||
), time, reqData
|
||||
)
|
||||
}
|
||||
}
|
||||
onSuccess {
|
||||
onSuccess.invoke(it.data ?: ArrayList())
|
||||
}
|
||||
onError{
|
||||
onError {
|
||||
onError.invoke(it.message ?: "")
|
||||
}
|
||||
}
|
||||
@@ -84,7 +94,7 @@ class TravelRealityModel private constructor() {
|
||||
deviceKey = "getDevice_${System.currentTimeMillis()}"
|
||||
request<BaseResponse<List<CrossDeviceBean>?>>(deviceKey) {
|
||||
loader {
|
||||
apiCall{
|
||||
apiCall {
|
||||
val time = System.currentTimeMillis().toString()
|
||||
val md5String = "${CROSS_DEVICE.uppercase(Locale.getDefault())}$time"
|
||||
val loc = CallerChassisLocationWGS84ListenerManager.getChassisLocationWGS84()
|
||||
@@ -92,13 +102,17 @@ class TravelRealityModel private constructor() {
|
||||
if (cityCode.isEmpty()) {
|
||||
cityCode = "0734"
|
||||
}
|
||||
getNetWorkApi(HostConst.getNDEHost()).getCrossDevice(Md5Util.getMD5Result(md5String), time, "", loc.longitude, loc.latitude, cityCode)
|
||||
getNetWorkApi(HostConst.getNDEHost()).getCrossDevice(
|
||||
Md5Util.getMD5Result(
|
||||
md5String
|
||||
), time, "", loc.longitude, loc.latitude, cityCode
|
||||
)
|
||||
}
|
||||
}
|
||||
onSuccess {
|
||||
onSuccess.invoke(it.result ?: ArrayList())
|
||||
}
|
||||
onError{
|
||||
onError {
|
||||
onError.invoke(it.message ?: "")
|
||||
}
|
||||
}
|
||||
@@ -117,15 +131,16 @@ class TravelRealityModel private constructor() {
|
||||
if (liveKey.isNotEmpty()) {
|
||||
cancel(liveKey)
|
||||
}
|
||||
cancelDownload()
|
||||
}
|
||||
|
||||
/**
|
||||
* 智慧路口路网范围
|
||||
*/
|
||||
fun getCityRoadRange(onSuccess: ((List<List<Double>?>?) -> Unit), onError: ((String) -> Unit)) {
|
||||
request<BaseResponse<List<List<Double>?>?>>{
|
||||
request<BaseResponse<List<List<Double>?>?>> {
|
||||
loader {
|
||||
apiCall{
|
||||
apiCall {
|
||||
val time = System.currentTimeMillis().toString()
|
||||
val md5String = "${CITY_ROAD_RANGE.uppercase(Locale.getDefault())}$time"
|
||||
val loc = CallerChassisLocationWGS84ListenerManager.getChassisLocationWGS84()
|
||||
@@ -133,13 +148,17 @@ class TravelRealityModel private constructor() {
|
||||
if (cityCode.isEmpty()) {
|
||||
cityCode = "0734"
|
||||
}
|
||||
getNetWorkApi(HostConst.getNDEHost()).getCityRoadRange(Md5Util.getMD5Result(md5String), time, loc.longitude, loc.latitude, cityCode)
|
||||
getNetWorkApi(HostConst.getNDEHost()).getCityRoadRange(
|
||||
Md5Util.getMD5Result(
|
||||
md5String
|
||||
), time, loc.longitude, loc.latitude, cityCode
|
||||
)
|
||||
}
|
||||
}
|
||||
onSuccess {
|
||||
onSuccess.invoke(it.result)
|
||||
}
|
||||
onError{
|
||||
onError {
|
||||
onError.invoke(it.message ?: "")
|
||||
}
|
||||
}
|
||||
@@ -148,11 +167,14 @@ class TravelRealityModel private constructor() {
|
||||
/**
|
||||
* 智慧道路轨迹
|
||||
*/
|
||||
fun getCityRoadTrack(onSuccess: ((List<List<List<Double>?>?>?) -> Unit), onError: ((String) -> Unit)) {
|
||||
fun getCityRoadTrack(
|
||||
onSuccess: ((List<List<List<Double>?>?>?) -> Unit),
|
||||
onError: ((String) -> Unit)
|
||||
) {
|
||||
trackKey = "getTrack_${System.currentTimeMillis()}"
|
||||
request<BaseResponse<List<List<List<Double>?>?>?>>(trackKey) {
|
||||
loader {
|
||||
apiCall{
|
||||
apiCall {
|
||||
val time = System.currentTimeMillis().toString()
|
||||
val md5String = "${CITY_ROAD_TRACK.uppercase(Locale.getDefault())}$time"
|
||||
val loc = CallerChassisLocationWGS84ListenerManager.getChassisLocationWGS84()
|
||||
@@ -160,13 +182,17 @@ class TravelRealityModel private constructor() {
|
||||
if (cityCode.isEmpty()) {
|
||||
cityCode = "0734"
|
||||
}
|
||||
getNetWorkApi(HostConst.getNDEHost()).getCityRoadTrack(Md5Util.getMD5Result(md5String), time, loc.longitude, loc.latitude, cityCode)
|
||||
getNetWorkApi(HostConst.getNDEHost()).getCityRoadTrack(
|
||||
Md5Util.getMD5Result(
|
||||
md5String
|
||||
), time, loc.longitude, loc.latitude, cityCode
|
||||
)
|
||||
}
|
||||
}
|
||||
onSuccess {
|
||||
onSuccess.invoke(it.result)
|
||||
}
|
||||
onError{
|
||||
onError {
|
||||
onError.invoke(it.message ?: "")
|
||||
}
|
||||
}
|
||||
@@ -194,7 +220,8 @@ class TravelRealityModel private constructor() {
|
||||
)
|
||||
val md5String = "/${BATCH_LIVE.uppercase(Locale.getDefault())}$time"
|
||||
MoGoRetrofitFactory.getInstanceNoCallAdapter(HostConst.getNDEHost())
|
||||
.create(INDERoadCameraApiService::class.java).cameraLiveBatchRequest(Md5Util.getMD5Result(md5String), time, map)
|
||||
.create(INDERoadCameraApiService::class.java)
|
||||
.cameraLiveBatchRequest(Md5Util.getMD5Result(md5String), time, map)
|
||||
}
|
||||
}
|
||||
onSuccess {
|
||||
@@ -206,18 +233,18 @@ class TravelRealityModel private constructor() {
|
||||
}
|
||||
}
|
||||
|
||||
fun downloadImage(context: Context, url: String?,
|
||||
latLng: LatLng,
|
||||
onSuccess: ((Bitmap, LatLng) -> Unit),
|
||||
onFailed: ((LatLng) -> Unit)
|
||||
fun downloadImage(
|
||||
context: Context, url: String?,
|
||||
latLng: LatLng,
|
||||
onSuccess: ((Bitmap, LatLng) -> Unit),
|
||||
onFailed: ((LatLng) -> Unit)
|
||||
) {
|
||||
if (url.isNullOrEmpty()) return
|
||||
val radiusPx = AutoSizeUtils.dp2px(context, 24f).toFloat()
|
||||
val options = RequestOptions().transform(
|
||||
GranularRoundedCorners(radiusPx, radiusPx,0f,0f)
|
||||
GranularRoundedCorners(radiusPx, radiusPx, 0f, 0f)
|
||||
)
|
||||
Glide.with(context)
|
||||
.asBitmap()
|
||||
Glide.with(context).asBitmap()
|
||||
.apply(options)
|
||||
.load(url)
|
||||
.into(object : CustomTarget<Bitmap>() {
|
||||
@@ -234,11 +261,22 @@ class TravelRealityModel private constructor() {
|
||||
})
|
||||
}
|
||||
|
||||
private fun cancelDownload() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算Marker相对最近线段ab应该摆放的位置
|
||||
* 0:左,1:上,2:右,3:下
|
||||
*/
|
||||
fun calculateOrientation(pLon: Double, pLat: Double, aLon: Double, aLat: Double, bLon: Double, bLat: Double): Int {
|
||||
fun calculateOrientation(
|
||||
pLon: Double,
|
||||
pLat: Double,
|
||||
aLon: Double,
|
||||
aLat: Double,
|
||||
bLon: Double,
|
||||
bLat: Double
|
||||
): Int {
|
||||
// 0:左,1:上,2:右,3:下
|
||||
var orientation = 0
|
||||
// 线段与正北方向的夹角,范围[0,360]
|
||||
@@ -260,6 +298,7 @@ class TravelRealityModel private constructor() {
|
||||
1
|
||||
}
|
||||
}
|
||||
|
||||
2 -> {
|
||||
orientation = if (abAngle > 180) {
|
||||
1
|
||||
@@ -267,6 +306,7 @@ class TravelRealityModel private constructor() {
|
||||
3
|
||||
}
|
||||
}
|
||||
|
||||
else -> {// 点p在线段ab所在的直线上
|
||||
orientation = 1// 未计算后面线段,写死上方
|
||||
}
|
||||
@@ -293,6 +333,7 @@ class TravelRealityModel private constructor() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
2 -> {// 顺时针方向为右侧
|
||||
orientation = when {
|
||||
abAngle in 0.0..90.0 -> {
|
||||
@@ -312,6 +353,7 @@ class TravelRealityModel private constructor() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else -> {// 点p在线段ab所在的直线上
|
||||
orientation = 0// 未计算后面线段,写死左侧
|
||||
}
|
||||
@@ -363,4 +405,77 @@ class TravelRealityModel private constructor() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun calculateVertex(context: Context, orientation: Int, point: Point): List<Point> {
|
||||
val anchorPair = calculateAnchor(orientation)
|
||||
val pointList = ArrayList<Point>()
|
||||
var width = 0
|
||||
var height = 0
|
||||
if (AppIdentityModeUtils.isDriver(FunctionBuildConfig.appIdentityMode)) {
|
||||
when (orientation) {
|
||||
0 -> {// 内容居左,箭头朝右
|
||||
width = AutoSizeUtils.dp2px(context, 390f)
|
||||
height = AutoSizeUtils.dp2px(context, 320f)
|
||||
}
|
||||
|
||||
1 -> {
|
||||
width = AutoSizeUtils.dp2px(context, 320f)
|
||||
height = AutoSizeUtils.dp2px(context, 390f)
|
||||
}
|
||||
|
||||
2 -> {
|
||||
width = AutoSizeUtils.dp2px(context, 390f)
|
||||
height = AutoSizeUtils.dp2px(context, 320f)
|
||||
}
|
||||
|
||||
else -> {
|
||||
width = AutoSizeUtils.dp2px(context, 320f)
|
||||
height = AutoSizeUtils.dp2px(context, 390f)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
when (orientation) {
|
||||
0 -> {// 内容居左,箭头朝右
|
||||
width = AutoSizeUtils.dp2px(context, 396f)
|
||||
height = AutoSizeUtils.dp2px(context, 324f)
|
||||
}
|
||||
|
||||
1 -> {
|
||||
width = AutoSizeUtils.dp2px(context, 324f)
|
||||
height = AutoSizeUtils.dp2px(context, 396f)
|
||||
}
|
||||
|
||||
2 -> {
|
||||
width = AutoSizeUtils.dp2px(context, 396f)
|
||||
height = AutoSizeUtils.dp2px(context, 324f)
|
||||
}
|
||||
|
||||
else -> {
|
||||
width = AutoSizeUtils.dp2px(context, 324f)
|
||||
height = AutoSizeUtils.dp2px(context, 396f)
|
||||
}
|
||||
}
|
||||
}
|
||||
var leftTopP: Point = Point()
|
||||
leftTopP.x = (point.x - width * anchorPair.first + 0.5).toInt()
|
||||
leftTopP.y = (point.y - height * anchorPair.second + 0.5).toInt()
|
||||
|
||||
var rightTopP: Point = Point()
|
||||
rightTopP.x = (leftTopP.x + width + 0.5).toInt()
|
||||
rightTopP.y = leftTopP.y
|
||||
|
||||
var leftBottomP: Point = Point()
|
||||
leftBottomP.x = leftTopP.x
|
||||
leftBottomP.y = (leftTopP.y + height + 0.5).toInt()
|
||||
|
||||
var rightBottomP: Point = Point()
|
||||
rightBottomP.x = (leftTopP.x + width + 0.5).toInt()
|
||||
rightBottomP.y = (leftTopP.y + height + 0.5).toInt()
|
||||
|
||||
pointList.add(leftTopP)
|
||||
pointList.add(rightTopP)
|
||||
pointList.add(leftBottomP)
|
||||
pointList.add(rightBottomP)
|
||||
return pointList
|
||||
}
|
||||
}
|
||||
@@ -275,6 +275,10 @@ class TravelRealityView @JvmOverloads constructor(
|
||||
* 清除所有Marker和Polyline
|
||||
*/
|
||||
fun clearAllMarkersAndPolyline() {
|
||||
Log.d(TAG, "clearAllMarkersAndPolyline")
|
||||
nonFrequentHandler?.removeCallbacksAndMessages(null)
|
||||
travelNetWorkModel.cancelAllRequest()
|
||||
retryCount = 0
|
||||
// 清除之前的所有Marker
|
||||
Message.obtain().apply {
|
||||
what = CLEAR_ALL_DATA
|
||||
@@ -393,6 +397,7 @@ class TravelRealityView @JvmOverloads constructor(
|
||||
CallerPlanningRottingListenerManager.removeListener("${TAG}${this.hashCode()}")
|
||||
nonFrequentHandler?.looper?.quitSafely()
|
||||
nonFrequentHandler = null
|
||||
travelNetWorkModel.cancelAllRequest()
|
||||
}
|
||||
|
||||
private fun initHandlers() {
|
||||
@@ -1111,8 +1116,6 @@ class TravelRealityView @JvmOverloads constructor(
|
||||
Log.d(TAG, "下发全局轨迹!")
|
||||
globalPathResp?.let { globalPath ->
|
||||
// nonFrequentHandler?.removeCallbacksAndMessages(null)
|
||||
Log.d(TAG, "取消之前的网络请求!")
|
||||
travelNetWorkModel.cancelAllRequest()
|
||||
|
||||
val pointList = ArrayList<Point>()
|
||||
globalPath.wayPointsList.forEach { loc ->
|
||||
@@ -1169,6 +1172,17 @@ class TravelRealityView @JvmOverloads constructor(
|
||||
}
|
||||
}
|
||||
|
||||
private fun getRectVertex(orientation: Int, latLng: LatLng) {
|
||||
if (mAMap != null && mAMap!!.projection != null) {
|
||||
|
||||
val point = mAMap!!.projection!!.toScreenLocation(latLng)
|
||||
point?.let {
|
||||
val pointList = travelNetWorkModel.calculateVertex(context, orientation, it)
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
interface OnDrawListener {
|
||||
// isEvent为true表示是事件,反之则表示全息路口
|
||||
fun onDraw(eventList: List<EventDrawBean>, isEvent: Boolean)
|
||||
|
||||
Reference in New Issue
Block a user