package com.qhclh.ytzh.work.productiondaily;

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

import com.qhclh.ytzh.R;
import com.qhclh.ytzh.bean.ProductionDailyDetailBean;

import java.util.List;

/**
 * Created by 青花瓷 on 2017/12/5.
 */

public class ProductiondailydetailAdapter extends BaseAdapter {
    private Context context;
    private List<ProductionDailyDetailBean> list;
    private LayoutInflater layoutInflater;

    public ProductiondailydetailAdapter(Context context, List<ProductionDailyDetailBean> list) {
        this.context = context;
        this.list = list;
        layoutInflater = LayoutInflater.from(context);
    }

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

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

    @Override
    public long getItemId(int i) {
        return list.get(i).getHouse_ID();
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        ViewHolder viewHolder;
        ProductionDailyDetailBean message = list.get(i);
        if (view == null){
            view = layoutInflater.inflate(R.layout.item_productiondailydetail,viewGroup,false);
            viewHolder = new ViewHolder();

            viewHolder.production_info_buildinghome = view.findViewById(R.id.production_info_buildinghome);
            viewHolder.production_info_dayage = view.findViewById(R.id.production_info_dayage);
            viewHolder.production_info_survival = view.findViewById(R.id.production_info_survival);
            viewHolder.production_info_death = view.findViewById(R.id.production_info_death);
            viewHolder.production_info_eliminate = view.findViewById(R.id.production_info_eliminate);
            viewHolder.production_info_water = view.findViewById(R.id.production_info_water);
            viewHolder.production_info_weight = view.findViewById(R.id.production_info_weight);

            view.setTag(viewHolder);
        }else {
            viewHolder = (ViewHolder) view.getTag();
        }

        viewHolder.production_info_buildinghome.setText(message.getHouse_Name()+"");
        viewHolder.production_info_dayage.setText(message.getDays()+"");
        viewHolder.production_info_survival.setText(message.getCunhuolv()+"");
        viewHolder.production_info_death.setText(message.getDieNumber()+"");
        viewHolder.production_info_eliminate.setText(message.getObsolete()+"");
        viewHolder.production_info_water.setText(message.getWaterIntake()+"");
        viewHolder.production_info_weight.setText(message.getWeight()+"");
        return view;
    }

    private class ViewHolder{
        private TextView production_info_buildinghome;
        private TextView production_info_dayage;
        private TextView production_info_survival;
        private TextView production_info_death;
        private TextView production_info_eliminate;
        private TextView production_info_water;
        private TextView production_info_weight;

    }
}
