[SweeperCloud]refactor: 任务恢复时更新 请求进入自动驾驶 按钮样式,同时需要考虑子任务类型和子任务状态;
This commit is contained in:
@@ -36,6 +36,7 @@ import com.mogo.och.sweepercloud.view.SweeperCurrentTaskInfoView
|
||||
import com.zhjt.mogo.adas.data.sweeper.SweeperCloudTask
|
||||
import com.zhjt.mogo.adas.data.sweeper.bootable.SweeperBootable
|
||||
import com.zhjt.mogo.adas.data.sweeper.common.SweeperCommon
|
||||
import com.zhjt.mogo.adas.data.sweeper.common.SweeperCommon.TaskStatus
|
||||
import com.zhjt.mogo.adas.data.sweeper.task.SweeperTask
|
||||
import com.zhjt.mogo.adas.data.sweeper.task.SweeperTask.SubTaskInfo
|
||||
import com.zhjt.mogo.adas.data.sweeper.task.SweeperTask.TaskModel
|
||||
@@ -143,7 +144,10 @@ class SweeperFragment : BaseSweeperTabFragment<SweeperFragment?, SweeperPresente
|
||||
|
||||
override fun setAutoState(state: Int) {
|
||||
super.setAutoState(state)
|
||||
getCurrentTaskView().updateStartAutoPilotBtnState(state)
|
||||
getCurrentTaskView().updateStartAutoPilotBtnByAutoPilotState(
|
||||
state == STATUS_AUTOPILOT_ENABLE,
|
||||
mCurrentRunningSubTaskInfo?.taskModel == TaskModel.AUTO,
|
||||
mCurrentRunningSubTaskInfo?.taskStatus == TaskStatus.RUNNING)
|
||||
}
|
||||
|
||||
fun onSweeperFutianCleanSystemState(cleanSystemState: ChassisStatesOuterClass.SweeperFuTianTaskSystemStates) {
|
||||
@@ -216,6 +220,9 @@ class SweeperFragment : BaseSweeperTabFragment<SweeperFragment?, SweeperPresente
|
||||
addTaskData()
|
||||
mPresenter?.isHasTaskInfo(true)
|
||||
|
||||
//更新自动驾驶按钮样式
|
||||
updateStartAutoPilotBtnByAutoPilotState()
|
||||
|
||||
//恢复高精地图上的Marker
|
||||
mCurrentRunningSubTaskInfo?.also {
|
||||
addHDMapMarkerBySubTask(it)
|
||||
@@ -227,6 +234,9 @@ class SweeperFragment : BaseSweeperTabFragment<SweeperFragment?, SweeperPresente
|
||||
addTaskData()
|
||||
mPresenter?.isHasTaskInfo(true)
|
||||
|
||||
//更新自动驾驶按钮样式
|
||||
updateStartAutoPilotBtnByAutoPilotState()
|
||||
|
||||
if (taskInfo.isPop) {
|
||||
showReceivedBigTaskDialog()
|
||||
} else {
|
||||
@@ -243,6 +253,14 @@ class SweeperFragment : BaseSweeperTabFragment<SweeperFragment?, SweeperPresente
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateStartAutoPilotBtnByAutoPilotState() {
|
||||
getCurrentTaskView().updateStartAutoPilotBtnByAutoPilotState(
|
||||
mPresenter?.autopilotState == STATUS_AUTOPILOT_ENABLE,
|
||||
mCurrentRunningSubTaskInfo?.taskModel == TaskModel.AUTO,
|
||||
mCurrentRunningSubTaskInfo?.taskStatus == TaskStatus.RUNNING
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据云端同步的子任务状态,更新列表中任务状态
|
||||
*/
|
||||
|
||||
@@ -64,7 +64,7 @@ class SweeperCurrentTaskInfoView : ConstraintLayout {
|
||||
/**
|
||||
* 根据当前自动驾驶状态,更新【请求进入自动驾驶】按钮样式
|
||||
*/
|
||||
fun updateStartAutoPilotBtnState(autopilotState: Int) {
|
||||
fun updateStartAutoPilotBtnByAutoPilotState(autopilotState: Int) {
|
||||
when (autopilotState) {
|
||||
//不可自动驾驶
|
||||
IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE -> {
|
||||
@@ -90,102 +90,119 @@ class SweeperCurrentTaskInfoView : ConstraintLayout {
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置当前任务数据
|
||||
* 根据 当前自动驾驶状态-是否是自动驾驶子任务-子任务是否在运行,更新【请求进入自动驾驶】按钮样式
|
||||
*/
|
||||
@SuppressLint("SetTextI18n")
|
||||
fun setData(
|
||||
taskInfo: TaskInfo?,
|
||||
currentPosition: Int = -1
|
||||
fun updateStartAutoPilotBtnByAutoPilotState(
|
||||
isManualAutoPilotState: Boolean,
|
||||
isAutoSubTask: Boolean,
|
||||
isSubTaskRunning: Boolean
|
||||
) {
|
||||
// 更新 任务名称、任务时间
|
||||
taskInfo?.apply {
|
||||
this@SweeperCurrentTaskInfoView.listTask = subListList
|
||||
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
|
||||
)
|
||||
}"
|
||||
}
|
||||
// 更新大任务状态
|
||||
updateTaskStateText(taskInfo?.taskStatus ?: TaskStatus.TO_START)
|
||||
// 更新子任务列表
|
||||
listTask?.let {
|
||||
//特殊处理当前暂无执行中任务的情况
|
||||
if (currentPosition == -1) {
|
||||
setCurrentData(currentPosition + 1)
|
||||
} else {
|
||||
setCurrentData(currentPosition)
|
||||
}
|
||||
if (isManualAutoPilotState && isAutoSubTask && isSubTaskRunning) {
|
||||
tvStartAuto.setTextColor(Color.parseColor("#FFFFFFFF"))
|
||||
tvStartAuto.isSelected = true
|
||||
} else {
|
||||
tvStartAuto.setTextColor(Color.parseColor("#66FFFFFF"))
|
||||
tvStartAuto.isSelected = false
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置任务的状态
|
||||
*/
|
||||
private fun updateTaskStateText(taskStatus: SweeperCommon.TaskStatus) {
|
||||
when (taskStatus) {
|
||||
SweeperCommon.TaskStatus.RUNNING -> {
|
||||
tvTaskState.text = "任务执行中"
|
||||
tvTaskState.setBackgroundResource(R.drawable.bg_shape_task_state_working)
|
||||
/**
|
||||
* 设置当前任务数据
|
||||
*/
|
||||
@SuppressLint("SetTextI18n")
|
||||
fun setData(
|
||||
taskInfo: TaskInfo?,
|
||||
currentPosition: Int = -1
|
||||
) {
|
||||
// 更新 任务名称、任务时间
|
||||
taskInfo?.apply {
|
||||
this@SweeperCurrentTaskInfoView.listTask = subListList
|
||||
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
|
||||
)
|
||||
}"
|
||||
}
|
||||
|
||||
SweeperCommon.TaskStatus.SUSPENDED -> {
|
||||
tvTaskState.text = "任务已暂停"
|
||||
tvTaskState.setBackgroundResource(R.drawable.bg_shape_task_state_not_ready)
|
||||
}
|
||||
|
||||
else -> {
|
||||
tvTaskState.text = "任务待开始"
|
||||
tvTaskState.setBackgroundResource(R.drawable.bg_shape_task_state_not_ready)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 填充数据
|
||||
*/
|
||||
private fun setCurrentData(currentPosition: Int) {
|
||||
listTask?.let {
|
||||
if (it.size == 1) {
|
||||
preSubTask.setData(it[currentPosition], isLastTask = true)
|
||||
currentSubTask.visibility = View.INVISIBLE
|
||||
lastSubTask.visibility = View.INVISIBLE
|
||||
} else if (it.size == 2) {
|
||||
if (currentPosition == 0) {
|
||||
preSubTask.setData(it[currentPosition])
|
||||
currentSubTask.setData(it[1], isLastTask = true)
|
||||
// 更新大任务状态
|
||||
updateTaskStateText(taskInfo?.taskStatus ?: TaskStatus.TO_START)
|
||||
// 更新子任务列表
|
||||
listTask?.let {
|
||||
//特殊处理当前暂无执行中任务的情况
|
||||
if (currentPosition == -1) {
|
||||
setCurrentData(currentPosition + 1)
|
||||
} else {
|
||||
preSubTask.setData(it[currentPosition - 1])
|
||||
currentSubTask.setData(it[currentPosition], isLastTask = true)
|
||||
}
|
||||
preSubTask.visibility = View.VISIBLE
|
||||
currentSubTask.visibility = View.VISIBLE
|
||||
lastSubTask.visibility = View.GONE
|
||||
} else {
|
||||
preSubTask.visibility = View.VISIBLE
|
||||
currentSubTask.visibility = View.VISIBLE
|
||||
lastSubTask.visibility = View.VISIBLE
|
||||
//当前正在执行的任务是第一个子任务
|
||||
if (currentPosition == 0) {
|
||||
preSubTask.setData(it[currentPosition])
|
||||
currentSubTask.setData(it[1])
|
||||
lastSubTask.setData(it[2], isLastTask = true)
|
||||
//当前正在执行的任务是最后一个子任务
|
||||
} else if (currentPosition == it.size - 1) {
|
||||
preSubTask.setData(it[currentPosition - 2])
|
||||
currentSubTask.setData(it[currentPosition - 1])
|
||||
lastSubTask.setData(it[currentPosition], isLastTask = true)
|
||||
} else {
|
||||
preSubTask.setData(it[currentPosition - 1])
|
||||
currentSubTask.setData(it[currentPosition])
|
||||
lastSubTask.setData(it[currentPosition + 1], isLastTask = true)
|
||||
setCurrentData(currentPosition)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置任务的状态
|
||||
*/
|
||||
private fun updateTaskStateText(taskStatus: SweeperCommon.TaskStatus) {
|
||||
when (taskStatus) {
|
||||
SweeperCommon.TaskStatus.RUNNING -> {
|
||||
tvTaskState.text = "任务执行中"
|
||||
tvTaskState.setBackgroundResource(R.drawable.bg_shape_task_state_working)
|
||||
}
|
||||
|
||||
SweeperCommon.TaskStatus.SUSPENDED -> {
|
||||
tvTaskState.text = "任务已暂停"
|
||||
tvTaskState.setBackgroundResource(R.drawable.bg_shape_task_state_not_ready)
|
||||
}
|
||||
|
||||
else -> {
|
||||
tvTaskState.text = "任务待开始"
|
||||
tvTaskState.setBackgroundResource(R.drawable.bg_shape_task_state_not_ready)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 填充数据
|
||||
*/
|
||||
private fun setCurrentData(currentPosition: Int) {
|
||||
listTask?.let {
|
||||
if (it.size == 1) {
|
||||
preSubTask.setData(it[currentPosition], isLastTask = true)
|
||||
currentSubTask.visibility = View.INVISIBLE
|
||||
lastSubTask.visibility = View.INVISIBLE
|
||||
} else if (it.size == 2) {
|
||||
if (currentPosition == 0) {
|
||||
preSubTask.setData(it[currentPosition])
|
||||
currentSubTask.setData(it[1], isLastTask = true)
|
||||
} else {
|
||||
preSubTask.setData(it[currentPosition - 1])
|
||||
currentSubTask.setData(it[currentPosition], isLastTask = true)
|
||||
}
|
||||
preSubTask.visibility = View.VISIBLE
|
||||
currentSubTask.visibility = View.VISIBLE
|
||||
lastSubTask.visibility = View.GONE
|
||||
} else {
|
||||
preSubTask.visibility = View.VISIBLE
|
||||
currentSubTask.visibility = View.VISIBLE
|
||||
lastSubTask.visibility = View.VISIBLE
|
||||
//当前正在执行的任务是第一个子任务
|
||||
if (currentPosition == 0) {
|
||||
preSubTask.setData(it[currentPosition])
|
||||
currentSubTask.setData(it[1])
|
||||
lastSubTask.setData(it[2], isLastTask = true)
|
||||
//当前正在执行的任务是最后一个子任务
|
||||
} else if (currentPosition == it.size - 1) {
|
||||
preSubTask.setData(it[currentPosition - 2])
|
||||
currentSubTask.setData(it[currentPosition - 1])
|
||||
lastSubTask.setData(it[currentPosition], isLastTask = true)
|
||||
} else {
|
||||
preSubTask.setData(it[currentPosition - 1])
|
||||
currentSubTask.setData(it[currentPosition])
|
||||
lastSubTask.setData(it[currentPosition + 1], isLastTask = true)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user