mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-30 05:35:31 +00:00
Bug 1357579 - Correctly copy the sparse Boolean array when clearing Site Settings. r=ahunt
The checked items are stored in a *sparse* Boolean array, which we want to transform into an array (list) of the checked indices for transmission to Gecko. The current approach doesn't do this correctly, as it iterates over all (sparse and non-sparse) items, but uses SparseBooleanArray.size() (which only counts non-sparse items) as its iteration limit. This means that we only copy the checked state of the first n items, where n is the total count of checked items. For correctly iterating over the array to retrieve all indices that are true, we'd either have to use the largest available key (if we'd want to iterate over everything, including the sparse indices), or else use the approach chosen in this patch, namely using valueAt/keyAt in order to iterate over the internal array that's storing the values for all non-sparse indices. MozReview-Commit-ID: FRGI4Rr0uCb --HG-- extra : rebase_source : d9bb3a08af3a7ee2e730beb4777df30d019c922c
This commit is contained in:
parent
03a364a285
commit
d8a015d07f
@ -886,11 +886,11 @@ public abstract class GeckoApp
|
||||
ListView listView = ((AlertDialog) dialog).getListView();
|
||||
SparseBooleanArray checkedItemPositions = listView.getCheckedItemPositions();
|
||||
|
||||
// An array of the indices of the permissions we want to clear
|
||||
// An array of the indices of the permissions we want to clear.
|
||||
final ArrayList<Integer> permissionsToClear = new ArrayList<>();
|
||||
for (int i = 0; i < checkedItemPositions.size(); i++) {
|
||||
if (checkedItemPositions.get(i)) {
|
||||
permissionsToClear.add(i);
|
||||
if (checkedItemPositions.valueAt(i)) {
|
||||
permissionsToClear.add(checkedItemPositions.keyAt(i));
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user