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.cpzslibs.prot.handset.bean.ConsigneeBean;
import cn.net.cpzslibs.prot.handset.bean.res.TrainStationBean;

public class StationListItemView implements Vu{
	private View rootView;
	private TextView tv_spinner_item;

	@Override
	public void init(LayoutInflater inflater, ViewGroup container) {
		rootView = inflater.inflate(R.layout.spiner_item_text_layout, container, false);
		tv_spinner_item = (TextView) rootView.findViewById(R.id.tv_spinner_item);
	}

	@Override
	public View getView() {
		return rootView;
	}
	
	public void setStationView(Object obj, int position){
		 if (obj instanceof String) {
			 setStringTextView((String) obj, position);
		} else if (obj instanceof TrainStationBean){
			setTrainStationView((TrainStationBean) obj, position);
		} else if (obj instanceof ConsigneeBean) {
			setConsigeeView((ConsigneeBean)obj,position);
		}
		
	}

	private void setConsigeeView(ConsigneeBean obj, int position) {
		tv_spinner_item.setText(obj.getConsignee()+"");
	}

	private void setTrainStationView(TrainStationBean obj, int position) {
		tv_spinner_item.setText(obj.getStation()+"");
		
	}

	private void setStringTextView(String obj, int position) {
		tv_spinner_item.setText(obj);		
	}
	

}
