修复同一个appid下但方向不同的事件提醒tts播报
This commit is contained in:
@@ -140,8 +140,12 @@ class WarningFloat {
|
||||
* 设置视图状态监听;show,dismiss
|
||||
* @param listener 设置视图状态监听
|
||||
*/
|
||||
fun setWarningStatusListener(listener: WarningStatusListener?) =
|
||||
apply { config.listener = listener }
|
||||
fun addWarningStatusListener(listener: WarningStatusListener?) =
|
||||
apply {
|
||||
if (listener != null) {
|
||||
config.statusListenerMap.add(listener)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建浮窗,包括Activity浮窗和系统浮窗,如若系统浮窗无权限,先进行权限申请
|
||||
|
||||
@@ -119,7 +119,9 @@ internal class WarningFloatWindowHelper(
|
||||
* 入场动画
|
||||
*/
|
||||
private fun enterAnim(floatingView: View) {
|
||||
config.listener?.onShow()
|
||||
config.statusListenerMap.forEach { listener ->
|
||||
listener.onShow()
|
||||
}
|
||||
if (frameLayout == null || config.isAnim) return
|
||||
enterAnimator = AnimatorManager(frameLayout!!, params, windowManager, config)
|
||||
.enterAnim()?.apply {
|
||||
@@ -158,7 +160,9 @@ internal class WarningFloatWindowHelper(
|
||||
* 退出动画
|
||||
*/
|
||||
fun exitAnim() {
|
||||
config.listener?.onDismiss()
|
||||
config.statusListenerMap.forEach { listener ->
|
||||
listener.onDismiss()
|
||||
}
|
||||
if (frameLayout == null || (config.isAnim && enterAnimator == null)) return
|
||||
enterAnimator?.cancel()
|
||||
val animator: Animator? =
|
||||
|
||||
@@ -54,7 +54,7 @@ data class WarningNotificationConfig(
|
||||
var floatAnimator: OnFloatAnimator? = DefaultAnimator(),
|
||||
|
||||
// 设置视图状态监听;show,dismiss
|
||||
var listener: WarningStatusListener? = null,
|
||||
var statusListenerMap: ArrayList< WarningStatusListener> = ArrayList(),
|
||||
|
||||
// Callbacks
|
||||
var callbacks: OnFloatCallbacks? = null,
|
||||
|
||||
@@ -66,7 +66,7 @@ class MoGoWarningFragment : MvpFragment<MoGoWarningContract.View?, WaringPresent
|
||||
)
|
||||
)
|
||||
|
||||
if (mWarningFloat != null) {
|
||||
if (mWarningFloat != null && mWarningFloat!!.config.floatTag != tag) {
|
||||
WarningFloat.dismiss(mWarningFloat!!.config.floatTag, true)
|
||||
}
|
||||
|
||||
@@ -77,7 +77,21 @@ class MoGoWarningFragment : MvpFragment<MoGoWarningContract.View?, WaringPresent
|
||||
//.setCountDownTime(10000)
|
||||
.setGravity(Gravity.CENTER_HORIZONTAL, offsetY = 110)
|
||||
.setImmersionStatusBar(true)
|
||||
.setWarningStatusListener(listener)
|
||||
.addWarningStatusListener(listener)
|
||||
.addWarningStatusListener(object : WarningStatusListener {
|
||||
override fun onShow() {
|
||||
// 创建弹窗成功才进行TTS播报
|
||||
Logger.d(
|
||||
"MoGoWarningFragment",
|
||||
"mWarningFloat = $mWarningFloat---ttsContent = $ttsContent"
|
||||
)
|
||||
if (mWarningFloat != null && !TextUtils.isEmpty(ttsContent)) {
|
||||
Logger.d("MoGoWarningFragment", "---> ttsContent = $ttsContent")
|
||||
AIAssist.getInstance(activity)
|
||||
.speakTTSVoice(ttsContent)
|
||||
}
|
||||
}
|
||||
})
|
||||
.setAnimator(object : DefaultAnimator() {
|
||||
override fun enterAnim(
|
||||
view: View,
|
||||
@@ -99,17 +113,6 @@ class MoGoWarningFragment : MvpFragment<MoGoWarningContract.View?, WaringPresent
|
||||
})
|
||||
.show()
|
||||
|
||||
// 创建弹窗成功才进行TTS播报
|
||||
Logger.d(
|
||||
"MoGoWarningFragment",
|
||||
"mWarningFloat = $mWarningFloat---ttsContent = $ttsContent"
|
||||
)
|
||||
if (mWarningFloat != null && !TextUtils.isEmpty(ttsContent)) {
|
||||
Logger.d("MoGoWarningFragment", "---> ttsContent = $ttsContent")
|
||||
AIAssist.getInstance(activity)
|
||||
.speakTTSVoice(ttsContent)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -54,6 +54,7 @@ class V2XWarningView @JvmOverloads constructor(
|
||||
}
|
||||
when (direction) {
|
||||
WarningDirectionEnum.ALERT_WARNING_NON -> {
|
||||
removeCallbacks(closeWarningTask)
|
||||
hmiWarningTopImg.visibility = View.GONE
|
||||
hmiWarningRightImg.visibility = View.GONE
|
||||
hmiWarningBottomImg.visibility = View.GONE
|
||||
|
||||
@@ -39,7 +39,6 @@ class MogoPrivateObuManager private constructor() {
|
||||
private var mIMoGoWaringProvider: IMoGoWaringProvider? = null
|
||||
private var mIMogoMapService: IMogoMapService? = null
|
||||
private var mContext: Context? = null
|
||||
private var isStrikeTts = false
|
||||
|
||||
fun init(context: Context?) {
|
||||
Logger.d(MogoObuConst.TAG_MOGO_OBU, "obuManager初始化--")
|
||||
@@ -250,39 +249,33 @@ class MogoPrivateObuManager private constructor() {
|
||||
ObuConstants.STATUS.UPDATE,// 更新
|
||||
-> {
|
||||
if (level == 2 || level == 3) {
|
||||
if (!isStrikeTts) {
|
||||
//显示警告红边
|
||||
mIMoGoWaringProvider!!.showWarning(direction)
|
||||
//显示弹框,语音提示
|
||||
mIMoGoWaringProvider!!.showWarningV2X(
|
||||
appId.toInt(),
|
||||
alertContent,
|
||||
ttsContent,
|
||||
appId,
|
||||
object : WarningStatusListener {
|
||||
override fun onShow() {
|
||||
isStrikeTts = true
|
||||
}
|
||||
|
||||
override fun onDismiss() {
|
||||
isStrikeTts = false
|
||||
}
|
||||
//显示警告红边
|
||||
mIMoGoWaringProvider!!.showWarning(direction)
|
||||
//显示弹框,语音提示
|
||||
mIMoGoWaringProvider!!.showWarningV2X(
|
||||
appId.toInt(),
|
||||
alertContent,
|
||||
ttsContent,// 只有第一次才tts,防止更新的时候不断的提醒
|
||||
(appId + direction.direction).toString(),//使用当前事件类型+方向记录tag,当发生变化的时候关闭当前弹出新的
|
||||
object : WarningStatusListener {
|
||||
override fun onDismiss() {
|
||||
// 关闭警告红边
|
||||
mIMoGoWaringProvider?.showWarning(WarningDirectionEnum.ALERT_WARNING_NON)
|
||||
}
|
||||
)
|
||||
// 更新数据
|
||||
TrafficDataConvertUtils.cvxRtiThreatIndInfo2TrafficData(info)?.let {
|
||||
TrafficMarkerDrawer.updateITrafficThreatLevelInfo(it)
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
// 更新数据
|
||||
TrafficDataConvertUtils.cvxRtiThreatIndInfo2TrafficData(info)?.let {
|
||||
TrafficMarkerDrawer.updateITrafficThreatLevelInfo(it)
|
||||
}
|
||||
}
|
||||
// 删除
|
||||
ObuConstants.STATUS.DELETE -> {
|
||||
isStrikeTts = false
|
||||
// 关闭警告红边
|
||||
mIMoGoWaringProvider!!.showWarning(WarningDirectionEnum.ALERT_WARNING_NON)
|
||||
mIMoGoWaringProvider?.showWarning(WarningDirectionEnum.ALERT_WARNING_NON)
|
||||
// 移除顶部弹窗
|
||||
mIMoGoWaringProvider?.disableWarningV2X(appId)
|
||||
mIMoGoWaringProvider?.disableWarningV2X((appId + direction.direction).toString())
|
||||
// 更新数据
|
||||
TrafficDataConvertUtils.cvxRtiThreatIndInfo2TrafficData(info)?.let {
|
||||
// 事件结束,还原车辆颜色
|
||||
@@ -347,34 +340,28 @@ class MogoPrivateObuManager private constructor() {
|
||||
ObuConstants.STATUS.UPDATE// 更新
|
||||
-> {
|
||||
if (level == 2 || level == 3) {
|
||||
if (!isStrikeTts) {
|
||||
// 更新数据
|
||||
TrafficDataConvertUtils.cvxPtcThreatIndInfo2TrafficData(info)?.let {
|
||||
TrafficMarkerDrawer.updateITrafficInfo(it)
|
||||
}
|
||||
//显示警告红边
|
||||
mIMoGoWaringProvider!!.showWarning(direction)
|
||||
mIMoGoWaringProvider!!.showWarningV2X(
|
||||
v2xType.toInt(),
|
||||
alertContent,
|
||||
ttsContent,
|
||||
v2xType,
|
||||
object : WarningStatusListener {
|
||||
override fun onShow() {
|
||||
isStrikeTts = true
|
||||
}
|
||||
|
||||
override fun onDismiss() {
|
||||
isStrikeTts = false
|
||||
}
|
||||
//显示警告红边
|
||||
mIMoGoWaringProvider?.showWarning(direction)
|
||||
mIMoGoWaringProvider?.showWarningV2X(
|
||||
v2xType.toInt(),
|
||||
alertContent,
|
||||
ttsContent,// 只有第一次才tts,防止更新的时候不断的提醒
|
||||
(v2xType + direction.direction).toString(),//使用当前事件类型+方向记录tag,当发生变化的时候关闭当前弹出新的
|
||||
object : WarningStatusListener {
|
||||
override fun onDismiss() {
|
||||
// 关闭警告红边
|
||||
mIMoGoWaringProvider!!.showWarning(WarningDirectionEnum.ALERT_WARNING_NON)
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
// 更新数据
|
||||
TrafficDataConvertUtils.cvxPtcThreatIndInfo2TrafficData(info)?.let {
|
||||
TrafficMarkerDrawer.updateITrafficInfo(it)
|
||||
}
|
||||
}
|
||||
// 删除
|
||||
ObuConstants.STATUS.DELETE -> {
|
||||
isStrikeTts = false
|
||||
// 关闭警告红边
|
||||
mIMoGoWaringProvider!!.showWarning(WarningDirectionEnum.ALERT_WARNING_NON)
|
||||
// 更新数据
|
||||
@@ -496,7 +483,9 @@ class MogoPrivateObuManager private constructor() {
|
||||
)
|
||||
when (status) {
|
||||
// 添加
|
||||
ObuConstants.STATUS.ADD -> {
|
||||
ObuConstants.STATUS.ADD,
|
||||
ObuConstants.STATUS.UPDATE,
|
||||
-> {
|
||||
changeTrafficLightStatus(appId, lights, indicator)
|
||||
}
|
||||
// 删除
|
||||
@@ -505,9 +494,6 @@ class MogoPrivateObuManager private constructor() {
|
||||
// 移除顶部弹窗
|
||||
mIMoGoWaringProvider?.disableWarningV2X(appId.toString())
|
||||
}
|
||||
else -> {
|
||||
changeTrafficLightStatus(appId, lights, indicator)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -540,15 +526,12 @@ class MogoPrivateObuManager private constructor() {
|
||||
mIMoGoWaringProvider!!.showWarningV2X(
|
||||
appId,
|
||||
alertContent,
|
||||
ttsContent,
|
||||
ttsContent,// 只有第一次才tts,防止更新的时候不断的提醒
|
||||
appId.toString(),
|
||||
object : WarningStatusListener {
|
||||
override fun onShow() {
|
||||
isStrikeTts = true
|
||||
}
|
||||
|
||||
override fun onDismiss() {
|
||||
isStrikeTts = false
|
||||
//关闭显示警告红边
|
||||
mIMoGoWaringProvider?.showWarning(WarningDirectionEnum.ALERT_WARNING_NON)
|
||||
}
|
||||
}
|
||||
)
|
||||
@@ -579,17 +562,9 @@ class MogoPrivateObuManager private constructor() {
|
||||
mIMoGoWaringProvider!!.showWarningV2X(
|
||||
EventTypeEnum.TYPE_USECASE_ID_IVP_GREEN.poiType.toInt(),
|
||||
alertContent,
|
||||
ttsContent,
|
||||
ttsContent,// 只有第一次才tts,防止更新的时候不断的提醒
|
||||
appId.toString(),
|
||||
object : WarningStatusListener {
|
||||
override fun onShow() {
|
||||
isStrikeTts = true
|
||||
}
|
||||
|
||||
override fun onDismiss() {
|
||||
isStrikeTts = false
|
||||
}
|
||||
}
|
||||
null
|
||||
)
|
||||
}
|
||||
// 黄灯
|
||||
@@ -714,29 +689,26 @@ class MogoPrivateObuManager private constructor() {
|
||||
// 添加,更新 add的时候,可能级别是2,
|
||||
ObuConstants.STATUS.ADD,
|
||||
ObuConstants.STATUS.UPDATE -> {
|
||||
Log.d(
|
||||
MogoObuConst.TAG_MOGO_OBU,
|
||||
"appId2 = $appId --- level = $level ---ttsContent = $ttsContent --- alertContent = $alertContent --- direction = $direction"
|
||||
)
|
||||
if (level == 2 || level == 3) {
|
||||
Log.d(
|
||||
MogoObuConst.TAG_MOGO_OBU,
|
||||
"appId2 = $appId --- level = $level ---ttsContent = $ttsContent --- alertContent = $alertContent --- direction = $direction"
|
||||
)
|
||||
//显示警告红边
|
||||
mIMoGoWaringProvider?.showWarning(direction)
|
||||
//显示弹框,语音提示
|
||||
mIMoGoWaringProvider?.showWarningV2X(
|
||||
appId,
|
||||
alertContent,
|
||||
if (!isStrikeTts) ttsContent else "",
|
||||
(appId + direction.direction).toString(),
|
||||
ttsContent,// 只有第一次才tts,防止更新的时候不断的提醒
|
||||
(appId + direction.direction).toString(),//使用当前事件类型+方向记录tag,当发生变化的时候关闭当前弹出新的
|
||||
object : WarningStatusListener {
|
||||
override fun onShow() {
|
||||
isStrikeTts = true
|
||||
}
|
||||
|
||||
override fun onDismiss() {
|
||||
isStrikeTts = false
|
||||
// 关闭警告红边
|
||||
mIMoGoWaringProvider!!.showWarning(WarningDirectionEnum.ALERT_WARNING_NON)
|
||||
}
|
||||
}
|
||||
)
|
||||
//显示警告红边
|
||||
mIMoGoWaringProvider?.showWarning(direction)
|
||||
}
|
||||
//更新周边车辆进行预警颜色变换,车辆实时移动和变色
|
||||
TrafficDataConvertUtils.cvxV2vThreatIndInfo2TrafficData(info)?.let {
|
||||
@@ -745,11 +717,10 @@ class MogoPrivateObuManager private constructor() {
|
||||
}
|
||||
// 删除
|
||||
ObuConstants.STATUS.DELETE -> {
|
||||
isStrikeTts = false
|
||||
// 关闭警告红边
|
||||
mIMoGoWaringProvider!!.showWarning(WarningDirectionEnum.ALERT_WARNING_NON)
|
||||
// 移除顶部弹窗
|
||||
mIMoGoWaringProvider?.disableWarningV2X(appId.toString())
|
||||
mIMoGoWaringProvider?.disableWarningV2X((appId + direction.direction).toString())
|
||||
//更新周边车辆进行预警颜色变换,车辆实时移动和变色
|
||||
TrafficDataConvertUtils.cvxV2vThreatIndInfo2TrafficData(info)?.let {
|
||||
it.threatLevel = 0x01
|
||||
|
||||
@@ -5,6 +5,9 @@ package com.mogo.service.warning;
|
||||
* @date 2021/9/13 4:41 下午
|
||||
*/
|
||||
public interface WarningStatusListener {
|
||||
void onShow();
|
||||
void onDismiss();
|
||||
default void onShow() {
|
||||
}
|
||||
|
||||
default void onDismiss() {
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user