/*
 * $URL$
 * $Revision$
 * $LastChangedBy$
 * $LastChangedDate$
 *
 * Copyright (c) 2011 spherIC, Switzerland
 * All rights reserved.
 *
 * This software is the confidential and proprietary information
 * of spherIC. ("Confidential Information"). You shall not
 * disclose such Confidential Information and shall use it only
 * in accordance with the terms of the license agreement you
 * entered into with spherIC.
 */
package ch.spherIC.recurvebowsight.components;

import android.content.Context;

import android.util.AttributeSet;

import android.widget.Spinner;


/**
 * XSpinner class with special functionality
 */
public class XSpinner extends Spinner {

    /**
     * Creates a new XSpinner object.
     *
     * @param  context {@link Context}
     */
    public XSpinner(final Context context) {
        super(context);
    }

    /**
     * Creates a new XSpinner object.
     *
     * @param  context {@link Context}
     * @param  attrs {@link AttributeSet}
     */
    public XSpinner(final Context context, final AttributeSet attrs) {
        super(context, attrs);
    }

    /**
     * Creates a newXSpinner object.
     *
     * @param  context {@link Context}
     * @param  attrs {@link AttributeSet}
     * @param  defStyle  int
     */
    public XSpinner(final Context context, final AttributeSet attrs, final int defStyle) {
        super(context, attrs, defStyle);
    }


    /**
     * Sets the value of $param.name$
     *
     * @param  value  DOCUMENT ME!
     */
    public void setSelectionByVal(final String value) {

        if (value != null) {
            int count = getCount();

            for (int i = 0; i < count; i++) {
                if (getItemAtPosition(i).toString().equals(value)) {
                    setSelection(i);
                    break;
                }
            }
        }
    }


    @Override
    public void onDetachedFromWindow() {
        super.onDetachedFromWindow();
    }

}
