Fix bug 3167945 - list selection mode should persist across rotations
Modal multi-choice mode action modes will now be restarted when restoring instance state provided that the application has set a multi-choice mode callback before instance state is restored. This matches other list state restoration behavior with adapters. Change-Id: I8e96e079faa3a086d3d4480d65b8c53a60f4c0ea
This commit is contained in:
@@ -1210,6 +1210,7 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
|
||||
int position;
|
||||
int height;
|
||||
String filter;
|
||||
boolean inActionMode;
|
||||
int checkedItemCount;
|
||||
SparseBooleanArray checkState;
|
||||
LongSparseArray<Boolean> checkIdState;
|
||||
@@ -1232,6 +1233,7 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
|
||||
position = in.readInt();
|
||||
height = in.readInt();
|
||||
filter = in.readString();
|
||||
inActionMode = in.readByte() != 0;
|
||||
checkedItemCount = in.readInt();
|
||||
checkState = in.readSparseBooleanArray();
|
||||
long[] idState = in.createLongArray();
|
||||
@@ -1251,6 +1253,7 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
|
||||
out.writeInt(position);
|
||||
out.writeInt(height);
|
||||
out.writeString(filter);
|
||||
out.writeByte((byte) (inActionMode ? 1 : 0));
|
||||
out.writeInt(checkedItemCount);
|
||||
out.writeSparseBooleanArray(checkState);
|
||||
out.writeLongArray(checkIdState != null ? checkIdState.getKeys() : new long[0]);
|
||||
@@ -1330,6 +1333,8 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
|
||||
}
|
||||
}
|
||||
|
||||
ss.inActionMode = mChoiceMode == CHOICE_MODE_MULTIPLE_MODAL && mChoiceActionMode != null;
|
||||
|
||||
ss.checkState = mCheckStates;
|
||||
ss.checkIdState = mCheckedIdStates;
|
||||
ss.checkedItemCount = mCheckedItemCount;
|
||||
@@ -1376,6 +1381,11 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
|
||||
|
||||
mCheckedItemCount = ss.checkedItemCount;
|
||||
|
||||
if (ss.inActionMode && mChoiceMode == CHOICE_MODE_MULTIPLE_MODAL &&
|
||||
mMultiChoiceModeCallback != null) {
|
||||
mChoiceActionMode = startActionMode(mMultiChoiceModeCallback);
|
||||
}
|
||||
|
||||
requestLayout();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user