//package cn.flightfeather.thirdappmodule.module.task;
|
//
|
//import android.app.AlertDialog;
|
//import android.arch.lifecycle.ViewModelProviders;
|
//import android.content.DialogInterface;
|
//import android.content.Intent;
|
//import android.os.Bundle;
|
//import android.support.annotation.Nullable;
|
//import android.support.v4.app.Fragment;
|
//import android.support.v7.widget.LinearLayoutManager;
|
//import android.support.v7.widget.RecyclerView;
|
//import android.view.LayoutInflater;
|
//import android.view.View;
|
//import android.view.ViewGroup;
|
//
|
//import org.greenrobot.eventbus.EventBus;
|
//import org.greenrobot.eventbus.Subscribe;
|
//import org.greenrobot.eventbus.ThreadMode;
|
//
|
//import java.util.ArrayList;
|
//import java.util.Calendar;
|
//import java.util.Date;
|
//import java.util.HashMap;
|
//import java.util.List;
|
//import java.util.Map;
|
//
|
//import cn.flightfeather.thirdappmodule.CommonApplication;
|
//import cn.flightfeather.thirdappmodule.R;
|
//import cn.flightfeather.thirdappmodule.activity.NewMonthTaskActivity;
|
//import cn.flightfeather.thirdappmodule.activity.ScenseMapActivity;
|
//import cn.flightfeather.thirdappmodule.activity.TaskActivity;
|
//import cn.flightfeather.thirdappmodule.adapter.RecyclerItemClickListener;
|
//import cn.flightfeather.thirdappmodule.adapter.TaskListAdapter;
|
//import cn.flightfeather.thirdappmodule.bean.entity.Subtask;
|
//import cn.flightfeather.thirdappmodule.bean.vo.TaskVo;
|
//import cn.flightfeather.thirdappmodule.common.net.ResultCallBack;
|
//import cn.flightfeather.thirdappmodule.model.event.NewTaskEvent;
|
//import cn.flightfeather.thirdappmodule.util.CommonUtils;
|
//import cn.flightfeather.thirdappmodule.util.Constant;
|
//import cn.flightfeather.thirdappmodule.util.DateFormatter;
|
//import cn.flightfeather.thirdappmodule.util.Domain;
|
//import cn.flightfeather.thirdappmodule.view.CircleProgressView;
|
//import retrofit2.Retrofit;
|
//
|
///**
|
// *
|
// */
|
//public class TaskFragment_A extends Fragment implements RecyclerItemClickListener.OnItemClickListener
|
// , View.OnClickListener {
|
//
|
// private int taskKindChoice = 1;
|
// private CommonApplication application;
|
// private Retrofit mRetrofit;
|
// private boolean requestAgain;
|
// private Map<String, List<TaskVo>> taskAllMapList = new HashMap<>();
|
// private boolean firstLoad = true;
|
// private String mCurYearMonth;
|
// private String mToday;
|
// private ArrayList<TaskVo> mTopClassTaskList = new ArrayList<>();
|
// private ArrayList<Subtask> mSubtaskList = new ArrayList<>();
|
// private ArrayList<TaskVo> mDayTaskList = new ArrayList<>();
|
// private CircleProgressView daytask_circleprogress;
|
// private CircleProgressView weektask_circleprogress;
|
// private CircleProgressView monthtask_circleprogress;
|
// private TaskListAdapter mAdapter;
|
// private View tv_no_task;
|
// private View view_waiting;
|
// private AlertDialog mCreateUnfixedScenseTaskDialog;
|
// private int mTopClassTaskChoice;
|
//
|
// private TaskViewModel taskViewModel;
|
//
|
//
|
// @Override
|
// public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
// Bundle savedInstanceState) {
|
// EventBus.getDefault().register(this);
|
// taskViewModel = ViewModelProviders.of(this).get(TaskViewModel.class);
|
// return inflater.inflate(R.layout.fragment_task, container, false);
|
// }
|
//
|
// @Override
|
// public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
|
// super.onViewCreated(view, savedInstanceState);
|
// initUI(view);
|
// initData();
|
// }
|
//
|
// /**
|
// * 获取数据
|
// */
|
// private void initData() {
|
// application = (CommonApplication) getActivity().getApplication();
|
// mRetrofit = application.getRetrofit();
|
// Date now = Calendar.getInstance().getTime();
|
// mCurYearMonth = DateFormatter.YearMonthFormat.format(now);
|
// mToday = DateFormatter.dateFormat2.format(now);
|
// getTodaySubTask();
|
// }
|
//
|
// private void initUI(View view) {
|
// ViewGroup rl_addTask = view.findViewById(R.id.rl_add_task);
|
// view.findViewById(R.id.rl_scense_map).setOnClickListener(this);
|
// view.findViewById(R.id.rl_add_scense).setOnClickListener(this);
|
// view.findViewById(R.id.day_task).setOnClickListener(this);
|
// view.findViewById(R.id.week_task).setOnClickListener(this);
|
// view.findViewById(R.id.month_task).setOnClickListener(this);
|
// view.findViewById(R.id.ll_container_taskadjust).setOnClickListener(this);
|
// view_waiting = view.findViewById(R.id.view_waiting);
|
// tv_no_task = view.findViewById(R.id.tv_no_task);
|
// RecyclerView mRecyclerView = (RecyclerView) view.findViewById(R.id.rv_container);
|
// LinearLayoutManager manager = new LinearLayoutManager(getActivity());
|
// mRecyclerView.setLayoutManager(manager);
|
// mAdapter = new TaskListAdapter(getActivity(), mSubtaskList);
|
// mAdapter.setShowDate(false);
|
// mRecyclerView.setAdapter(mAdapter);
|
// mRecyclerView.addOnItemTouchListener(new RecyclerItemClickListener(getActivity(), mRecyclerView, this));
|
// daytask_circleprogress = (CircleProgressView) view.findViewById(R.id.daytask_circleprogress);
|
// weektask_circleprogress = (CircleProgressView) view.findViewById(R.id.weektask_circleprogress);
|
// monthtask_circleprogress = (CircleProgressView) view.findViewById(R.id.monthtask_circleprogress);
|
//
|
// daytask_circleprogress.setRGB(83, 230, 149);
|
// weektask_circleprogress.setRGB(107, 191, 245);
|
// monthtask_circleprogress.setRGB(236, 120, 101);
|
//
|
// daytask_circleprogress.setProgress(0, 0);
|
// weektask_circleprogress.setProgress(0, 0);
|
// monthtask_circleprogress.setProgress(0, 0);
|
// rl_addTask.setOnClickListener(this);
|
// }
|
//
|
// private void getTodaySubTask() {
|
// view_waiting.setVisibility(View.VISIBLE);
|
// taskViewModel.getSubTaskByDate(new Date(), new ResultCallBack<List<Subtask>>() {
|
// @Override
|
// public void onPage(int current, int total) {
|
//
|
// }
|
//
|
// @Override
|
// public void onCacheSuccess(@org.jetbrains.annotations.Nullable List<Subtask> result) {
|
//
|
// }
|
//
|
// @Override
|
// public void onSuccess(@org.jetbrains.annotations.Nullable List<Subtask> result) {
|
// view_waiting.setVisibility(View.GONE);
|
// if (result != null) {
|
// refreshUI(result);
|
// }
|
// }
|
//
|
// @Override
|
// public void onFailure() {
|
// view_waiting.setVisibility(View.GONE);
|
// }
|
// });
|
// }
|
//
|
// private void refreshUI(List<Subtask> subTaskList) {
|
// mSubtaskList.clear();
|
// int subTaskTotalNumToday = 0;
|
// int subTaskFinishedNumToday = 0;
|
// for (Subtask subTask : subTaskList) {
|
// subTaskTotalNumToday++;
|
// if (subTask.getStatus().equals(Domain.TASK_STATUS_FINISHED)) {
|
// subTaskFinishedNumToday++;
|
// }
|
// mSubtaskList.add(subTask);
|
// }
|
//
|
// Subtask subtask = new Subtask();
|
// subtask.setPlanstarttime(new Date());
|
// subtask.setExtension1(String.valueOf(subTaskTotalNumToday));
|
// subtask.setExtension2(String.valueOf(subTaskFinishedNumToday));
|
// mSubtaskList.add(0, subtask);
|
//
|
// if (mSubtaskList.size() > 0) {
|
// mAdapter.notifyDataSetChanged();
|
// tv_no_task.setVisibility(View.GONE);
|
// }
|
// }
|
//
|
// /**
|
// * 遍历获取的数据,更新界面
|
// */
|
// private void invalidate() {
|
// mTopClassTaskList.clear();
|
// mDayTaskList.clear();
|
// mSubtaskList.clear();
|
// int daytaskTotalNumThisWeek = 0;
|
// int daytaskFinishedNumThisWeek = 0;
|
// int daytaskTotalNumThisMonth = 0;
|
// int daytaskFinishedNumThisMonth = 0;
|
// int subtaskTotalNumToday = 0;
|
// int subtaskFinishedNumToday = 0;
|
// for (TaskVo taskVo : taskAllMapList.get(mCurYearMonth)) {
|
// mTopClassTaskList.add(taskVo);
|
// for (TaskVo dayTaskVo : taskVo.getDaytaskList()) {
|
// daytaskTotalNumThisMonth++;
|
// mDayTaskList.add(dayTaskVo);
|
// long taskTime = dayTaskVo.getStarttime().getTime();
|
// long monday = CommonUtils.getTimesWeekmorning().getTime();
|
// long sunday = CommonUtils.getTimesWeeknight().getTime();
|
// if (taskTime >= monday && taskTime <= sunday) {
|
// daytaskTotalNumThisWeek++;
|
// if (dayTaskVo.getRuningstatus().equals(Domain.TASK_STATUS_FINISHED)) {
|
// daytaskFinishedNumThisWeek++;
|
// }
|
// }
|
// if (dayTaskVo.getRuningstatus().equals(Domain.TASK_STATUS_FINISHED)) {
|
// daytaskFinishedNumThisMonth++;
|
// }
|
// List<Subtask> subTaskList = dayTaskVo.getSubtaskList();
|
// for (Subtask subtask : subTaskList) {
|
// String subtaskStartTime = DateFormatter.dateFormat2.format(subtask.getPlanstarttime());
|
// if (subtaskStartTime.equals(mToday)) {
|
// subtaskTotalNumToday++;
|
// if (subtask.getStatus().equals(Domain.TASK_STATUS_FINISHED)) {
|
// subtaskFinishedNumToday++;
|
// }
|
// mSubtaskList.add(subtask);
|
// }
|
// }
|
// }
|
// }
|
// daytask_circleprogress.setProgress(subtaskFinishedNumToday, subtaskTotalNumToday);
|
// weektask_circleprogress.setProgress(daytaskFinishedNumThisWeek, daytaskTotalNumThisWeek);
|
// monthtask_circleprogress.setProgress(daytaskFinishedNumThisMonth, daytaskTotalNumThisMonth);
|
//
|
// if (mSubtaskList.size() > 0) {
|
// mAdapter.notifyDataSetChanged();
|
// tv_no_task.setVisibility(View.GONE);
|
// }
|
// }
|
//
|
// @Override
|
// public void onClick(View v) {
|
// int id = v.getId();
|
// if (id == R.id.rl_add_task) {
|
// showTaskKindDialog();
|
// } else if (id == R.id.rl_scense_map) {
|
// Intent intent1 = new Intent(getActivity(), ScenseMapActivity.class);
|
// intent1.putExtra(Constant.KEY_INTENT_TODAY_TASKLIST, mSubtaskList);
|
// getActivity().startActivityForResult(intent1, Constant.REQUESTCODE_FROM_TASKFRAGMENT);
|
// } else if (id == R.id.rl_add_scense) {
|
// startActivity(new Intent(getActivity(), SceneDetailActivity.class));
|
// } else if (id == R.id.day_task || id == R.id.week_task || id == R.id.month_task) {
|
// Intent intent = new Intent(getActivity(), TaskActivity.class);
|
// intent.putExtra(Constant.KEY_INTENT_TASK_PERIOD, v.getId());
|
// startActivity(intent);
|
// } else if (id == R.id.ll_container_taskadjust) {
|
// Intent intent2 = new Intent(getActivity(), MonthTaskManagementActivity.class);
|
// startActivity(intent2);
|
// }
|
// }
|
//
|
// /**
|
// * 显示新增任务类型:顶层任务、子任务
|
// * @deprecated Use {@link #showTaskKindDialog_newType()}
|
// */
|
// @Deprecated
|
// private void showTaskKindDialog() {
|
// AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
|
// //无固定场景巡查任务是当任务类型为巡查时才使用,故此次放该选项不合适,暂时先放此处
|
// final String[] items = {"顶层任务", "子任务", "无固定场景巡查任务"};
|
// builder.setTitle("选择任务类型");
|
// builder.setSingleChoiceItems(items, taskKindChoice,
|
// new DialogInterface.OnClickListener() {
|
// @Override
|
// public void onClick(DialogInterface dialog, int which) {
|
// taskKindChoice = which;
|
// }
|
// });
|
// builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
|
// @Override
|
// public void onClick(DialogInterface dialog, int which) {
|
// dialog.dismiss();
|
// Intent intent;
|
// if (taskKindChoice < 2) {
|
// if (taskKindChoice == 0) {
|
// intent = new Intent(getActivity(), NewMonthTaskActivity.class);
|
// } else {
|
//// intent = new Intent(getActivity(), MOVMapActivity.class);
|
//// intent.putExtra(Constant.KEY_INTENT_MODE, MOVMapActivity.MODE_ADD_SUBTASK);
|
// intent = new Intent(getActivity(), NewSubTaskActivity.class);
|
// }
|
// startActivity(intent);
|
// } else {
|
// showCreateUnfixedScenseTaskDialog();
|
// }
|
//
|
// }
|
// });
|
// builder.create().show();
|
// }
|
//
|
// /**
|
// * 更换新样式的弹出框,功能未修改
|
// * 显示新增任务类型:顶层任务、子任务
|
// */
|
// private void showTaskKindDialog_newType() {
|
//
|
// }
|
//
|
// private void showCreateUnfixedScenseTaskDialog() {
|
// AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
|
// final ArrayList<TaskVo> list = new ArrayList<>();
|
// for (TaskVo taskVo : mTopClassTaskList) {
|
// if (taskVo.getExtension2() != null && taskVo.getExtension2().equals(Domain.UNFIXED_SCNESE_ALLOWED)) {
|
// list.add(taskVo);
|
// }
|
// }
|
// final String[] items = new String[list.size()];
|
// for (int i = 0; i < items.length; i++) {
|
// TaskVo taskVo = list.get(i);
|
// items[i] = taskVo.getName();
|
// }
|
// builder.setSingleChoiceItems(items, mTopClassTaskChoice,
|
// new DialogInterface.OnClickListener() {
|
// @Override
|
// public void onClick(DialogInterface dialog, int which) {
|
// mTopClassTaskChoice = which;
|
// }
|
// });
|
// builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
|
// @Override
|
// public void onClick(DialogInterface dialog, int which) {
|
// if (list.isEmpty()) {
|
// return;
|
// }
|
// showCheckTaskInfoDialog(list.get(mTopClassTaskChoice));
|
// }
|
// });
|
// mCreateUnfixedScenseTaskDialog = builder.create();
|
// mCreateUnfixedScenseTaskDialog.show();
|
// }
|
//
|
// private void showCheckTaskInfoDialog(final TaskVo taskVo) {
|
// AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
|
// builder.setTitle("提示");
|
// builder.setMessage("当前选中的顶层任务为" + taskVo.getName());
|
// builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
|
// @Override
|
// public void onClick(DialogInterface dialog, int which) {
|
// taskViewModel.createSubtask(taskVo);
|
// }
|
// });
|
// builder.create().show();
|
// }
|
//
|
// private void showTurnToInspectionDialog(final Subtask subtask) {
|
// new AlertDialog.Builder(getActivity()).setTitle("提示")
|
// .setMessage("子任务创建成功,前往执行?")
|
// .setNegativeButton(R.string.cancel, null)
|
// .setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
|
// @Override
|
// public void onClick(DialogInterface dialog, int which) {
|
// dialog.cancel();
|
// if (subtask != null) {
|
// Intent intent = new Intent("cn.flightfeather.thirdapp.broadcasereceiver.MainReceiver");
|
// try {
|
// intent.putExtra("subtask", subtask);
|
//// Log.e("数据!!", intent.getStringExtra("subtask"));
|
// intent.setAction(Constant.GOTOSUBTASK);
|
//// getActivity().switchSelectedFragment(ll_inspection);
|
// getActivity().sendBroadcast(intent);
|
// } catch (NullPointerException e) {
|
// e.printStackTrace();
|
// }
|
// }
|
// }
|
// }).show();
|
// }
|
//
|
// @Override
|
// public void onItemClick(View view, int position) {
|
//
|
// }
|
//
|
// @Override
|
// public void onItemLongClick(View view, int position) {
|
//
|
// }
|
//
|
// @Subscribe(threadMode = ThreadMode.MAIN)
|
// public void onNewTaskCreated(NewTaskEvent event) {
|
// getTodaySubTask();
|
// }
|
//}
|