package cn.flightfeather.thirdapp.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.thirdapp.R; import cn.flightfeather.thirdapp.bean.vo.ProblemlistVo; import cn.flightfeather.thirdapp.util.Domain; /** * Created by note_ff_1602 on 2018/1/26. */ public class ProblemListAdapter extends RecyclerView.Adapter { private Context context; private LayoutInflater layoutInflater; private List 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 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); } } }