package com.qhclh.ytzh.work.tablepoultry;

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.bean.ReportBean;

import java.util.List;

/**
 * Created by 青花瓷 on 2017/6/29.
 */
///< 利润分析中的适配器
public class LvReportInfoAdapter extends BaseAdapter {
    private Context context;
    private List<ReportBean> list;

    public LvReportInfoAdapter(Context context, List<ReportBean> 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 position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        ReportBean message = list.get(position);
        if (convertView == null) {
            holder = new ViewHolder();
            convertView = LayoutInflater.from(context).inflate(R.layout.item_lv_buildhouse_info, null);
            holder.item_dayage = (TextView) convertView.findViewById(R.id.item_dayage);
            holder.item_death = (TextView) convertView.findViewById(R.id.item_death);
            holder.item_eliminatee = (TextView) convertView.findViewById(R.id.item_eliminatee);
            holder.item_water = (TextView) convertView.findViewById(R.id.item_water);
            holder.item_weight = (TextView) convertView.findViewById(R.id.item_weight);
            holder.ll_buildhouseinfo =  convertView.findViewById(R.id.ll_buildhouseinfo);


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

        ///< 自己看拼音吧 我也不想看了
        holder.item_dayage.setText(message.getItem_dayage());
        holder.item_death.setText(message.getItem_death());
        holder.item_eliminatee.setText(message.getItem_eliminatee());
        holder.item_water.setText(message.getItem_water());
        holder.item_weight.setText(message.getItem_weight());

        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_dayage;
        TextView item_death;
        TextView item_eliminatee;
        TextView item_water;
        TextView item_weight;
        LinearLayout ll_buildhouseinfo;
    }
}


