riku
2022-02-18 d59d55575d913646b7a90fca651904ab889c6723
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
package cn.flightfeather.thirdappmodule.adapter;
 
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
 
import java.util.List;
import java.util.Objects;
 
import cn.flightfeather.thirdappmodule.R;
import cn.flightfeather.thirdappmodule.bean.vo.ProblemlistVo;
import cn.flightfeather.thirdappmodule.util.Domain;
 
/**
 * Created by note_ff_1602 on 2018/1/26.
 */
 
public class ProblemListAdapter extends RecyclerView.Adapter<ProblemListAdapter.ProblemListHolder> {
    private Context context;
    private LayoutInflater layoutInflater;
    private List<ProblemlistVo> problemlistVoList;
    public static  final int PROBLEM_LIST =10;
    public static final int RECHECK_LIST =11;
    public static final int PROBLEM_CHECK_LIST =12;
    public static final int CHANGE_CHECK_LIST =13;
    private int type;
 
    public ProblemListAdapter(Context context, List<ProblemlistVo> problemlistVoList, int type) {
        this.context = context;
        this.problemlistVoList = problemlistVoList;
        layoutInflater = LayoutInflater.from(context);
        this.type = type;
    }
 
    @Override
    public ProblemListHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = layoutInflater.inflate(R.layout.item_problem_list,parent,false);
        return new ProblemListHolder(view);
    }
 
    @Override
    public void onBindViewHolder(ProblemListHolder holder, int position) {
        ProblemlistVo problemlistVo = problemlistVoList.get(position);
        holder.tv_count.setText(""+(position+1));
        holder.tv_name.setText(problemlistVo.getProblemname());
        holder.tv_loaction.setText(problemlistVo.getLocation());
        switch (type) {
            case PROBLEM_LIST:
                if (problemlistVo.getIschanged()){
                    holder.tv_status.setText("已整改");
                }else {
                    holder.tv_status.setText("未整改");
                }
                break;
            case RECHECK_LIST:
                if (problemlistVo.getIsrechecked()){
                    holder.tv_status.setText("已复核");
                }else {
                    holder.tv_status.setText("未复核");
                }
                break;
            case PROBLEM_CHECK_LIST:
                if (Objects.equals(problemlistVo.getExtension3(), Domain.PROBLEM_UNCHECKED)) {
                    holder.tv_status.setText("未审核");
                } else if (Objects.equals(problemlistVo.getExtension3(), Domain.PROBLEM_CHECK_FAIL)) {
                    holder.tv_status.setText("未通过");
                } else {
                    holder.tv_status.setText("已审核");
                }
                break;
            case CHANGE_CHECK_LIST:
                if (Objects.equals(problemlistVo.getExtension3(), Domain.CHANGE_UNCHECKED)) {
                    holder.tv_status.setText("未审核");
                } else if (Objects.equals(problemlistVo.getExtension3(), Domain.CHANGE_CHECK_FAIL)) {
                    holder.tv_status.setText("未通过");
                } else if (Objects.equals(problemlistVo.getExtension3(), Domain.CHANGE_CHECK_PASS)) {
                    holder.tv_status.setText("通过");
                } else {
                    holder.tv_status.setText("未整改");
                }
                break;
        }
    }
 
    @Override
    public int getItemCount() {
        return problemlistVoList.size();
    }
 
    public class ProblemListHolder extends RecyclerView.ViewHolder{
        TextView tv_count;
        TextView tv_name;
        TextView tv_loaction;
        TextView tv_status;
 
        public ProblemListHolder(View itemView) {
            super(itemView);
            tv_count = (TextView) itemView.findViewById(R.id.tv_count);
            tv_name = (TextView) itemView.findViewById(R.id.tv_name);
            tv_loaction = (TextView) itemView.findViewById(R.id.tv_location);
            tv_status = (TextView) itemView.findViewById(R.id.tv_status);
        }
    }
}