[650]feat: 路侧事件弹框,增加caller 调用方式;

This commit is contained in:
aibingbing
2024-06-18 18:41:23 +08:00
parent 150e30f635
commit b7fa4ff81f
7 changed files with 131 additions and 14 deletions

View File

@@ -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
//停止播放
}
}
}

View File

@@ -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}"
)
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 689 B

View File

@@ -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">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/containerEvent"
@@ -83,4 +83,14 @@
app:layout_constraintTop_toBottomOf="@id/containerLivePlay"
tools:text="更新时间10:38:20" />
<ImageView
android:id="@+id/ivClose"
android:layout_width="@dimen/dp_32"
android:layout_height="@dimen/dp_32"
android:layout_marginTop="@dimen/dp_2"
android:layout_marginEnd="@dimen/dp_2"
android:padding="@dimen/dp_2"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</com.mogo.eagle.core.widget.RoundConstraintLayout>

View File

@@ -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')"
}
}

View File

@@ -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)
}

View File

@@ -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<IRoadV2NEventWindowListener>() {
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
)
}
}
}