package com.oo.eye.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.app.baselibrary.commonUtil.CheckUtil;
import com.app.baselibrary.recycler.adapter.BaseRecyclerViewAdapter;
import com.app.baselibrary.recycler.itemholder.ItemViewHolder;
import com.oo.eye.R;
import com.oo.eye.bean.ChartsBean;
import com.oo.eye.bean.StudentBean;

import java.util.List;

/**
 * Date : 2018/8/28.
 * Author:  cxh
 */

public class TestResultListAdapter extends BaseRecyclerViewAdapter<StudentBean, ItemViewHolder> {
    private final LayoutInflater mInflater;

    public TestResultListAdapter(List<StudentBean> list, Context context) {
        super(list, context);
        mInflater = LayoutInflater.from(mContext);
    }

    @Override
    public ItemViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return new ItemViewHolder(mInflater.inflate(R.layout.item_testresultlist, parent, false));
    }

    @Override
    public void onBindViewHolder(ItemViewHolder holder, int position) {
        final StudentBean studentBean = mList.get(position);
        TextView orderText = (TextView) holder.itemView.findViewById(R.id.test_number);
        orderText.setText(CheckUtil.isEmpty(studentBean.getNumber()) ? "--" : studentBean.getNumber());
        TextView groupText = (TextView) holder.itemView.findViewById(R.id.test_group);
        groupText.setText(studentBean.getClassname());
        TextView nameText = (TextView) holder.itemView.findViewById(R.id.test_name);
        nameText.setText(studentBean.getRealname());
        TextView birthdayText = (TextView) holder.itemView.findViewById(R.id.test_birthday);
        birthdayText.setText(CheckUtil.isEmpty(studentBean.getBirthday()) ? "--" : studentBean.getBirthday());
        TextView testResult = (TextView) holder.itemView.findViewById(R.id.test_result);
        testResult.setText(studentBean.getLeft_eye() + " | " + studentBean.getRight_eye());
        TextView isA = (TextView) holder.itemView.findViewById(R.id.test_isa);
        boolean isa = studentBean.getLeft_eye() >= 5.0 && studentBean.getRight_eye() >= 5.0;
        isA.setText(isa ? "是" : "否");
    }


    @Override
    public int getItemCount() {
        return mList.size();
    }
}
