[V2X]移除无用场景

This commit is contained in:
renwj
2022-02-10 19:44:53 +08:00
parent 898472b8a9
commit 8e5e2afd38
71 changed files with 275 additions and 6828 deletions

View File

@@ -582,70 +582,68 @@ class MoGoHmiFragment : MvpFragment<MoGoWarningContract.View?, WaringPresenter?>
* @param tag tag绑定弹窗的标志
*/
@Synchronized
override fun showWarningV2X(v2xType: Int, alertContent: String?, ttsContent: String?, tag: String?, listenerIMoGo: IMoGoWarningStatusListener?, playTts: Boolean, expireTime: Long) {
activity?.let {
val floatWindow = mWarningFloat
val showTag = floatWindow?.config?.floatTag
if (floatWindow == null || TextUtils.isEmpty(showTag)) {
val notificationView = V2XNotificationView(it)
notificationView.setWarningIcon(EventTypeEnum.getWarningIcon(v2xType.toString()))
val warningContent = alertContent ?: EventTypeEnum.getWarningContent(v2xType.toString())
if (warningContent.isEmpty()) {
Logger.e(TAG, "Show warningContent is null or empty!")
return
override fun showWarningV2X(v2xType: Int, alertContent: CharSequence?, ttsContent: String?, tag: String?, listenerIMoGo: IMoGoWarningStatusListener?, playTts: Boolean, expireTime: Long) {
lifecycleScope.launchWhenResumed {
activity?.let {
val floatWindow = mWarningFloat
val showTag = floatWindow?.config?.floatTag
if (floatWindow == null || TextUtils.isEmpty(showTag) || !floatWindow.isShow()) {
val notificationView = V2XNotificationView(it)
notificationView.setWarningIcon(EventTypeEnum.getWarningIcon(v2xType.toString()))
val warningContent = alertContent ?: EventTypeEnum.getWarningContent(v2xType.toString())
if (warningContent.isEmpty()) {
Logger.e(TAG, "Show warningContent is null or empty!")
return@launchWhenResumed
} else {
notificationView.setWarningContent(warningContent)
}
if (mWarningFloat != null && mWarningFloat!!.config.floatTag != tag) {
WarningFloat.dismiss(mWarningFloat!!.config.floatTag, true)
}
mWarningFloat = WarningFloat.with(it)
.setTag(tag)
.setLayout(notificationView)
.setSidePattern(SidePattern.RESULT_TOP)
.setCountDownTime(expireTime)
.setGravity(Gravity.CENTER_HORIZONTAL, offsetY = 110)
.setImmersionStatusBar(true)
.isEnqueue(true)
.addWarningStatusListener(listenerIMoGo)
.addWarningStatusListener(object : IMoGoWarningStatusListener {
override fun onShow() {
// 创建弹窗成功才进行TTS播报
Logger.d(
"MoGoWarningFragment",
"mWarningFloat = $mWarningFloat---ttsContent = $ttsContent"
)
if (mWarningFloat != null && !TextUtils.isEmpty(ttsContent) && playTts) {
Logger.d("MoGoWarningFragment", "---> ttsContent = $ttsContent")
AIAssist.getInstance(activity)
.speakTTSVoice(ttsContent)
}
}
})
.setAnimator(object : DefaultAnimator() {
override fun enterAnim(
view: View,
params: WindowManager.LayoutParams,
windowManager: WindowManager,
sidePattern: SidePattern
): Animator? =
super.enterAnim(view, params, windowManager, sidePattern)?.apply {
interpolator = OvershootInterpolator()
}
override fun exitAnim(
view: View,
params: WindowManager.LayoutParams,
windowManager: WindowManager,
sidePattern: SidePattern
): Animator? =
super.exitAnim(view, params, windowManager, sidePattern)?.setDuration(200)
})
.show()
} else {
notificationView.setWarningContent(warningContent)
}
if (mWarningFloat != null && mWarningFloat!!.config.floatTag != tag) {
WarningFloat.dismiss(mWarningFloat!!.config.floatTag, true)
}
mWarningFloat = WarningFloat.with(it)
.setTag(tag)
.setLayout(notificationView)
.setSidePattern(SidePattern.RESULT_TOP)
.setCountDownTime(expireTime)
.setGravity(Gravity.CENTER_HORIZONTAL, offsetY = 110)
.setImmersionStatusBar(true)
.isEnqueue(true)
.addWarningStatusListener(listenerIMoGo)
.addWarningStatusListener(object : IMoGoWarningStatusListener {
override fun onShow() {
// 创建弹窗成功才进行TTS播报
Logger.d(
"MoGoWarningFragment",
"mWarningFloat = $mWarningFloat---ttsContent = $ttsContent"
)
if (mWarningFloat != null && !TextUtils.isEmpty(ttsContent) && playTts) {
Logger.d("MoGoWarningFragment", "---> ttsContent = $ttsContent")
AIAssist.getInstance(activity)
.speakTTSVoice(ttsContent)
}
}
})
.setAnimator(object : DefaultAnimator() {
override fun enterAnim(
view: View,
params: WindowManager.LayoutParams,
windowManager: WindowManager,
sidePattern: SidePattern
): Animator? =
super.enterAnim(view, params, windowManager, sidePattern)?.apply {
interpolator = OvershootInterpolator()
}
override fun exitAnim(
view: View,
params: WindowManager.LayoutParams,
windowManager: WindowManager,
sidePattern: SidePattern
): Animator? =
super.exitAnim(view, params, windowManager, sidePattern)?.setDuration(200)
})
.show()
} else {
if (floatWindow.isShow()) {
val notification = floatWindow.config.layoutView as? V2XNotificationView
if (alertContent?.isNotEmpty() == true) {
notification?.setWarningContent(alertContent)
@@ -747,6 +745,10 @@ class MoGoHmiFragment : MvpFragment<MoGoWarningContract.View?, WaringPresenter?>
flV2XWarningView?.showWarning(direction, closeTime)
}
override fun dismissWarning(direction: WarningDirectionEnum) {
flV2XWarningView?.dismissWarning(direction)
}
/**
* 展示云公告顶部弹窗
* @param trafficStylePushData

View File

@@ -39,7 +39,7 @@ class V2XNotificationView @JvmOverloads constructor(
}
}
fun setWarningContent(@Nullable warningContent: String) {
fun setWarningContent(@Nullable warningContent: CharSequence) {
UiThreadHandler.post {
tvWaringContent.text = warningContent
}

View File

@@ -2,10 +2,21 @@ package com.mogo.eagle.core.function.hmi.ui.widget
import android.content.Context
import android.util.AttributeSet
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.widget.RelativeLayout
import com.mogo.eagle.core.data.enums.WarningDirectionEnum
import com.mogo.eagle.core.data.enums.WarningDirectionEnum.ALERT_WARNING_ALL
import com.mogo.eagle.core.data.enums.WarningDirectionEnum.ALERT_WARNING_BOTTOM
import com.mogo.eagle.core.data.enums.WarningDirectionEnum.ALERT_WARNING_BOTTOM_LEFT
import com.mogo.eagle.core.data.enums.WarningDirectionEnum.ALERT_WARNING_BOTTOM_RIGHT
import com.mogo.eagle.core.data.enums.WarningDirectionEnum.ALERT_WARNING_LEFT
import com.mogo.eagle.core.data.enums.WarningDirectionEnum.ALERT_WARNING_NON
import com.mogo.eagle.core.data.enums.WarningDirectionEnum.ALERT_WARNING_RIGHT
import com.mogo.eagle.core.data.enums.WarningDirectionEnum.ALERT_WARNING_TOP
import com.mogo.eagle.core.data.enums.WarningDirectionEnum.ALERT_WARNING_TOP_LEFT
import com.mogo.eagle.core.data.enums.WarningDirectionEnum.ALERT_WARNING_TOP_RIGHT
import com.mogo.eagle.core.function.hmi.R
import com.mogo.eagle.core.utilcode.mogo.logger.Logger
import com.mogo.eagle.core.utilcode.util.UiThreadHandler
@@ -25,7 +36,7 @@ class V2XWarningView @JvmOverloads constructor(
private val closeWarningTask: Runnable = Runnable {
Logger.d("V2XWarningView", "预警红边:倒计时结束")
showWarning(WarningDirectionEnum.ALERT_WARNING_NON)
showWarning(ALERT_WARNING_NON)
}
init {
@@ -52,67 +63,67 @@ class V2XWarningView @JvmOverloads constructor(
UiThreadHandler.post {
// 如果传入的不是关闭显示,则设置倒计时,定时关闭红框警示
if (direction != WarningDirectionEnum.ALERT_WARNING_NON) {
if (direction != ALERT_WARNING_NON) {
removeCallbacks(closeWarningTask)
postDelayed(closeWarningTask, closeTime)
}
when (direction) {
WarningDirectionEnum.ALERT_WARNING_NON -> {
ALERT_WARNING_NON -> {
removeCallbacks(closeWarningTask)
hmiWarningTopImg.visibility = View.GONE
hmiWarningRightImg.visibility = View.GONE
hmiWarningBottomImg.visibility = View.GONE
hmiWarningLeftImg.visibility = View.GONE
}
WarningDirectionEnum.ALERT_WARNING_TOP -> {
ALERT_WARNING_TOP -> {
hmiWarningTopImg.visibility = View.VISIBLE
hmiWarningRightImg.visibility = View.GONE
hmiWarningBottomImg.visibility = View.GONE
hmiWarningLeftImg.visibility = View.GONE
}
WarningDirectionEnum.ALERT_WARNING_RIGHT -> {
ALERT_WARNING_RIGHT -> {
hmiWarningTopImg.visibility = View.GONE
hmiWarningRightImg.visibility = View.VISIBLE
hmiWarningBottomImg.visibility = View.GONE
hmiWarningLeftImg.visibility = View.GONE
}
WarningDirectionEnum.ALERT_WARNING_BOTTOM -> {
ALERT_WARNING_BOTTOM -> {
hmiWarningTopImg.visibility = View.GONE
hmiWarningRightImg.visibility = View.GONE
hmiWarningBottomImg.visibility = View.VISIBLE
hmiWarningLeftImg.visibility = View.GONE
}
WarningDirectionEnum.ALERT_WARNING_LEFT -> {
ALERT_WARNING_LEFT -> {
hmiWarningTopImg.visibility = View.GONE
hmiWarningRightImg.visibility = View.GONE
hmiWarningBottomImg.visibility = View.GONE
hmiWarningLeftImg.visibility = View.VISIBLE
}
WarningDirectionEnum.ALERT_WARNING_TOP_RIGHT -> {
ALERT_WARNING_TOP_RIGHT -> {
hmiWarningTopImg.visibility = View.VISIBLE
hmiWarningRightImg.visibility = View.VISIBLE
hmiWarningBottomImg.visibility = View.GONE
hmiWarningLeftImg.visibility = View.GONE
}
WarningDirectionEnum.ALERT_WARNING_BOTTOM_RIGHT -> {
ALERT_WARNING_BOTTOM_RIGHT -> {
hmiWarningTopImg.visibility = View.GONE
hmiWarningRightImg.visibility = View.VISIBLE
hmiWarningBottomImg.visibility = View.VISIBLE
hmiWarningLeftImg.visibility = View.GONE
}
WarningDirectionEnum.ALERT_WARNING_BOTTOM_LEFT -> {
ALERT_WARNING_BOTTOM_LEFT -> {
hmiWarningTopImg.visibility = View.GONE
hmiWarningRightImg.visibility = View.GONE
hmiWarningBottomImg.visibility = View.VISIBLE
hmiWarningLeftImg.visibility = View.VISIBLE
}
WarningDirectionEnum.ALERT_WARNING_TOP_LEFT -> {
ALERT_WARNING_TOP_LEFT -> {
hmiWarningTopImg.visibility = View.VISIBLE
hmiWarningRightImg.visibility = View.GONE
hmiWarningBottomImg.visibility = View.GONE
hmiWarningLeftImg.visibility = View.VISIBLE
}
WarningDirectionEnum.ALERT_WARNING_ALL -> {
ALERT_WARNING_ALL -> {
hmiWarningTopImg.visibility = View.VISIBLE
hmiWarningRightImg.visibility = View.VISIBLE
hmiWarningBottomImg.visibility = View.VISIBLE
@@ -121,4 +132,50 @@ class V2XWarningView @JvmOverloads constructor(
}
}
}
fun dismissWarning(direction: WarningDirectionEnum) {
if (direction == ALERT_WARNING_NON) {
return
}
removeCallbacks(closeWarningTask)
when (direction) {
ALERT_WARNING_TOP -> {
hmiWarningTopImg.visibility = View.GONE
}
ALERT_WARNING_RIGHT -> {
hmiWarningRightImg.visibility = View.GONE
}
ALERT_WARNING_BOTTOM -> {
hmiWarningBottomImg.visibility = View.GONE
}
ALERT_WARNING_LEFT -> {
hmiWarningLeftImg.visibility = View.GONE
}
ALERT_WARNING_TOP_RIGHT -> {
hmiWarningTopImg.visibility = View.GONE
hmiWarningRightImg.visibility = View.GONE
}
ALERT_WARNING_BOTTOM_RIGHT -> {
hmiWarningRightImg.visibility = View.GONE
hmiWarningBottomImg.visibility = View.GONE
}
ALERT_WARNING_BOTTOM_LEFT -> {
hmiWarningBottomImg.visibility = View.GONE
hmiWarningLeftImg.visibility = View.GONE
}
ALERT_WARNING_TOP_LEFT -> {
hmiWarningTopImg.visibility = View.GONE
hmiWarningLeftImg.visibility = View.GONE
}
ALERT_WARNING_ALL -> {
hmiWarningTopImg.visibility = View.GONE
hmiWarningRightImg.visibility = View.GONE
hmiWarningBottomImg.visibility = View.GONE
hmiWarningLeftImg.visibility = View.GONE
}
else -> {
Log.d("XXX", "Not Support Direction")
}
}
}
}