package com.qhclh.ytzh.work.carsmannage;

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

import java.util.List;

/**
 * Created by 青花瓷 on 2018/1/22.
 */

public class CarsInfosAdapter extends BaseAdapter {
    private Context context;
    private List<ScanBean> list;
    private LayoutInflater layoutInflater;

    public CarsInfosAdapter(Context context, List<ScanBean> 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;
        ScanBean message = list.get(i);
        if (view == null){
            view = layoutInflater.inflate(R.layout.item_carsinfos,viewGroup,false);
            viewHolder = new ViewHolder();
            viewHolder.Employee_Name = view.findViewById(R.id.Employee_Name);
            viewHolder.Car_Name = view.findViewById(R.id.Car_Name);
            viewHolder.CreateTime = view.findViewById(R.id.CreateTime);

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

        viewHolder.Employee_Name.setText("司机："+message.getInfos_driver());
        viewHolder.Car_Name.setText("车牌："+message.getInfos_carname());
        viewHolder.CreateTime.setText("日期："+message.getCreatetime());

        return view;
    }


    private class ViewHolder{
        private TextView Employee_Name;
        private TextView Car_Name;
        private TextView CreateTime;
    }
}
