Fix issue #5433910: RTE while adding an account from settings

Make the new marshalling/unmarshalling code for the long sparse
array of ints always consistent.

And sane.

Change-Id: Ifbfbe6e56f59e469acb66257c504b1168d6566fa
This commit is contained in:
Dianne Hackborn
2011-10-09 14:11:05 -07:00
parent 421fa27445
commit 43ee0ab877

View File

@@ -1443,14 +1443,13 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
inActionMode = in.readByte() != 0;
checkedItemCount = in.readInt();
checkState = in.readSparseBooleanArray();
long[] idState = in.createLongArray();
int[] idPositions = in.createIntArray();
final int idLength = idState.length;
if (idLength > 0) {
final int N = in.readInt();
if (N > 0) {
checkIdState = new LongSparseArray<Integer>();
for (int i = 0; i < idLength; i++) {
checkIdState.put(idState[i], idPositions[i]);
for (int i=0; i<N; i++) {
final long key = in.readLong();
final int value = in.readInt();
checkIdState.put(key, value);
}
}
}
@@ -1467,15 +1466,11 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
out.writeByte((byte) (inActionMode ? 1 : 0));
out.writeInt(checkedItemCount);
out.writeSparseBooleanArray(checkState);
out.writeLongArray(checkIdState != null ? checkIdState.getKeys() : new long[0]);
int size = checkIdState != null ? checkIdState.size() : 0;
int[] idPositions = new int[size];
if (size > 0) {
for (int i = 0; i < size; i++) {
idPositions[i] = checkIdState.valueAt(i);
}
out.writeIntArray(idPositions);
final int N = checkIdState != null ? checkIdState.size() : 0;
out.writeInt(N);
for (int i=0; i<N; i++) {
out.writeLong(checkIdState.keyAt(i));
out.writeInt(checkIdState.valueAt(i));
}
}