[8.1.2][opt]新增决策的路口场景
This commit is contained in:
@@ -7,10 +7,15 @@ import android.os.SystemClock
|
|||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import androidx.constraintlayout.widget.ConstraintLayout
|
import androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
import chassis.Chassis
|
||||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotIdentifyListener
|
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotIdentifyListener
|
||||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotPlanningActionsListener
|
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotPlanningActionsListener
|
||||||
|
import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisStatesListener
|
||||||
|
import com.mogo.eagle.core.function.api.map.road.IMoGoMapRoadListener
|
||||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotIdentifyListenerManager
|
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotIdentifyListenerManager
|
||||||
|
import com.mogo.eagle.core.function.call.autopilot.CallerChassisStatesListenerManager
|
||||||
import com.mogo.eagle.core.function.call.autopilot.CallerPlanningActionsListenerManager
|
import com.mogo.eagle.core.function.call.autopilot.CallerPlanningActionsListenerManager
|
||||||
|
import com.mogo.eagle.core.function.call.map.CallerMapRoadListenerManager
|
||||||
import com.mogo.eagle.core.function.map.R
|
import com.mogo.eagle.core.function.map.R
|
||||||
import com.mogo.eagle.core.utilcode.util.ThreadUtils
|
import com.mogo.eagle.core.utilcode.util.ThreadUtils
|
||||||
import com.shuyu.gsyvideoplayer.GSYVideoManager
|
import com.shuyu.gsyvideoplayer.GSYVideoManager
|
||||||
@@ -19,6 +24,7 @@ import com.shuyu.gsyvideoplayer.model.VideoOptionModel
|
|||||||
import com.shuyu.gsyvideoplayer.player.IjkPlayerManager
|
import com.shuyu.gsyvideoplayer.player.IjkPlayerManager
|
||||||
import com.shuyu.gsyvideoplayer.player.PlayerFactory
|
import com.shuyu.gsyvideoplayer.player.PlayerFactory
|
||||||
import com.shuyu.gsyvideoplayer.utils.GSYVideoType
|
import com.shuyu.gsyvideoplayer.utils.GSYVideoType
|
||||||
|
import com.zhidaoauto.map.data.road.StopLine
|
||||||
import kotlinx.android.synthetic.main.layout_decision_container.view.tvPre1
|
import kotlinx.android.synthetic.main.layout_decision_container.view.tvPre1
|
||||||
import kotlinx.android.synthetic.main.layout_decision_container.view.tvPre2
|
import kotlinx.android.synthetic.main.layout_decision_container.view.tvPre2
|
||||||
import kotlinx.android.synthetic.main.layout_decision_container.view.tvPre3
|
import kotlinx.android.synthetic.main.layout_decision_container.view.tvPre3
|
||||||
@@ -36,7 +42,7 @@ class DecisionLayout @JvmOverloads constructor(
|
|||||||
context: Context,
|
context: Context,
|
||||||
attrs: AttributeSet? = null
|
attrs: AttributeSet? = null
|
||||||
) : ConstraintLayout(context, attrs), IMoGoAutopilotIdentifyListener,
|
) : ConstraintLayout(context, attrs), IMoGoAutopilotIdentifyListener,
|
||||||
IMoGoAutopilotPlanningActionsListener {
|
IMoGoAutopilotPlanningActionsListener, IMoGoMapRoadListener, IMoGoChassisStatesListener {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private const val TAG = "DecisionLayout"
|
private const val TAG = "DecisionLayout"
|
||||||
@@ -84,12 +90,16 @@ class DecisionLayout @JvmOverloads constructor(
|
|||||||
super.onAttachedToWindow()
|
super.onAttachedToWindow()
|
||||||
CallerAutopilotIdentifyListenerManager.addListener(TAG, this)
|
CallerAutopilotIdentifyListenerManager.addListener(TAG, this)
|
||||||
CallerPlanningActionsListenerManager.addListener(TAG, this)
|
CallerPlanningActionsListenerManager.addListener(TAG, this)
|
||||||
|
CallerMapRoadListenerManager.addListener(TAG, this)
|
||||||
|
CallerChassisStatesListenerManager.addListener(TAG, this)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDetachedFromWindow() {
|
override fun onDetachedFromWindow() {
|
||||||
super.onDetachedFromWindow()
|
super.onDetachedFromWindow()
|
||||||
CallerAutopilotIdentifyListenerManager.removeListener(TAG)
|
CallerAutopilotIdentifyListenerManager.removeListener(TAG)
|
||||||
CallerPlanningActionsListenerManager.removeListener(TAG)
|
CallerPlanningActionsListenerManager.removeListener(TAG)
|
||||||
|
CallerMapRoadListenerManager.removeListener(TAG)
|
||||||
|
CallerChassisStatesListenerManager.removeListener(TAG)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onCreate(savedInstanceState: Bundle?) {
|
fun onCreate(savedInstanceState: Bundle?) {
|
||||||
@@ -147,6 +157,53 @@ class DecisionLayout @JvmOverloads constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Volatile
|
||||||
|
private var turnLightStatus: Int = -1
|
||||||
|
override fun onAutopilotLightSwitchData(lightSwitch: Chassis.LightSwitch?) {
|
||||||
|
lightSwitch?.let {
|
||||||
|
turnLightStatus = when (it.number) {
|
||||||
|
Chassis.LightSwitch.LIGHT_LEFT_VALUE -> {
|
||||||
|
1
|
||||||
|
}
|
||||||
|
|
||||||
|
Chassis.LightSwitch.LIGHT_RIGHT_VALUE -> {
|
||||||
|
2
|
||||||
|
}
|
||||||
|
|
||||||
|
Chassis.LightSwitch.LIGHT_NONE_VALUE -> {
|
||||||
|
0
|
||||||
|
}
|
||||||
|
|
||||||
|
else -> {
|
||||||
|
-1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private var lastUpdateTime = 0L
|
||||||
|
override fun onStopLineInfo(info: StopLine) {
|
||||||
|
if (info.distance < 15) {
|
||||||
|
val time = System.currentTimeMillis()
|
||||||
|
if (time - lastUpdateTime > 500) {
|
||||||
|
lastUpdateTime = time
|
||||||
|
ThreadUtils.runOnUiThread {
|
||||||
|
when (turnLightStatus) {
|
||||||
|
0 -> {
|
||||||
|
updateAnim(8)
|
||||||
|
}
|
||||||
|
1 -> {
|
||||||
|
updateAnim(7)
|
||||||
|
}
|
||||||
|
2 -> {
|
||||||
|
updateAnim(9)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressLint("SetTextI18n")
|
@SuppressLint("SetTextI18n")
|
||||||
private fun updateAnim(type: Int) {
|
private fun updateAnim(type: Int) {
|
||||||
val randomNum = 80 + Random(SystemClock.elapsedRealtime()).nextInt(16)
|
val randomNum = 80 + Random(SystemClock.elapsedRealtime()).nextInt(16)
|
||||||
|
|||||||
Reference in New Issue
Block a user