/**
 * Copyright (C) 2005-2012 XELOG AG
 */
package ch.spherIC.recurvebowsight.components;

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 ch.spherIC.recurvebowsight.R;

import java.util.List;


/**
 * @author  FC Smilari
 */
public class MainConfigurationArrayAdapter extends ArrayAdapter<String[]> {

    /**
     * Konstruktor.
     *
     * @param  context
     * @param  textViewResourceId
     * @param  objects
     */
    public MainConfigurationArrayAdapter(final Context context, final int textViewResourceId, final String[][] objects) {
        super(context, textViewResourceId, objects);
    }

    /**
     * Konstruktor.
     *
     * @param  context
     * @param  textViewResourceId
     * @param  objects
     */
    public MainConfigurationArrayAdapter(final Context context, final int textViewResourceId, final List<String[]> objects) {
        super(context, textViewResourceId, objects);
    }

    @Override
    public View getView(final int position, final View convertView, final ViewGroup parent) {

        LayoutInflater inflater = getLayoutInflater();
        View item = inflater.inflate(R.layout.rbs_main_config_item, parent, false);
        XTextView textViewMain = (XTextView) item.findViewById(R.id.mainConfigListItemTxtMain);
        TextView textViewSub = (TextView) item.findViewById(R.id.mainConfigListItemTxtSub);

        if (getItem(position) != null) {
            if (getItem(position).length >= 1) {
                textViewMain.setText(getItem(position)[0]);
            }
            if (getItem(position).length >= 2) {
                textViewSub.setText(getItem(position)[1]);
            }
        }

        return item;
    }

    protected LayoutInflater getLayoutInflater() {
        return (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    }

}
