From b7fa4ff81fd3c770164b5b96b7ce6ddbc25c6729 Mon Sep 17 00:00:00 2001 From: aibingbing Date: Tue, 18 Jun 2024 18:41:23 +0800 Subject: [PATCH] =?UTF-8?q?[650]feat:=20=E8=B7=AF=E4=BE=A7=E4=BA=8B?= =?UTF-8?q?=E4=BB=B6=E5=BC=B9=E6=A1=86=EF=BC=8C=E5=A2=9E=E5=8A=A0caller=20?= =?UTF-8?q?=E8=B0=83=E7=94=A8=E6=96=B9=E5=BC=8F=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hmi/ui/v2n/PassengerV2NEventView.kt | 58 ++++++++++++++---- .../hmi/ui/v2n/V2NEventLivePlayView.kt | 8 +++ .../hmi_v2n_event_icon_close_passenger.png | Bin 0 -> 689 bytes .../layout/hmi_view_passenger_v2n_event.xml | 12 +++- .../core/data/road/RoadV2NEventWindowBean.kt | 17 +++++ .../hmi/v2n/IRoadV2NEventWindowListener.kt | 13 ++++ ...CallerRoadV2NEventWindowListenerManager.kt | 37 +++++++++++ 7 files changed, 131 insertions(+), 14 deletions(-) create mode 100644 core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xhdpi/hmi_v2n_event_icon_close_passenger.png create mode 100644 core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/road/RoadV2NEventWindowBean.kt create mode 100644 core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/hmi/v2n/IRoadV2NEventWindowListener.kt create mode 100644 core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/hmi/CallerRoadV2NEventWindowListenerManager.kt diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/v2n/PassengerV2NEventView.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/v2n/PassengerV2NEventView.kt index a9ad3ddcf8..5e4613c2a8 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/v2n/PassengerV2NEventView.kt +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/v2n/PassengerV2NEventView.kt @@ -3,12 +3,19 @@ package com.mogo.eagle.core.function.hmi.ui.v2n import android.content.Context import android.util.AttributeSet import android.view.LayoutInflater +import android.view.View import androidx.constraintlayout.widget.ConstraintLayout import androidx.core.content.ContextCompat +import com.mogo.commons.voice.AIAssist import com.mogo.eagle.core.data.config.FunctionBuildConfig +import com.mogo.eagle.core.data.road.RoadV2NEventWindowBean +import com.mogo.eagle.core.function.api.hmi.v2n.IRoadV2NEventWindowListener +import com.mogo.eagle.core.function.call.hmi.CallerRoadV2NEventWindowListenerManager import com.mogo.eagle.core.function.hmi.R import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils +import com.mogo.eagle.core.utilcode.util.DateTimeUtils import kotlinx.android.synthetic.main.hmi_view_passenger_v2n_event.view.containerLivePlay +import kotlinx.android.synthetic.main.hmi_view_passenger_v2n_event.view.ivClose import kotlinx.android.synthetic.main.hmi_view_passenger_v2n_event.view.ivPassengerV2XImage import kotlinx.android.synthetic.main.hmi_view_passenger_v2n_event.view.tvPassengerV2XContent import kotlinx.android.synthetic.main.hmi_view_passenger_v2n_event.view.tvPassengerV2XTime @@ -20,7 +27,7 @@ class PassengerV2NEventView @JvmOverloads constructor( context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0 -) : ConstraintLayout(context, attrs, defStyleAttr) { +) : ConstraintLayout(context, attrs, defStyleAttr), IRoadV2NEventWindowListener { companion object { const val TAG = "PassengerV2NEventView" @@ -30,6 +37,8 @@ class PassengerV2NEventView @JvmOverloads constructor( AppIdentityModeUtils.isPassenger(FunctionBuildConfig.appIdentityMode) } + private var currentEventUUID: String = "" + init { LayoutInflater.from(context).inflate(R.layout.hmi_view_passenger_v2n_event, this, true) initView() @@ -42,25 +51,48 @@ class PassengerV2NEventView @JvmOverloads constructor( ) else ContextCompat.getDrawable(context, R.drawable.bg_v2n_event_driver) - //TODO - ivPassengerV2XImage.setImageDrawable( - ContextCompat.getDrawable( - context, - R.drawable.v2x_icon_shigong_zhandao - ) - ) - tvPassengerV2XContent.text = "前方150米 道路施工 前方150米 道路施工 前方150米 道路施工" - tvPassengerV2XTime.text = "更新时间:10:38:20" - containerLivePlay.startPlay("https://video.zhidaozhixing.com/hy/LI_008_070.flv?txSecret=28ece9ad0bd67d06a7d391ed42264a99&txTime=66922502") + ivClose.setOnClickListener { + visibility = View.GONE + } } override fun onAttachedToWindow() { super.onAttachedToWindow() - //CallerMsgBoxEventListenerManager.addListener(TAG,this) + CallerRoadV2NEventWindowListenerManager.addListener(TAG, this) } override fun onDetachedFromWindow() { super.onDetachedFromWindow() - //CallerMsgBoxEventListenerManager.removeListener(TAG) + CallerRoadV2NEventWindowListenerManager.removeListener(TAG) + } + + override fun show(dataBean: RoadV2NEventWindowBean) { + currentEventUUID = dataBean.uuid + + //TODO + ivPassengerV2XImage.setImageDrawable( + ContextCompat.getDrawable( + context, + dataBean.iconResId + ) + ) + tvPassengerV2XContent.text = dataBean.hintStr + tvPassengerV2XTime.text = + "更新时间:${DateTimeUtils.getTimeText(dataBean.timestamp, DateTimeUtils.HH_mm_ss)}" + containerLivePlay.startPlay("https://video.zhidaozhixing.com/hy/LI_008_070.flv?txSecret=28ece9ad0bd67d06a7d391ed42264a99&txTime=66922502") + if (dataBean.isNeedTTS) { + AIAssist.getInstance(context) + .speakTTSVoiceWithLevel(dataBean.hintStr, AIAssist.LEVEL0) + } + visibility = View.VISIBLE + } + + override fun dismiss(eventId: String) { + if (eventId == currentEventUUID) { + visibility = View.GONE + currentEventUUID = "" + //TODO + //停止播放 + } } } \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/v2n/V2NEventLivePlayView.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/v2n/V2NEventLivePlayView.kt index b7e93ca65d..094c1520ea 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/v2n/V2NEventLivePlayView.kt +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/v2n/V2NEventLivePlayView.kt @@ -186,5 +186,13 @@ class V2NEventLivePlayView @JvmOverloads constructor( override fun onDetachedFromWindow() { super.onDetachedFromWindow() stopLoading() + try { + svpPlayer?.gsyVideoManager?.stop() + } catch (e: Exception) { + CallerLogger.w( + "${SceneConstant.M_HMI}$TAG", + "onDetachedFromWindow, e=${e.message}" + ) + } } } \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xhdpi/hmi_v2n_event_icon_close_passenger.png b/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xhdpi/hmi_v2n_event_icon_close_passenger.png new file mode 100644 index 0000000000000000000000000000000000000000..9e3b259a2ce2de116c945ad2411a0344581c5a10 GIT binary patch literal 689 zcmeAS@N?(olHy`uVBq!ia0vp^Qa~)p!3HGt@7W~)DaPU;cPEB*=VV?2IWDOYo@u_m z3|c@o2Loe!CIbsd2@r$yF)%PMU}Rth(u^Rn1xyIp1S;2DvJI?j{af zQ4!Y@s_aWS<+wGkzS7iCdi}3pUvk;SzfiJj6vkvHyKrse{A%&PoA);cUo+-?B=M;D`*KqU zhh4ue@782K-69hqo}dvR86kJVI6yEW&Vy$O^W{c`b!XnBtTc-XZhKrenbSx%>V#GD zzW=PRm%IrQx8F1QLi&$MTupYo%W9N0=dd=`s&TM&8fdgNSxK@szVs02VW@ssasTOS z={56DJl%WHe79!(bz$pCcayfv*k-K#`@!lNOYa2lnxV8$@LFKZ*Bz6m#4cRx#(t7T z)v>MiW7PK8rA?OxO zIUW+VUlf1LMpT|b*t+9QZ(o7A!G{%1N4EsAF-c5fVejr^)!KGNTfj}pN4wy}?cE8| zQ#E)D1*OXp*B`#on#tPia(&aA41u|&Tdx|O{r^tM{HW*i>81_unfsrwsOk0RcLgOE MPgg&ebxsLQ0D+nnegFUf literal 0 HcmV?d00001 diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/layout/hmi_view_passenger_v2n_event.xml b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/hmi_view_passenger_v2n_event.xml index c8e902495b..6fc547d18d 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/res/layout/hmi_view_passenger_v2n_event.xml +++ b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/hmi_view_passenger_v2n_event.xml @@ -4,7 +4,7 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="@dimen/dp_600" android:layout_height="wrap_content" - android:background="@drawable/bg_v2n_event_driver"> + android:background="@drawable/hmi_v2n_event_bg_passenger"> + + \ No newline at end of file diff --git a/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/road/RoadV2NEventWindowBean.kt b/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/road/RoadV2NEventWindowBean.kt new file mode 100644 index 0000000000..d94a964cbf --- /dev/null +++ b/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/road/RoadV2NEventWindowBean.kt @@ -0,0 +1,17 @@ +package com.mogo.eagle.core.data.road + +/** + * 路侧道路事件 弹框 + */ +data class RoadV2NEventWindowBean( + var uuid: String, //当前事件弹框 ID, show时生成,用于dismiss时使用 + var timestamp: Long = 0, //事件发生事件戳 + var iconResId: Int, //事件icon resource id + var hintStr: String, //事件提示文案 + var isNeedTTS: Boolean = false, //事件文案是否需要同步tts + var cameraIp: String // 路侧carema ip,用于请求获取拉流地址 +) { + override fun toString(): String { + return "RoadV2NEventWindowBean(id='$uuid', timestamp=$timestamp, iconResId=$iconResId, hintStr='$hintStr', isNeedTTS=$isNeedTTS, cameraIp='$cameraIp')" + } +} \ No newline at end of file diff --git a/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/hmi/v2n/IRoadV2NEventWindowListener.kt b/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/hmi/v2n/IRoadV2NEventWindowListener.kt new file mode 100644 index 0000000000..8d4244662c --- /dev/null +++ b/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/hmi/v2n/IRoadV2NEventWindowListener.kt @@ -0,0 +1,13 @@ +package com.mogo.eagle.core.function.api.hmi.v2n + +import com.mogo.eagle.core.data.road.RoadV2NEventWindowBean + +/** + * 路侧道路事件弹框, 调用接口 + */ +interface IRoadV2NEventWindowListener { + + fun show(dataBean: RoadV2NEventWindowBean) + + fun dismiss(eventId: String) +} \ No newline at end of file diff --git a/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/hmi/CallerRoadV2NEventWindowListenerManager.kt b/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/hmi/CallerRoadV2NEventWindowListenerManager.kt new file mode 100644 index 0000000000..266ccae0d6 --- /dev/null +++ b/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/hmi/CallerRoadV2NEventWindowListenerManager.kt @@ -0,0 +1,37 @@ +package com.mogo.eagle.core.function.call.hmi + +import com.mogo.eagle.core.data.road.RoadV2NEventWindowBean +import com.mogo.eagle.core.function.api.hmi.v2n.IRoadV2NEventWindowListener +import com.mogo.eagle.core.function.call.base.CallerBase +import java.util.UUID + +/** + * 路侧V2N事件弹框 调用者管理类 + */ +object CallerRoadV2NEventWindowListenerManager : CallerBase() { + + fun show( + timestamp: Long, + iconResId: Int, + hintStr: String, + isNeedTTS: Boolean, + cameraIp: String + ): String { + val uuid = UUID.randomUUID().toString() + val data = RoadV2NEventWindowBean(uuid, timestamp, iconResId, hintStr, isNeedTTS, cameraIp) + M_LISTENERS.forEach { + val listener = it.value + listener.show(data) + } + return uuid + } + + fun dismiss(uuid: String) { + M_LISTENERS.forEach { + val listener = it.value + listener.dismiss( + uuid + ) + } + } +} \ No newline at end of file