完成红绿灯、限速标志的接口封装以及自测触发
This commit is contained in:
@@ -7,10 +7,28 @@ package com.mogo.module.hmi;
|
||||
public class WaringConst {
|
||||
public static String MODULE_NAME = "MODULE_LEFT_PANEL";
|
||||
|
||||
// V2X 弹窗预警
|
||||
// 是否展示:true-展示,false-关闭
|
||||
public static String BROADCAST_V2X_IS_SHOW_EXTRA_KEY = "v2xIsShow";
|
||||
// 预警类型:@WarningTypeEnum
|
||||
public static String BROADCAST_V2X_TYPE_EXTRA_KEY = "v2xType";
|
||||
// 预警弹窗文字内容
|
||||
public static String BROADCAST_V2X_ALERT_CONTENT_EXTRA_KEY = "alertContent";
|
||||
// 预警弹窗TTS播报
|
||||
public static String BROADCAST_V2X_TTS_CONTENT_EXTRA_KEY = "ttsContent";
|
||||
// 弹窗标志,一个弹窗绑定一个标志,不可重复
|
||||
public static String BROADCAST_V2X_TAG_EXTRA_KEY = "tag";
|
||||
|
||||
// 交通的灯
|
||||
// 是否展示:true-展示,false-关闭
|
||||
public static String BROADCAST_V2X_TRAFFIC_LIGHT_IS_SHOW__EXTRA_KEY = "trafficLightIsShow";
|
||||
// 选中的交通等类型,red、yellow、green
|
||||
public static String BROADCAST_V2X_TRAFFIC_LIGHT_CHECK_TYPE_EXTRA_KEY = "trafficLightCheckType";
|
||||
|
||||
// 限速标志
|
||||
// 是否展示:true-展示,false-关闭
|
||||
public static String BROADCAST_V2X_LIMITING_VELOCITY_IS_SHOW__EXTRA_KEY = "limitingVelocityIsShow";
|
||||
// 限速的速度
|
||||
public static String BROADCAST_V2X_LIMITING_VELOCITY_SPEED__EXTRA_KEY = "limitingVelocitySpeed";
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
package com.mogo.module.hmi.receiver
|
||||
|
||||
import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import com.alibaba.android.arouter.launcher.ARouter
|
||||
import com.mogo.module.hmi.WaringConst
|
||||
import com.mogo.service.IMogoServiceApis
|
||||
import com.mogo.service.MogoServicePaths
|
||||
import com.mogo.service.warning.IMoGoWaringProvider
|
||||
import com.mogo.utils.logger.Logger
|
||||
|
||||
/**
|
||||
* V2X 预警广播接收。用于跨应用,跨进程,内部也可以通过这种方式 控制限速标志
|
||||
*
|
||||
* @author donghongyu
|
||||
*/
|
||||
class V2XLimitingVelocityBroadcastReceiver : BroadcastReceiver() {
|
||||
private var mContext: Context? = null
|
||||
|
||||
companion object {
|
||||
private const val TAG = "V2XLimitingVelocityBroadcastReceiver"
|
||||
private var mMogoServiceApis: IMogoServiceApis? = null
|
||||
private var mIMoGoWaringProvider: IMoGoWaringProvider? = null
|
||||
}
|
||||
|
||||
override fun onReceive(context: Context, intent: Intent) {
|
||||
try {
|
||||
mMogoServiceApis = ARouter.getInstance().build(MogoServicePaths.PATH_SERVICE_APIS)
|
||||
.navigation(context) as IMogoServiceApis
|
||||
mIMoGoWaringProvider = mMogoServiceApis!!.waringProviderApi
|
||||
mContext = context
|
||||
|
||||
val limitingVelocityIsShow =
|
||||
intent.getBooleanExtra(
|
||||
WaringConst.BROADCAST_V2X_LIMITING_VELOCITY_IS_SHOW__EXTRA_KEY,
|
||||
false
|
||||
)
|
||||
val limitingVelocitySpeed =
|
||||
intent.getIntExtra(
|
||||
WaringConst.BROADCAST_V2X_LIMITING_VELOCITY_SPEED__EXTRA_KEY,
|
||||
0
|
||||
)
|
||||
|
||||
Logger.d(
|
||||
TAG,
|
||||
"limitingVelocityIsShow:$limitingVelocityIsShow limitingVelocitySpeed:$limitingVelocitySpeed"
|
||||
)
|
||||
if (limitingVelocityIsShow) {
|
||||
// 分发场景
|
||||
dispatchShowWaring(limitingVelocitySpeed)
|
||||
} else {
|
||||
dispatchCloseWaring()
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 展示限速标志
|
||||
*
|
||||
* @param limitingVelocitySpeed 限速速度
|
||||
*/
|
||||
private fun dispatchShowWaring(limitingVelocitySpeed: Int) {
|
||||
mIMoGoWaringProvider!!.showLimitingVelocity(limitingVelocitySpeed)
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭限速标志
|
||||
*/
|
||||
private fun dispatchCloseWaring() {
|
||||
mIMoGoWaringProvider!!.disableLimitingVelocity()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package com.mogo.module.hmi.receiver
|
||||
|
||||
import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import com.alibaba.android.arouter.launcher.ARouter
|
||||
import com.mogo.module.hmi.WaringConst
|
||||
import com.mogo.service.IMogoServiceApis
|
||||
import com.mogo.service.MogoServicePaths
|
||||
import com.mogo.service.warning.IMoGoWaringProvider
|
||||
import com.mogo.utils.logger.Logger
|
||||
|
||||
/**
|
||||
* V2X 预警广播接收。用于跨应用,跨进程,内部也可以通过这种方式 触发红绿灯场景
|
||||
*
|
||||
* @author donghongyu
|
||||
*/
|
||||
class V2XTrafficLightBroadcastReceiver : BroadcastReceiver() {
|
||||
private var mContext: Context? = null
|
||||
|
||||
companion object {
|
||||
private const val TAG = "V2XTrafficLightBroadcastReceiver"
|
||||
private var mMogoServiceApis: IMogoServiceApis? = null
|
||||
private var mIMoGoWaringProvider: IMoGoWaringProvider? = null
|
||||
}
|
||||
|
||||
override fun onReceive(context: Context, intent: Intent) {
|
||||
try {
|
||||
mMogoServiceApis = ARouter.getInstance().build(MogoServicePaths.PATH_SERVICE_APIS)
|
||||
.navigation(context) as IMogoServiceApis
|
||||
mIMoGoWaringProvider = mMogoServiceApis!!.waringProviderApi
|
||||
mContext = context
|
||||
|
||||
val trafficLightIsShow =
|
||||
intent.getBooleanExtra(
|
||||
WaringConst.BROADCAST_V2X_TRAFFIC_LIGHT_IS_SHOW__EXTRA_KEY,
|
||||
false
|
||||
)
|
||||
val trafficLightCheckType =
|
||||
intent.getIntExtra(
|
||||
WaringConst.BROADCAST_V2X_TRAFFIC_LIGHT_CHECK_TYPE_EXTRA_KEY,
|
||||
0
|
||||
)
|
||||
|
||||
Logger.d(
|
||||
TAG,
|
||||
"trafficLightIsShow:$trafficLightIsShow trafficLightCheckType:$trafficLightCheckType"
|
||||
)
|
||||
if (trafficLightIsShow) {
|
||||
// 分发场景
|
||||
dispatchShowWaring(trafficLightCheckType)
|
||||
} else {
|
||||
dispatchCloseWaring()
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 展示交通灯
|
||||
*
|
||||
* @param trafficLightCheckType 选中的交通的灯 0-都是默认,1-红,2-黄,3-绿
|
||||
*/
|
||||
private fun dispatchShowWaring(trafficLightCheckType: Int) {
|
||||
mIMoGoWaringProvider!!.showWarningTrafficLight(trafficLightCheckType)
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭交通灯
|
||||
*/
|
||||
private fun dispatchCloseWaring() {
|
||||
mIMoGoWaringProvider!!.disableWarningTrafficLight()
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import com.alibaba.android.arouter.launcher.ARouter
|
||||
import com.mogo.module.common.enum.WarningTypeEnum
|
||||
import com.mogo.module.hmi.WaringConst
|
||||
import com.mogo.service.IMogoServiceApis
|
||||
import com.mogo.service.MogoServicePaths
|
||||
@@ -15,11 +16,11 @@ import com.mogo.utils.logger.Logger
|
||||
*
|
||||
* @author donghongyu
|
||||
*/
|
||||
class WarningBroadcastReceiver : BroadcastReceiver() {
|
||||
class V2XWarningBroadcastReceiver : BroadcastReceiver() {
|
||||
private var mContext: Context? = null
|
||||
|
||||
companion object {
|
||||
private const val TAG = "TestPanelBroadcastReceiver"
|
||||
private const val TAG = "V2XWarningBroadcastReceiver"
|
||||
private var mMogoServiceApis: IMogoServiceApis? = null
|
||||
private var mIMoGoWaringProvider: IMoGoWaringProvider? = null
|
||||
}
|
||||
@@ -78,6 +79,9 @@ class WarningBroadcastReceiver : BroadcastReceiver() {
|
||||
ttsContent: String?,
|
||||
tag: String?
|
||||
) {
|
||||
if (v2xType == WarningTypeEnum.WARNING_RED_LIGHT) {
|
||||
mIMoGoWaringProvider!!.showLimitingVelocity(1)
|
||||
}
|
||||
mIMoGoWaringProvider!!.showWarningV2X(
|
||||
v2xType,
|
||||
alertContent,
|
||||
@@ -13,6 +13,7 @@ import com.mogo.module.hmi.notification.anim.DefaultAnimator
|
||||
import com.mogo.module.hmi.notification.enums.SidePattern
|
||||
import com.mogo.module.hmi.ui.widget.ViewV2XNotification
|
||||
import com.mogo.module.hmi.utils.WarningUtils
|
||||
import kotlinx.android.synthetic.main.fragment_warning.*
|
||||
|
||||
/**
|
||||
* @author xiaoyuzhou
|
||||
@@ -98,19 +99,39 @@ class MoGoWarningFragment : MvpFragment<MoGoWarningContract.View?, WaringPresent
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 展示红绿灯预警
|
||||
*
|
||||
* @param checkLightId 0-都是默认,1-红,2-黄,3-绿
|
||||
*/
|
||||
override fun showWarningTrafficLight(checkLightId: Int) {
|
||||
|
||||
viewTrafficLightVr.showWarningTrafficLight(checkLightId)
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭红绿灯预警展示,并重制灯态
|
||||
*/
|
||||
override fun disableWarningTrafficLight() {
|
||||
|
||||
viewTrafficLightVr.disableWarningTrafficLight()
|
||||
}
|
||||
|
||||
/**
|
||||
* 控制展示限速标志及内容
|
||||
*/
|
||||
override fun showLimitingVelocity(limitingSpeed: Int) {
|
||||
|
||||
tvLimitingVelocity.visibility = View.VISIBLE
|
||||
if (limitingSpeed > 0) {
|
||||
tvLimitingVelocity.text = "$limitingSpeed"
|
||||
} else {
|
||||
tvLimitingVelocity.text = "0"
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 控制关闭限速标志及内容
|
||||
*/
|
||||
override fun disableLimitingVelocity() {
|
||||
|
||||
tvLimitingVelocity.visibility = View.GONE
|
||||
tvLimitingVelocity.text = "0"
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package com.mogo.module.hmi.ui.widget
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import com.mogo.module.hmi.R
|
||||
import kotlinx.android.synthetic.main.view_traffic_light_vr.view.*
|
||||
@@ -21,7 +22,6 @@ class ViewTrafficLight @JvmOverloads constructor(
|
||||
|
||||
init {
|
||||
LayoutInflater.from(context).inflate(R.layout.view_traffic_light_vr, this, true)
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -30,6 +30,7 @@ class ViewTrafficLight @JvmOverloads constructor(
|
||||
* @param checkLightId 0-都是默认,1-红,2-黄,3-绿
|
||||
*/
|
||||
fun showWarningTrafficLight(checkLightId: Int) {
|
||||
clTrafficLight.visibility = View.VISIBLE
|
||||
when (checkLightId) {
|
||||
0 -> {
|
||||
ctvRedTrafficLight.isChecked = false
|
||||
@@ -54,4 +55,14 @@ class ViewTrafficLight @JvmOverloads constructor(
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭红绿灯预警展示,并重制灯态
|
||||
*/
|
||||
fun disableWarningTrafficLight() {
|
||||
clTrafficLight.visibility = View.GONE
|
||||
ctvRedTrafficLight.isChecked = false
|
||||
ctvYellowTrafficLight.isChecked = false
|
||||
ctvGreenTrafficLight.isChecked = false
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user