完成了预警红边的迁移HMI

调用方式为
//显示警告红边
mIMoGoWaringProvider!!.showWarning(direction)
This commit is contained in:
董宏宇
2021-09-10 22:02:24 +08:00
parent d6c348f1c7
commit 2efc04d1d1
31 changed files with 487 additions and 122 deletions

View File

@@ -1,6 +1,7 @@
package com.mogo.module.hmi.ui
import com.mogo.commons.mvp.IView
import com.mogo.module.data.enums.WarningDirectionEnum
/**
@@ -9,10 +10,6 @@ import com.mogo.commons.mvp.IView
*/
interface MoGoWarningContract {
/**
*
*/
interface View : IView {
/**
@@ -81,5 +78,20 @@ interface MoGoWarningContract {
* 关闭限速预警
*/
fun disableLimitingVelocity()
/**
* 展示指定方位上的红框预警
* @param direction
* @see WarningDirectionEnum
*/
fun showWarning(direction: WarningDirectionEnum)
/**
* 展示指定方位上的红框预警
* @param direction
* @see WarningDirectionEnum
* @param closeTime 倒计时
*/
fun showWarning(direction: WarningDirectionEnum, closeTime: Long)
}
}

View File

@@ -14,6 +14,7 @@ import com.mogo.module.hmi.notification.WarningFloat
import com.mogo.module.hmi.notification.anim.DefaultAnimator
import com.mogo.module.hmi.notification.enums.SidePattern
import com.mogo.module.hmi.ui.widget.V2XNotificationView
import com.mogo.module.data.enums.WarningDirectionEnum
import com.mogo.utils.logger.Logger
import kotlinx.android.synthetic.main.fragment_warning.*
@@ -95,7 +96,10 @@ class MoGoWarningFragment : MvpFragment<MoGoWarningContract.View?, WaringPresent
.show()
// 创建弹窗成功才进行TTS播报
Logger.d("MoGoWarningFragment", " mWarningFloat = " + mWarningFloat + "---ttsContent = " + ttsContent)
Logger.d(
"MoGoWarningFragment",
"mWarningFloat = $mWarningFloat---ttsContent = $ttsContent"
)
if (mWarningFloat != null && !TextUtils.isEmpty(ttsContent)) {
Logger.d("MoGoWarningFragment", "---> ttsContent = $ttsContent")
AIAssist.getInstance(activity)
@@ -171,4 +175,23 @@ class MoGoWarningFragment : MvpFragment<MoGoWarningContract.View?, WaringPresent
tvLimitingVelocity.visibility = View.GONE
tvLimitingVelocity.text = "0"
}
/**
* 展示指定方位上的红框预警
* @param direction
* @see WarningDirectionEnum
*/
override fun showWarning(direction: WarningDirectionEnum) {
flV2XWarningView.showWarning(direction)
}
/**
* 展示指定方位上的红框预警
* @param direction
* @see WarningDirectionEnum
* @param closeTime 倒计时
*/
override fun showWarning(direction: WarningDirectionEnum, closeTime: Long) {
flV2XWarningView.showWarning(direction, closeTime)
}
}

View File

@@ -10,27 +10,4 @@ class WaringPresenter(view: MoGoWarningContract.View?) :
Presenter<MoGoWarningContract.View?>(view) {
fun showWarningV2X(v2xType: Int, alertMessage: String, tag: String) {
}
fun disableWarningV2X(tag: String) {
mView?.disableWarningV2X(tag)
}
fun showWarningTrafficLight(checkLightId: Int) {
mView?.showWarningTrafficLight(checkLightId)
}
fun disableWarningTrafficLight() {
mView?.disableWarningTrafficLight()
}
fun showLimitingVelocity(limitingSpeed: Int) {
mView?.showLimitingVelocity(limitingSpeed)
}
fun disableLimitingVelocity() {
mView?.disableLimitingVelocity()
}
}

View File

@@ -0,0 +1,118 @@
package com.mogo.module.hmi.ui.widget
import android.content.Context
import android.util.AttributeSet
import android.view.LayoutInflater
import android.view.View
import android.widget.RelativeLayout
import com.mogo.module.data.enums.WarningDirectionEnum
import com.mogo.module.hmi.R
import com.mogo.utils.logger.Logger
import kotlinx.android.synthetic.main.module_hmi_warning_v2x.view.*
/**
*@author xiaoyuzhou
*@date 2021/9/10 7:44 下午
*/
class V2XWarningView @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0
) : RelativeLayout(context, attrs, defStyleAttr) {
private val ALL_CLOSE_TIMER = 10000L
private val closeWarningTask: Runnable = Runnable {
showWarning(WarningDirectionEnum.ALERT_WARNING_NON)
}
init {
LayoutInflater.from(context).inflate(R.layout.module_hmi_warning_v2x, this, true)
}
/**
* 展示指定方位上的红框预警
* @param direction
* @see WarningDirectionEnum
*/
fun showWarning(direction: WarningDirectionEnum) {
showWarning(direction, ALL_CLOSE_TIMER)
}
/**
* 展示指定方位上的红框预警
* @param direction
* @see WarningDirectionEnum
* @param closeTime 倒计时
*/
fun showWarning(direction: WarningDirectionEnum, closeTime: Long) {
Logger.d("V2XWarningView", "预警红边:预警方向->$direction 预警倒计时->$closeTime")
// 如果传入的不是关闭显示,则设置倒计时,定时关闭红框警示
if (direction != WarningDirectionEnum.ALERT_WARNING_NON) {
removeCallbacks(closeWarningTask)
postDelayed(closeWarningTask, closeTime)
}
when (direction) {
WarningDirectionEnum.ALERT_WARNING_NON -> {
hmiWarningTopImg.visibility = View.GONE
hmiWarningRightImg.visibility = View.GONE
hmiWarningBottomImg.visibility = View.GONE
hmiWarningLeftImg.visibility = View.GONE
}
WarningDirectionEnum.ALERT_WARNING_TOP -> {
hmiWarningTopImg.visibility = View.VISIBLE
hmiWarningRightImg.visibility = View.GONE
hmiWarningBottomImg.visibility = View.GONE
hmiWarningLeftImg.visibility = View.GONE
}
WarningDirectionEnum.ALERT_WARNING_RIGHT -> {
hmiWarningTopImg.visibility = View.GONE
hmiWarningRightImg.visibility = View.VISIBLE
hmiWarningBottomImg.visibility = View.GONE
hmiWarningLeftImg.visibility = View.GONE
}
WarningDirectionEnum.ALERT_WARNING_BOTTOM -> {
hmiWarningTopImg.visibility = View.GONE
hmiWarningRightImg.visibility = View.GONE
hmiWarningBottomImg.visibility = View.VISIBLE
hmiWarningLeftImg.visibility = View.GONE
}
WarningDirectionEnum.ALERT_WARNING_LEFT -> {
hmiWarningTopImg.visibility = View.GONE
hmiWarningRightImg.visibility = View.GONE
hmiWarningBottomImg.visibility = View.GONE
hmiWarningLeftImg.visibility = View.VISIBLE
}
WarningDirectionEnum.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 -> {
hmiWarningTopImg.visibility = View.GONE
hmiWarningRightImg.visibility = View.VISIBLE
hmiWarningBottomImg.visibility = View.VISIBLE
hmiWarningLeftImg.visibility = View.GONE
}
WarningDirectionEnum.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 -> {
hmiWarningTopImg.visibility = View.VISIBLE
hmiWarningRightImg.visibility = View.GONE
hmiWarningBottomImg.visibility = View.GONE
hmiWarningLeftImg.visibility = View.VISIBLE
}
WarningDirectionEnum.ALERT_WARNING_ALL -> {
hmiWarningTopImg.visibility = View.VISIBLE
hmiWarningRightImg.visibility = View.GONE
hmiWarningBottomImg.visibility = View.GONE
hmiWarningLeftImg.visibility = View.VISIBLE
}
}
}
}

View File

@@ -8,6 +8,7 @@ import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.mogo.module.data.enums.WarningDirectionEnum;
import com.mogo.module.hmi.WaringConst;
import com.mogo.module.hmi.ui.MoGoWarningFragment;
import com.mogo.service.MogoServicePaths;
@@ -101,4 +102,13 @@ public class MoGoWarningProvider implements IMoGoWaringProvider {
mMoGoWarningFragment.disableWarningV2X(tag);
}
@Override
public void showWarning(@NonNull WarningDirectionEnum direction) {
mMoGoWarningFragment.showWarning(direction);
}
@Override
public void showWarning(@NonNull WarningDirectionEnum direction, long closeTime) {
mMoGoWarningFragment.showWarning(direction, closeTime);
}
}

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:angle="90"
android:endColor="#00F03232"
android:startColor="#66FF0808"
android:type="linear"/>
</shape>

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:angle="0"
android:endColor="#00F03232"
android:startColor="#66FF0808"
android:type="linear"/>
</shape>

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:angle="180"
android:endColor="#00F03232"
android:startColor="#66FF0808"
android:type="linear"/>
</shape>

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:angle="270"
android:endColor="#00FF0606"
android:startColor="#66FF0808"
android:type="linear"/>
</shape>

View File

@@ -5,6 +5,15 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.mogo.module.hmi.ui.widget.V2XWarningView
android:id="@+id/flV2XWarningView"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<com.mogo.module.hmi.ui.widget.SpeedPanelView
android:id="@+id/flSpeedChartView"
android:layout_width="@dimen/module_ext_speed_width"

View File

@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!--四个方向,碰撞预警-->
<ImageView
android:id="@+id/hmiWarningTopImg"
android:layout_width="match_parent"
android:layout_height="@dimen/dp_290"
android:background="@drawable/module_hmi_warning_bkg_top"
android:visibility="gone"
tools:visibility="visible" />
<ImageView
android:id="@+id/hmiWarningLeftImg"
android:layout_width="@dimen/dp_290"
android:layout_height="match_parent"
android:background="@drawable/module_hmi_warning_bkg_left"
android:visibility="gone"
tools:visibility="visible" />
<ImageView
android:id="@+id/hmiWarningRightImg"
android:layout_width="@dimen/dp_290"
android:layout_height="match_parent"
android:layout_gravity="end"
android:background="@drawable/module_hmi_warning_bkg_right"
android:visibility="gone"
tools:visibility="visible" />
<ImageView
android:id="@+id/hmiWarningBottomImg"
android:layout_width="match_parent"
android:layout_height="@dimen/dp_290"
android:layout_gravity="bottom"
android:background="@drawable/module_hmi_warning_bkg_bottom"
android:visibility="gone"
tools:visibility="visible" />
</FrameLayout>