From 98270da425f1f29be562dba41b0120c922f9ded8 Mon Sep 17 00:00:00 2001 From: chenfufeng Date: Thu, 17 Oct 2024 17:23:33 +0800 Subject: [PATCH] =?UTF-8?q?[6.7.0][Opt]=E8=B5=B7=E7=BB=88=E7=82=B9?= =?UTF-8?q?=E7=BB=98=E5=88=B6=E7=9B=91=E5=90=ACOch=E4=B8=9A=E5=8A=A1?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=8F=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../function/hmi/map/MapContainerLayout.kt | 3 + .../core/function/view/TravelRealityView.kt | 134 ++++++++++++------ 2 files changed, 96 insertions(+), 41 deletions(-) diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/map/MapContainerLayout.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/map/MapContainerLayout.kt index 21e538c995..48e9dd35d8 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/map/MapContainerLayout.kt +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/map/MapContainerLayout.kt @@ -179,12 +179,14 @@ class MapContainerLayout @JvmOverloads constructor( override fun onAnimationStart(animation: Animator) { super.onAnimationStart(animation) isPlayingAnim = true + overMapView.setIsPlaying(true) overMapView.setMapFlag(isScaled) } override fun onAnimationCancel(animation: Animator) { super.onAnimationCancel(animation) isPlayingAnim = false + overMapView.setIsPlaying(false) overMapView.swapSettings() updateShadowBg(isScaled) isScaled = !isScaled @@ -199,6 +201,7 @@ class MapContainerLayout @JvmOverloads constructor( override fun onAnimationEnd(animation: Animator) { super.onAnimationEnd(animation) isPlayingAnim = false + overMapView.setIsPlaying(false) overMapView.swapSettings() updateShadowBg(isScaled) isScaled = !isScaled diff --git a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/view/TravelRealityView.kt b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/view/TravelRealityView.kt index ad7e07a6b5..b18f4b5686 100644 --- a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/view/TravelRealityView.kt +++ b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/view/TravelRealityView.kt @@ -33,9 +33,11 @@ import com.amap.api.maps.model.PolylineOptions import com.mogo.eagle.core.data.config.FunctionBuildConfig import com.mogo.eagle.core.data.map.MogoLatLng import com.mogo.eagle.core.data.map.MogoLocation +import com.mogo.eagle.core.data.och.OchInfo import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLocationGCJ02Listener import com.mogo.eagle.core.function.api.autopilot.IMoGoPlanningRottingListener +import com.mogo.eagle.core.function.api.datacenter.IDataCenterBizListener import com.mogo.eagle.core.function.business.travelreality.CrossDeviceBean import com.mogo.eagle.core.function.business.travelreality.DeviceInfoBean import com.mogo.eagle.core.function.business.travelreality.EventBean @@ -48,6 +50,7 @@ import com.mogo.eagle.core.function.business.travelreality.view.VideoMarkerEntit import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ02ListenerManager import com.mogo.eagle.core.function.call.autopilot.CallerPlanningRottingListenerManager +import com.mogo.eagle.core.function.call.datacenter.CallerDataCenterBizListener import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager import com.mogo.eagle.core.function.map.R import com.mogo.eagle.core.function.smp.view.SmallMapView @@ -74,7 +77,8 @@ class TravelRealityView @JvmOverloads constructor( attrs: AttributeSet? = null, defStyleAttr: Int = 0 ) : ConstraintLayout(context, attrs, defStyleAttr), IMoGoChassisLocationGCJ02Listener, - IMoGoPlanningRottingListener, IMoGoAutopilotStatusListener { + IMoGoPlanningRottingListener, IMoGoAutopilotStatusListener, + IDataCenterBizListener { companion object { private const val TAG = "TravelRealityView" @@ -227,6 +231,9 @@ class TravelRealityView @JvmOverloads constructor( */ @Volatile private var isSmallMap: Boolean = true + + @Volatile + private var isPlayingAnim = false private var iconRes = R.drawable.small_map_car @Volatile @@ -236,6 +243,8 @@ class TravelRealityView @JvmOverloads constructor( private var mPolyline: Polyline? = null private var mSmallStartMarker: Marker? = null private var mSmallEndMarker: Marker? = null + private var mStartLatLng: LatLng? = null + private var mEndLatLng: LatLng? = null init { try { @@ -321,6 +330,10 @@ class TravelRealityView @JvmOverloads constructor( this.isSmallMap = isSmallMap } + fun setIsPlaying(isPlaying: Boolean) { + isPlayingAnim = isPlaying + } + fun swapSettings() { if (isSmallMap) { Message.obtain().apply { @@ -329,6 +342,7 @@ class TravelRealityView @JvmOverloads constructor( } // 显示小地图样式 changeMapSettings(true) + resumeStartEndMarker() globalPathResp?.let { if (it.wayPointsList.size > 0) { drawRotting() @@ -339,6 +353,7 @@ class TravelRealityView @JvmOverloads constructor( hideSmallCarMarker() // 显示行程总览地图样式 changeMapSettings(false) + resumeStartEndMarker() // 绘制自车 mLocation?.let { drawCarMarker(it) } val globalPath = reqData @@ -595,6 +610,7 @@ class TravelRealityView @JvmOverloads constructor( // 注册定位监听 CallerChassisLocationGCJ02ListenerManager.addListener("${TAG}${this.hashCode()}", this) CallerAutoPilotStatusListenerManager.addListener("${TAG}${this.hashCode()}", this) + CallerDataCenterBizListener.addListener("${TAG}${this.hashCode()}", this) } override fun onDetachedFromWindow() { @@ -606,6 +622,7 @@ class TravelRealityView @JvmOverloads constructor( CallerChassisLocationGCJ02ListenerManager.removeListener("${TAG}${this.hashCode()}") CallerPlanningRottingListenerManager.removeListener("${TAG}${this.hashCode()}") CallerAutoPilotStatusListenerManager.removeListener("${TAG}${this.hashCode()}") + CallerDataCenterBizListener.removeListener("${TAG}${this.hashCode()}") nonFrequentHandler?.looper?.quitSafely() nonFrequentHandler = null travelNetWorkModel.cancelAllRequest() @@ -684,38 +701,6 @@ class TravelRealityView @JvmOverloads constructor( globalData[0].lon ) CallerLogger.w("$M_MAP$TAG", "起终点距离为:$distance") -// if (distance < 2000) { -// roadRange = maxRoadRange -// roadWidth = minRoadWidth -// globalWidth = minGlobalWidth -// } else { -// roadRange = minRoadRange -// roadWidth = maxRoadWidth -// globalWidth = maxGlobalWidth -// } - val optionList = ArrayList() - optionList.add( - MarkerOptions().apply { - icon(BitmapDescriptorFactory.fromResource(startPointDrawable)) - position( - coordinateConverterWgsToGcj( - globalData[0].lat, - globalData[0].lon - ) - ) - } - ) - val endOption = MarkerOptions() - endOption.icon(BitmapDescriptorFactory.fromResource(endPointDrawable)) - endOption.position( - coordinateConverterWgsToGcj( - globalData[globalData.size - 1].lat, - globalData[globalData.size - 1].lon - ) - ) - optionList.add(endOption) - // 绘制起终点 - drawStartEndMarker(optionList) // 绘制全局轨迹 drawPolyline(DRAW_POLY_LINE, globalOptions) } @@ -1523,14 +1508,6 @@ class TravelRealityView @JvmOverloads constructor( clearPolyline() if (mAMap != null) { if (mCoordinatesLatLng.size >= 2) { - // 设置开始结束Marker位置 - mSmallStartMarker!!.position = mCoordinatesLatLng[0] - mSmallEndMarker!!.position = mCoordinatesLatLng[mCoordinatesLatLng.size - 1] - mSmallStartMarker!!.setToTop() - mSmallStartMarker!!.isVisible = true - mSmallEndMarker!!.isVisible = true - mSmallEndMarker!!.setToTop() - //存放所有点的经纬度 val boundsBuilder = LatLngBounds.Builder() for (i in mCoordinatesLatLng.indices) { @@ -1571,6 +1548,15 @@ class TravelRealityView @JvmOverloads constructor( } } + private fun hideStartEndMarker() { + if (mSmallStartMarker != null) { + mSmallStartMarker!!.isVisible = false + } + if (mSmallEndMarker != null) { + mSmallEndMarker!!.isVisible = false + } + } + private fun hideSmallCarMarker() { mSmallCarMarker?.isVisible = false } @@ -1702,6 +1688,72 @@ class TravelRealityView @JvmOverloads constructor( return latLngList } + override fun invokeOchInfo(ochInfo: OchInfo) { + super.invokeOchInfo(ochInfo) + Log.d(TAG, "invokeOchInfo:$ochInfo") + if (ochInfo.type == 0) { + val locList = ochInfo.latLonList + if (locList.isEmpty() || locList.size < 2) { + mStartLatLng = null + mEndLatLng = null + UiThreadHandler.post { + hideStartEndMarker() + } + } else { + // 设置开始结束Marker位置 + mStartLatLng = coordinateConverterWgsToGcj( + locList[0].latitude, + locList[0].longitude + ) + mEndLatLng = coordinateConverterWgsToGcj( + locList[1].latitude, + locList[1].longitude + ) + } + if (!isPlayingAnim) { + drawStartAndEnd() + } + } + } + + private fun resumeStartEndMarker() { + if (mStartLatLng != null && mEndLatLng != null) { + drawStartAndEnd() + } else { + if (isSmallMap) { + UiThreadHandler.post { + hideStartEndMarker() + } + } else { + drawStartEndMarker(emptyList()) + } + } + } + + private fun drawStartAndEnd() { + if (isSmallMap) { + UiThreadHandler.post { + mSmallStartMarker!!.position = mStartLatLng + mSmallEndMarker!!.position = mEndLatLng + mSmallStartMarker!!.setToTop() + mSmallStartMarker!!.isVisible = true + mSmallEndMarker!!.isVisible = true + mSmallEndMarker!!.setToTop() + } + } else { + val options = ArrayList() + options.add(MarkerOptions().also { option -> + option.icon(BitmapDescriptorFactory.fromResource(startPointDrawable)) + option.position(mStartLatLng) + }) + options.add(MarkerOptions().also { option -> + option.icon(BitmapDescriptorFactory.fromResource(endPointDrawable)) + option.position(mEndLatLng) + }) + drawStartEndMarker(options) + } + } + interface OnDrawListener { // isEvent为true表示是事件,反之则表示全息路口 fun onDraw(eventList: List, isEvent: Boolean)