Search in sources :

Example 16 with SparseBooleanArray

use of android.util.SparseBooleanArray in project platform_frameworks_base by android.

the class RecentTasks method syncPersistentTaskIdsLocked.

private void syncPersistentTaskIdsLocked() {
    for (int i = mPersistedTaskIds.size() - 1; i >= 0; i--) {
        int userId = mPersistedTaskIds.keyAt(i);
        if (mUsersWithRecentsLoaded.get(userId)) {
            // Recents are loaded only after task ids are loaded. Therefore, the set of taskids
            // referenced here should not be null.
            mPersistedTaskIds.valueAt(i).clear();
        }
    }
    for (int i = size() - 1; i >= 0; i--) {
        TaskRecord task = get(i);
        if (task.isPersistable && (task.stack == null || !task.stack.isHomeStack())) {
            // TODO Investigate why it can happen. For now initialize with an empty set
            if (mPersistedTaskIds.get(task.userId) == null) {
                Slog.wtf(TAG, "No task ids found for userId " + task.userId + ". task=" + task + " mPersistedTaskIds=" + mPersistedTaskIds);
                mPersistedTaskIds.put(task.userId, new SparseBooleanArray());
            }
            mPersistedTaskIds.get(task.userId).put(task.taskId, true);
        }
    }
}
Also used : SparseBooleanArray(android.util.SparseBooleanArray)

Example 17 with SparseBooleanArray

use of android.util.SparseBooleanArray in project platform_frameworks_base by android.

the class TaskPersister method loadPersistedTaskIdsForUser.

@NonNull
SparseBooleanArray loadPersistedTaskIdsForUser(int userId) {
    if (mTaskIdsInFile.get(userId) != null) {
        return mTaskIdsInFile.get(userId).clone();
    }
    final SparseBooleanArray persistedTaskIds = new SparseBooleanArray();
    synchronized (mIoLock) {
        BufferedReader reader = null;
        String line;
        try {
            reader = new BufferedReader(new FileReader(getUserPersistedTaskIdsFile(userId)));
            while ((line = reader.readLine()) != null) {
                for (String taskIdString : line.split("\\s+")) {
                    int id = Integer.parseInt(taskIdString);
                    persistedTaskIds.put(id, true);
                }
            }
        } catch (FileNotFoundException e) {
        // File doesn't exist. Ignore.
        } catch (Exception e) {
            Slog.e(TAG, "Error while reading taskIds file for user " + userId, e);
        } finally {
            IoUtils.closeQuietly(reader);
        }
    }
    mTaskIdsInFile.put(userId, persistedTaskIds);
    return persistedTaskIds.clone();
}
Also used : SparseBooleanArray(android.util.SparseBooleanArray) BufferedReader(java.io.BufferedReader) FileNotFoundException(java.io.FileNotFoundException) FileReader(java.io.FileReader) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) XmlPullParserException(org.xmlpull.v1.XmlPullParserException) NonNull(android.annotation.NonNull)

Example 18 with SparseBooleanArray

use of android.util.SparseBooleanArray in project android-topeka by googlesamples.

the class MultiSelectQuizView method getBundleableAnswer.

private boolean[] getBundleableAnswer() {
    SparseBooleanArray checkedItemPositions = mListView.getCheckedItemPositions();
    final int answerSize = checkedItemPositions.size();
    if (0 == answerSize) {
        return null;
    }
    final int optionsSize = getQuiz().getOptions().length;
    boolean[] bundleableAnswer = new boolean[optionsSize];
    int key;
    for (int i = 0; i < answerSize; i++) {
        key = checkedItemPositions.keyAt(i);
        bundleableAnswer[key] = checkedItemPositions.valueAt(i);
    }
    return bundleableAnswer;
}
Also used : SparseBooleanArray(android.util.SparseBooleanArray) SuppressLint(android.annotation.SuppressLint)

Example 19 with SparseBooleanArray

use of android.util.SparseBooleanArray in project android-topeka by googlesamples.

the class SelectItemQuizView method isAnswerCorrect.

@Override
protected boolean isAnswerCorrect() {
    final SparseBooleanArray checkedItemPositions = mListView.getCheckedItemPositions();
    final int[] answer = getQuiz().getAnswer();
    return AnswerHelper.isAnswerCorrect(checkedItemPositions, answer);
}
Also used : SparseBooleanArray(android.util.SparseBooleanArray)

Example 20 with SparseBooleanArray

use of android.util.SparseBooleanArray in project android-topeka by googlesamples.

the class ToggleTranslateQuizView method isAnswerCorrect.

@Override
protected boolean isAnswerCorrect() {
    final SparseBooleanArray checkedItemPositions = mListView.getCheckedItemPositions();
    final int[] answer = getQuiz().getAnswer();
    return AnswerHelper.isAnswerCorrect(checkedItemPositions, answer);
}
Also used : SparseBooleanArray(android.util.SparseBooleanArray)

Aggregations

SparseBooleanArray (android.util.SparseBooleanArray)235 Selection (com.android.documentsui.dirlist.MultiSelectManager.Selection)30 ArrayList (java.util.ArrayList)25 View (android.view.View)20 Point (android.graphics.Point)18 ViewGroup (android.view.ViewGroup)16 Paint (android.graphics.Paint)13 HashMap (java.util.HashMap)12 Map (java.util.Map)11 SparseArray (android.util.SparseArray)7 File (java.io.File)7 Pattern (java.util.regex.Pattern)7 Cursor (android.database.Cursor)6 SparseIntArray (android.util.SparseIntArray)6 ActionMenuChildView (com.actionbarsherlock.internal.view.menu.ActionMenuView.ActionMenuChildView)6 IndentingPrintWriter (com.android.internal.util.IndentingPrintWriter)6 Account (android.accounts.Account)5 NonNull (android.annotation.NonNull)5 ContentValues (android.content.ContentValues)5 SQLiteDatabase (android.database.sqlite.SQLiteDatabase)5