Example usage for android.util SparseBooleanArray indexOfKey

List of usage examples for android.util SparseBooleanArray indexOfKey

Introduction

In this page you can find the example usage for android.util SparseBooleanArray indexOfKey.

Prototype

public int indexOfKey(int key) 

Source Link

Document

Returns the index for which #keyAt would return the specified key, or a negative number if the specified key is not mapped.

Usage

From source file:Main.java

/**
 * Checks whether a provided answer is correct.
 *
 * @param checkedItems The items that were selected.
 * @param answerIds The actual correct answer ids.
 * @return <code>true</code> if correct else <code>false</code>.
 */// www .j av  a  2s . c o  m
public static boolean isAnswerCorrect(SparseBooleanArray checkedItems, int[] answerIds) {
    if (null == checkedItems || null == answerIds) {
        Log.i(TAG, "isAnswerCorrect got a null parameter input.");
        return false;
    }
    for (int answer : answerIds) {
        if (0 > checkedItems.indexOfKey(answer)) {
            return false;
        }
    }
    return checkedItems.size() == answerIds.length;
}

From source file:Main.java

/**
 * Checks whether a provided answer is correct.
 *
 * @param checkedItems The items that were selected.
 * @param answerIds The actual correct answer ids.
 * @return <code>true</code> if correct else <code>false</code>.
 *//*from w w  w. j  a  v a  2 s  .c om*/
public static boolean isAnswerCorrect(SparseBooleanArray checkedItems, int[] answerIds) {
    if (null == checkedItems || null == answerIds) {
        Log.i(TAG, "isAnswerCorrect got a null parameter input.");
        return false;
    }
    for (int answer : answerIds) {
        if (0 > checkedItems.indexOfKey(answer)) {
            return false;
        }
    }
    return true;
}