[Sweeper-Cloud]

feat: “请求进入自动驾驶”按钮根据自驾状态切换背景和字体颜色;
feat: 修改文案 正在作业->任务执行中,暂未准备->任务待开始,当前作业模式->当前上装作业;
This commit is contained in:
aibingbing
2023-06-16 15:52:15 +08:00
parent 0a2fa12244
commit 3b467a517e
4 changed files with 67 additions and 14 deletions

View File

@@ -122,6 +122,11 @@ class SweeperFragment : BaseSweeperTabFragment<SweeperFragment?, SweeperPresente
}
}
override fun setAutoState(state: Int) {
super.setAutoState(state)
getCurrentView().updateStartAutoPilotBtnState(state)
}
fun onSweeperFutianCleanSystemState(cleanSystemState: ChassisStatesOuterClass.SweeperFuTianTaskSystemStates) {
mCleanSystemState = cleanSystemState
sweeper_cl_work_mode.setSweeperFutianCleanSystemState(mSubTaskType, cleanSystemState)

View File

@@ -1,11 +1,13 @@
package com.mogo.och.sweepercloud.view
import android.content.Context
import android.graphics.Color
import android.util.AttributeSet
import android.view.LayoutInflater
import android.view.View
import android.widget.TextView
import androidx.constraintlayout.widget.ConstraintLayout
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener
import com.mogo.och.common.module.utils.DateTimeUtil
import com.mogo.och.sweepercloud.R
import com.zhjt.mogo.adas.data.sweeper.common.SweeperCommon.TaskStatus
@@ -27,8 +29,20 @@ class SweeperCurrentTaskInfoView : ConstraintLayout {
initView(context)
}
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super(context, attrs, defStyleAttr) {}
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int, defStyleRes: Int) : super(context, attrs, defStyleAttr, defStyleRes) {}
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super(
context,
attrs,
defStyleAttr
) {
}
constructor(
context: Context,
attrs: AttributeSet?,
defStyleAttr: Int,
defStyleRes: Int
) : super(context, attrs, defStyleAttr, defStyleRes) {
}
private fun initView(context: Context) {
LayoutInflater.from(context).inflate(R.layout.sweeper_current_task_info, this)
@@ -39,6 +53,34 @@ class SweeperCurrentTaskInfoView : ConstraintLayout {
return tvStartAuto
}
/**
* 根据当前自动驾驶状态,更新【请求进入自动驾驶】按钮样式
*/
fun updateStartAutoPilotBtnState(autopilotState: Int) {
when (autopilotState) {
//不可自动驾驶
IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE -> {
tvStartAuto.setTextColor(Color.parseColor("#66FFFFFF"))
tvStartAuto.isSelected = false
}
//人工驾驶
IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE -> {
tvStartAuto.setTextColor(Color.parseColor("#FFFFFFFF"))
tvStartAuto.isSelected = true
}
//自动驾驶中
IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING -> {
tvStartAuto.setTextColor(Color.parseColor("#66FFFFFF"))
tvStartAuto.isSelected = false
}
//平行驾驶
IMoGoAutopilotStatusListener.STATUS_PARALLEL_DRIVING -> {
tvStartAuto.setTextColor(Color.parseColor("#66FFFFFF"))
tvStartAuto.isSelected = false
}
}
}
/**
* 设置当前任务数据
*/
@@ -51,12 +93,13 @@ class SweeperCurrentTaskInfoView : ConstraintLayout {
tvTaskName.text = taskName
val calendarStart = DateTimeUtil.formatLongToCalendar(taskStartTime)
val calendarEnd = DateTimeUtil.formatLongToCalendar(taskEndTime)
tvTaskTime.text = "${DateTimeUtil.formatCalendarToString(calendarStart, DateTimeUtil.HH_mm)}-${
DateTimeUtil.formatCalendarToString(
calendarEnd,
DateTimeUtil.HH_mm
)
}"
tvTaskTime.text =
"${DateTimeUtil.formatCalendarToString(calendarStart, DateTimeUtil.HH_mm)}-${
DateTimeUtil.formatCalendarToString(
calendarEnd,
DateTimeUtil.HH_mm
)
}"
}
listTask?.let {
//特殊处理当前暂无执行中任务的情况
@@ -75,10 +118,10 @@ class SweeperCurrentTaskInfoView : ConstraintLayout {
*/
private fun setSubTaskState(isWorking: Boolean) {
if (isWorking) {
tvTaskState.text = "正在作业"
tvTaskState.text = "任务执行中"
tvTaskState.setBackgroundResource(R.drawable.bg_shape_task_state_working)
} else {
tvTaskState.text = "暂未准备"
tvTaskState.text = "任务待开始"
tvTaskState.setBackgroundResource(R.drawable.bg_shape_task_state_not_ready)
}
}

View File

@@ -1,10 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<item android:state_selected="true">
<shape android:shape="rectangle">
<corners android:bottomRightRadius="30dp" android:bottomLeftRadius="@dimen/dp_30"/>
<corners android:bottomLeftRadius="@dimen/dp_30" android:bottomRightRadius="@dimen/dp_30" />
<gradient android:angle="180" android:endColor="#2F6EFF" android:startColor="#20AAFF" />
</shape>
</item>
<item android:state_selected="false">
<shape>
<solid android:color="#4D2F6EFF" />
<corners android:bottomLeftRadius="@dimen/dp_30" android:bottomRightRadius="@dimen/dp_30" />
</shape>
</item>
</selector>

View File

@@ -26,7 +26,7 @@
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/dp_36"
android:layout_marginTop="@dimen/dp_20"
android:text="当前作业模式:"
android:text="当前上装模式:"
android:textColor="@color/white"
android:textSize="@dimen/dp_32"
app:layout_constraintStart_toStartOf="parent"