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
package cn.flightfeather.thirdapp.dataanalysis;
 
import android.content.Context;
import android.content.Intent;
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.ProgressBar;
import android.widget.TextView;
 
import java.util.List;
 
import am.widget.circleprogressbar.CircleProgressBar;
import cn.flightfeather.thirdapp.R;
import cn.flightfeather.thirdapp.bean.vo.TaskVo;
import cn.flightfeather.thirdapp.util.CommonUtils;
import cn.flightfeather.thirdapp.view.ScrollTextView;
 
/**
 * Created by hyhb01 on 2018/3/20.
 * 顶层任务进度是适配器
 */
 
public class TaskProgressAdapter extends RecyclerView.Adapter<TaskProgressAdapter.TaskProgressHoler> {
 
    private Context context;
    private List<TaskVo> taskProgressVoList;
 
    public TaskProgressAdapter(List<TaskVo> taskProgressVos, Context context){
        this.taskProgressVoList = taskProgressVos;
        this.context = context;
    }
 
    @Override
    public TaskProgressHoler onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(context).inflate(R.layout.item_task_progress_2, parent, false);
        return new TaskProgressHoler(view);
    }
 
    @Override
    public void onBindViewHolder(TaskProgressHoler holder, final int position) {
        //region 顶层任务状态
        TaskVo thistaskProgressVo = taskProgressVoList.get(position);
        int toptaskprogress = (int) (thistaskProgressVo.getCompletetask()/(float) thistaskProgressVo.getTotaltask()*100);
        holder.text_top_task.setText(taskProgressVoList.get(position).getName());
        holder.progress_complete.setProgress(toptaskprogress);
        holder.image_top_task.setImageResource(CommonUtils.getIconByTaskType(taskProgressVoList.get(position).getTypeno().toString()));
        switch (toptaskprogress) {
            case 0:
                holder.text_taskStatus.setText("未开始");
                break;
            case 100:
                holder.text_taskStatus.setText("已结束");
                break;
            default:
                holder.text_taskStatus.setText("进行中");
                break;
        }
        //endregion
 
        //region 我的任务进度
//        int mytaskprogress = (int) (thistaskProgressVo.getMycompletetask()/(float) thistaskProgressVo.getMytotaltask()*100);
//        holder.TV_my_progress.setTitle(String.valueOf(mytaskprogress) + "%");
//        holder.PB_my_progress.setProgress(mytaskprogress);
        //endregion
 
        holder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
//                showDialog(taskProgressVoList.get(position));
                //region 点击跳转至对应顶层任务的具体界面
                TaskVo taskProgressVo = taskProgressVoList.get(position);
                Intent intent = new Intent(context, AnalysisTabActivity.class);
                intent.putExtra(AnalysisTabActivity.ARG_PARAM1, taskProgressVo);
                context.startActivity(intent);
                //endregion
            }
        });
    }
 
    @Override
    public int getItemCount() {
        return taskProgressVoList.size();
    }
 
    class TaskProgressHoler extends RecyclerView.ViewHolder{
 
        ScrollTextView text_top_task;//顶层任务名称
 
        TextView text_taskStatus;//顶层任务当前状态“未开始”、“进行中”、“已结束”
 
        CircleProgressBar progress_complete;//完成百分比进度
 
        ImageView image_top_task;//任务图标随着任务类型不同而改变
 
        private TextView TV_top_task_progress;
        private TextView TV_my_progress;
        private TextView TV_No;
 
        private ProgressBar PB_top_task_progress;
        private ProgressBar PB_my_progress;
 
 
 
        public TaskProgressHoler(View itemView) {
            super(itemView);
            text_top_task = itemView.findViewById(R.id.text_top_task);
            text_taskStatus = itemView.findViewById(R.id.text_taskStatus);
            progress_complete = itemView.findViewById(R.id.progress_complete);
            image_top_task = itemView.findViewById(R.id.image_top_task);
        }
    }
 
}