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
//package cn.flightfeather.thirdapp.dataanalysis;
//
//import android.content.Context;
//import android.graphics.Color;
//import android.os.Bundle;
//import android.support.annotation.Nullable;
//import android.support.v4.app.Fragment;
//import android.support.v7.widget.DividerItemDecoration;
//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 android.widget.ImageView;
//import android.widget.TextView;
//
//import com.github.mikephil.charting.animation.Easing;
//import com.github.mikephil.charting.charts.BarChart;
//import com.github.mikephil.charting.components.AxisBase;
//import com.github.mikephil.charting.components.Description;
//import com.github.mikephil.charting.components.XAxis;
//import com.github.mikephil.charting.components.YAxis;
//import com.github.mikephil.charting.data.BarData;
//import com.github.mikephil.charting.data.BarDataSet;
//import com.github.mikephil.charting.data.BarEntry;
//import com.github.mikephil.charting.formatter.IAxisValueFormatter;
//import com.github.mikephil.charting.formatter.PercentFormatter;
//
//import java.text.DecimalFormat;
//import java.text.SimpleDateFormat;
//import java.util.ArrayList;
//import java.util.List;
//
//import butterknife.BindView;
//import butterknife.ButterKnife;
//import butterknife.Unbinder;
//import cn.flightfeather.thirdapp.R;
//import cn.flightfeather.thirdapp.adapter.AllRecyclerViewAdapter;
//import cn.flightfeather.thirdapp.bean.vo.TaskVo;
//import cn.flightfeather.thirdapp.util.CommonUtils;
//import cn.flightfeather.thirdapp.view.ScrollTextView;
//
///**
// * 2018.11.09
// * @author riku
// * 顶层任务的详细进度信息
// */
//public class ProgressDetailFragment_B extends Fragment {
//
//    private static final String ARG_PARAM1 = "taskProgressVo";//参数标签
//
//    private TaskVo taskProgressVo;//需要activity传入一个具体的顶层任务对象,用于显示其详细进度信息
//
//    private Unbinder unbinder;
//
//    public ProgressDetailFragment_B() {
//        // Required empty public constructor
//    }
//
//    /**
//     * Use this factory method to create a new instance of
//     * this fragment using the provided parameters.
//     *
//     * @param taskProgressVo
//     * @return A new instance of fragment ProgressDetailFragment.
//     */
//    // TODO: Rename and change types and number of parameters
//    public static ProgressDetailFragment_B newInstance(TaskVo taskProgressVo) {
//        ProgressDetailFragment_B fragment = new ProgressDetailFragment_B();
//        Bundle args = new Bundle();
//        args.putSerializable(ARG_PARAM1, taskProgressVo);
//        fragment.setArguments(args);
//        return fragment;
//    }
//
//    @Override
//    public void onCreate(Bundle savedInstanceState) {
//        super.onCreate(savedInstanceState);
//        if (getArguments() != null) {
//            taskProgressVo = (TaskVo) getArguments().getSerializable(ARG_PARAM1);
//        }
//    }
//
//    @Override
//    public View onCreateView(LayoutInflater inflater, ViewGroup container,
//                             Bundle savedInstanceState) {
//        View view = inflater.inflate(R.layout.dialog_anysis_sub_progress, container, false);
//        unbinder = ButterKnife.bind(this, view);
//        initUI();
//        initStandardBarchart();
//        return view;
//    }
//
//
//    @Override
//    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
//        super.onViewCreated(view, savedInstanceState);
//
//    }
//
//
//    @Override
//    public void onAttach(Context context) {
//        super.onAttach(context);
//    }
//
//    @Override
//    public void onDetach() {
//        super.onDetach();
//    }
//
//    @Override
//    public void onDestroyView() {
//        super.onDestroyView();
//        unbinder.unbind();
//    }
//
//    //<editor-fold desc="初始化界面UI">
//    private final static String NOTASK = "无任务";
//
//    @BindView(R.id.tv_top_task)
//    ScrollTextView tv_top_task;
//
//    @BindView(R.id.iv_top_task)
//    ImageView iv_top_task;
//
//    @BindView(R.id.tv_total_progress)
//    TextView tv_total_progress;
//
//    @BindView(R.id.tv_my_progress)
//    TextView tv_my_progress;
//
//    @BindView(R.id.rv_dialog_task_progress)
//    RecyclerView rv_dialog_task_progress;
//
//    private void initUI(){
//        final DecimalFormat decimalFormat = new DecimalFormat("#0.00");
//        tv_total_progress.setSelected(true);
//        tv_top_task.setText(taskProgressVo.getName());
//        //根据任务类型选择不同的图标
//        iv_top_task.setImageResource(CommonUtils.getIconByTaskType(taskProgressVo.getTypeno().toString()));
//        //数据
//        ArrayList<TaskVo> daytaskprogresslist = new ArrayList<>();
//        daytaskprogresslist.addAll(taskProgressVo.getDaytaskList());//当前顶层任务的所有日任务
//
//        //设置列表显示对其方式
//        LinearLayoutManager layoutManager1 = new LinearLayoutManager(getActivity());
//        layoutManager1.setOrientation(LinearLayoutManager.VERTICAL);
//        rv_dialog_task_progress.setLayoutManager(layoutManager1);
//        rv_dialog_task_progress.addItemDecoration(new DividerItemDecoration(getActivity(), DividerItemDecoration.VERTICAL));
//        //**总进度列表
//        final AllRecyclerViewAdapter<TaskVo> adapter1 = new AllRecyclerViewAdapter<TaskVo>(daytaskprogresslist, R.layout.item_day_task_progress, getActivity()) {
//            @Override
//            public void bindView(MyViewHolder holder, TaskVo obj, boolean bool, int position) {
//                SimpleDateFormat simpleDateFormat = new SimpleDateFormat("MM月dd日");
//                holder.setText(R.id.tv_item1, simpleDateFormat.format(obj.getStarttime()));
//                holder.setText(R.id.tv_item2, String.valueOf(obj.getCompletetask()) + "/" + String.valueOf(obj.getTotaltask()));
//                if (obj.getTotaltask() == 0)
//                    holder.setText(R.id.tv_item3, NOTASK);
//                else
//                    holder.setText(R.id.tv_item3, decimalFormat.format(((float)obj.getCompletetask() / (float)obj.getTotaltask() * 100)) + "%");
//            }
//        };
//        //**用户进度列表
//        final AllRecyclerViewAdapter<TaskVo> adapter2 = new AllRecyclerViewAdapter<TaskVo>(daytaskprogresslist, R.layout.item_day_task_progress, getActivity()) {
//            @Override
//            public void bindView(MyViewHolder holder, TaskVo obj, boolean bool, int position) {
//                SimpleDateFormat simpleDateFormat = new SimpleDateFormat("MM月dd日");
//                holder.setText(R.id.tv_item1, simpleDateFormat.format(obj.getStarttime()));
//                holder.setText(R.id.tv_item2, String.valueOf(obj.getMycompletetask()) + "/" + String.valueOf(obj.getMytotaltask()));
//                if (obj.getMytotaltask() == 0)
//                    holder.setText(R.id.tv_item3, NOTASK);
//                else
//                    holder.setText(R.id.tv_item3, decimalFormat.format(((float)obj.getMycompletetask() / (float)obj.getMytotaltask() * 100)) + "%");
//            }
//        };
//        rv_dialog_task_progress.setAdapter(adapter1);
//
//        tv_total_progress.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//                tv_total_progress.setSelected(true);
//                tv_my_progress.setSelected(false);
//                tv_total_progress.setTextColor(Color.WHITE);
//                tv_my_progress.setTextColor(Color.BLACK);
//                rv_dialog_task_progress.setAdapter(adapter1);
//            }
//        });
//
//        tv_my_progress.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//                tv_my_progress.setSelected(true);
//                tv_total_progress.setSelected(false);
//                tv_my_progress.setTextColor(Color.WHITE);
//                tv_total_progress.setTextColor(Color.BLACK);
//                rv_dialog_task_progress.setAdapter(adapter2);
//            }
//        });
//    }
//    //</editor-fold>
//
//
//    //<editor-fold desc="初始化任务进度直方图">
//    @BindView(R.id.barChart_progress)
//    BarChart mStandardChart;//每个顶层任务的具体直方图数据
//    /*
//    柱状图,顶层任务的完成百分比
//     */
//    private void initStandardBarchart() {
//
//        List<TaskVo> daytaskprogresslist = taskProgressVo.getDaytaskList();//当前顶层任务的所有日任务
//
//        //坐标轴
//        XAxis xAxis = mStandardChart.getXAxis();
//        xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
//        xAxis.setDrawGridLines(false);
//        xAxis.setGranularity(1f);//坐标间隔
////        xAxis.setLabelCount(2, true);//进入时的标签个数
//        xAxis.setCenterAxisLabels(true);//标签处于图表中间
//        xAxis.setAxisMinimum(0f);
//        xAxis.setValueFormatter(new MyDateFormmater(daytaskprogresslist));
//
//        YAxis rightAxis = mStandardChart.getAxisRight();
//        rightAxis.setEnabled(false);
////        rightAxis.setDrawGridLines(false);
////        rightAxis.setDrawAxisLine(false);
////        rightAxis.setDrawLabels(false);
//
//        YAxis leftAxis = mStandardChart.getAxisLeft();
//        leftAxis.setDrawGridLines(false);
//        leftAxis.setDrawAxisLine(false);
//        leftAxis.setDrawLabels(false);
//        leftAxis.setDrawTopYLabelEntry(true);
//        leftAxis.setZeroLineColor(Color.BLACK);
//        leftAxis.setDrawZeroLine(true);
//        leftAxis.setAxisMinimum(0f);
//        leftAxis.setAxisMaximum(100f);
//        leftAxis.setValueFormatter(new PercentFormatter());
////        LimitLine limitLine = new LimitLine(100f);
////        limitLine.setLineColor(Color.BLACK);
////        leftAxis.addLimitLine(limitLine);
//
//        //Entry数据
//        List<BarEntry> totalEntries = new ArrayList<>();;//每日总任务进度
//        List<BarEntry> userEntries = new ArrayList<>();;//每日用户进度
//        //Test*********
////        totalEntries.add(new BarEntry(0f, 0f));
////        totalEntries.add(new BarEntry(1f, 0f));
////        totalEntries.add(new BarEntry(2f, 40f));
////        totalEntries.add(new BarEntry(3f, 70f));
////        totalEntries.add(new BarEntry(4f, 80f));
////        totalEntries.add(new BarEntry(5f, 50f));
////        totalEntries.add(new BarEntry(6f, 30f));
////        totalEntries.add(new BarEntry(7f, 10f));
////
////        userEntries.add(new BarEntry(0f, 0f));
////        userEntries.add(new BarEntry(1f, 60f));
////        userEntries.add(new BarEntry(2f, 70));
////        userEntries.add(new BarEntry(3f, 70));
////        userEntries.add(new BarEntry(4f, 35));
////        userEntries.add(new BarEntry(5f, 35));
////        userEntries.add(new BarEntry(6f, 35));
////        userEntries.add(new BarEntry(7f, 35));
//        //*************
//
//        for (int i = 0; i < daytaskprogresslist.size(); i++){//初始化数据
//            float y1 = daytaskprogresslist.get(i).getTotaltask();
//            if (y1 != 0)
//                y1 = ((float)daytaskprogresslist.get(i).getCompletetask() / (float) daytaskprogresslist.get(i).getTotaltask() * 100);
//            else
//                y1 = 100f;
//            totalEntries.add(new BarEntry((float)i, y1));
//
//            float y2 = daytaskprogresslist.get(i).getMytotaltask();
//            if (y2 != 0)
//                y2 = ((float)daytaskprogresslist.get(i).getMycompletetask() / (float)daytaskprogresslist.get(i).getMytotaltask() * 100);
//            else
//                y2 = 100f;
//            userEntries.add(new BarEntry((float)i, y2));
//        }
//
//        BarDataSet barDataSetTotal = new BarDataSet(totalEntries, "总进度");
//        BarDataSet barDataSetUser = new BarDataSet(userEntries, "我的进度");
//        barDataSetTotal.setAxisDependency(YAxis.AxisDependency.LEFT);
////        barDataSetTotal.setAxisDependency(YAxis.AxisDependency.RIGHT);
//        barDataSetUser.setAxisDependency(YAxis.AxisDependency.LEFT);
////        barDataSetUser.setAxisDependency(YAxis.AxisDependency.RIGHT);
//        barDataSetTotal.setColor(Color.argb(128, 255, 0, 0));
//        barDataSetUser.setColor(Color.argb(128, 0, 255, 0));
//
//        float groupSpace = 0.06f;
//        float barSpace = 0.02f; // x2 dataset
//        float barWidth = 0.45f; // x2 dataset
//        // (0.02 + 0.45) * 2 + 0.06 = 1.00 -> interval per "group"
//        BarData barData = new BarData(barDataSetTotal, barDataSetUser);
////        BarData barData = new BarData(barDataSetTotal);
//        barData.setValueFormatter(new PercentFormatter());
//        barData.setValueTextSize(8f);
//        barData.setHighlightEnabled(false);//高亮
//        barData.setBarWidth(barWidth);
//        if (!totalEntries.isEmpty() || !userEntries.isEmpty()) {//数据全为空时,不显示
//            mStandardChart.setData(barData);
//            mStandardChart.setFitBars(true);//x轴坐标显示对应每个bar
//            mStandardChart.groupBars(0f, groupSpace, barSpace);
//        }
//
//        //General Chart Settings & Styling
//        mStandardChart.setNoDataText("任务还未开始执行,暂无数据");//Sets the title that should appear if the chart is empty.
////        mStandardChart.setDrawBorders(false);//Enables / disables drawing the chart borders (lines surrounding the chart).
//        //图标描述
//        Description description = new Description();
//        description.setText("");
//        mStandardChart.setDescription(description);
//
////        mStandardChart.setTouchEnabled(true);//触摸
////        mStandardChart.setDragEnabled(true);//拖拽
//        mStandardChart.setScaleEnabled(false);//缩放
//
//        mStandardChart.animateY(1400, Easing.EasingOption.EaseOutSine);
//        mStandardChart.fitScreen();
//
//        //视图设置
//        mStandardChart.setVisibleXRangeMaximum(6f);
//        mStandardChart.setVisibleXRangeMinimum(6f);
//
////        mStandardChart.invalidate();
//
//    }
//    //</editor-fold>
//
//    class MyDateFormmater implements IAxisValueFormatter {
//
//        DecimalFormat mFormat;
//        List<TaskVo> daytaskprogresslist;
//        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd日");
//
//        MyDateFormmater(List<TaskVo> daytaskprogresslist) {
//            mFormat = new DecimalFormat("###,###,##0");
//            this.daytaskprogresslist = daytaskprogresslist;
//        }
//
//        @Override
//        public String getFormattedValue(float value, AxisBase axis) {
//            try {
//                return simpleDateFormat.format(daytaskprogresslist.get((int)value).getStarttime());
//            }catch (Exception e){
//                e.printStackTrace();
//                return "";
//            }
//        }
//    }
//
//}