package com.stety.zakladka;

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

/**
 * List Adapter for Navigation Drawer.
 */
public class NavDrawerListAdapter extends ArrayAdapter<String>
{
    private static Context context;

    private static final int[] icons = {
            R.drawable.student,
            R.drawable.teacher
    };

    public NavDrawerListAdapter(Context context, String[] items)
    {
        super(context, R.layout.list_item, items);
        this.context = context;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent)
    {
        String[] items = context.getResources().getStringArray(R.array.nav_drawer_items);
        LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View rowView = inflater.inflate(R.layout.drawer_list_item, parent, false);
        TextView textView = (TextView) rowView.findViewById(R.id.item);
        ImageView imageView = (ImageView) rowView.findViewById(R.id.icon);
        textView.setText(items[position]);
        imageView.setImageResource(icons[position]);
        return rowView;
    }
}
