diff --git a/OCH/sweeper/sweeper-cloud/src/main/java/com/mogo/och/sweepercloud/view/SubTaskView.kt b/OCH/sweeper/sweeper-cloud/src/main/java/com/mogo/och/sweepercloud/view/SubTaskView.kt index 2138ce3e83..cef3af8496 100644 --- a/OCH/sweeper/sweeper-cloud/src/main/java/com/mogo/och/sweepercloud/view/SubTaskView.kt +++ b/OCH/sweeper/sweeper-cloud/src/main/java/com/mogo/och/sweepercloud/view/SubTaskView.kt @@ -6,7 +6,6 @@ import android.util.AttributeSet import android.view.LayoutInflater import android.view.View import androidx.constraintlayout.widget.ConstraintLayout -import com.mogo.och.common.module.utils.DateTimeUtil import com.mogo.och.sweepercloud.R import com.mogo.och.sweepercloud.bean.SubInfo import kotlinx.android.synthetic.main.sweeper_subtask_view.view.* @@ -32,25 +31,11 @@ class SubTaskView : ConstraintLayout { */ fun setData(taskInfo: SubInfo, isSelect: Boolean = false, isLastTask: Boolean = false) { tvSubTaskName.text = taskInfo.taskName - var mileage: String = if (taskInfo.mileage < 1000) { - "${taskInfo.mileage}米" - } else { - "${taskInfo.mileage / 1000F}千米" - } - val time=taskInfo.timeSpent.toLong() - var timeSpent=if(DateTimeUtil.secondsToHourStr(time)!=""){ - "${DateTimeUtil.secondsToHourStr(time)}小时${DateTimeUtil.secondsToMinuteStr(time)}分钟" - }else{ - "${DateTimeUtil.secondsToMinuteStr(time)}分钟" - } - tvSubTaskDesc.text = "全程约${mileage},预计耗时$timeSpent" tvSubTaskName.setTextColor(if (isSelect) Color.parseColor("#3BD2FF") else Color.parseColor("#FFFFFF")) if (isSelect) { - ivSubTaskSelect.visibility = View.VISIBLE - ivSubTask.visibility = View.GONE + ivSubTask.setImageResource(R.drawable.sweeper_icon_select_subtask) } else { - ivSubTaskSelect.visibility = View.GONE - ivSubTask.visibility = View.VISIBLE + ivSubTask.setImageResource(R.drawable.sweeper_icon_not_select_subtask) } ivRightDownArrow.visibility = if (isLastTask) View.GONE else View.VISIBLE } diff --git a/OCH/sweeper/sweeper-cloud/src/main/java/com/mogo/och/sweepercloud/view/SweeperCurrentTaskInfoView.kt b/OCH/sweeper/sweeper-cloud/src/main/java/com/mogo/och/sweepercloud/view/SweeperCurrentTaskInfoView.kt index 00d79fdf04..301b513e3e 100644 --- a/OCH/sweeper/sweeper-cloud/src/main/java/com/mogo/och/sweepercloud/view/SweeperCurrentTaskInfoView.kt +++ b/OCH/sweeper/sweeper-cloud/src/main/java/com/mogo/och/sweepercloud/view/SweeperCurrentTaskInfoView.kt @@ -1,21 +1,15 @@ 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 androidx.constraintlayout.widget.ConstraintLayout -import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener -import com.mogo.eagle.core.utilcode.util.ClickUtils -import com.mogo.eagle.core.utilcode.util.ToastUtils import com.mogo.och.common.module.utils.DateTimeUtil import com.mogo.och.sweepercloud.R import com.mogo.och.sweepercloud.bean.SubInfo import com.mogo.och.sweepercloud.bean.SweeperSubTaskBean import com.mogo.och.sweepercloud.constant.SubTaskTypeEnum -import com.mogo.och.sweepercloud.presenter.SweeperPresenter -import com.mogo.och.sweepercloud.ui.popwindow.MenuPopWindow import kotlinx.android.synthetic.main.sweeper_current_task_info.view.* /** @@ -25,14 +19,10 @@ class SweeperCurrentTaskInfoView : ConstraintLayout { private val TAG: String = "SweeperCurrentTaskInfoView" //当前任务操作菜单 - private var mTaskMenuPopWindow: MenuPopWindow? = null - private var presenter: SweeperPresenter? = null private var mCurrentPosition = 0 private var listTask: List? = null private var mSubTaskType: SubTaskTypeEnum = SubTaskTypeEnum.AUTOPILOT_SUBTYPE private var mSubTaskStatus: Int = 1 - //当前自动驾驶状态 - private val mCurrentAutopilotStatus = 0 constructor(context: Context) : super(context) {} constructor(context: Context, attrs: AttributeSet?) : super(context, attrs) { @@ -44,37 +34,17 @@ class SweeperCurrentTaskInfoView : ConstraintLayout { private fun initView(context: Context) { LayoutInflater.from(context).inflate(R.layout.sweeper_current_task_info, this) - setEnableClickBtn(false) - tvStartAuto.setOnClickListener { - if (ClickUtils.isFastClick()){//防止重复点击 - if (mSubTaskStatus==1){ - ToastUtils.showLong("任务未开始无轨迹,无法启动自驾") - return@setOnClickListener - } - if (mSubTaskType==SubTaskTypeEnum.MANUAL_DRIVING_SUBTYPE){ - ToastUtils.showLong("人工子任务无轨迹,无法启动自驾") - return@setOnClickListener - } - if (mCurrentAutopilotStatus!=IMoGoAutopilotStatusListener.STATUS_PARALLEL_DRIVING){ - presenter?.startAutopilot() - } - } - } + setSubTaskState(false) } /** * 设置当前任务数据 */ fun setData( - workModePanelView: SweeperWorkModeView, subTaskBean: SweeperSubTaskBean?, currentPosition: Int, - menuItemClickListener: MenuPopWindow.OnMenuItemOnClickListener, - presenter: SweeperPresenter? ) { - this.presenter = presenter this.mCurrentPosition = currentPosition - mTaskMenuPopWindow = MenuPopWindow(context, menuItemClickListener) subTaskBean?.apply { this@SweeperCurrentTaskInfoView.listTask = subList tvTaskName.text = taskName @@ -82,110 +52,24 @@ class SweeperCurrentTaskInfoView : ConstraintLayout { tvTaskTime.text = DateTimeUtil.formatCalendarToString(calendar, DateTimeUtil.HH_mm) } listTask?.let { - mSubTaskStatus=it[currentPosition].taskStatus - setEnableClickBtn(mSubTaskStatus==2) + mSubTaskStatus = it[currentPosition].taskStatus + setSubTaskState(mSubTaskStatus == 2) } setCurrentData(currentPosition) - //任务操作菜单打开关闭处理 - ivMore.setOnClickListener { - if (mTaskMenuPopWindow?.isShowing != true) { - mTaskMenuPopWindow?.showAsDropDown( - workModePanelView, - resources.getDimension(R.dimen.dp_580).toInt(), - resources.getDimension(R.dimen.dp_36).toInt() - ) - } else { - mTaskMenuPopWindow?.dismiss() - } - } - } /** - * 设置准备就绪按钮时都可以点击 + * 设置子任务的状态 */ - fun setEnableClickBtn(isWorking: Boolean) { - readyTaskBtn.isClickable=!isWorking - presenter?.setWorking(isWorking) + fun setSubTaskState(isWorking: Boolean) { if (isWorking) { tvTaskState.text = "正在作业" - readyTaskBtn.text="任务中" - readyTaskBtn.setTextColor(Color.parseColor("#FFFFFFFF")) tvTaskState.setBackgroundResource(R.drawable.bg_shape_task_state_working) - readyTaskBtn.setBackgroundResource(R.drawable.sweeper_task_working) } else { tvTaskState.text = "暂未准备" - readyTaskBtn.text="开始任务" - readyTaskBtn.setTextColor(Color.parseColor("#66FFFFFF")) tvTaskState.setBackgroundResource(R.drawable.bg_shape_task_state_not_ready) - readyTaskBtn.setBackgroundResource(R.drawable.sweeper_task_not_working) } } - - /** - * 设置准备就绪按钮时都可以点击 - */ - fun setStartAutoBtn(autopilotState: Int) { - when (autopilotState) { - IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE -> { - tvStartAuto.text="自动驾驶" - tvStartAuto.setTextColor(Color.parseColor("#66FFFFFF")) - tvStartAuto.setBackgroundResource(R.drawable.sweeper_start_auto_not_running) - } - IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE -> { - tvStartAuto.text="自动驾驶" - tvStartAuto.setTextColor(Color.parseColor("#66FFFFFF")) - tvStartAuto.setBackgroundResource(R.drawable.sweeper_start_auto_not_running) - } - IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING -> { - tvStartAuto.text="自动驾驶" - tvStartAuto.setTextColor(Color.parseColor("#FFFFFFFF")) - tvStartAuto.setBackgroundResource(R.drawable.sweeper_start_auto_running) - } - IMoGoAutopilotStatusListener.STATUS_PARALLEL_DRIVING -> { - tvStartAuto.text="平行驾驶" - tvStartAuto.setTextColor(Color.parseColor("#FFFFFFFF")) - tvStartAuto.setBackgroundResource(R.drawable.sweeper_start_auto_running) - } - } - } - - /** - * 开始子任务 - */ - private fun startSubTask() { - listTask?.let { - presenter?.startTask( - isFirstSubTask(), - isLastSubTask(), - it[mCurrentPosition].taskId, - if (it[mCurrentPosition].taskType == SubTaskTypeEnum.AUTOPILOT_SUBTYPE.code) SubTaskTypeEnum.AUTOPILOT_SUBTYPE else SubTaskTypeEnum.MANUAL_DRIVING_SUBTYPE, - mSubTaskStatus - ) - } - } - - /** - * 是否第一个子任务 - */ - private fun isFirstSubTask(): Boolean { - return mCurrentPosition == 0 - } - - /** - * 是否第一个子任务 - */ - private fun isLastSubTask(): Boolean { - return mCurrentPosition == (listTask?.size?.minus(1)) - } - - /** - * 设置任务状态 - */ - fun setTaskStatus(status: Int) { - this.mSubTaskStatus = status - } - /** * 填充数据 */ @@ -205,13 +89,13 @@ class SweeperCurrentTaskInfoView : ConstraintLayout { preSubTask.setData(it[mCurrentPosition - 1]) currentSubTask.setData(it[mCurrentPosition], isSelect = true, isLastTask = true) } - preSubTask.visibility=View.VISIBLE - currentSubTask.visibility=View.VISIBLE - lastSubTask.visibility=View.GONE + 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 + preSubTask.visibility = View.VISIBLE + currentSubTask.visibility = View.VISIBLE + lastSubTask.visibility = View.VISIBLE //当前正在执行的任务是第一个子任务 if (mCurrentPosition == 0) { preSubTask.setData(it[mCurrentPosition], isSelect = true) diff --git a/OCH/sweeper/sweeper-cloud/src/main/res/drawable-xhdpi/icon_manual_driving.png b/OCH/sweeper/sweeper-cloud/src/main/res/drawable-xhdpi/icon_manual_driving.png new file mode 100755 index 0000000000..8e1fa65d96 Binary files /dev/null and b/OCH/sweeper/sweeper-cloud/src/main/res/drawable-xhdpi/icon_manual_driving.png differ diff --git a/OCH/sweeper/sweeper-cloud/src/main/res/layout/sweeper_current_task_info.xml b/OCH/sweeper/sweeper-cloud/src/main/res/layout/sweeper_current_task_info.xml index 5a5b5fa4b1..35db9f7bb3 100644 --- a/OCH/sweeper/sweeper-cloud/src/main/res/layout/sweeper_current_task_info.xml +++ b/OCH/sweeper/sweeper-cloud/src/main/res/layout/sweeper_current_task_info.xml @@ -1,159 +1,109 @@ - + android:background="@drawable/bg_shape_task_panel"> - + + + + + + + android:layout_height="2dp" + android:layout_marginTop="@dimen/dp_26" + android:background="@drawable/sweeper_task_dividing_line1_selector" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/tvTaskTime" /> - + - + - + - + - - - - - - - - - - - - - - - - \ No newline at end of file + + \ No newline at end of file diff --git a/OCH/sweeper/sweeper-cloud/src/main/res/layout/sweeper_subtask_view.xml b/OCH/sweeper/sweeper-cloud/src/main/res/layout/sweeper_subtask_view.xml index 25964e716b..c23679c874 100644 --- a/OCH/sweeper/sweeper-cloud/src/main/res/layout/sweeper_subtask_view.xml +++ b/OCH/sweeper/sweeper-cloud/src/main/res/layout/sweeper_subtask_view.xml @@ -3,64 +3,51 @@ android:layout_width="match_parent" android:layout_height="match_parent" xmlns:app="http://schemas.android.com/apk/res-auto" - xmlns:tools="http://schemas.android.com/tools"> + > + android:id="@+id/ivManualDriving" + android:layout_width="@dimen/dp_56" + android:layout_height="@dimen/dp_56" + android:src="@drawable/icon_manual_driving" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintTop_toTopOf="parent" + android:layout_marginEnd="@dimen/dp_26" + android:layout_marginTop="@dimen/dp_20" + /> - \ No newline at end of file