[M2] M2 添加pnc,转向,红绿灯组件
This commit is contained in:
@@ -26,8 +26,6 @@ class PM2DrivingInfoFragment :
|
||||
}
|
||||
|
||||
override fun initViews() {
|
||||
//设置红绿灯代理
|
||||
// CallerHmiManager.INSTANCE.setProxyTrafficLightView(mTrafficLightView);
|
||||
}
|
||||
|
||||
override fun initViews(savedInstanceState: Bundle?) {
|
||||
|
||||
@@ -1,148 +0,0 @@
|
||||
package com.mogo.och.bus.passenger.ui.widget
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
import android.widget.ImageView
|
||||
import com.mogo.eagle.core.function.api.hmi.view.IViewTrafficLight
|
||||
import com.mogo.eagle.core.utilcode.util.UiThreadHandler
|
||||
import com.mogo.och.bus.passenger.R
|
||||
import com.mogo.och.common.module.wigets.OCHGradientTextView
|
||||
|
||||
/**
|
||||
* @author: wangmingjun
|
||||
* @date: 2023/2/2
|
||||
*/
|
||||
class M2TrafficLightView(context: Context?, attrs: AttributeSet?, defStyleAttr: Int)
|
||||
: IViewTrafficLight(context,
|
||||
attrs, defStyleAttr){
|
||||
|
||||
private var mLightIconIV: ImageView? = null
|
||||
private var mLightTimeTV: OCHGradientTextView? = null
|
||||
private var mCurrentLightId = 0
|
||||
|
||||
private fun init(context: Context) {
|
||||
LayoutInflater.from(context).inflate(R.layout.p_m2_traffic_light_view, this, true)
|
||||
mLightIconIV = findViewById(R.id.bus_traffic_light_iv)
|
||||
mLightTimeTV = findViewById(R.id.bus_traffic_light_time_tv)
|
||||
}
|
||||
|
||||
/**
|
||||
* 展示红绿灯预警
|
||||
*
|
||||
* @param checkLightId 0-都是默认,1-红,2-黄,3-绿
|
||||
* @param lightSource 1:云端下发;2:自车感知
|
||||
*/
|
||||
override fun showWarningTrafficLight(checkLightId: Int, lightSource: Int) {
|
||||
super.showWarningTrafficLight(checkLightId, lightSource)
|
||||
mCurrentLightId = checkLightId
|
||||
updateTrafficLightIcon(checkLightId)
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭红绿灯预警展示,并重制灯态
|
||||
*/
|
||||
override fun disableWarningTrafficLight() {
|
||||
super.disableWarningTrafficLight()
|
||||
UiThreadHandler.post {
|
||||
mCurrentLightId = 0
|
||||
visibility = GONE
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param redNum 红灯倒计时
|
||||
* @param yellowNum 黄灯倒计时
|
||||
* @param greenNum 绿灯倒计时
|
||||
*/
|
||||
override fun changeCountdownTrafficLightNum(redNum: Int, yellowNum: Int, greenNum: Int) {
|
||||
super.changeCountdownTrafficLightNum(redNum, yellowNum, greenNum)
|
||||
when (mCurrentLightId) {
|
||||
1 -> changeCountdownRed(redNum)
|
||||
2 -> changeCountdownYellow(yellowNum)
|
||||
3 -> changeCountdownGreen(greenNum)
|
||||
else -> UiThreadHandler.post {
|
||||
mLightTimeTV!!.text = ""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun changeCountdownRed(redNum: Int) {
|
||||
super.changeCountdownRed(redNum)
|
||||
UiThreadHandler.post {
|
||||
if (redNum > 0) {
|
||||
mLightTimeTV!!.setVertrial(true)
|
||||
mLightTimeTV!!.setmColorList(
|
||||
intArrayOf(
|
||||
resources.getColor(R.color.bus_traffic_light_red_color_up),
|
||||
resources.getColor(R.color.bus_traffic_light_red_color_down)
|
||||
)
|
||||
)
|
||||
mLightTimeTV!!.text = redNum.toString()
|
||||
} else {
|
||||
mLightTimeTV!!.text = ""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun changeCountdownGreen(greenNum: Int) {
|
||||
super.changeCountdownGreen(greenNum)
|
||||
UiThreadHandler.post {
|
||||
if (greenNum > 0) {
|
||||
mLightTimeTV!!.setVertrial(true)
|
||||
mLightTimeTV!!.setmColorList(
|
||||
intArrayOf(
|
||||
resources.getColor(R.color.bus_traffic_light_green_color_up),
|
||||
resources.getColor(R.color.bus_traffic_light_green_color_down)
|
||||
)
|
||||
)
|
||||
mLightTimeTV!!.text = greenNum.toString()
|
||||
} else {
|
||||
mLightTimeTV!!.text = ""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun changeCountdownYellow(yellowNum: Int) {
|
||||
super.changeCountdownYellow(yellowNum)
|
||||
UiThreadHandler.post {
|
||||
if (yellowNum > 0) {
|
||||
mLightTimeTV!!.setVertrial(true)
|
||||
mLightTimeTV!!.setmColorList(
|
||||
intArrayOf(
|
||||
resources.getColor(R.color.bus_traffic_light_yellow_color_up),
|
||||
resources.getColor(R.color.bus_traffic_light_yellow_color_down)
|
||||
)
|
||||
)
|
||||
mLightTimeTV!!.text = yellowNum.toString()
|
||||
} else {
|
||||
mLightTimeTV!!.text = ""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新红绿灯icon
|
||||
*
|
||||
* @param lightId 0-都是默认,1-红,2-黄,3-绿
|
||||
*/
|
||||
private fun updateTrafficLightIcon(lightId: Int) {
|
||||
UiThreadHandler.post {
|
||||
when (lightId) {
|
||||
1 -> {
|
||||
mLightIconIV!!.setBackgroundResource(R.drawable.bus_light_red_nor)
|
||||
visibility = VISIBLE
|
||||
}
|
||||
2 -> {
|
||||
mLightIconIV!!.setBackgroundResource(R.drawable.bus_lightyellow_nor)
|
||||
visibility = VISIBLE
|
||||
}
|
||||
3 -> {
|
||||
mLightIconIV!!.setBackgroundResource(R.drawable.bus_light_green_nor)
|
||||
visibility = VISIBLE
|
||||
}
|
||||
else -> visibility = GONE
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<!-- 行车卡片--><!-- 全览地图带站点-->
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
@@ -11,7 +12,16 @@
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
android:text="这是driving"
|
||||
android:textSize="@dimen/dp_60"/>
|
||||
<!-- 行车卡片--><!-- 全览地图带站点-->
|
||||
|
||||
<!-- 红绿灯-->
|
||||
<!-- <com.mogo.eagle.core.function.hmi.ui.widget.SingleTrafficLightView/>-->
|
||||
|
||||
<!-- 转向灯 IMoGoChassisLamplightListener-->
|
||||
|
||||
<!-- <com.mogo.eagle.core.function.hmi.ui.turnlight.TurnLightViewStatus-->
|
||||
<!-- android:layout_width="wrap_content"-->
|
||||
<!-- android:layout_height="wrap_content" />-->
|
||||
|
||||
<com.mogo.eagle.core.function.overview.view.OverMapView
|
||||
android:id="@+id/overMapView"
|
||||
android:layout_width="match_parent"
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<!-- 图片或视频广告-->
|
||||
<!-- 高精地图 消息盒子-->
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
@@ -13,4 +13,13 @@
|
||||
android:text="这是hdMap"
|
||||
android:textSize="@dimen/dp_60"/>
|
||||
|
||||
<!-- 消息盒子气泡 -->
|
||||
<!--<com.mogo.eagle.core.function.hmi.ui.msgbox.PassengerMsgBoxBubbleView-->
|
||||
<!-- android:layout_width=""-->
|
||||
<!-- android:layout_height=""/>-->
|
||||
|
||||
<!--pnc行为决策-->
|
||||
<!-- <com.mogo.eagle.core.function.hmi.ui.vehicle.PncActionsView-->
|
||||
<!-- android:layout_width=""-->
|
||||
<!-- android:layout_height=""/>-->
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -1,35 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="@dimen/dp_225"
|
||||
android:layout_height="@dimen/dp_154"
|
||||
android:visibility="visible">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="@dimen/dp_210"
|
||||
android:layout_height="@dimen/dp_120"
|
||||
android:background="@drawable/bg_p_m2_traffic_light_background"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
android:layout_marginLeft="@dimen/dp_15"
|
||||
android:layout_marginTop="@dimen/dp_17"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/bus_traffic_light_iv"
|
||||
android:layout_width="@dimen/dp_154"
|
||||
android:layout_height="@dimen/dp_154"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"/>
|
||||
|
||||
<com.mogo.och.common.module.wigets.OCHGradientTextView
|
||||
android:id="@+id/bus_traffic_light_time_tv"
|
||||
android:layout_width="@dimen/dp_130"
|
||||
android:layout_height="match_parent"
|
||||
android:textSize="@dimen/dp_60"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
android:gravity="center" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
Reference in New Issue
Block a user