[6.5.0]融合红绿灯额外提示
This commit is contained in:
@@ -153,6 +153,11 @@ class TrafficLightDispatcher : IMoGoAutopilotIdentifyListener, IMoGoTrafficLight
|
||||
convert(light.nextTwoState),light.nextTwoDuration.toInt(),
|
||||
DataSourceType.TELEMATIC_UNION_V2N
|
||||
)
|
||||
//当前灯态倒计时小于5S时,展示额外的提示框
|
||||
if(light.duration < 5){
|
||||
onTrafficLightPrompt(convert(light.state),light.duration.toInt())
|
||||
}
|
||||
//TODO 提示框的消失逻辑
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -264,6 +269,20 @@ class TrafficLightDispatcher : IMoGoAutopilotIdentifyListener, IMoGoTrafficLight
|
||||
CallerTrafficLightListenerManager.disableTrafficLight()
|
||||
}
|
||||
|
||||
/**
|
||||
* 融合V2N红绿灯额外提示框提醒
|
||||
*/
|
||||
@ChainLog(
|
||||
linkChainLog = ChainConstant.CHAIN_TYPE_SOCKET_TRAFFIC_LIGHT,
|
||||
linkCode = ChainConstant.CHAIN_SOURCE_ADAS,
|
||||
nodeAliasCode = ChainConstant.CHAIN_CODE_ADAS_TRAFFIC_LIGHT,
|
||||
paramIndexes = [0, 1])
|
||||
override fun onTrafficLightPrompt(currentState: TrafficLightEnum, currentDuration: Int) {
|
||||
super.onTrafficLightPrompt(currentState, currentDuration)
|
||||
Log.i("xuxinchao","融合V2N红绿灯额外提示框提醒 Dis")
|
||||
CallerTrafficLightListenerManager.onShowTrafficLightPrompt(currentState, currentDuration)
|
||||
}
|
||||
|
||||
/**
|
||||
* 融合V2N红绿灯数据,带有下一下二灯态
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,126 @@
|
||||
package com.mogo.eagle.core.function.hmi.ui.notice.traffic
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.util.Log
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.widget.TextView
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import androidx.core.content.ContextCompat
|
||||
import com.mogo.eagle.core.data.enums.TrafficLightEnum
|
||||
import com.mogo.eagle.core.function.api.datacenter.union.IMoGoTrafficLightListener
|
||||
import com.mogo.eagle.core.function.call.v2x.CallerTrafficLightListenerManager
|
||||
import com.mogo.eagle.core.function.hmi.R
|
||||
import com.mogo.eagle.core.function.hmi.ui.widget.TypefaceTextView
|
||||
import com.mogo.eagle.core.utilcode.util.ThreadUtils
|
||||
|
||||
/**
|
||||
* 融合红绿灯变灯提示
|
||||
* 鹰眼650需求
|
||||
*/
|
||||
class TrafficLightPromptView @JvmOverloads constructor(
|
||||
context: Context,
|
||||
attrs: AttributeSet? = null,
|
||||
defStyleAttr: Int = 0
|
||||
) : ConstraintLayout(context, attrs, defStyleAttr), IMoGoTrafficLightListener {
|
||||
|
||||
companion object {
|
||||
private const val TAG = "TrafficLightPromptView"
|
||||
}
|
||||
|
||||
private var user = 0 //使用方,driver:0 passenger:1
|
||||
private var tvPromptTitle: TextView ?= null
|
||||
private var tvPromptContent: TextView ?= null
|
||||
private var tvTrafficNum: TypefaceTextView ?= null
|
||||
private var tvTrafficNumDecimal: TypefaceTextView ?= null
|
||||
private val randomList = ArrayList<Float>()
|
||||
|
||||
init {
|
||||
val typedArray = context.obtainStyledAttributes(attrs, R.styleable.TrafficLightPromptView)
|
||||
user = typedArray.getInt(R.styleable.TrafficLightPromptView_promptUser,0)
|
||||
typedArray.recycle()
|
||||
}
|
||||
|
||||
override fun onAttachedToWindow() {
|
||||
super.onAttachedToWindow()
|
||||
if(user == 0){
|
||||
LayoutInflater.from(context).inflate(R.layout.view_traffic_light_prompt, this, true)
|
||||
tvPromptTitle = findViewById(R.id.tvPromptTitle)
|
||||
}else{
|
||||
LayoutInflater.from(context).inflate(R.layout.view_traffic_light_prompt_p, this, true)
|
||||
}
|
||||
tvPromptContent = findViewById(R.id.tvPromptContent)
|
||||
tvTrafficNum = findViewById(R.id.tvTrafficNum)
|
||||
tvTrafficNumDecimal = findViewById(R.id.tvTrafficNumDecimal)
|
||||
CallerTrafficLightListenerManager.addListener(TAG, this)
|
||||
|
||||
randomList.add(0.99f)
|
||||
randomList.add(0.72f)
|
||||
randomList.add(0.44f)
|
||||
randomList.add(0.21f)
|
||||
randomList.add(0.06f)
|
||||
|
||||
// tvPromptContent?.text = "请准备出发"
|
||||
// tvTrafficNum?.text = "12"
|
||||
// tvTrafficNumDecimal?.text = ".56"
|
||||
}
|
||||
|
||||
override fun onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow()
|
||||
CallerTrafficLightListenerManager.removeListener(TAG)
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 红绿灯额外提示框
|
||||
* @param currentState 当前灯态
|
||||
* @param currentDuration 当前灯态倒计时
|
||||
*/
|
||||
override fun onShowTrafficLightPrompt(currentState: TrafficLightEnum, currentDuration: Int) {
|
||||
super.onShowTrafficLightPrompt(currentState, currentDuration)
|
||||
Log.i("xuxinchao","TrafficLightPromptView onTrafficLightPrompt")
|
||||
Log.i("xuxinchao","onShowTrafficLightPrompt user="+user)
|
||||
ThreadUtils.runOnUiThread {
|
||||
when(currentState){
|
||||
TrafficLightEnum.GREEN->{
|
||||
this@TrafficLightPromptView.visibility = View.VISIBLE
|
||||
if(user == 0){
|
||||
tvTrafficNum?.setTextColor(ContextCompat.getColor(context,R.color.light_prompt_green))
|
||||
tvTrafficNumDecimal?.setTextColor(ContextCompat.getColor(context,R.color.light_prompt_green))
|
||||
}else{
|
||||
Log.i("xuxinchao","user="+user)
|
||||
tvTrafficNum?.setTextColor(ContextCompat.getColor(context,R.color.light_prompt_green_p))
|
||||
tvTrafficNumDecimal?.setTextColor(ContextCompat.getColor(context,R.color.light_prompt_green_p))
|
||||
}
|
||||
}
|
||||
TrafficLightEnum.RED->{
|
||||
this@TrafficLightPromptView.visibility = View.VISIBLE
|
||||
if(user == 0){
|
||||
tvTrafficNum?.setTextColor(ContextCompat.getColor(context,R.color.light_prompt_red))
|
||||
tvTrafficNumDecimal?.setTextColor(ContextCompat.getColor(context,R.color.light_prompt_red))
|
||||
}else{
|
||||
tvTrafficNum?.setTextColor(ContextCompat.getColor(context,R.color.light_prompt_red_p))
|
||||
tvTrafficNumDecimal?.setTextColor(ContextCompat.getColor(context,R.color.light_prompt_red_p))
|
||||
}
|
||||
}
|
||||
TrafficLightEnum.YELLOW->{
|
||||
this@TrafficLightPromptView.visibility = View.VISIBLE
|
||||
if(user == 0){
|
||||
tvTrafficNum?.setTextColor(ContextCompat.getColor(context,R.color.light_prompt_yellow))
|
||||
tvTrafficNumDecimal?.setTextColor(ContextCompat.getColor(context,R.color.light_prompt_yellow))
|
||||
}else{
|
||||
tvTrafficNum?.setTextColor(ContextCompat.getColor(context,R.color.light_prompt_yellow_p))
|
||||
tvTrafficNumDecimal?.setTextColor(ContextCompat.getColor(context,R.color.light_prompt_yellow_p))
|
||||
}
|
||||
}
|
||||
TrafficLightEnum.BLACK->{
|
||||
this@TrafficLightPromptView.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
tvTrafficNum?.text = currentDuration.toString()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 65 KiB |
@@ -0,0 +1,48 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="@dimen/dp_500"
|
||||
android:layout_height="@dimen/dp_144"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:background="@drawable/bg_light_prompt">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvPromptTitle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
android:layout_marginTop="@dimen/dp_30"
|
||||
android:layout_marginLeft="@dimen/dp_150"
|
||||
android:textSize="@dimen/sp_30"
|
||||
android:textColor="@color/white"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvPromptContent"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvPromptTitle"
|
||||
app:layout_constraintLeft_toLeftOf="@id/tvPromptTitle"
|
||||
android:textSize="@dimen/sp_21"
|
||||
android:textColor="@color/white"
|
||||
/>
|
||||
|
||||
<com.mogo.eagle.core.function.hmi.ui.widget.TypefaceTextView
|
||||
android:id="@+id/tvTrafficNumDecimal"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="@id/tvPromptContent"
|
||||
android:textSize="@dimen/sp_30"
|
||||
/>
|
||||
|
||||
<com.mogo.eagle.core.function.hmi.ui.widget.TypefaceTextView
|
||||
android:id="@+id/tvTrafficNum"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintBottom_toBottomOf="@id/tvTrafficNumDecimal"
|
||||
app:layout_constraintRight_toLeftOf="@id/tvTrafficNumDecimal"
|
||||
android:textSize="@dimen/sp_76"
|
||||
/>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -0,0 +1,38 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="@dimen/dp_650"
|
||||
android:layout_height="@dimen/dp_200"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:background="@drawable/bg_light">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvPromptContent"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
android:textSize="@dimen/sp_32"
|
||||
android:textColor="@color/light_prompt_content"
|
||||
android:layout_marginTop="@dimen/dp_50"
|
||||
android:layout_marginStart="@dimen/dp_50"
|
||||
/>
|
||||
|
||||
<com.mogo.eagle.core.function.hmi.ui.widget.TypefaceTextView
|
||||
android:id="@+id/tvTrafficNum"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintBottom_toBottomOf="@id/tvPromptContent"
|
||||
app:layout_constraintLeft_toRightOf="@id/tvPromptContent"
|
||||
android:textSize="@dimen/sp_76"
|
||||
/>
|
||||
|
||||
<com.mogo.eagle.core.function.hmi.ui.widget.TypefaceTextView
|
||||
android:id="@+id/tvTrafficNumDecimal"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintBottom_toBottomOf="@id/tvTrafficNum"
|
||||
app:layout_constraintLeft_toRightOf="@id/tvTrafficNum"
|
||||
android:textSize="@dimen/sp_30"
|
||||
/>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -129,4 +129,11 @@
|
||||
</attr>
|
||||
</declare-styleable>
|
||||
|
||||
<declare-styleable name="TrafficLightPromptView">
|
||||
<attr name="promptUser">
|
||||
<enum name="driver" value="0"/>
|
||||
<enum name="passenger" value="1"/>
|
||||
</attr>
|
||||
</declare-styleable>
|
||||
|
||||
</resources>
|
||||
@@ -92,4 +92,12 @@
|
||||
<color name="summary_danger_num">#106FF0</color>
|
||||
<color name="summary_tip">#42464F</color>
|
||||
|
||||
<color name="light_prompt_content">#131415 </color>
|
||||
<color name="light_prompt_red">#FF3B2D</color>
|
||||
<color name="light_prompt_green">#31FF56</color>
|
||||
<color name="light_prompt_yellow">#FFCD3D</color>
|
||||
<color name="light_prompt_red_p">#F63C12</color>
|
||||
<color name="light_prompt_green_p">#36DB1C</color>
|
||||
<color name="light_prompt_yellow_p">#FDB700</color>
|
||||
|
||||
</resources>
|
||||
@@ -30,6 +30,11 @@ interface IMoGoTrafficLightListener {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 红绿灯额外提示框
|
||||
*/
|
||||
fun onTrafficLightPrompt(currentState: TrafficLightEnum,currentDuration: Int){}
|
||||
|
||||
/**
|
||||
* 融合红绿灯,带有下一灯态和下二灯态
|
||||
*/
|
||||
@@ -57,6 +62,13 @@ interface IMoGoTrafficLightListener {
|
||||
*/
|
||||
fun showTrafficLight(checkLightId: TrafficLightEnum, lightSource: DataSourceType) {}
|
||||
|
||||
/**
|
||||
* 红绿灯额外提示框
|
||||
* @param currentState 当前灯态
|
||||
* @param currentDuration 当前灯态倒计时
|
||||
*/
|
||||
fun onShowTrafficLightPrompt(currentState: TrafficLightEnum,currentDuration: Int){}
|
||||
|
||||
/**
|
||||
* 展示融合带有下一下二灯态的红绿灯
|
||||
* @param currentState 当前灯态
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.mogo.eagle.core.function.call.v2x
|
||||
|
||||
import android.util.Log
|
||||
import com.mogo.eagle.core.data.enums.DataSourceType
|
||||
import com.mogo.eagle.core.data.enums.TrafficLightEnum
|
||||
import com.mogo.eagle.core.data.biz.trafficlight.TrafficLightResult
|
||||
@@ -71,6 +72,18 @@ object CallerTrafficLightListenerManager : CallerBase<IMoGoTrafficLightListener>
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 红绿灯额外提示框
|
||||
* @param currentState 当前灯态
|
||||
* @param currentDuration 当前灯态倒计时
|
||||
*/
|
||||
fun onShowTrafficLightPrompt(currentState: TrafficLightEnum,currentDuration: Int){
|
||||
M_LISTENERS.forEach{
|
||||
val listener = it.value
|
||||
listener.onShowTrafficLightPrompt(currentState,currentDuration)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 展示融合带有下一下二灯态的红绿灯
|
||||
* @param currentState 当前灯态
|
||||
|
||||
Reference in New Issue
Block a user