package com.qhclh.ytzh.index.planorder;

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

import java.util.List;

/**
 * Created by 青花瓷 on 2017/11/29.
 */
///< 雏苗司机单
public class ChickenDBAdapter extends BaseAdapter {
    private Context context;
    private List<ChickenDBean> list;

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

    @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) {
        ChickenDBean message = list.get(i);
        ViewHolder viewHolder;
        if (view == null){
            view = LayoutInflater.from(context).inflate(R.layout.item_chickendriverbill,viewGroup,false);
            viewHolder = new ViewHolder();
            viewHolder.cdb_name = view.findViewById(R.id.cdb_name);
            viewHolder.cdb_driver = view.findViewById(R.id.cdb_driver);
            viewHolder.cdb_time = view.findViewById(R.id.cdb_time);
            view.setTag(viewHolder);

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

        viewHolder.cdb_name.setText(message.getCarname());
        viewHolder.cdb_driver.setText(message.getCarDriver());
        viewHolder.cdb_time.setText(message.getTime());

        return view;
    }

    private class ViewHolder {
        private TextView cdb_name;
        private TextView cdb_driver;
        private TextView cdb_time;
    }
}
