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
//package cn.flightfeather.thirdapp.dataanalysis;
//
//
//import android.app.Fragment;
//import android.content.Context;
//import android.graphics.Color;
//import android.icu.text.DecimalFormat;
//import android.os.Build;
//import android.os.Bundle;
//import android.support.annotation.Nullable;
//import android.support.annotation.RequiresApi;
//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 com.github.mikephil.charting.animation.Easing;
//import com.github.mikephil.charting.charts.PieChart;
//import com.github.mikephil.charting.components.Legend;
//import com.github.mikephil.charting.data.PieData;
//import com.github.mikephil.charting.data.PieDataSet;
//import com.github.mikephil.charting.data.PieEntry;
//import com.github.mikephil.charting.formatter.PercentFormatter;
//import com.github.mikephil.charting.utils.ColorTemplate;
//
//import java.util.ArrayList;
//import java.util.Collections;
//import java.util.Comparator;
//import java.util.HashMap;
//import java.util.List;
//import java.util.Objects;
//
//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.ProblemlistVo;
//import cn.flightfeather.thirdapp.bean.vo.TaskVo;
//
///**
// * 2018.11.14
// * @author riku
// * 顶层任务的问题类型统计
// */
//public class ProblemDetailFragment_B extends Fragment {
//
//    private Context context;
//
//    private static final String ARG_PARAM1 = "taskProgressVo";//参数标签
//
//    private TaskVo taskProgressVo;//需要activity传入一个具体的顶层任务对象,用于显示其详细进度信息
//
//    private Unbinder unbinder;
//
//
//    public ProblemDetailFragment_B() {
//        // Required empty public constructor
//    }
//
//    public static ProblemDetailFragment_B newInstance(TaskVo taskProgressVo) {
//        ProblemDetailFragment_B fragment = new ProblemDetailFragment_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.fragment_analysis_problem_1, container, false);
//        unbinder = ButterKnife.bind(this, view);
//        return view;
//    }
//
//
//    @RequiresApi(api = Build.VERSION_CODES.N)
//    @Override
//    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
//        super.onViewCreated(view, savedInstanceState);
//        context = getActivity();
//        initPieChart(view);
//        initRecyclerView(view);
//    }
//
//    @Override
//    public void onDestroyView() {
//        super.onDestroyView();
//        unbinder.unbind();
//    }
//
//    //<editor-fold desc="初始化饼图以及对应的列表">
//    private List<ProblemlistVo> problemlists;//问题列表
//    private ArrayList<PieEntry> entries = new ArrayList<>();//饼图数据
//    private AllRecyclerViewAdapter<PieEntry> entryAdapter = null;//list列表适配器(问题统计数据)
//    private final static int MAX_CHART_COUNT = 20; //饼图最多显示区块数
//    private final static String REMAIN_PROBLEM = "其余";
//
//    @BindView(R.id.rv_problem_type)
//    RecyclerView rv_problem_type;
//
//    @BindView(R.id.PC_problem)
//    PieChart mChart;
//
//    /**
//     * 问题类型分布的列表
//     * @param view 问题类型分布fragment
//     */
//    @RequiresApi(api = Build.VERSION_CODES.N)
//    private void initRecyclerView(View view) {
//        final DecimalFormat decimalFormat = new DecimalFormat("#0.00");
//        rv_problem_type = (RecyclerView) view.findViewById(R.id.rv_problem_type);
//        entryAdapter = new AllRecyclerViewAdapter<PieEntry>(entries, R.layout.item_day_task_progress, context) {
//            @Override
//            public void bindView(MyViewHolder holder, PieEntry obj, boolean bool, int position) {
//                float total = 0;
//                for (PieEntry entry : entries) {
//                    total = total + entry.getValue();
//                }
//                holder.setText(R.id.tv_item1, entries.get(position).getLabel())
//                        .setText(R.id.tv_item2, entries.get(position).getValue() + "")
//                        .setText(R.id.tv_item3, decimalFormat.format(entries.get(position).getValue()/ total * 100) + "%");
//            }
//        };
//
//        LinearLayoutManager layoutManager = new LinearLayoutManager(context);
//        layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
//        rv_problem_type.setLayoutManager(layoutManager);
//        rv_problem_type.addItemDecoration(new DividerItemDecoration(context, DividerItemDecoration.VERTICAL));
//        rv_problem_type.setAdapter(entryAdapter);
//    }
//
//    private void initPieChart(View view) {
//
//        //饼图样式设置***************************************************************************************************
//        mChart.setUsePercentValues(true);
//        mChart.getDescription().setEnabled(false);
//        mChart.setExtraOffsets(5, 10, 5, 5);
////        mChart.setExtraOffsets(20.f, 0.f, 20.f, 0.f);
//
//        mChart.setDragDecelerationFrictionCoef(0.95f);
//
////        mChart.setCenterTextTypeface(mTfLight);
////        mChart.setCenterText(generateCenterSpannableText());
//
//        mChart.setDrawHoleEnabled(true);
//        mChart.setHoleColor(Color.WHITE);
//
//        mChart.setTransparentCircleColor(Color.WHITE);
//        mChart.setTransparentCircleAlpha(110);
//
//        mChart.setHoleRadius(39f);
//        mChart.setTransparentCircleRadius(41f);
//
//        mChart.setDrawCenterText(true);
//
//        mChart.setRotationAngle(0);
//        // enable rotation of the chart by touch
//        mChart.setRotationEnabled(true);
//        mChart.setHighlightPerTapEnabled(true);
//
//        Legend l = mChart.getLegend();
//        l.setVerticalAlignment(Legend.LegendVerticalAlignment.TOP);
//        l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.LEFT);
//        l.setOrientation(Legend.LegendOrientation.VERTICAL);
//        l.setDrawInside(false);
//        l.setXEntrySpace(7f);
//        l.setYEntrySpace(0f);
//        l.setYOffset(0f);
//
//        // entry label styling
//        mChart.setEntryLabelColor(Color.WHITE);
////        mChart.setEntryLabelTypeface(mTfRegular);
//        mChart.setEntryLabelTextSize(12f);
//        mChart.setDrawEntryLabels(false);
//
//        //test
////        setData(new ArrayList<ProblemlistVo>());
//        //
//
//    }
//
//    private void setData(List<ProblemlistVo> problemlists) {
//        //数据初始化***************************************************************************************************
//        entries.clear();
//
//        PieDataSet dataSet = new PieDataSet(entries, "问题类型");
//
//        //test*****
////        int count = 5;
////        int mult = 100;
////        String[] mParties = {"路面积尘", "地面局部未硬化", "站厂出入口无外围护", "无喷淋装置", REMAIN_PROBLEM};
////        for (int i = 0; i < count; i++) {
////            entries.add(new PieEntry((int) (Math.random() * mult) + mult / 5, mParties[i]));
////        }
//        //*********
//
//        //初始化数据
//        HashMap<String, Integer> problemTypeMap = new HashMap<>();
//        while (!problemlists.isEmpty()) {
//            String problemType = problemlists.get(0).getTypename();
//            if (problemType == null) {
//                problemlists.remove(0);
//                continue;
//            }
//
//            int problemCount = 0;
//            for (int i = 0; i < problemlists.size(); i++) {
//                if (Objects.equals(problemType, problemlists.get(i).getTypename())) {
//                    problemCount++;
//                    problemlists.remove(i);
//                    i--;
//                }
//            }
//            problemTypeMap.put(problemType, problemCount);
//        }
//        //按HashMap的value降序排序
//        List<HashMap.Entry<String, Integer>> list = new ArrayList<>(problemTypeMap.entrySet());
//        Collections.sort(list, new Comparator<HashMap.Entry<String, Integer>>() {
//            @Override
//            public int compare(HashMap.Entry<String, Integer> o1, HashMap.Entry<String, Integer> o2) {
//                return o2.getValue().compareTo(o1.getValue());
//            }
//        });
////        problemTypeMap.clear();
////        problemTypeMap.entrySet().addAll(list);
//        //初始化Entry,限定最多显示5个扇区,超出的合并为第5个扇区
//        String remainProblemType = "";
//        int remainProblemCount = 0;
//        int chartcount = 0;
//        for (HashMap.Entry<String, Integer> entry : list) {
//            if (chartcount < MAX_CHART_COUNT - 1) {
//                entries.add(new PieEntry((float)entry.getValue(), entry.getKey()));
//            } else {
//                remainProblemCount = remainProblemCount + entry.getValue();
//                remainProblemType = entry.getKey();
//            }
//            chartcount++;
//        }
//        if (chartcount == MAX_CHART_COUNT) {
//            entries.add(new PieEntry((float) remainProblemCount, remainProblemType));
//        } else if (chartcount > MAX_CHART_COUNT) {
//            entries.add(new PieEntry((float) remainProblemCount, REMAIN_PROBLEM));
//        }
//
//        // add a lot of colors
//        ArrayList<Integer> colors = new ArrayList<>();
//
//        for (int c : ColorTemplate.JOYFUL_COLORS)
//            colors.add(c);
//
//        for (int c : ColorTemplate.COLORFUL_COLORS)
//            colors.add(c);
//
//        for (int c : ColorTemplate.VORDIPLOM_COLORS)
//            colors.add(c);
//
//        for (int c : ColorTemplate.LIBERTY_COLORS)
//            colors.add(c);
//
//        for (int c : ColorTemplate.PASTEL_COLORS)
//            colors.add(c);
//
//        colors.add(ColorTemplate.getHoloBlue());
//
//        dataSet.setColors(colors);
//
//        //value line
//        dataSet.setValueLinePart1OffsetPercentage(80.f);
//        dataSet.setValueLinePart1Length(0.2f);
//        dataSet.setValueLinePart2Length(0.4f);
//        //dataSet.setXValuePosition(PieDataSet.ValuePosition.OUTSIDE_SLICE);
//        dataSet.setYValuePosition(PieDataSet.ValuePosition.OUTSIDE_SLICE);
//
//        //
//        PieData data = new PieData(dataSet);
//        data.setValueFormatter(new PercentFormatter());
//        data.setValueTextSize(11f);
//        data.setValueTextColor(Color.BLACK);
////        data.setValueTypeface(mTfLight);
//        if (!entries.isEmpty()) {//数据全为空时,不显示
//            mChart.setData(data);
//        } else {
//            mChart.setData(null);
//        }
//        mChart.setNoDataText("暂无数据");
//
//        // undo all highlights
//        mChart.highlightValues(null);
//
//        mChart.animateY(1400, Easing.EasingOption.EaseInOutQuad);
//    }
//    //</editor-fold>
//
//    /**
//     * 按照搜索条件查询问题分布结果
//     */
////    private void search() {
////        final SweetAlertDialog dialog = DialogUtil.createSweetLoadingDialog(getActivity(), "Loading...");
////        AreaVo areaVo = new AreaVo();
////        areaVo.setProvincecode(((Province)SP_province.getSelectedItem()).getProvincecode());
////        areaVo.setProvincename(((Province)SP_province.getSelectedItem()).getProvincename());
////        areaVo.setCitycode(((City)SP_city.getSelectedItem()).getCitycode());
////        areaVo.setCityname(((City)SP_city.getSelectedItem()).getCityname());
////        areaVo.setDistrictcode(((District)SP_district.getSelectedItem()).getDistrictcode());
////        areaVo.setDistrictname(((District)SP_district.getSelectedItem()).getDistrictname());
////        areaVo.setTowncode(((Town) SP_town.getSelectedItem()).getTowncode());
////        areaVo.setTownname(((Town) SP_town.getSelectedItem()).getTownname());
////        areaVo = gettime(areaVo);
////        int position = SP_scense_type.getSelectedItemPosition();
////        areaVo.setScensetypeid(scenseTypeData.get(position).getValue());
////        Call<List<ProblemlistVo>> getProblemByArea = problemListService.getByArea(areaVo);
////        getProblemByArea.enqueue(new Callback<List<ProblemlistVo>>() {
////            @Override
////            public void onResponse(Call<List<ProblemlistVo>> call, Response<List<ProblemlistVo>> response) {
////                if (response.body() != null) {
////                    problemlists = response.body();
////                }
////                setData(problemlists);
////                entryAdapter.notifyDataSetChanged();//刷新列表
////                DialogUtil.closeDialog(dialog);
////            }
////
////            @Override
////            public void onFailure(Call<List<ProblemlistVo>> call, Throwable t) {
////                setData(problemlists);
////                DialogUtil.closeDialog(dialog);
////            }
////        });
////
////        setChartTitle();//刷新标题
////        setDateDisplay();//刷新时间
////    }
//}