package com.qhclh.ytzh.work.scan;

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

import java.util.List;

/**
 * Created by 青花瓷 on 2017/11/30.
 */
///< 扫一扫毛鸡
public class MaojiScanAdapter extends BaseAdapter {

    private Context context;
    private List<MaojiScanBean> list;
    private LayoutInflater layoutInflater;

    public MaojiScanAdapter(Context context, List<MaojiScanBean> 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;
        MaojiScanBean message = list.get(i);
        if (view == null){
            view = layoutInflater.inflate(R.layout.item_maojiinfos,viewGroup,false);
            viewHolder = new ViewHolder();
            viewHolder.infosmaoji_carname = view.findViewById(R.id.infosmaoji_carname);
            viewHolder.infosmaoji_driver = view.findViewById(R.id.infosmaoji_driver);
            viewHolder.infosmaoji_phone = view.findViewById(R.id.infosmaoji_phone);

            viewHolder.infosmaoji_yangzhichang = view.findViewById(R.id.infosmaoji_yangzhichang);
            viewHolder.infosmaoji_daodayangzhichangshijian = view.findViewById(R.id.infosmaoji_daodayangzhichangshijian);
            viewHolder.infosmaoji_likaiyangzhichang = view.findViewById(R.id.infosmaoji_likaiyangzhichang);
            viewHolder.infosmaoji_shipingchang = view.findViewById(R.id.infosmaoji_shipingchang);
            viewHolder.infosmaoji_daodashipchang = view.findViewById(R.id.infosmaoji_daodashipchang);
            viewHolder.infosmaoji_daodaguajipingtai = view.findViewById(R.id.infosmaoji_daodaguajipingtai);


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

        viewHolder.infosmaoji_carname.setText(message.getInfos_carname());
        viewHolder.infosmaoji_driver.setText(message.getInfos_driver());
        viewHolder.infosmaoji_phone.setText(message.getInfos_phone());

        viewHolder.infosmaoji_yangzhichang.setText(message.getInfos_yangzhichang());
        viewHolder.infosmaoji_daodayangzhichangshijian.setText(message.getDaodayangzhichang());
        viewHolder.infosmaoji_likaiyangzhichang.setText(message.getLikaiyangzhichang());
        viewHolder.infosmaoji_shipingchang.setText(message.getShipingchang());
        viewHolder.infosmaoji_daodashipchang.setText(message.getDaodashipingchang());
        viewHolder.infosmaoji_daodaguajipingtai.setText(message.getDaodaguajipingtai());


        return view;
    }

    private class ViewHolder{
        private TextView infosmaoji_carname;
        private TextView infosmaoji_driver;
        private TextView infosmaoji_phone;

        private TextView infosmaoji_yangzhichang;
        private TextView infosmaoji_daodayangzhichangshijian;
        private TextView infosmaoji_likaiyangzhichang;
        private TextView infosmaoji_shipingchang;
        private TextView infosmaoji_daodashipchang;
        private TextView infosmaoji_daodaguajipingtai;
    }
}
