@@ -29,7 +29,9 @@ class MoGoHmiFragment : MvpFragment<MoGoWarningContract.View?, WaringPresenter?>
|
||||
|
||||
var mWarningFloat: WarningFloat.Builder? = null
|
||||
|
||||
override fun initViews() {}
|
||||
override fun initViews() {
|
||||
autopilotStatus.visibility = View.VISIBLE
|
||||
}
|
||||
|
||||
override fun getLayoutId(): Int {
|
||||
return R.layout.fragment_hmi
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
package com.mogo.eagle.core.function.hmi.ui.widget
|
||||
|
||||
import android.content.Context
|
||||
import android.content.res.TypedArray
|
||||
import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import com.mogo.eagle.core.function.hmi.R
|
||||
import com.mogo.eagle.core.utilcode.util.LogUtils
|
||||
import kotlinx.android.synthetic.main.view_autopilot_status.view.*
|
||||
|
||||
/**
|
||||
* @author xiaoyuzhou
|
||||
* @date 2021/9/22 3:59 下午
|
||||
* 自动驾驶状态按钮
|
||||
*/
|
||||
class AutoPilotStatusView @JvmOverloads constructor(
|
||||
context: Context,
|
||||
attrs: AttributeSet
|
||||
) : ConstraintLayout(context, attrs) {
|
||||
|
||||
private val TAG = "AutopilotStatusView"
|
||||
|
||||
private var mAutopilotStatus: Int = 0
|
||||
|
||||
init {
|
||||
val typedArray: TypedArray =
|
||||
context.obtainStyledAttributes(attrs, R.styleable.AutopilotStatusView)
|
||||
mAutopilotStatus = typedArray.getInt(R.styleable.AutopilotStatusView_autopilotStatus, 0)
|
||||
typedArray.recycle()
|
||||
|
||||
LogUtils.dTag(TAG, "autopilotStatus: $mAutopilotStatus")
|
||||
|
||||
initView(context)
|
||||
}
|
||||
|
||||
private fun initView(context: Context) {
|
||||
LayoutInflater.from(context).inflate(R.layout.view_autopilot_status, this, true)
|
||||
|
||||
val lp = LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)
|
||||
layoutParams = lp
|
||||
|
||||
setAutoPilotStatus(mAutopilotStatus)
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置自动驾驶状态
|
||||
* 0-// 不可自动驾驶,adas与工控机没有链接,或工控机异常
|
||||
* 1-// 可自动驾驶,目前处于人工干预状态
|
||||
* 2-// 自动驾驶中
|
||||
*/
|
||||
fun setAutoPilotStatus(autopilotStatus: Int) {
|
||||
mAutopilotStatus = autopilotStatus
|
||||
when (autopilotStatus) {
|
||||
0 -> {// 不可自动驾驶,adas与工控机没有链接,或工控机异常
|
||||
clAutopilotStatus.setBackgroundResource(R.drawable.module_hmi_autopilot_status_disabled_bg)
|
||||
tvStatusDes.setTextColor(resources.getColor(R.color.module_mogo_autopilot_status_disable))
|
||||
}
|
||||
1 -> {// 可自动驾驶,目前处于人工干预状态
|
||||
clAutopilotStatus.setBackgroundResource(R.drawable.module_hmi_autopilot_status_enable_bg)
|
||||
tvStatusDes.setTextColor(resources.getColor(R.color.module_mogo_autopilot_status_enable))
|
||||
}
|
||||
2 -> {// 自动驾驶中
|
||||
clAutopilotStatus.setBackgroundResource(R.drawable.module_hmi_autopilot_status_checked_bg)
|
||||
tvStatusDes.setTextColor(resources.getColor(R.color.module_mogo_autopilot_status_enable))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -18,12 +18,24 @@
|
||||
android:id="@+id/flSpeedChartView"
|
||||
android:layout_width="@dimen/module_ext_speed_width"
|
||||
android:layout_height="@dimen/module_ext_speed_height"
|
||||
android:layout_marginLeft="@dimen/dp_40"
|
||||
android:layout_marginTop="@dimen/dp_40"
|
||||
android:layout_marginLeft="@dimen/module_mogo_autopilot_status_margin_left"
|
||||
android:layout_marginTop="@dimen/module_ext_arcView_top"
|
||||
android:elevation="@dimen/dp_10"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<com.mogo.eagle.core.function.hmi.ui.widget.AutoPilotStatusView
|
||||
android:id="@+id/autopilotStatus"
|
||||
android:layout_width="@dimen/module_mogo_autopilot_status_bg_width"
|
||||
android:layout_height="@dimen/module_mogo_autopilot_status_bg_height"
|
||||
android:layout_marginTop="@dimen/module_mogo_autopilot_status_margin_top"
|
||||
android:elevation="@dimen/dp_10"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintLeft_toLeftOf="@+id/flSpeedChartView"
|
||||
app:layout_constraintTop_toBottomOf="@+id/flSpeedChartView"
|
||||
tools:autopilotStatus="running"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<com.mogo.eagle.core.function.hmi.ui.widget.TrafficLightView
|
||||
android:id="@+id/viewTrafficLightVr"
|
||||
android:layout_width="wrap_content"
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
<?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:id="@+id/clAutopilotStatus"
|
||||
android:layout_width="@dimen/module_mogo_autopilot_status_bg_width"
|
||||
android:layout_height="@dimen/module_mogo_autopilot_status_bg_height"
|
||||
android:background="@drawable/module_hmi_autopilot_status_bg">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/ivStatusIcon"
|
||||
android:layout_width="@dimen/module_mogo_autopilot_status_icon_width"
|
||||
android:layout_height="@dimen/module_mogo_autopilot_status_icon_width"
|
||||
android:layout_marginStart="@dimen/module_mogo_autopilot_status_icon_margin"
|
||||
android:src="@drawable/icon_autopilot_status"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvStatusDes"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/module_mogo_autopilot_status_text_margin_start"
|
||||
android:text="自动驾驶"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="@dimen/module_mogo_autopilot_status_text_size"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/ivStatusIcon"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
Reference in New Issue
Block a user