From a0eeeac82010e03ce8949bf7efed909afdbaf41c Mon Sep 17 00:00:00 2001 From: Adam Powell Date: Fri, 5 Nov 2010 11:55:05 -0700 Subject: [PATCH] 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 --- core/java/android/widget/AbsListView.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/core/java/android/widget/AbsListView.java b/core/java/android/widget/AbsListView.java index d4a26cc722d23..d0ed23f8e2028 100644 --- a/core/java/android/widget/AbsListView.java +++ b/core/java/android/widget/AbsListView.java @@ -1210,6 +1210,7 @@ public abstract class AbsListView extends AdapterView implements Te int position; int height; String filter; + boolean inActionMode; int checkedItemCount; SparseBooleanArray checkState; LongSparseArray checkIdState; @@ -1232,6 +1233,7 @@ public abstract class AbsListView extends AdapterView 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 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 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 implements Te mCheckedItemCount = ss.checkedItemCount; + if (ss.inActionMode && mChoiceMode == CHOICE_MODE_MULTIPLE_MODAL && + mMultiChoiceModeCallback != null) { + mChoiceActionMode = startActionMode(mMultiChoiceModeCallback); + } + requestLayout(); }