[sweeper-cloud]删除清扫车无用的布局和部分代码
This commit is contained in:
@@ -56,7 +56,7 @@ import androidx.fragment.app.FragmentTransaction;
|
||||
* @author tongchenfei
|
||||
*/
|
||||
public abstract class BaseSweeperTabFragment<V extends IView, P extends Presenter<V>> extends MvpFragment<V, P> implements IMogoMapListener,
|
||||
View.OnClickListener, IWeltMapSwitchToSmallCallback, View.OnTouchListener {
|
||||
IWeltMapSwitchToSmallCallback, View.OnTouchListener {
|
||||
|
||||
private static final String TAG = "BaseSweeperTabFragment";
|
||||
//地图放大缩小
|
||||
@@ -73,14 +73,6 @@ public abstract class BaseSweeperTabFragment<V extends IView, P extends Presente
|
||||
private Group groupTestPanel;
|
||||
//清扫车车辆基本信息 速度 档位 转向灯 红绿灯等
|
||||
private SweeperTrafficDataView mTrafficDataView;
|
||||
//人工驾驶地图View组控制
|
||||
private Group mGroupNaviPanel;
|
||||
//人工驾驶地图Fragment
|
||||
private SweeperAmapNaviFragment mOchAmapNaviFragment;
|
||||
//关闭人工驾驶小地图
|
||||
private ImageView mCloseNavIcon;
|
||||
//刷新人工驾驶地图按钮
|
||||
private ImageView mRefreshNavi;
|
||||
//作业任务贴边数据展示图
|
||||
private WeltSmallMapView mMapWeltView;
|
||||
//任务作业全览图
|
||||
@@ -113,7 +105,6 @@ public abstract class BaseSweeperTabFragment<V extends IView, P extends Presente
|
||||
protected void initViews() {
|
||||
mapBizView = findViewById(R.id.mapBizView);
|
||||
groupTestPanel = findViewById(R.id.groupTestPanel);
|
||||
mGroupNaviPanel = findViewById(R.id.group_navi_panel);
|
||||
flTaskListPanelContainer = findViewById(R.id.module_mogo_och_task_list_container);
|
||||
mTrafficDataView = findViewById(R.id.sweeper_arc);
|
||||
panelView = LayoutInflater.from(getContext()).inflate(getTaskListPanelViewId(), flTaskListPanelContainer);
|
||||
@@ -121,8 +112,6 @@ public abstract class BaseSweeperTabFragment<V extends IView, P extends Presente
|
||||
mSettingBtn = findViewById(R.id.sweeper_setting_model_icon);
|
||||
mCardBtn = findViewById(R.id.sweeper_card_model_icon);
|
||||
mAICollectBtn = findViewById(R.id.sweeper_collect_model_icon);
|
||||
mCloseNavIcon = findViewById(R.id.sweeper_close_navi_icon);
|
||||
mRefreshNavi = findViewById(R.id.sweeper_refresh_navi);
|
||||
mMapWeltView = findViewById(R.id.sweeper_task_welt_small_map);
|
||||
mFlWeltMapOverView = findViewById(R.id.sweeper_welt_map_overview);
|
||||
initListener();
|
||||
@@ -255,8 +244,6 @@ public abstract class BaseSweeperTabFragment<V extends IView, P extends Presente
|
||||
|
||||
private void initListener() {
|
||||
MogoMapListenerHandler.Companion.getMogoMapListenerHandler().registerHostMapListener(TAG, this);
|
||||
mCloseNavIcon.setOnClickListener(this);
|
||||
mRefreshNavi.setOnClickListener(this);
|
||||
mMapWeltView.getSwitchToBig().setOnClickListener((v) -> {
|
||||
showOrHideOverMapViewFragment(true);
|
||||
});
|
||||
@@ -373,54 +360,6 @@ public abstract class BaseSweeperTabFragment<V extends IView, P extends Presente
|
||||
CallerDevaToolsManager.INSTANCE.initAiCollect(mAICollectBtn);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 展示人工驾驶地图导航
|
||||
*/
|
||||
protected void showAmapNaviToStationFragment(boolean isShow) {
|
||||
FragmentTransaction transaction = getChildFragmentManager().beginTransaction();
|
||||
if (isShow) {
|
||||
mGroupNaviPanel.setVisibility(View.VISIBLE);
|
||||
if (mOchAmapNaviFragment == null) {
|
||||
mOchAmapNaviFragment=SweeperAmapNaviFragment.newInstance();
|
||||
}
|
||||
if (mOchAmapNaviFragment.isHidden()) {
|
||||
transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
|
||||
.show(mOchAmapNaviFragment).commitAllowingStateLoss();
|
||||
return;
|
||||
}
|
||||
if (mOchAmapNaviFragment.isAdded()) {
|
||||
transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
|
||||
.show(mOchAmapNaviFragment).commitAllowingStateLoss();
|
||||
return;
|
||||
}
|
||||
transaction
|
||||
.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
|
||||
.add(R.id.module_mogo_och_navi_panel_container, mOchAmapNaviFragment)
|
||||
.show(mOchAmapNaviFragment).commitAllowingStateLoss();
|
||||
} else {
|
||||
AmapNaviToDestinationModel.getInstance(getContext()).destroyAmaNavi();
|
||||
if (mOchAmapNaviFragment != null) {
|
||||
transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_CLOSE)
|
||||
.hide(mOchAmapNaviFragment).commitAllowingStateLoss();
|
||||
}
|
||||
mGroupNaviPanel.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
int id = v.getId();
|
||||
if (id == R.id.sweeper_close_navi_icon) {
|
||||
showAmapNaviToStationFragment(false);
|
||||
} else if (id == R.id.sweeper_refresh_navi) {
|
||||
refreshNavi();
|
||||
}
|
||||
}
|
||||
|
||||
public abstract void refreshNavi();
|
||||
|
||||
/**
|
||||
* 设置作业任务全览图隐藏或者显示
|
||||
*
|
||||
|
||||
@@ -1,48 +1,35 @@
|
||||
package com.mogo.och.sweepercloud.fragment
|
||||
|
||||
import android.graphics.Color
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import chassis.ChassisStatesOuterClass
|
||||
import com.amap.api.maps.model.LatLng
|
||||
import com.mogo.commons.AbsMogoApplication
|
||||
import com.mogo.eagle.core.data.map.MogoLocation
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotControlManager
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.d
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant
|
||||
import com.mogo.eagle.core.utilcode.util.ClickUtils
|
||||
import com.mogo.eagle.core.utilcode.util.ToastUtils
|
||||
import com.mogo.och.common.module.utils.CoordinateCalculateRouteUtil
|
||||
import com.mogo.och.sweepercloud.R
|
||||
import com.mogo.och.sweepercloud.bean.*
|
||||
import com.mogo.och.sweepercloud.bean.SubInfo
|
||||
import com.mogo.och.sweepercloud.bean.SweeperMainTaskBean
|
||||
import com.mogo.och.sweepercloud.bean.SweeperRoutePlanningUpdateReqBean
|
||||
import com.mogo.och.sweepercloud.bean.SweeperSubTaskBean
|
||||
import com.mogo.och.sweepercloud.constant.SubTaskTypeEnum
|
||||
import com.mogo.och.sweepercloud.constant.TaskStatusEnum
|
||||
import com.mogo.och.sweepercloud.database.MyDataBase
|
||||
import com.mogo.och.sweepercloud.presenter.SweeperPresenter
|
||||
import com.mogo.och.sweepercloud.ui.adapter.TaskListAdapter
|
||||
import com.mogo.och.sweepercloud.ui.dialog.SweeperManualDrivingDialog
|
||||
import com.mogo.och.sweepercloud.ui.dialog.SweeperNoTitleCommonDialog
|
||||
import com.mogo.och.sweepercloud.ui.popwindow.MenuPopWindow
|
||||
import com.mogo.och.sweepercloud.ui.dialog.SweeperCloudDialog
|
||||
import kotlinx.android.synthetic.main.fragment_och_sweeper.*
|
||||
import kotlinx.android.synthetic.main.sweeper_current_task_info.view.*
|
||||
import kotlinx.android.synthetic.main.sweeper_no_data_common_view.*
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
/**
|
||||
* 清扫车主界面
|
||||
*/
|
||||
class SweeperFragment : BaseSweeperTabFragment<SweeperFragment?,SweeperPresenter?>(), MenuPopWindow.OnMenuItemOnClickListener {
|
||||
class SweeperFragment : BaseSweeperTabFragment<SweeperFragment?, SweeperPresenter?>(){
|
||||
|
||||
companion object {
|
||||
const val TAG = "SweeperFragment"
|
||||
}
|
||||
|
||||
private var mAdapter: TaskListAdapter? = null
|
||||
private var mCurrentSubPosition: Int = 0 //子任务下标
|
||||
private var mSubMutableList: MutableList<SubInfo>? = null
|
||||
private var mSubTaskBean: SweeperSubTaskBean? = null
|
||||
@@ -58,25 +45,10 @@ class SweeperFragment : BaseSweeperTabFragment<SweeperFragment?,SweeperPresenter
|
||||
|
||||
override fun initViews() {
|
||||
super.initViews()
|
||||
mAdapter = context?.let { TaskListAdapter() }
|
||||
val linearLayoutManager = LinearLayoutManager(context)
|
||||
linearLayoutManager.orientation = LinearLayoutManager.VERTICAL
|
||||
rvTaskList?.layoutManager = linearLayoutManager
|
||||
rvTaskList?.adapter = mAdapter
|
||||
mAdapter?.setOnTaskItemClickListener(onTaskItemClickListener)
|
||||
initListener()
|
||||
sweeper_cl_work_mode.setTrafficDataView(trafficDataView)
|
||||
sweeper_current_task_view.readyTaskBtn.setOnClickListener {
|
||||
if (ClickUtils.isFastClick()) {//防止重复点击
|
||||
if (mSubTaskType.code == SubTaskTypeEnum.MANUAL_DRIVING_SUBTYPE.code) {
|
||||
manualDriving(false)
|
||||
} else {
|
||||
//开始执行任务
|
||||
mSubInfo?.apply {
|
||||
presenter?.startTask(isFirstSubTask(), isLastSubTask(), taskId, mSubTaskType, taskStatus)
|
||||
}
|
||||
}
|
||||
}
|
||||
sweeper_current_task_view.setOnClickListener {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,35 +64,6 @@ class SweeperFragment : BaseSweeperTabFragment<SweeperFragment?,SweeperPresenter
|
||||
override fun getTaskListPanelViewId(): Int {
|
||||
return R.layout.fragment_och_sweeper
|
||||
}
|
||||
|
||||
/**
|
||||
* 任务列表面板隐藏或显示
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private fun setShowTaskListPanelView(isShow: Boolean) {
|
||||
tvTaskConfirm.setTextColor(Color.parseColor("#66FFFFFF"))
|
||||
tvTaskConfirm.isSelected = false
|
||||
if (isShow) {
|
||||
sweeper_current_task_list_view.visibility = View.VISIBLE
|
||||
} else {
|
||||
sweeper_current_task_list_view.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 当前任务面板隐藏或显示
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private fun setShowCurrentTaskPanelView(isShow: Boolean) {
|
||||
if (isShow) {
|
||||
sweeper_current_task_view.visibility = View.VISIBLE
|
||||
} else {
|
||||
sweeper_current_task_view.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* VR模式切换
|
||||
*
|
||||
@@ -138,63 +81,45 @@ class SweeperFragment : BaseSweeperTabFragment<SweeperFragment?,SweeperPresenter
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据自动驾驶状态更新按钮
|
||||
* 设置子任务的状态
|
||||
*/
|
||||
fun startAutoBtn(autopilotState: Int) {
|
||||
sweeper_current_task_view.setStartAutoBtn(autopilotState)
|
||||
fun setSubTaskState(isWorking: Boolean) {
|
||||
sweeper_current_task_view.setSubTaskState(isWorking)
|
||||
}
|
||||
|
||||
/**
|
||||
* 任务按钮状态
|
||||
*/
|
||||
fun setTaskBtn(isWorking: Boolean) {
|
||||
sweeper_current_task_view.setEnableClickBtn(isWorking)
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置各种监听事件
|
||||
*/
|
||||
private fun initListener() {
|
||||
tvTaskConfirm.setOnClickListener {
|
||||
mMainTask?.let { task ->
|
||||
mCurrentSubPosition = 0
|
||||
mSubTaskBean = SweeperSubTaskBean(task.mainTaskId, task.mainTaskName, task.mainTaskStartTime, 1, mSubMutableList)
|
||||
//获取当前子任务列表
|
||||
presenter?.getSubTaskList(task.mainTaskId, mSubTaskBean)
|
||||
mAdapter?.selectPosition(-1)
|
||||
}
|
||||
}
|
||||
//列表任务刷新
|
||||
ivTaskListRefresh.setOnClickListener {
|
||||
mPresenter?.getMainTaskList(true)
|
||||
}
|
||||
//无任务时刷新
|
||||
ivNoTaskRefresh.setOnClickListener {
|
||||
mPresenter?.getMainTaskList(true)
|
||||
}
|
||||
}
|
||||
|
||||
private val onTaskItemClickListener = object : TaskListAdapter.TaskItemClickListener {
|
||||
override fun onItemClick(position: Int, mainTask: SweeperMainTaskBean) {
|
||||
mAdapter?.selectPosition(position)
|
||||
tvTaskConfirm.isSelected = true
|
||||
tvTaskConfirm.setTextColor(Color.parseColor("#FFFFFFFF"))
|
||||
this@SweeperFragment.mMainTask = mainTask
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
override fun onMenuItemClick(itemType: TaskStatusEnum) {
|
||||
when (itemType.code) {
|
||||
TaskStatusEnum.JUMP_OVER_SUBTASK.code -> {//跳过任务
|
||||
mSubInfo?.let {
|
||||
//如果当前只有一个子任务,则isFirst设置为false
|
||||
presenter?.subTaskSkip(if (mSubMutableList?.size == 1) false else isFirstSubTask(), isLastSubTask(), it.taskId)
|
||||
var builder: SweeperCloudDialog.Builder = SweeperCloudDialog.Builder()
|
||||
builder.titleStr="任务接取"
|
||||
builder.contentStr="请确认是否接取任务AAAAAAA"
|
||||
builder.tipStr="(任务时间09:00-12:00)"
|
||||
builder.leftStr="确认"
|
||||
builder.middleStr=""
|
||||
builder.rightStr="拒绝"
|
||||
builder.countDownTime=15
|
||||
builder.listener=object : SweeperCloudDialog.SweeperCloudClickListener {
|
||||
override fun onConfirm() {
|
||||
ToastUtils.showLong("确认")
|
||||
}
|
||||
|
||||
override fun onRefuse() {
|
||||
ToastUtils.showLong("拒绝")
|
||||
}
|
||||
|
||||
override fun onCountDownStop() {
|
||||
ToastUtils.showLong("倒计时结束")
|
||||
}
|
||||
|
||||
override fun onNext() {
|
||||
ToastUtils.showLong("下一个")
|
||||
}
|
||||
|
||||
}
|
||||
TaskStatusEnum.END_TASK.code -> {//结束主任务
|
||||
endMainTask()
|
||||
}
|
||||
val dialog= context?.let { it1 -> builder.build(it1) }
|
||||
dialog?.show()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -204,253 +129,6 @@ class SweeperFragment : BaseSweeperTabFragment<SweeperFragment?,SweeperPresenter
|
||||
sweeper_cl_work_mode.setSweeperFutianCleanSystemState(mSubTaskType, cleanSystemState)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置当前主任务列表数据
|
||||
*/
|
||||
fun setMainTaskList(mainTaskBeanList: MutableList<SweeperMainTaskBean>?, refresh: Boolean) {
|
||||
setShowCurrentTaskPanelView(false)
|
||||
setShowTaskListPanelView(true)
|
||||
sweeper_cl_work_mode.visibility = View.GONE
|
||||
if (mainTaskBeanList != null && mainTaskBeanList.isNotEmpty()) {
|
||||
noTaskDataView.visibility = View.GONE
|
||||
sweeperListCl.visibility = View.VISIBLE
|
||||
mAdapter?.setTaskListData(mainTaskBeanList)
|
||||
} else {
|
||||
noTaskDataView.visibility = View.VISIBLE
|
||||
sweeperListCl.visibility = View.GONE
|
||||
}
|
||||
if (refresh) {
|
||||
ToastUtils.showLong("已刷新")
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置当前子任务列表数据
|
||||
*/
|
||||
fun setSubTaskBean(subTaskBean: SweeperSubTaskBean, isWorkingSubTask: Boolean) {
|
||||
this.mSubTaskBean = subTaskBean
|
||||
this.mSubTaskBean?.let {
|
||||
setShowCurrentTaskPanelView(true)
|
||||
setShowTaskListPanelView(false)
|
||||
sweeper_cl_work_mode.visibility = View.VISIBLE
|
||||
mCurrentSubPosition = if (isWorkingSubTask) {//如果是正在执行的子任务
|
||||
it.sort - 1
|
||||
} else {
|
||||
0
|
||||
}
|
||||
d(SceneConstant.M_SWEEPER + TAG, "setSubTaskBean mCurrentSubPosition:$mCurrentSubPosition")
|
||||
sweeper_current_task_view.setData(sweeper_cl_work_mode, it, mCurrentSubPosition, this, presenter)
|
||||
mSubMutableList = it.subList
|
||||
setSubTaskData()
|
||||
if (mSubTaskType.code == SubTaskTypeEnum.AUTOPILOT_SUBTYPE.code) {//自动驾驶子任务需要调用详情
|
||||
mSubInfo?.let { subInfo ->
|
||||
presenter?.getSubTaskDetail(isFirstSubTask(), isLastSubTask(), subInfo.taskId, mSubTaskType, false)//加载子任务详情包括轨迹信息
|
||||
}
|
||||
}
|
||||
mMainTask = SweeperMainTaskBean(it.taskId, it.taskName, 0, it.taskStartTime)
|
||||
clearAllMarkerAndPolyline()
|
||||
addWeltData()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新子任务状态
|
||||
*/
|
||||
fun updateSubTaskStatus(typeEnum: TaskStatusEnum, isLastSubTask: Boolean) {
|
||||
if (isLastSubTask) {
|
||||
showAmapNaviToStationFragment(false)
|
||||
clearAllMarkerAndPolyline()
|
||||
//整个大任务结束,则删除它相关的贴边数据缓存
|
||||
lifecycleScope.launch(Dispatchers.IO) {
|
||||
MyDataBase.getInstance().weltDataDao.deleteAllWeltData()
|
||||
mPresenter?.clearRouteList()
|
||||
}
|
||||
setTaskProgress("0")
|
||||
|
||||
val builder = SweeperManualDrivingDialog.Builder()
|
||||
val endConfirmDialog = builder
|
||||
.tips("任务已完成")
|
||||
.confirmStr("确认")
|
||||
.build(requireContext())
|
||||
endConfirmDialog?.setClickListener(object: SweeperManualDrivingDialog.ClickListener{
|
||||
override fun confirm() {
|
||||
mPresenter?.getMainTaskList(false)
|
||||
}
|
||||
})
|
||||
endConfirmDialog?.show()
|
||||
return
|
||||
}
|
||||
when (typeEnum.code) {
|
||||
TaskStatusEnum.END_SUBTASK.code -> {//子任务结束
|
||||
mCurrentSubPosition++
|
||||
setSubTaskData()
|
||||
d(SceneConstant.M_SWEEPER + TAG, "END_SUBTASK mCurrentSubPosition:$mCurrentSubPosition")
|
||||
if (mSubTaskType.code == SubTaskTypeEnum.AUTOPILOT_SUBTYPE.code) {//自动驾驶子任务
|
||||
//关闭人工驾驶导航
|
||||
showAmapNaviToStationFragment(false)
|
||||
mSubInfo?.apply {
|
||||
presenter?.getSubTaskDetail(isFirstSubTask(), isLastSubTask(), taskId, mSubTaskType, true)
|
||||
}
|
||||
sweeper_current_task_view.setCurrentData(mCurrentSubPosition)
|
||||
} else {
|
||||
manualDriving(true)
|
||||
}
|
||||
}
|
||||
TaskStatusEnum.JUMP_OVER_SUBTASK.code -> { //子任务跳过
|
||||
//是否是最后一个子任务结束
|
||||
mCurrentSubPosition++
|
||||
setSubTaskData()
|
||||
d(SceneConstant.M_SWEEPER + TAG, "JUMP_OVER_SUBTASK mCurrentSubPosition:$mCurrentSubPosition")
|
||||
showAmapNaviToStationFragment(false)
|
||||
if (mSubTaskType.code == SubTaskTypeEnum.AUTOPILOT_SUBTYPE.code) {//自动驾驶子任务
|
||||
//关闭人工驾驶导航
|
||||
showAmapNaviToStationFragment(false)
|
||||
mSubInfo?.apply {
|
||||
presenter?.getSubTaskDetail(isFirstSubTask(), isLastSubTask(), taskId, mSubTaskType, true)
|
||||
}
|
||||
sweeper_current_task_view.setCurrentData(mCurrentSubPosition)
|
||||
} else {
|
||||
manualDriving(true)
|
||||
}
|
||||
}
|
||||
TaskStatusEnum.START_SUBTASK.code -> { //子任务开始
|
||||
setTaskBtn(true)
|
||||
sweeper_current_task_view.setTaskStatus(2)
|
||||
if (mSubTaskType == SubTaskTypeEnum.MANUAL_DRIVING_SUBTYPE) {
|
||||
sweeper_current_task_view.setCurrentData(mCurrentSubPosition)
|
||||
}
|
||||
}
|
||||
}
|
||||
setEndStationMarker()
|
||||
}
|
||||
|
||||
/**
|
||||
* 主任务重置
|
||||
*/
|
||||
fun setMainTaskReset(isSuccess: Boolean) {
|
||||
if (isSuccess) {
|
||||
//任务重置后,重新拉取任务列表数据
|
||||
mPresenter?.getMainTaskList(false)
|
||||
//清除任务全览图的marker和路线
|
||||
clearAllMarkerAndPolyline()
|
||||
showAmapNaviToStationFragment(false)
|
||||
setTaskProgress("0")
|
||||
//整个大任务结束,则删除它相关的贴边数据缓存
|
||||
lifecycleScope.launch(Dispatchers.IO) {
|
||||
MyDataBase.getInstance().weltDataDao.deleteAllWeltData()
|
||||
mPresenter?.clearRouteList()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置当前选中的子任务信息
|
||||
*/
|
||||
private fun setSubTaskData() {
|
||||
mSubMutableList?.let {
|
||||
mSubInfo = it[mCurrentSubPosition]
|
||||
mSubTaskType = if (it[mCurrentSubPosition].taskType == SubTaskTypeEnum.AUTOPILOT_SUBTYPE.code)
|
||||
SubTaskTypeEnum.AUTOPILOT_SUBTYPE else SubTaskTypeEnum.MANUAL_DRIVING_SUBTYPE
|
||||
//设置当前子任务信息
|
||||
presenter?.setSubtask(isFirstSubTask(), isLastSubTask(), it[mCurrentSubPosition].taskId, it[mCurrentSubPosition].taskType)
|
||||
}
|
||||
/**
|
||||
* 计算任务的进度
|
||||
*/
|
||||
lifecycleScope.launch(Dispatchers.IO) {
|
||||
mSubMutableList?.let {
|
||||
var sum: Double = 0.0
|
||||
for (index in it.indices) {
|
||||
sum += it[index].mileage
|
||||
}
|
||||
var completed: Double = 0.0
|
||||
for (index in it.indices) {
|
||||
if (index < mCurrentSubPosition) {
|
||||
// 已完成的子任务记入完成度,进行中的不计入
|
||||
completed += it[index].mileage
|
||||
}
|
||||
}
|
||||
val progress = "${((completed / sum) * 100.0).roundToInt()}%"
|
||||
setTaskProgress(progress)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 结束主任务
|
||||
*/
|
||||
private fun endMainTask() {
|
||||
//结束任务
|
||||
val builder = SweeperNoTitleCommonDialog.Builder()
|
||||
val endConfirmDialog = builder
|
||||
.tips("是否结束任务?")
|
||||
.confirmStr("确认")
|
||||
.cancelStr("取消")
|
||||
.build(requireContext())
|
||||
endConfirmDialog?.setClickListener(object : SweeperNoTitleCommonDialog.ClickListener {
|
||||
override fun confirm() {
|
||||
mMainTask?.let {
|
||||
presenter?.mainTaskReset(it.mainTaskId)
|
||||
}
|
||||
}
|
||||
|
||||
override fun cancel() {
|
||||
endConfirmDialog?.dismiss()
|
||||
}
|
||||
})
|
||||
endConfirmDialog?.show()
|
||||
}
|
||||
|
||||
/**
|
||||
* 人工驾驶子任务
|
||||
*/
|
||||
private fun manualDriving(isCancelAutoPoilot: Boolean) {
|
||||
if (isCancelAutoPoilot) { // 人工子任务 先取消自动驾驶
|
||||
CallerAutoPilotStatusListenerManager.updateAutopilotControlParameters(null)
|
||||
CallerAutoPilotControlManager.cancelAutoPilot()
|
||||
}
|
||||
|
||||
mSubInfo?.apply {
|
||||
val builder = SweeperManualDrivingDialog.Builder()
|
||||
val endConfirmDialog = builder
|
||||
.tips("前方子任务${taskName}请人工驾驶至(${endSiteName})")
|
||||
.confirmStr("确认")
|
||||
.build(requireContext())
|
||||
endConfirmDialog?.setClickListener(object : SweeperManualDrivingDialog.ClickListener {
|
||||
override fun confirm() {
|
||||
presenter?.startTask(isFirstSubTask(), isLastSubTask(), taskId, mSubTaskType, taskStatus)
|
||||
val startPoint =
|
||||
CoordinateCalculateRouteUtil.coordinateConverterWgsToGcj(AbsMogoApplication.getApp(), startWgs84Lon, startWgs84Lat)
|
||||
val endPoint = CoordinateCalculateRouteUtil.coordinateConverterWgsToGcj(AbsMogoApplication.getApp(), endWgs84Lon, endWgs84Lat)
|
||||
startNaviToStation(
|
||||
true,
|
||||
startPoint.latitude,
|
||||
startPoint.longitude,
|
||||
endPoint.latitude,
|
||||
endPoint.longitude
|
||||
)
|
||||
showAmapNaviToStationFragment(true)
|
||||
}
|
||||
})
|
||||
endConfirmDialog?.show()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否第一个子任务
|
||||
*/
|
||||
fun isFirstSubTask(): Boolean {
|
||||
return mCurrentSubPosition == 0
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否最后一个子任务
|
||||
*/
|
||||
fun isLastSubTask(): Boolean {
|
||||
return mCurrentSubPosition == (mSubMutableList?.size?.minus(1))
|
||||
}
|
||||
|
||||
/**
|
||||
* 当前位置经纬度
|
||||
*/
|
||||
@@ -458,15 +136,6 @@ class SweeperFragment : BaseSweeperTabFragment<SweeperFragment?,SweeperPresenter
|
||||
this.mLocation = location
|
||||
}
|
||||
|
||||
override fun refreshNavi() {
|
||||
mSubInfo?.apply {
|
||||
mLocation?.let {
|
||||
val endPoint = CoordinateCalculateRouteUtil.coordinateConverterWgsToGcj(AbsMogoApplication.getApp(), endWgs84Lon, endWgs84Lat)
|
||||
startNaviToStation(true, it.latitude, it.longitude, endPoint.latitude, endPoint.longitude)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun addWeltData() {
|
||||
lifecycleScope.launch(Dispatchers.IO) {
|
||||
mSubMutableList?.let { subList ->
|
||||
@@ -481,14 +150,14 @@ class SweeperFragment : BaseSweeperTabFragment<SweeperFragment?,SweeperPresenter
|
||||
subList[index].startWgs84Lat
|
||||
)
|
||||
val startLatLng = LatLng(startPoint.latitude, startPoint.longitude)
|
||||
dataList.add(index,startLatLng)
|
||||
dataList.add(index, startLatLng)
|
||||
val endPoint = CoordinateCalculateRouteUtil.coordinateConverterWgsToGcj(
|
||||
AbsMogoApplication.getApp(),
|
||||
subList[index].endWgs84Lon,
|
||||
subList[index].endWgs84Lat
|
||||
)
|
||||
val endLatLng = LatLng(endPoint.latitude, endPoint.longitude)
|
||||
dataList.add(index+1,endLatLng)
|
||||
dataList.add(index + 1, endLatLng)
|
||||
}
|
||||
setTaskListCoordinatesLatLng(dataList)
|
||||
setEndStationMarker()
|
||||
@@ -496,7 +165,7 @@ class SweeperFragment : BaseSweeperTabFragment<SweeperFragment?,SweeperPresenter
|
||||
}
|
||||
}
|
||||
|
||||
private fun setEndStationMarker(){
|
||||
private fun setEndStationMarker() {
|
||||
lifecycleScope.launch(Dispatchers.IO) {
|
||||
mSubInfo?.let {
|
||||
val endPoint = CoordinateCalculateRouteUtil.coordinateConverterWgsToGcj(
|
||||
@@ -511,7 +180,6 @@ class SweeperFragment : BaseSweeperTabFragment<SweeperFragment?,SweeperPresenter
|
||||
}
|
||||
|
||||
|
||||
|
||||
//模拟结束子任务
|
||||
override fun debugEndSubTask() {
|
||||
mPresenter?.onArriveTaskEnd(null)
|
||||
|
||||
@@ -125,7 +125,6 @@ public class SweeperPresenter extends Presenter<SweeperFragment>
|
||||
if (autopilotStatusInfo == null) return;
|
||||
CallerLogger.INSTANCE.d(M_SWEEPER + TAG, "onAutopilotStatusResponse state:" + autopilotStatusInfo.getState());
|
||||
SweeperTaskModel.getInstance().setAutopilotState(autopilotStatusInfo.getState());
|
||||
ThreadUtils.runOnUiThread(() -> mView.startAutoBtn(autopilotStatusInfo.getState()));
|
||||
switch (autopilotStatusInfo.getState()) {
|
||||
case IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE://不可自动驾驶
|
||||
break;
|
||||
@@ -379,75 +378,24 @@ public class SweeperPresenter extends Presenter<SweeperFragment>
|
||||
SweeperTaskModel.getInstance().getCurrentTask();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取主任务列表
|
||||
*/
|
||||
public void getMainTaskList(boolean refresh) {
|
||||
SweeperTaskModel.getInstance().getMainTaskList(refresh);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取子任务列表
|
||||
*/
|
||||
public void getSubTaskList(int taskId, SweeperSubTaskBean sweeperSubTaskBean) {
|
||||
SweeperTaskModel.getInstance().getSubTaskList(taskId, sweeperSubTaskBean);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取子任务详情包括轨迹文件信息
|
||||
*/
|
||||
public void getSubTaskDetail(boolean isFirst, boolean isEnd, int subTaskId, SubTaskTypeEnum subTaskType, boolean isStartSubtask) {
|
||||
SweeperTaskModel.getInstance().getSubTaskDetail(isFirst, isEnd, subTaskId, subTaskType, isStartSubtask);
|
||||
}
|
||||
|
||||
/**
|
||||
* 开始任务
|
||||
*/
|
||||
public void startTask(boolean isFirst, boolean isEnd, int subTaskId, SubTaskTypeEnum subTaskType, int subTaskStatus) {
|
||||
if (SubTaskTypeEnum.AUTOPILOT_SUBTYPE.getCode() == subTaskStatus) {
|
||||
SweeperTaskModel.getInstance().subTaskStart(isFirst, isEnd, subTaskId, subTaskType);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 子任务结束上报
|
||||
*/
|
||||
public void subTaskEnd(boolean isFirst, boolean isEnd, int subTaskId) {
|
||||
SweeperTaskModel.getInstance().subTaskEnd(isFirst, isEnd, subTaskId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 子任务跳过上报
|
||||
*/
|
||||
public void subTaskSkip(boolean isFirst, boolean isEnd, int subTaskId) {
|
||||
SweeperTaskModel.getInstance().subTaskSkip(isFirst, isEnd, subTaskId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 主任务重置
|
||||
*/
|
||||
public void mainTaskReset(int taskId) {
|
||||
SweeperTaskModel.getInstance().mainTaskReset(taskId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMainTaskList(List<SweeperMainTaskBean> mainTaskBeanList, boolean refresh) {
|
||||
mView.setMainTaskList(mainTaskBeanList,refresh);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSubTaskBean(SweeperSubTaskBean subTaskBean, boolean isWorkingSubTask) {
|
||||
mView.setSubTaskBean(subTaskBean, isWorkingSubTask);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSubTaskStatus(TaskStatusEnum typeEnum, boolean isLastSubTask) {
|
||||
mView.updateSubTaskStatus(typeEnum, isLastSubTask);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMainTaskReset(boolean isSuccess) {
|
||||
mView.setMainTaskReset(isSuccess);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,33 +1,16 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
android:orientation="vertical">
|
||||
<!--清扫模式面板-->
|
||||
<com.mogo.och.sweepercloud.view.SweeperWorkModeView
|
||||
android:id="@+id/sweeper_cl_work_mode"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/sweeper_arc"
|
||||
android:visibility="gone" />
|
||||
android:layout_height="wrap_content" />
|
||||
<!--清扫任务当前面板-->
|
||||
<com.mogo.och.sweepercloud.view.SweeperCurrentTaskInfoView
|
||||
android:id="@+id/sweeper_current_task_view"
|
||||
app:layout_constraintTop_toBottomOf="@+id/sweeper_cl_work_mode"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="0dp"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintBottom_toTopOf="@+id/sweeper_switch_model_layout"
|
||||
android:visibility="gone"
|
||||
android:layout_weight="1"
|
||||
android:layout_marginTop="-20dp"
|
||||
/>
|
||||
<com.mogo.och.common.module.wigets.OCHBorderShadowLayout
|
||||
android:id="@+id/sweeper_current_task_list_view"
|
||||
android:layout_width="@dimen/dp_616"
|
||||
@@ -40,87 +23,13 @@
|
||||
app:shadow_position="outer"
|
||||
app:xOffset="0dp"
|
||||
app:yOffset="0dp">
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/sweeperListCl"
|
||||
<com.mogo.och.sweepercloud.view.SweeperCurrentTaskInfoView
|
||||
android:id="@+id/sweeper_current_task_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:visibility="gone"
|
||||
android:background="@drawable/bg_shape_task_panel">
|
||||
<View
|
||||
android:id="@+id/sweeperListLine"
|
||||
android:layout_width="@dimen/dp_10"
|
||||
android:layout_height="@dimen/dp_36"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@+id/sweeperListTitle"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/sweeperListTitle"
|
||||
android:background="@drawable/sweeper_list_left_top_line"/>
|
||||
<TextView
|
||||
android:id="@+id/sweeperListTitle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="@dimen/dp_42"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
android:layout_marginStart="@dimen/dp_38"
|
||||
android:text="任务列表"
|
||||
android:layout_marginTop="@dimen/dp_43"
|
||||
/>
|
||||
<ImageView
|
||||
android:id="@+id/ivTaskListRefresh"
|
||||
android:layout_width="@dimen/dp_42"
|
||||
android:layout_height="@dimen/dp_42"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@+id/sweeperListTitle"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/sweeperListTitle"
|
||||
android:layout_marginEnd="@dimen/dp_39"
|
||||
android:src="@drawable/sweeper_refresh"
|
||||
/>
|
||||
<View
|
||||
android:id="@+id/viewTaskListLine"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="2dp"
|
||||
android:background="@drawable/sweeper_task_dividing_line1_selector"
|
||||
app:layout_constraintTop_toBottomOf="@+id/sweeperListTitle"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
android:layout_marginTop="@dimen/dp_43"/>
|
||||
<View
|
||||
android:id="@+id/viewTaskListLine1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="2dp"
|
||||
android:background="@drawable/sweeper_task_dividing_line2_selector"
|
||||
app:layout_constraintTop_toBottomOf="@+id/viewTaskListLine"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"/>
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/rvTaskList"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginBottom="@dimen/dp_116"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/viewTaskListLine"
|
||||
tools:itemCount="6"
|
||||
tools:listitem="@layout/sweeper_item_task_info" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvTaskConfirm"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/dp_116"
|
||||
android:background="@drawable/sweeper_task_list_btn"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
android:text="确认"
|
||||
android:textColor="#999999"
|
||||
android:gravity="center"
|
||||
android:textSize="@dimen/dp_42"
|
||||
/>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
<include layout="@layout/sweeper_no_data_common_view"
|
||||
android:visibility="visible"/>
|
||||
android:visibility="visible" />
|
||||
<include
|
||||
layout="@layout/sweeper_no_data_common_view"
|
||||
/>
|
||||
</com.mogo.och.common.module.wigets.OCHBorderShadowLayout>
|
||||
</LinearLayout>
|
||||
@@ -4,8 +4,8 @@
|
||||
android:id="@+id/noTaskDataView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:visibility="visible"
|
||||
android:background="@drawable/bg_shape_task_panel">
|
||||
android:background="@drawable/bg_shape_task_panel"
|
||||
android:visibility="gone">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/ivNoTaskData"
|
||||
|
||||
Reference in New Issue
Block a user