use of android.util.SparseBooleanArray in project android_frameworks_base by crdroidandroid.
the class MultiSelectManagerTest method testProvisionalSelection_Apply.
public void testProvisionalSelection_Apply() {
Selection s = mManager.getSelection();
SparseBooleanArray provisional = new SparseBooleanArray();
provisional.append(1, true);
provisional.append(2, true);
s.setProvisionalSelection(getItemIds(provisional));
s.applyProvisionalSelection();
assertSelection(items.get(1), items.get(2));
}
use of android.util.SparseBooleanArray in project android_frameworks_base by crdroidandroid.
the class MultiSelectManagerTest method testProvisionalSelection_Cancel.
public void testProvisionalSelection_Cancel() {
mManager.toggleSelection(items.get(1));
mManager.toggleSelection(items.get(2));
Selection s = mManager.getSelection();
SparseBooleanArray provisional = new SparseBooleanArray();
provisional.append(3, true);
provisional.append(4, true);
s.setProvisionalSelection(getItemIds(provisional));
s.cancelProvisionalSelection();
// Original selection should remain.
assertSelection(items.get(1), items.get(2));
}
use of android.util.SparseBooleanArray in project android_frameworks_base by crdroidandroid.
the class MultiSelectManagerTest method testProvisionalSelection_IntersectsAppliedSelection.
public void testProvisionalSelection_IntersectsAppliedSelection() {
mManager.toggleSelection(items.get(1));
mManager.toggleSelection(items.get(2));
Selection s = mManager.getSelection();
SparseBooleanArray provisional = new SparseBooleanArray();
provisional.append(2, true);
provisional.append(3, true);
s.setProvisionalSelection(getItemIds(provisional));
assertSelection(items.get(1), items.get(2), items.get(3));
}
use of android.util.SparseBooleanArray in project android_frameworks_base by crdroidandroid.
the class MultiSelectManagerTest method testProvisionalSelection_IntersectsExistingProvisionalSelection.
public void testProvisionalSelection_IntersectsExistingProvisionalSelection() {
Selection s = mManager.getSelection();
SparseBooleanArray provisional = new SparseBooleanArray();
provisional.append(1, true);
provisional.append(2, true);
s.setProvisionalSelection(getItemIds(provisional));
provisional.clear();
provisional.append(1, true);
s.setProvisionalSelection(getItemIds(provisional));
assertSelection(items.get(1));
}
use of android.util.SparseBooleanArray in project android_frameworks_base by crdroidandroid.
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();
}
Aggregations