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.ProductionDailyBean;

import java.util.List;

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

public class ProductiondailyAdapter extends BaseAdapter {
    private Context context;
    private List<ProductionDailyBean> list;
    private LayoutInflater layoutInflater;

    public ProductiondailyAdapter(Context context, List<ProductionDailyBean> 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).getId();
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {

        ViewHolder viewHolder;
        ProductionDailyBean message = list.get(i);
        if (view == null){
            view = layoutInflater.inflate(R.layout.item_productiondaily,viewGroup,false);
            viewHolder = new ViewHolder();

            viewHolder.productiondaily_batch = view.findViewById(R.id.productiondaily_batch);
            viewHolder.productiondaily_addrs = view.findViewById(R.id.productiondaily_addrs);
            viewHolder.productiondaily_time = view.findViewById(R.id.productiondaily_time);

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

        viewHolder.productiondaily_batch.setText("批次:"+message.getProductionbatch());
        ///< 养殖场位置改成日期，日期位置改成单据状态
//        viewHolder.productiondaily_addrs.setText("养殖场:"+message.getProductionaddrs());
        viewHolder.productiondaily_addrs.setText("日期:"+message.getPtime());
//        viewHolder.productiondaily_time.setText(""+message.getPtime());
        viewHolder.productiondaily_time.setText(""+message.getShenghezhuangtai());

        return view;
    }

    private class ViewHolder{
        private TextView productiondaily_batch;
        private TextView productiondaily_addrs;
        private TextView productiondaily_time;

    }
}
