package com.qhclh.ytzh.work.Poultrydailyreport;

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 java.util.List;

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

    public PoultryReportInfoAdapter(Context context, List<PoultryReportBean> 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).getHouse_ID();
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        PoultryReportBean message = list.get(position);
        if (convertView == null) {
            holder = new ViewHolder();
            convertView = LayoutInflater.from(context).inflate(R.layout.item_lv_poultry_info, null);
            holder.item_zhouling = (TextView) convertView.findViewById(R.id.item_zhouling);
            holder.item_musitao = (TextView) convertView.findViewById(R.id.item_musitao);
            holder.item_gongsitao = (TextView) convertView.findViewById(R.id.item_gongsitao);
            holder.item_muchenghuolv = (TextView) convertView.findViewById(R.id.item_muchenghuolv);
            holder.item_gongchenghuolv = (TextView) convertView.findViewById(R.id.item_gongchenghuolv);
            holder.item_muzhiliaoliang = (TextView) convertView.findViewById(R.id.item_muzhiliaoliang);
            holder.item_mucaishi = (TextView) convertView.findViewById(R.id.item_mucaishi);


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


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

        ///< 自己看拼音吧 我也不想看了
        holder.item_zhouling.setText(message.getWeek());
        holder.item_musitao.setText(message.getFemaleSiTaoNumber());
        holder.item_gongsitao.setText(message.getMaleSiTaoNumber());
        holder.item_muchenghuolv.setText(message.getFemaleSurvivalRate());
        holder.item_gongchenghuolv.setText(message.getMaleSurvivalRate());
        holder.item_muzhiliaoliang.setText(message.getFemalePerFeedNumber());
        holder.item_mucaishi.setText(message.getFemaleEatTime());

        holder.item_dongshe.setText(message.getHouse_Name());

        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_zhouling;
        TextView item_musitao;
        TextView item_gongsitao;

        TextView item_muchenghuolv;
        TextView item_gongchenghuolv;
        TextView item_muzhiliaoliang;
        TextView item_mucaishi;


        TextView item_dongshe;
        LinearLayout ll_buildhouseinfo;
    }
}


