增加HMI中红绿灯View代理设置,setProxyTrafficLightView,代理View需要实现IViewTrafficLight抽象类

Signed-off-by: donghongyu <donghongyu@zhidaoauto.com>
This commit is contained in:
donghongyu
2022-03-11 19:04:03 +08:00
parent b1299cf805
commit 839df02f43
7 changed files with 143 additions and 41 deletions

View File

@@ -28,6 +28,7 @@ import com.mogo.eagle.core.data.enums.WarningDirectionEnum
import com.mogo.eagle.core.data.notice.NoticeNormalData
import com.mogo.eagle.core.data.notice.NoticeTrafficStylePushData
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotIdentifyListener
import com.mogo.eagle.core.function.api.hmi.view.IViewTrafficLight
import com.mogo.eagle.core.function.api.hmi.warning.IMoGoWaringProvider
import com.mogo.eagle.core.function.api.hmi.warning.IMoGoWarningStatusListener
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotManager
@@ -99,6 +100,10 @@ class MoGoHmiFragment : MvpFragment<MoGoWarningContract.View?, WaringPresenter?>
private var autoPilotBadCaseView: AutoPilotBadCaseView? = null
// HMI 视图控件代理
// 红绿灯View代理
private var mViewTrafficLightVr: IViewTrafficLight? = null
private var onBadCaseShow: (() -> View)? = null
private var onBadCaseHide: (() -> Unit)? = null
@@ -277,6 +282,8 @@ class MoGoHmiFragment : MvpFragment<MoGoWarningContract.View?, WaringPresenter?>
view.postDelayed({
activity?.let { CarcorderPreviewView.show(it) }
}, 1000)*/
setProxyTrafficLightView(viewTrafficLightVr)
}
@OptIn(ExperimentalCoroutinesApi::class)
@@ -299,7 +306,8 @@ class MoGoHmiFragment : MvpFragment<MoGoWarningContract.View?, WaringPresenter?>
}
}
if (record.type == 2 && (record.stat == 101 || record.stat == 100)) {
CallerMapDataCollectorManager.finish(record.id, record.stat, "", record.fileName ?: "", record.note ?: "")
CallerMapDataCollectorManager.finish(record.id, record.stat, "", record.fileName
?: "", record.note ?: "")
}
}
@@ -391,6 +399,10 @@ class MoGoHmiFragment : MvpFragment<MoGoWarningContract.View?, WaringPresenter?>
}
}
override fun setProxyTrafficLightView(view: IViewTrafficLight) {
mViewTrafficLightVr = view
}
private fun showBadCasesFloat(dismiss: (() -> Unit)?) {
Log.d("QQQ", "showBadCaseToolsFloat")
context?.let { it ->
@@ -597,6 +609,20 @@ class MoGoHmiFragment : MvpFragment<MoGoWarningContract.View?, WaringPresenter?>
} else {
setToolsViewVisibility(View.GONE)
}
// 控制 限速UI 展示
if (HmiBuildConfig.isShowLimitingVelocityView) {
showLimitingVelocity(View.VISIBLE)
} else {
showLimitingVelocity(View.GONE)
}
// 控制 红绿灯 展示
if (HmiBuildConfig.isShowTrafficLightView) {
setTrafficLightVrVisibility(View.VISIBLE)
} else {
setTrafficLightVrVisibility(View.GONE)
}
}
override fun getLayoutId(): Int {
@@ -615,6 +641,10 @@ class MoGoHmiFragment : MvpFragment<MoGoWarningContract.View?, WaringPresenter?>
viewSpeedChart?.visibility = visibility
}
override fun setTrafficLightVrVisibility(visibility: Int) {
mViewTrafficLightVr?.visibility = visibility
}
override fun setAutopilotStatusViewVisibility(visibility: Int) {
viewAutopilotStatus?.visibility = visibility
}
@@ -771,30 +801,30 @@ class MoGoHmiFragment : MvpFragment<MoGoWarningContract.View?, WaringPresenter?>
* @param checkLightId 0-都是默认不亮起1-红2-黄3-绿
*/
override fun showWarningTrafficLight(checkLightId: Int) {
viewTrafficLightVr?.showWarningTrafficLight(checkLightId)
mViewTrafficLightVr?.showWarningTrafficLight(checkLightId)
}
override fun isWarningTrafficLightShow(): Boolean {
return viewTrafficLightVr?.visibility == View.VISIBLE
return mViewTrafficLightVr?.visibility == View.VISIBLE
}
/**
* 关闭红绿灯预警展示,并重制灯态
*/
override fun disableWarningTrafficLight() {
viewTrafficLightVr?.disableWarningTrafficLight()
mViewTrafficLightVr?.disableWarningTrafficLight()
}
override fun changeCountdownRed(redNum: Int) {
viewTrafficLightVr?.changeCountdownRed(redNum)
mViewTrafficLightVr?.changeCountdownRed(redNum)
}
override fun changeCountdownYellow(yellowNum: Int) {
viewTrafficLightVr?.changeCountdownYellow(yellowNum)
mViewTrafficLightVr?.changeCountdownYellow(yellowNum)
}
override fun changeCountdownGreen(greenNum: Int) {
viewTrafficLightVr?.changeCountdownGreen(greenNum)
mViewTrafficLightVr?.changeCountdownGreen(greenNum)
}
/**
@@ -803,7 +833,7 @@ class MoGoHmiFragment : MvpFragment<MoGoWarningContract.View?, WaringPresenter?>
* @param greenNum 绿灯倒计时
*/
override fun changeCountdownTrafficLightNum(readNum: Int, yellowNum: Int, greenNum: Int) {
viewTrafficLightVr?.changeCountdownTrafficLightNum(readNum, yellowNum, greenNum)
mViewTrafficLightVr?.changeCountdownTrafficLightNum(readNum, yellowNum, greenNum)
}
/**
@@ -1106,9 +1136,9 @@ class MoGoHmiFragment : MvpFragment<MoGoWarningContract.View?, WaringPresenter?>
val tipsView = upgradeTipsView?.invoke()
//如果工控机处于“下载中”、“可升级(下载完成)”、“升级中”、“升级失败”状态时,工具箱入口显示红色角标
if (AdUpgradeStateHelper.showUpgradeTips(downloadStatus, upgradeStatus)) {
if (HmiBuildConfig.isShowUpgradeTipsView){
if (HmiBuildConfig.isShowUpgradeTipsView) {
viewUpgradeTips?.visibility = View.VISIBLE
}else{
} else {
tipsView?.let {
it.visibility = View.VISIBLE
}

View File

@@ -5,6 +5,7 @@ import android.util.AttributeSet
import android.view.LayoutInflater
import android.view.View
import androidx.constraintlayout.widget.ConstraintLayout
import com.mogo.eagle.core.function.api.hmi.view.IViewTrafficLight
import com.mogo.eagle.core.function.hmi.R
import com.mogo.eagle.core.utilcode.util.UiThreadHandler
import kotlinx.android.synthetic.main.view_traffic_light_vr.view.*
@@ -15,10 +16,10 @@ import kotlinx.android.synthetic.main.view_traffic_light_vr.view.*
* 红绿灯控件
*/
class TrafficLightView @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0
) : ConstraintLayout(context, attrs, defStyleAttr) {
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0
) : IViewTrafficLight(context, attrs, defStyleAttr) {
init {
@@ -30,7 +31,7 @@ class TrafficLightView @JvmOverloads constructor(
*
* @param checkLightId 0-都是默认1-红2-黄3-绿
*/
fun showWarningTrafficLight(checkLightId: Int) {
override fun showWarningTrafficLight(checkLightId: Int) {
UiThreadHandler.post {
visibility = View.VISIBLE
when (checkLightId) {
@@ -61,7 +62,7 @@ class TrafficLightView @JvmOverloads constructor(
/**
* 关闭红绿灯预警展示,并重制灯态
*/
fun disableWarningTrafficLight() {
override fun disableWarningTrafficLight() {
UiThreadHandler.post {
visibility = View.GONE
ctvRedTrafficLight.isChecked = false
@@ -79,7 +80,7 @@ class TrafficLightView @JvmOverloads constructor(
* @param yellowNum 黄灯倒计时
* @param greenNum 绿灯倒计时
*/
fun changeCountdownTrafficLightNum(readNum: Int, yellowNum: Int, greenNum: Int) {
override fun changeCountdownTrafficLightNum(readNum: Int, yellowNum: Int, greenNum: Int) {
UiThreadHandler.post {
changeCountdownGreen(readNum)
changeCountdownYellow(yellowNum)
@@ -87,7 +88,7 @@ class TrafficLightView @JvmOverloads constructor(
}
}
fun changeCountdownGreen(greenNum: Int) {
override fun changeCountdownGreen(greenNum: Int) {
UiThreadHandler.post {
if (greenNum > 0) {
ctvGreenTrafficLight.text = "$greenNum"
@@ -97,7 +98,7 @@ class TrafficLightView @JvmOverloads constructor(
}
}
fun changeCountdownYellow(yellowNum: Int) {
override fun changeCountdownYellow(yellowNum: Int) {
UiThreadHandler.post {
if (yellowNum > 0) {
ctvYellowTrafficLight.text = "$yellowNum"
@@ -107,7 +108,7 @@ class TrafficLightView @JvmOverloads constructor(
}
}
fun changeCountdownRed(redNum: Int) {
override fun changeCountdownRed(redNum: Int) {
UiThreadHandler.post {
if (redNum > 0) {
ctvRedTrafficLight.text = "$redNum"
@@ -117,5 +118,4 @@ class TrafficLightView @JvmOverloads constructor(
}
}
}