package com.qhclh.ytzh.work.Hatchery;

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

import com.qhclh.ytzh.R;
import com.qhclh.ytzh.work.Poultrydailyreport.PoultryReportBean;

import java.util.List;

/**
 * Created by 青花瓷 on 2017/6/29.
 */
///< 具体信息
public class HatcheryReportInfoAdapter extends BaseAdapter {
    private Context context;
    private List<HatcheryReportBean> list;

    public HatcheryReportInfoAdapter(Context context, List<HatcheryReportBean> list) {
        this.context = context;
        this.list = list;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return list.get(position).getID();
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        HatcheryReportBean message = list.get(position);
        if (convertView == null) {
            holder = new ViewHolder();
            convertView = LayoutInflater.from(context).inflate(R.layout.item_lv_hatchery_info, null);
            holder.item_rufushijian = (TextView) convertView.findViewById(R.id.item_rufushijian);
            holder.item_yangzhichang = (TextView) convertView.findViewById(R.id.item_yangzhichang);
            holder.item_zhouling = (TextView) convertView.findViewById(R.id.item_zhouling);
            holder.item_shangfushuliang = (TextView) convertView.findViewById(R.id.item_shangfushuliang);
            holder.item_huopeidanshuliang = (TextView) convertView.findViewById(R.id.item_huopeidanshuliang);
            holder.item_sipeidanshuliang = (TextView) convertView.findViewById(R.id.item_sipeidanshuliang);
            holder.item_yujichuchushu = (TextView) convertView.findViewById(R.id.item_yujichuchushu);
            holder.item_jianpeidanlv = (TextView) convertView.findViewById(R.id.item_jianpeidanlv);


            holder.ll_buildhouseinfo =  convertView.findViewById(R.id.ll_buildhouseinfo);
            holder.item_sipeilv =  convertView.findViewById(R.id.item_sipeilv);


            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }

        ///< 自己看拼音吧 我也不想看了
        holder.item_rufushijian.setText(message.getHatchIncubateDate());
        holder.item_yangzhichang.setText(message.getBreedFactory_Name());
        holder.item_zhouling.setText(message.getWeekAge());

        holder.item_shangfushuliang.setText(message.getHatchIncubateNumber());
        holder.item_huopeidanshuliang.setText(message.getNumberSurvival_HatchDownTray());
        holder.item_sipeidanshuliang.setText(message.getNumberDead_HatchDownTray());

        holder.item_yujichuchushu.setText(message.getNumber_HatchChickOut_Estimated());
        holder.item_jianpeidanlv.setText(message.getSurvivalyRate());

        holder.item_sipeilv.setText(message.getDeadRate());

        if (position%2==0){
            holder.ll_buildhouseinfo.setBackgroundColor(context.getResources().getColor(R.color.greyf4f4f4));
        }else {
            holder.ll_buildhouseinfo.setBackgroundColor(context.getResources().getColor(R.color.white));
        }

        return convertView;
    }
    private class ViewHolder {
        TextView item_rufushijian;
        TextView item_yangzhichang;
        TextView item_zhouling;

        TextView item_shangfushuliang;
        TextView item_huopeidanshuliang;
        TextView item_sipeidanshuliang;

        TextView item_yujichuchushu;
        TextView item_jianpeidanlv;

        TextView item_sipeilv;
        LinearLayout ll_buildhouseinfo;
    }
}


