[清扫车]任务列表切换到当前任务简单逻辑处理

This commit is contained in:
bxb
2023-01-31 17:38:23 +08:00
parent 9abdb2f123
commit 1bf71b4c38
11 changed files with 65 additions and 98 deletions

View File

@@ -2,7 +2,6 @@ package com.mogo.och.sweeper.fragment
import android.view.View
import androidx.recyclerview.widget.LinearLayoutManager
import com.mogo.eagle.core.utilcode.util.ToastUtils
import com.mogo.och.sweeper.R
import com.mogo.och.sweeper.bean.TaskInfoBean
import com.mogo.och.sweeper.constant.TaskMenuTypeEnum
@@ -14,12 +13,14 @@ import kotlinx.android.synthetic.main.fragment_och_sweeper.*
/**
* 清扫车主界面
*/
class SweeperFragment : BaseSweeperTabFragment<SweeperFragment?, SweeperPresenter?>(),MenuPopWindow.OnMenuItemOnClickListener {
class SweeperFragment : BaseSweeperTabFragment<SweeperFragment?, SweeperPresenter?>(), MenuPopWindow.OnMenuItemOnClickListener {
private var mAdapter: TaskListAdapter? = null
//当前任务操作菜单
private var mTaskMenuPopWindow: MenuPopWindow? = null
//
private var mPosition:Int=-1
private var mPosition: Int = -1
private val mutableList: MutableList<TaskInfoBean> by lazy { mutableListOf() }
override fun getTagName(): String {
return "SweepersFragment"
@@ -43,7 +44,7 @@ class SweeperFragment : BaseSweeperTabFragment<SweeperFragment?, SweeperPresente
rvTaskList?.layoutManager = linearLayoutManager
rvTaskList?.adapter = mAdapter
mAdapter?.setOnTaskItemClickListener(onTaskItemClickListener)
mTaskMenuPopWindow= context?.let { MenuPopWindow(it,this) }
mTaskMenuPopWindow = context?.let { MenuPopWindow(it, this) }
initListener()
}
@@ -78,21 +79,21 @@ class SweeperFragment : BaseSweeperTabFragment<SweeperFragment?, SweeperPresente
}
/**
* 改变自动驾驶状态
*
* @param autopilotStatus 0:不可用 1:可用状态 2:自动驾驶中
* 设置自动驾驶可用状态
*/
fun onAutopilotStatusChanged(autopilotStatus:Int) {
fun onAutopilotEnableChange(isEnable: Boolean) {
currentTaskPanelView.setEnableClickBtn(isEnable)
}
/**
* 设置各种监听事件
*/
private fun initListener() {
tvTaskConfirm.setOnClickListener {
setShowTaskListPanelView(false)
workModePanelView.visibility = View.VISIBLE
setShowCurrentTaskPanelView(true)
currentTaskPanelView.setData(mutableList,mPosition)
currentTaskPanelView.setData(mutableList, mPosition)
}
//清扫模式选择面板打开关闭处理
workModePanelView.setOnClickListener { v: View? ->
@@ -100,7 +101,7 @@ class SweeperFragment : BaseSweeperTabFragment<SweeperFragment?, SweeperPresente
}
//任务操作菜单打开关闭处理
currentTaskPanelView.getIvMore().setOnClickListener { v: View? ->
if (mTaskMenuPopWindow?.isShowing!=true) {
if (mTaskMenuPopWindow?.isShowing != true) {
mTaskMenuPopWindow?.showAsDropDown(
workModePanelView,
resources.getDimension(R.dimen.dp_580).toInt(),
@@ -115,20 +116,23 @@ class SweeperFragment : BaseSweeperTabFragment<SweeperFragment?, SweeperPresente
private val onTaskItemClickListener = object : TaskListAdapter.TaskItemClickListener {
override fun onItemClick(position: Int) {
mAdapter?.selectPosition(position)
mPosition=position
tvTaskConfirm.isSelected=true
mPosition = position
tvTaskConfirm.isSelected = true
}
}
override fun onMenuItemClick(itemType: TaskMenuTypeEnum) {
when(itemType.code){
TaskMenuTypeEnum.JUMP_OVER_TASK.code->{
when (itemType.code) {
TaskMenuTypeEnum.JUMP_OVER_TASK.code -> {
setShowTaskListPanelView(true)
setShowCurrentTaskPanelView(false)
workModePanelView.visibility = View.GONE
}
TaskMenuTypeEnum.END_TASK.code->{
TaskMenuTypeEnum.END_TASK.code -> {
setShowTaskListPanelView(true)
setShowCurrentTaskPanelView(false)
workModePanelView.visibility = View.GONE
}
}
}

View File

@@ -82,8 +82,8 @@ public class SweeperPresenter extends Presenter<SweeperFragment>
if (currentAutopilotStatus != IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE) {
currentAutopilotStatus = IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE;
}
// 改变UI自动驾驶状态
runOnUIThread(() -> mView.onAutopilotStatusChanged(currentAutopilotStatus));
// 设置自动驾驶状态是否可用
runOnUIThread(() -> mView.onAutopilotEnableChange(true));
break;
case IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING:
if (currentAutopilotStatus != IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING) {
@@ -91,22 +91,19 @@ public class SweeperPresenter extends Presenter<SweeperFragment>
SweeperTaskModel.getInstance().triggerStartServiceEvent(
SweeperTaskModel.getInstance().isRestartAutopilot(), true);
}
// 改变UI自动驾驶状态
runOnUIThread(() -> mView.onAutopilotStatusChanged(currentAutopilotStatus));
// 设置自动驾驶状态是否可用
runOnUIThread(() -> mView.onAutopilotEnableChange(true));
break;
case IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE:
if (currentAutopilotStatus != IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE) {
currentAutopilotStatus = IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE;
}
// 改变UI自动驾驶状态
runOnUIThread(() -> mView.onAutopilotStatusChanged(currentAutopilotStatus));
// 设置自动驾驶状态是否可用
runOnUIThread(() -> mView.onAutopilotEnableChange(false));
break;
case IMoGoAutopilotStatusListener.STATUS_PARALLEL_DRIVING:
if (currentAutopilotStatus != IMoGoAutopilotStatusListener.STATUS_PARALLEL_DRIVING) {
currentAutopilotStatus = IMoGoAutopilotStatusListener.STATUS_PARALLEL_DRIVING;
}
// 改变UI自动驾驶状态
runOnUIThread(() -> mView.onAutopilotStatusChanged(currentAutopilotStatus));
default:
// 设置自动驾驶状态是否可用
runOnUIThread(() -> mView.onAutopilotEnableChange(false));
break;
}
}

View File

@@ -1,6 +1,7 @@
package com.mogo.och.sweeper.view
import android.content.Context
import android.graphics.Color
import android.util.AttributeSet
import android.view.LayoutInflater
import android.view.View
@@ -30,8 +31,14 @@ class SubTaskView : ConstraintLayout {
*/
fun setData(taskInfo:TaskInfoBean,isSelect:Boolean=false,isLastTask:Boolean=false){
tvSubTaskName.text = taskInfo.taskName
tvSubTaskName.setTextColor(if (isSelect) 0x3BD2FF else 0xFFFFFF)
ivSubTask.setImageResource(if (isSelect) R.drawable.sweeper_icon_select_subtask else R.drawable.sweeper_icon_not_select_subtask)
tvSubTaskName.setTextColor(if (isSelect) Color.parseColor("#3BD2FF")else Color.parseColor("#FFFFFF"))
if (isSelect){
ivSubTaskSelect.visibility=View.VISIBLE
ivSubTask.visibility=View.GONE
}else{
ivSubTaskSelect.visibility=View.GONE
ivSubTask.visibility=View.VISIBLE
}
ivRightDownArrow.visibility=if (isLastTask) View.GONE else View.VISIBLE
}
}

View File

@@ -63,4 +63,11 @@ class SweeperCurrentTaskInfoView : ConstraintLayout {
}
}
}
/**
* 设置准备就绪按钮时都可以点击
*/
fun setEnableClickBtn(isEnable:Boolean){
readyTaskBtn.isSelected= isEnable
}
}

View File

@@ -82,7 +82,7 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:text="确认"
android:textColor="#728bb0"
android:textColor="@color/white"
android:gravity="center"
android:textSize="@dimen/dp_42"
/>

View File

@@ -1,58 +0,0 @@
<?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:layout_width="match_parent"
android:layout_height="wrap_content">
<com.mogo.och.sweeper.view.VerticalDashLineView
android:id="@+id/module_mogo_och_sweeper_station_bottom_dash"
android:layout_width="1dp"
android:layout_height="30dp"
app:layout_constraintLeft_toLeftOf="@id/module_mogo_och_sweeper_station_icon"
app:layout_constraintRight_toRightOf="@id/module_mogo_och_sweeper_station_icon"
app:layout_constraintTop_toTopOf="@id/module_mogo_och_sweeper_station_name"
android:layout_marginTop="15dp"/>
<com.mogo.och.sweeper.view.VerticalDashLineView
android:id="@+id/module_mogo_och_sweeper_station_top_dash"
android:layout_width="1dp"
android:layout_height="30dp"
app:layout_constraintBottom_toBottomOf="@id/module_mogo_och_sweeper_station_name"
android:layout_marginBottom="15dp"
app:layout_constraintLeft_toLeftOf="@id/module_mogo_och_sweeper_station_icon"
app:layout_constraintRight_toRightOf="@id/module_mogo_och_sweeper_station_icon" />
<ImageView
android:id="@+id/module_mogo_och_sweeper_station_icon"
android:layout_width="20dp"
android:layout_height="20dp"
android:scaleType="center"
android:src="@drawable/sweeper_icon_select_subtask"
app:layout_constraintBottom_toBottomOf="@id/module_mogo_och_sweeper_station_name"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintVertical_bias="0.4"
app:layout_constraintTop_toTopOf="@id/module_mogo_och_sweeper_station_name" />
<TextView
android:id="@+id/module_mogo_och_sweeper_station_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/module_mogo_och_sweeper_station_name_margin_left"
android:text="后鲁站"
android:textColor="@color/sweeper_arrived_station_name_text_color"
android:textSize="@dimen/module_mogo_och_sweeper_station_name_text_size"
app:layout_constraintLeft_toRightOf="@id/module_mogo_och_sweeper_station_icon"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"/>
<TextView
android:id="@+id/module_mogo_och_sweeper_station_notice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="起点"
android:textColor="@color/sweeper_station_notice_text_color"
android:textSize="@dimen/module_mogo_och_sweeper_station_notice_text_size"
android:layout_marginEnd="10dp"
app:layout_constraintBottom_toBottomOf="@id/module_mogo_och_sweeper_station_name"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@id/module_mogo_och_sweeper_station_name" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -23,7 +23,7 @@
android:background="@drawable/bg_shape_work_mode"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@+id/sweeper_arc"
android:visibility="visible"/>
android:visibility="gone"/>
<!--清扫任务当前面板-->
<com.mogo.och.sweeper.view.SweeperCurrentTaskInfoView
android:id="@+id/sweeper_current_task_view"
@@ -35,7 +35,7 @@
android:layout_marginStart="@dimen/dp_41"
android:layout_marginTop="@dimen/dp_36"
android:layout_marginBottom="@dimen/dp_30"
android:visibility="visible"
android:visibility="gone"
/>
<!--清扫任务列表面板-->
<FrameLayout
@@ -47,7 +47,7 @@
app:layout_constraintTop_toBottomOf="@id/sweeper_arc"
app:layout_goneMarginTop="@dimen/module_mogo_och_station_panel_container_margin_top_no_call"
app:layout_constraintBottom_toTopOf="@+id/sweeper_switch_model_layout"
android:visibility="gone"
android:visibility="visible"
android:layout_marginBottom="@dimen/dp_30"/>
<!--清扫模式选择面板-->
<com.mogo.och.sweeper.ui.SweeperOperatePanelView

View File

@@ -105,7 +105,7 @@
android:layout_marginTop="@dimen/dp_16"
/>
<TextView
android:id="@+id/switch_line_btn"
android:id="@+id/readyTaskBtn"
android:layout_width="match_parent"
android:layout_height="@dimen/sweeper_switch_line_btn_height_1"
android:background="@drawable/sweeper_ready"

View File

@@ -16,6 +16,17 @@
android:maxLines="2"
app:layout_constraintTop_toTopOf="parent"
/>
<ImageView
android:id="@+id/ivSubTaskSelect"
android:layout_width="@dimen/dp_50"
android:layout_height="@dimen/dp_50"
android:src="@drawable/sweeper_icon_select_subtask"
app:layout_constraintTop_toTopOf="@+id/tvSubTaskName"
app:layout_constraintBottom_toBottomOf="@+id/tvSubTaskName"
app:layout_constraintEnd_toStartOf="@+id/tvSubTaskName"
android:layout_marginEnd="@dimen/dp_10"
android:layout_marginTop="@dimen/dp_8"
android:visibility="gone"/>
<ImageView
android:id="@+id/ivSubTask"
android:layout_width="@dimen/dp_40"
@@ -43,9 +54,9 @@
android:layout_width="@dimen/dp_16"
android:layout_height="@dimen/dp_70"
android:src="@drawable/icon_right_down_arrow"
app:layout_constraintTop_toBottomOf="@+id/ivSubTask"
app:layout_constraintTop_toTopOf="@+id/tvSubTaskDesc"
android:layout_marginStart="@dimen/dp_46"
app:layout_constraintStart_toStartOf="parent"
android:layout_marginTop="@dimen/dp_16"
android:layout_marginTop="@dimen/dp_6"
/>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -82,13 +82,14 @@
android:layout_marginTop="@dimen/dp_16"
android:text="暂无"
android:textSize="@dimen/dp_34"
android:visibility="gone"
android:textColor="@color/white"
android:layout_marginStart="@dimen/dp_36"/>
<androidx.constraintlayout.widget.Group
android:id="@+id/groupWorkModelPanel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"
android:visibility="visible"
app:constraint_referenced_ids="tvCleaningMode,tvCleaningDirection,tvCleaningIntensity"
/>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -18,12 +18,10 @@
<string name="sweeper_line_end">终点: </string>
<string name="sweeper_change_line_commit_tip_s">更换路线成功</string>
<string name="sweeper_change_line_commit_tip_f">更换路线失败</string>
<!-- <string name="sweeper_arrive_to_end_title">去往下车地点</string>-->
<string name="sweeper_arrive_to_end_start">起点:</string>
<string name="sweeper_arrive_to_end_end">终点:</string>
<string name="sweeper_arrive_to_current_tag">当前站点:</string>
<string name="sweeper_arrive_to_next_tag">下一站:</string>
<string name="sweeper_auto_disable_tip">自动驾驶状态为0不可用</string>
<string name="sweeper_operate_panel_cmd_execute_timeout">预计等待%d秒</string>
</resources>