package com.tofly.ghrq_route.common.ui.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import com.tofly.ghrq_route.R;

import java.util.List;

/**
 * Created by Amu on 2017/4/18.
 */

public class PlanDatePickAdapter extends ArrayAdapter<String> {
    private Context mContext;
    private List<String> mData;

    public PlanDatePickAdapter(Context context, List<String> data){
        super(context, R.layout.my_simple_spinner_item, data);
        mContext = context;
        mData = data;
    }

    @Override
    public int getCount() {
        return mData.size();
    }

    @Override
    public String getItem(int position) {
        return mData.get(position);
    }

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

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder;
        if (convertView == null){
            convertView = View.inflate(mContext, R.layout.my_simple_spinner_item, null);
            viewHolder = new ViewHolder();
            viewHolder.devNameTv = (TextView) convertView.findViewById(R.id.text1);
            convertView.setTag(viewHolder);
        }else {
            viewHolder = (ViewHolder)convertView.getTag();
        }
        /*String devName = mData.get(position);
        viewHolder.devNameTv.setText(devName);*/
        viewHolder.devNameTv.setText(mContext.getString(R.string.pick_date));
        int pickerColor = mContext.getResources().getColor(R.color.top_bar);
        viewHolder.devNameTv.setTextColor(pickerColor);
        return convertView;
    }

    private class ViewHolder {
        public TextView devNameTv;
    }
}
