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

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import cn.net.caoyao.cpzshandset.R;
import cn.net.caoyao.cpzshandset.bean.TrainInvoiceBean;
import cn.net.caoyao.cpzshandset.bean.TruckInvoiceBean;

public class InvoiceListItemView implements Vu{
	private View rootView;
	private TextView tv_invoice_serial;
	private TextView tv_invoice_list_invoiceno;
	private TextView tv_invoice_list_time;
	private TextView tv_invoice_list_status;

	@Override
	public void init(LayoutInflater inflater, ViewGroup container) {
		rootView = inflater.inflate(R.layout.adapter_train_invoice_item, container, false);
		tv_invoice_serial = (TextView) rootView.findViewById(R.id.tv_invoice_serial);
		tv_invoice_list_invoiceno = (TextView) rootView.findViewById(R.id.tv_invoice_list_invoiceno);
		tv_invoice_list_time = (TextView) rootView.findViewById(R.id.tv_invoice_list_time);
		tv_invoice_list_status = (TextView) rootView.findViewById(R.id.tv_invoice_list_status);
	}

	@Override
	public View getView() {
		return rootView;
	}
	
	public void setInvoiceList(Object obj, int position){
		 if (obj instanceof TruckInvoiceBean) {
			 //汽车的订单列表
			 setTruckInvoice((TruckInvoiceBean) obj, position);
		} else if (obj instanceof TrainInvoiceBean){
			//火车的订单列表
			setTrainInvoice((TrainInvoiceBean) obj, position);
		}
		
	}
	
	private void setTruckInvoice(TruckInvoiceBean truckInvoice, int position){
		tv_invoice_serial.setText("" + (position + 1));
		tv_invoice_list_invoiceno.setText("运单号: " + truckInvoice.getOrderno());
		tv_invoice_list_time.setText("时    间: " + truckInvoice.getTimestamp());
	}
	private void setTrainInvoice(TrainInvoiceBean trainInvoice, int position){
		tv_invoice_serial.setText("" + (position + 1));
		tv_invoice_list_invoiceno.setText("运单号: " + trainInvoice.getOrderno());
		tv_invoice_list_time.setText("时    间: " + trainInvoice.getTimestamp());
	}

}
