package kz.arta.synergy.workflow.mobile.android.forms.mobile.adapters;

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

import java.util.List;

import kz.arta.synergy.workflow.mobile.android.R;
import kz.arta.synergy.workflow.mobile.android.common.utils.Fonts;

/**
 * Created by neox on 26.03.15.
 * Адаптер для выпадающего списка (используется в формах)
 */
public class AdapterFormsSpinner extends ArrayAdapter<String> {

    private List<String> items;
    private Context context;

    public AdapterFormsSpinner(Context context, List<String> items) {
        super(context, R.layout.spinner_item, items);
        this.context = context;
        this.items = items;
    }

    @Override
    public View getView(int position, View someView, ViewGroup arg2) {
        LayoutInflater inflater = LayoutInflater.from(context);
        if (someView == null) {
            someView = inflater.inflate(R.layout.spinner_item, arg2, false);
        }
        TextView userPosition = (TextView) someView.findViewById(R.id.spinner_item_name);
        userPosition.setText(items.get(position));
        userPosition.setTypeface(Fonts.getMedium(context));
        return someView;
    }
}
