riku
2021-02-25 e102578ebfc95c27aeb13dce13fb82af53a2bead
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
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
package cn.flightfeather.thirdapp.business.widgettype3;
 
 
import android.arch.lifecycle.ViewModelProviders;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.constraint.ConstraintLayout;
import android.support.constraint.Group;
import android.support.v4.app.Fragment;
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.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
 
import com.amap.api.location.AMapLocation;
import com.amap.api.location.AMapLocationClient;
import com.amap.api.location.AMapLocationClientOption;
import com.amap.api.location.AMapLocationListener;
import com.amap.api.services.weather.LocalWeatherForecastResult;
import com.amap.api.services.weather.LocalWeatherLive;
import com.amap.api.services.weather.LocalWeatherLiveResult;
import com.amap.api.services.weather.WeatherSearch;
import com.amap.api.services.weather.WeatherSearchQuery;
import com.ping.greendao.gen.ScenseDao;
 
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
 
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.Unbinder;
import cn.flightfeather.thirdapp.CommonApplication;
import cn.flightfeather.thirdapp.R;
import cn.flightfeather.thirdapp.bean.entity.Scense;
import cn.flightfeather.thirdapp.bean.entity.Subtask;
import cn.flightfeather.thirdapp.bean.vo.InspectionInfoVo;
import cn.flightfeather.thirdapp.bean.vo.RankVo;
import cn.flightfeather.thirdapp.bean.vo.TaskVo;
import cn.flightfeather.thirdapp.common.net.ResultCallBack;
import cn.flightfeather.thirdapp.dataanalysis.AnalysisOverViewFragment;
import cn.flightfeather.thirdapp.httpservice.InspectionService;
import cn.flightfeather.thirdapp.httpservice.TaskService;
import cn.flightfeather.thirdapp.model.bean.NightWorkFileVo;
import cn.flightfeather.thirdapp.module.nightwork.NightWorkRecordActivity;
import cn.flightfeather.thirdapp.module.nightwork.NightWorkViewModel;
import cn.flightfeather.thirdapp.util.Constant;
import cn.flightfeather.thirdapp.util.DateFormatter;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
 
/**
 * A simple {@link Fragment} subclass.
 */
public class HomeFragment_scene extends Fragment implements WeatherSearch.OnWeatherSearchListener, View.OnClickListener {
    private TextView tv_location;
    private ImageView iv_weather_icon;
    private TextView tv_temperature;
    private TextView tv_weather;
    private LinearLayout ll_weatherBG;
    private TextView tv_timeCurrent;
    private View sv_home_page;
    private boolean hidden  = false;
    private CommonApplication application;
    //定位相关
    private AMapLocationClient mLocationClient = null;
    //查询天气相关
    private boolean searchWeather = true;
    private WeatherSearchQuery query;
    private WeatherSearch mweathersearch;
    private String temperature, weather;
    //
    private ViewHolder1 viewHolder1;
    private ViewHolder2 viewHolder2;
    private ViewHolder3 viewHolder3;
    private ViewHolder4 viewHolder4;
    private ViewHolder5 viewHolder5;
    //ViewHolder1(今日任务)
    private ArrayList<Subtask> subtaskListOfUser = new ArrayList<>();
    //是否在切换回来时刷新
    private boolean isUnHiddenRefresh;
    private Unbinder unbinder;
 
    private NightWorkViewModel viewModel;
 
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        viewModel = ViewModelProviders.of(this).get(NightWorkViewModel.class);
        // Inflate the layout for this fragment
        View view = inflater.inflate(R.layout.fragment_home_pollution_scene, container, false);
        unbinder = ButterKnife.bind(this, view);
        return view;
    }
 
    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        searchWeather = true;
        initData();
        initUI(view);
        initCurLocation();
        initCurrentTime();
        initScrollView(savedInstanceState);
    }
 
 
 
    @Override
    public void onDestroy() {
        if (unbinder != null) {
            unbinder.unbind();
        }
        super.onDestroy();
        mLocationClient.onDestroy();
    }
 
    @Override
    public void onPause() {
        super.onPause();
        mLocationClient.stopLocation();
        searchWeather = true;
    }
 
    @Override
    public void onResume() {
        super.onResume();
        if (!hidden){
            mLocationClient.startLocation();
            initCurrentTime();
        }
//        refreshView();
    }
 
    @Override
    public void onStart() {
        super.onStart();
    }
 
    public HomeFragment_scene() {
        // Required empty public constructor
    }
 
    private void initData(){
        application = (CommonApplication) getActivity().getApplication();
    }
 
    private void initUI(View view) {
        tv_location = (TextView) view.findViewById(R.id.tv_location);
        tv_location.setOnClickListener(this);
        iv_weather_icon = (ImageView) view.findViewById(R.id.iv_weather_icon);
        //
        iv_weather_icon.setOnClickListener(this);
        //
        tv_temperature = (TextView) view.findViewById(R.id.tv_temperature);
        tv_weather = (TextView) view.findViewById(R.id.tv_weather);
        ll_weatherBG = (LinearLayout) view.findViewById(R.id.ll_weather_bg);
        tv_timeCurrent = (TextView) view.findViewById(R.id.tv_now_date_time);
        sv_home_page = view.findViewById(R.id.sv_home_page);
    }
    //初始化时间textView
    private void initCurrentTime() {
        Calendar calendar = Calendar.getInstance();
        tv_timeCurrent.setText(DateFormatter.dateFormatWeek.format(calendar.getTime()));
    }
 
    private void initScrollView(Bundle savedInstanceState){
//        sv_home_page.setLayoutManager(new LinearLayoutManager(getContext()));
//        parentAdapter = new RecyclerViewAdapter(getContext(),savedInstanceState);
//        sv_home_page.setAdapter(parentAdapter);
        viewHolder1 = new ViewHolder1(savedInstanceState, sv_home_page);
        viewHolder2 = new ViewHolder2(savedInstanceState, sv_home_page);
        viewHolder3 = new ViewHolder3(savedInstanceState, sv_home_page);
        viewHolder4 = new ViewHolder4(savedInstanceState, sv_home_page);
        viewHolder5 = new ViewHolder5();
 
        viewHolder1.initViewHolder1();
        viewHolder1.refreshView();
        viewHolder2.refreshView();
//        viewHolder3.initViewHolder3();
        viewHolder5.init();
    }
 
 
    private void initCurLocation() {
        final String curLocation = null;
        //声明定位回调监听器
        AMapLocationListener mLocationListener = new AMapLocationListener() {
            @Override
            public void onLocationChanged(AMapLocation aMapLocation) {
                if (aMapLocation != null) {
                    if (aMapLocation.getErrorCode() == 0) {
                        //可在其中解析amapLocation获取相应内容
                        //城市地址
                        String address = aMapLocation.getAddress();
                        tv_location.setText(address);
                        searchWeather(aMapLocation.getCity());
                    } else {
//                        Toast.makeText(getActivity(), "定位失败,请检查网络", Toast.LENGTH_SHORT).show();
                    }
                }
            }
        };
        //初始化定位
        mLocationClient = new AMapLocationClient(getActivity().getApplicationContext());
        //设置定位回调监听
        mLocationClient.setLocationListener(mLocationListener);
        //声明AMapLocationClientOption对象
        AMapLocationClientOption mLocationOption = null;
        //初始化AMapLocationClientOption对象
        mLocationOption = new AMapLocationClientOption();
        //设置定位模式为AMapLocationMode.Hight_Accuracy,高精度模式。
        mLocationOption.setLocationMode(AMapLocationClientOption.AMapLocationMode.Hight_Accuracy);
        //设置定位模式为AMapLocationMode.Battery_Saving,低功耗模式。
        mLocationOption.setLocationMode(AMapLocationClientOption.AMapLocationMode.Battery_Saving);
        //设置定位间隔,单位毫秒,默认为2000ms,最低1000ms。
        mLocationOption.setInterval(10000);
        //设置是否返回地址信息(默认返回地址信息)
        mLocationOption.setNeedAddress(true);
        //设置是否强制刷新WIFI,默认为true,强制刷新。
        mLocationOption.setWifiActiveScan(true);
        //设置是否允许模拟位置,默认为true,允许模拟位置
        mLocationOption.setMockEnable(true);
        //关闭缓存机制
        mLocationOption.setLocationCacheEnable(false);
        //给定位客户端对象设置定位参数
        mLocationClient.setLocationOption(mLocationOption);
        //启动定位
        mLocationClient.startLocation();
 
    }
    //根据城市搜索天气
    private void searchWeather(String city) {
        query = new WeatherSearchQuery(city, WeatherSearchQuery.WEATHER_TYPE_LIVE);
        mweathersearch = new WeatherSearch(getContext());
        mweathersearch.setOnWeatherSearchListener(this);
        mweathersearch.setQuery(query);
        mweathersearch.searchWeatherAsyn(); //异步搜索
    }
 
    @Override
    public void onHiddenChanged(boolean hidden) {
        super.onHiddenChanged(hidden);
        this.hidden = hidden;
        if (hidden) {
            mLocationClient.stopLocation();
            searchWeather = true;
        } else {
            mLocationClient.startLocation();
            initCurrentTime();
//            viewHolder2.clearView();
//            refreshView();
            if (isUnHiddenRefresh) {
                refreshView();
                isUnHiddenRefresh = !isUnHiddenRefresh;
            }
        }
    }
 
    //设置是否在切换回来时刷新
    public void setUnHiddenRefresh(boolean unHiddenRefresh) {
        isUnHiddenRefresh = unHiddenRefresh;
    }
 
    @Override
    public void onWeatherLiveSearched(LocalWeatherLiveResult localWeatherLiveResult, int i) {
        if (searchWeather) {
            if (i == 1000) {
                if (localWeatherLiveResult != null || localWeatherLiveResult.getLiveResult() != null) {
                    LocalWeatherLive weatherlive = localWeatherLiveResult.getLiveResult();
                    temperature = weatherlive.getTemperature() + "°";
                    weather = weatherlive.getWeather().trim();
                    tv_weather.setText(weather);
                    tv_temperature.setText(temperature);
                    if (weather != null && !weather.trim().equals("")) {
                        if (weather.equals("多云")) {
                            iv_weather_icon.setBackgroundResource(R.drawable.weather_icon_1);
                            ll_weatherBG.setBackgroundResource(R.drawable.home_feeds_weather_bkg_cloudy);
                        } else if (weather.equals("晴")) {
                            iv_weather_icon.setBackgroundResource(R.drawable.weather_icon_0);
                            ll_weatherBG.setBackgroundResource(R.drawable.home_feeds_weather_bkg_sunny);
                        } else if (weather.equals("阴")) {
                            iv_weather_icon.setBackgroundResource(R.drawable.weather_icon_2);
                            ll_weatherBG.setBackgroundResource(R.drawable.home_feeds_weather_bkg_cloudy);
                        } else if (weather.equals("小雨")) {
                            iv_weather_icon.setBackgroundResource(R.drawable.weather_icon_3);
                            ll_weatherBG.setBackgroundResource(R.drawable.home_feeds_weather_bkg_rain);
                        } else if (weather.equals("中雨")) {
                            iv_weather_icon.setBackgroundResource(R.drawable.weather_icon_4);
                            ll_weatherBG.setBackgroundResource(R.drawable.home_feeds_weather_bkg_rain);
                        } else if (weather.equals("大雨")) {
                            iv_weather_icon.setBackgroundResource(R.drawable.weather_icon_5);
                            ll_weatherBG.setBackgroundResource(R.drawable.home_feeds_weather_bkg_rain);
                        } else if(weather.equals("阵雨")){
                            iv_weather_icon.setBackgroundResource(R.drawable.weather_icon_8);
                            ll_weatherBG.setBackgroundResource(R.drawable.home_feeds_weather_bkg_rain);
                        } else if (weather.equals("雨夹雪")){
                            iv_weather_icon.setBackgroundResource(R.drawable.weather_icon_15);
                            ll_weatherBG.setBackgroundResource(R.drawable.home_feeds_weather_bkg_rain);
                        }else if (weather.equals("小雪")){
                            iv_weather_icon.setBackgroundResource(R.drawable.weather_icon_9);
                            ll_weatherBG.setBackgroundResource(R.drawable.home_feeds_weather_bkg_rain);
                        }else if (weather.equals("中雪")){
                            iv_weather_icon.setBackgroundResource(R.drawable.weather_icon_10);
                            ll_weatherBG.setBackgroundResource(R.drawable.home_feeds_weather_bkg_rain);
                        }else if (weather.equals("大雪")){
                            iv_weather_icon.setBackgroundResource(R.drawable.weather_icon_11);
                            ll_weatherBG.setBackgroundResource(R.drawable.home_feeds_weather_bkg_rain);
                        }
                    }
                    searchWeather = false;
                }
            }
        }
 
    }
 
    @Override
    public void onWeatherForecastSearched(LocalWeatherForecastResult localWeatherForecastResult, int i) {
 
    }
 
    @Override
    public void onClick(View view) {
        switch (view.getId()){
            case R.id.iv_weather_icon:
                Toast.makeText(getContext(),"打开天气详情", Toast.LENGTH_SHORT).show();
                break;
        }
 
    }
 
    public enum ITEM_TYPE {
        ITEM1,
        ITEM2,
        ITEM3,
        ITEM4,
        ITEM5
    }
 
    public void refreshView(){
        viewHolder1.initViewHolder1();
        viewHolder1.refreshView();
        viewHolder2.refreshView();
    }
 
    /**
     * 返回当前用户执行的子任务列表
     * @param msubtaskList
     * @return
     */
    public ArrayList<Subtask> getmSubtaskListOfUser(List<Subtask> msubtaskList){
        if (application.getCurrentUser().getUsertypeid() == 2) {//主管部门的任务展示按照区县划分
            subtaskListOfUser.clear();
            for (Subtask subtask : msubtaskList) {
                if (subtask.getDistrictcode().equals(application.getCurrentUser().getDguid()))//区县行政编码判定,只显示对应区县的任务
                    subtaskListOfUser.add(subtask);
            }
        }
        return subtaskListOfUser;
    }
 
 
    //<editor-fold desc="ViewHolder1">
    @BindView(R.id.text_rank) TextView text_rank;
    @BindView(R.id.image_rank) ImageView image_rank;
    @BindView(R.id.text_rank_detail_1) TextView text_rank_detail_1;
    @BindView(R.id.text_rank_detail_2) TextView text_rank_detail_2;
    @BindView(R.id.text_rank_detail_3) TextView text_rank_detail_3;
 
    private List<TaskVo> taskVoList = new ArrayList<>();//用户场景对应的区县所有的顶层任务
    private Scense curScene = new Scense();//当前用户对应的场景信息
    private int lastMonthRank;//上月排名
    private int monthBeforeLastMonthRank;//上上月排名
 
    public class ViewHolder1  {
 
        ViewHolder1(Bundle savedInstanceState, View itemView) {
 
        }
 
        void initViewHolder1(){
            String s1 = lastMonthRank == 0 || lastMonthRank > 99 ? "您上月无排名" : "您上月排名第" + lastMonthRank + "名";
            String s2 = "无排名对比";
            text_rank_detail_3.setText(R.string.rank_tip_4);
 
            //<editor-fold desc="填写排名">
            if (lastMonthRank == 0 || lastMonthRank > 99) {
                text_rank.setText("--");
            }else if (lastMonthRank > 0 && lastMonthRank < 10){
                String tmp = "0" + String.valueOf(lastMonthRank);
                text_rank.setText(tmp);
            }else {
                text_rank.setText(String.valueOf(lastMonthRank));
            }
            //</editor-fold>
 
            if (lastMonthRank == 0
                    || monthBeforeLastMonthRank == 0) {
                image_rank.setImageResource(R.drawable.icon_rank_no_change_2);
 
            } else {
                if (lastMonthRank == monthBeforeLastMonthRank) {
                    image_rank.setImageResource(R.drawable.icon_rank_no_change_2);
                    s2 = "较上上月排名无变化";
                    text_rank_detail_3.setText(R.string.rank_tip_3);
                } else if (lastMonthRank - monthBeforeLastMonthRank > 0) {
                    image_rank.setImageResource(R.drawable.icon_rank_down_2);
                    s2 = "较上上月排名下降" + (lastMonthRank - monthBeforeLastMonthRank) + "名";
                    text_rank_detail_3.setText(R.string.rank_tip_2);
                } else {
                    image_rank.setImageResource(R.drawable.icon_rank_up_2);
                    s2 = "较上上月排名上升" + (monthBeforeLastMonthRank - lastMonthRank) + "名";
                    text_rank_detail_3.setText(R.string.rank_tip_1);
                }
            }
 
            text_rank_detail_1.setText(s1);
            text_rank_detail_2.setText(s2);
        }
 
        void refreshView() {
            getTaskList();
        }
 
        void getTaskList() {
            ScenseDao scenseDao = application.getDaoSession().getScenseDao();
            String sceneId = application.getCurrentUser().getDguid();
            List<Scense> scenses = scenseDao.queryBuilder()
                    .where(ScenseDao.Properties.Guid.eq(
                            sceneId == null ? "" : sceneId)
                    ).list();
            if (!scenses.isEmpty()) {
                curScene = scenses.get(0);
            }
            //顶层任务
            Call<ArrayList<TaskVo>> getTopClassTaskList = application.getRetrofit().create(TaskService.class).getTopClassTaskList(0);
            final Scense finalScense = curScene;
            getTopClassTaskList.enqueue(new Callback<ArrayList<TaskVo>>() {
                @Override
                public void onResponse(Call<ArrayList<TaskVo>> call, Response<ArrayList<TaskVo>> response) {
                    if (response.body() != null) {
                        List<TaskVo> allTaskVoList = response.body();//返回结果默认按时间降序排序
                        for (TaskVo t : allTaskVoList) {
                            if (t.getDistrictcode().equals(finalScense.getDistrictcode())) {//主管部门的部门id就是区县id
                                taskVoList.add(t);
                            }
                        }
                        Date now = new Date();
                        if (taskVoList.size() >= 2 && (taskVoList.get(0).getStarttime().before(now))) {
                            getRank(taskVoList.get(1));
                            viewHolder3.refreshView();
                        }
                    }
                }
 
                @Override
                public void onFailure(Call<ArrayList<TaskVo>> call, Throwable t) {
                }
            });
        }
 
        private boolean isDone = false;//需要分别查询上月与上上月客户场景的排名,以便做比较
 
        void getRank(TaskVo taskVo) {
            final Call<RankVo> getRank = application.getRetrofit().create(TaskService.class).getRank(taskVo.getTguid(), String.valueOf(curScene.getTypeid()), curScene.getGuid());
            getRank.enqueue(new Callback<RankVo>() {
                @Override
                public void onResponse(Call<RankVo> call, Response<RankVo> response) {
                    if (response.body() != null) {
                        //上月排名
                        if (!isDone) {
                            RankVo rankVo = response.body();
                            List<RankVo.SceneRank> sceneRanks = rankVo.getSceneRanks();
                            AnalysisOverViewFragment.rankS(sceneRanks);
                            for (int i = 0; i < sceneRanks.size(); i++) {
                                if (curScene.getGuid().equals(sceneRanks.get(i).getSceneNameId())
                                        && sceneRanks.get(i).getScore() > -1) {
                                    lastMonthRank =sceneRanks.get(i).getRankNo();//上月排名
                                    initViewHolder1();
                                    break;
                                }
                            }
                            if (taskVoList.size() >= 3) {
                                isDone = true;
                                getRank(taskVoList.get(2));
                            }
                        }
                        //上上月排名
                        else {
                            RankVo rankVo = response.body();
                            List<RankVo.SceneRank> sceneRanks = rankVo.getSceneRanks();
                            AnalysisOverViewFragment.rankS(sceneRanks);
                            for (int i = 0; i < sceneRanks.size(); i++) {
                                if (curScene.getGuid().equals(sceneRanks.get(i).getSceneNameId())
                                        && sceneRanks.get(i).getScore() > -1) {
                                    monthBeforeLastMonthRank = sceneRanks.get(i).getRankNo();//上上月排名
                                    initViewHolder1();
                                    break;
                                }
                            }
                            isDone = false;
                        }
                    }
                }
 
                @Override
                public void onFailure(Call<RankVo> call, Throwable t) {
                }
            });
        }
 
    }
 
    //</editor-fold>
 
    //<editor-fold desc="ViewHolder2">
    @BindView(R.id.rv_announcement) RecyclerView rv_announcement;
    @BindView(R.id.text_no_announcement) TextView text_no_announcement;
 
    public class ViewHolder2  {
 
        ViewHolder2(Bundle savedInstanceState, View itemView) {
 
        }
 
        void refreshView(){
            initViewholder2();
        }
 
        private void initViewholder2(){
 
        }
 
    }
    //</editor-fold>
 
    //<editor-fold desc="ViewHolder3">
    @BindView(R.id.text_no_supervise_tips) TextView text_no_supervise_tips;//等待监管时的建议
 
    @BindView(R.id.text_inspection_time) TextView text_inspection_time;//监管时间
    @BindView(R.id.text_inspection_times) TextView text_inspection_times;//监管次数
    @BindView(R.id.group_1) Group group_1;//text_inspection_time and text_inspection_times
    @BindView(R.id.cl_1) ConstraintLayout cl_1;//text_inspection_time and text_inspection_times
 
    @BindView(R.id.text_change_promise) TextView text_change_promise;//是否承诺
    @BindView(R.id.text_change_status) TextView text_change_status;//是否整改
    @BindView(R.id.cl_2) ConstraintLayout cl_2;//text_change_promise and text_change_status
 
    @BindView(R.id.image_inspection_status) ImageView image_inspection_status;//监管状态
 
    public class ViewHolder3  {
 
        ViewHolder3(Bundle savedInstanceState, View itemView) {
        }
 
        void refreshView() {
            initViewHolder3();
        }
 
        /**
         * 在{@link ViewHolder1#getRank(TaskVo)}第一次被调用后(确保当前场景在当前时间有对应的顶层任务),才会调用此函数
         */
        private void initViewHolder3(){
            String sceneId = application.getCurrentUser().getDguid();
            String topTaskId = taskVoList.get(0).getTguid();
            Call<InspectionInfoVo> getInspectionInfoByScene = application.getRetrofit().create(InspectionService.class).getInspectionInfoByScene(sceneId, topTaskId);
            getInspectionInfoByScene.enqueue(new Callback<InspectionInfoVo>() {
                @Override
                public void onResponse(Call<InspectionInfoVo> call, Response<InspectionInfoVo> response) {
                    if (response.body() != null) {
                        initView(response.body());
                        viewHolder4.refreshView(response.body());
                    }
                }
 
                @Override
                public void onFailure(Call<InspectionInfoVo> call, Throwable t) {
 
                }
            });
        }
 
        void initView(InspectionInfoVo infoVo) {
            //已巡查
            if (infoVo.isInspected()) {
                text_no_supervise_tips.setVisibility(View.INVISIBLE);
                cl_1.setVisibility(View.VISIBLE);
                cl_2.setVisibility(View.VISIBLE);
                image_inspection_status.setSelected(true);
 
                text_inspection_time.setText(infoVo.getInspectionTime());
                text_inspection_times.setText(
                        String.valueOf(
                                infoVo.getUnChangedCount() + infoVo.getChangedCount()
                        )
                );
 
                text_change_promise.setSelected(infoVo.isPromised());
                text_change_promise.setText(infoVo.isPromised() ? R.string.promised : R.string.refused);
 
                text_change_status.setSelected(infoVo.isChanged());
                text_change_status.setText(infoVo.isChanged() ? R.string.changed : R.string.unchanged);
            }
            //未巡查
            else {
                text_no_supervise_tips.setVisibility(View.VISIBLE);
                cl_1.setVisibility(View.GONE);
                cl_2.setVisibility(View.INVISIBLE);
                image_inspection_status.setSelected(false);
            }
        }
 
 
    }
    //</editor-fold>
 
    //<editor-fold desc="ViewHolder4">
    @BindView(R.id.text_change_count) TextView text_change_count;
    @BindView(R.id.text_changed_count) TextView text_changed_count;
    @BindView(R.id.text_change_info) TextView text_change_info;
    @BindView(R.id.text_change_left_day) TextView text_change_left_day;
    @BindView(R.id.textView4) TextView textView4;
 
    @BindView(R.id.group_deadline) Group group_deadline;
    @BindView(R.id.image_done) ImageView image_done;
    public class ViewHolder4 {
 
        ViewHolder4(Bundle savedInstanceState, View itemView) {
 
        }
 
        void refreshView(InspectionInfoVo infoVo) {
            initViewHolder4(infoVo);
        }
 
        /**
         * 在{@link ViewHolder3#initViewHolder3()}函数第一次被调用后,才能调用此函数
         */
        void initViewHolder4(InspectionInfoVo infoVo) {
            text_change_count.setText(String.valueOf(infoVo.getUnChangedCount()));
            text_changed_count.setText(String.valueOf(infoVo.getChangedCount()));
            String promisedTime = infoVo.getPromisedTime();
            try {
                //未整改完成
                if (infoVo.getUnChangedCount() > 0) {
                    Date promisedTime_d = null;
                    if (promisedTime == null || promisedTime.equalsIgnoreCase("null")) {
                        promisedTime_d = DateFormatter.dateFormat2.parse(infoVo.getInspectionTime());
                    } else {
                        promisedTime_d = DateFormatter.dateFormat.parse(promisedTime);
                    }
                    Calendar calendar = Calendar.getInstance();
                    calendar.set(Calendar.HOUR_OF_DAY, 0);
                    calendar.set(Calendar.MINUTE, 0);
                    calendar.set(Calendar.SECOND, 0);
                    Date today = calendar.getTime();
                    int leftDays = (int) (promisedTime_d.getTime() - today.getTime()) / 1000 / 60 / 60 / 24;
                    if (leftDays >= 0) {
                        text_change_left_day.setText(String.valueOf(leftDays));
                    } else {
                        text_change_info.setText("您已逾期");
                        text_change_left_day.setText(String.valueOf(-leftDays));
                    }
                    group_deadline.setVisibility(View.VISIBLE);
                    image_done.setVisibility(View.GONE);
                }
                //整改完成
                else {
                    group_deadline.setVisibility(View.GONE);
                    image_done.setVisibility(View.VISIBLE);
                }
            } catch (ParseException e) {
                e.printStackTrace();
            }
        }
    }
    //</editor-fold>
 
    @BindView(R.id.cl_night_work) ConstraintLayout cl_night_work;
    @BindView(R.id.txt_news) TextView txt_news;
    public class ViewHolder5 {
 
        void init() {
            cl_night_work.setOnClickListener(v -> startActivity(new Intent(getContext(), NightWorkRecordActivity.class)));
            viewModel.getNightWorkFile(false, 1, new ResultCallBack<List<NightWorkFileVo>>(){
                @Override
                public void onCacheSuccess(@org.jetbrains.annotations.Nullable List<NightWorkFileVo> result) {
 
                }
 
                @Override
                public void onPage(int current, int total) {
 
                }
 
                @Override
                public void onSuccess(@org.jetbrains.annotations.Nullable List<NightWorkFileVo> result) {
                    if (result == null || result.isEmpty()) {
                        txt_news.setText("暂无新许可证");
                    } else {
                        txt_news.setText("有新许可证下发,请查看");
                    }
                }
 
                @Override
                public void onFailure() {
                    txt_news.setText("网络连接失败,请退出重试");
                }
            });
        }
    }
 
 
 
 
    //<editor-fold desc="点击事件">
    @OnClick({R.id.card_change_problem, R.id.card_changed_problem})
    void OnClick() {
        Intent intent = new Intent("cn.flightfeather.thirdapp.broadcasereceiver.MainReceiver");
        intent.setAction(Constant.GOTO_INSPECTION_FRAGMENT);
        getActivity().sendBroadcast(intent);
    }
    //</editor-fold>
}