package cn.net.caoyao.cpzshandset.ui.adapter;

import java.util.List;

import android.content.Context;
import cn.net.caoyao.cpzshandset.bean.InvoiceBean;
import cn.net.caoyao.cpzshandset.ui.adapter.base.BasePresenterAdapter;
import cn.net.caoyao.cpzshandset.ui.vus.TrayLabelItemView;

public class TrayPresentAdapter extends BasePresenterAdapter<TrayLabelItemView>{
	private Context context;
	private List<InvoiceBean> invoices;
	private int transid;
	private int transmode;
	private long transLId;
	private long product_id;
	private boolean isOnline = false;
	
	/**
	 * 
	 * @param context
	 * @param invoices
	 * @param transid
	 * @param transmode  发运方式： 1：火车发运(车皮)  2:汽车发运(货车)  3:线上订单发运
	 */
	public TrayPresentAdapter(Context context, List<InvoiceBean> invoices,int transid,int transmode) {
		this.context = context;
		this.invoices = invoices;
		this.transid = transid;
		this.transmode = transmode;
	}
	
	/**
	 * 
	 * @param context
	 * @param invoices
	 * @param transid
	 * @param transmode  发运方式： 1：火车发运(车皮)  2:汽车发运(货车)
	 */
	public TrayPresentAdapter(Context context, List<InvoiceBean> invoices,long transLId) {
		this.context = context;
		this.invoices = invoices;
		this.transLId = transLId;
		this.transmode = 3;
		this.isOnline = true;
	}
	/**
	 * 
	 * @param context
	 * @param invoices
	 * @param transid
	 * @param transmode  发运方式： 1：火车发运(车皮)  2:汽车发运(货车)
	 */
	public TrayPresentAdapter(Context context, List<InvoiceBean> invoices,long product_id,long driver_id) {
		this.context = context;
		this.invoices = invoices;
		this.product_id = product_id;
		this.transmode = 4;
		this.isOnline = true;
	}
	public void refreshData(List<InvoiceBean> invoices){
		this.invoices = invoices;
		notifyDataSetChanged();
	}
	
	@Override
	public int getCount() {
		return invoices.size();
	}

	@Override
	public Object getItem(int position) {
		return invoices.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	protected void onBindListItemVu(int position) {
		if (isOnline) {
			vu.setOnlineInvoiceView(invoices, position, context);
		} else {
			vu.setInvoiceView(invoices,position,context,transid,transmode);
		}
	}

	@Override
	protected Class<TrayLabelItemView> getVuClass() {
		return TrayLabelItemView.class;
	}

}
