riku
2025-10-27 0f58aa8ea118c3bd0b28396febc58fdbd94eef75
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
//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();
//    }
//}