Fix bug #7274075 Non-functional CheckedTextView on Nexus 7 Jelly Bean 4.1.1

This regression has been introduced by this Change: Ia846de16bbc54f0729608259aa4b530da9404245

- in CHOICE_MODE_SINGLE you need to clear the checked states before doing anything
- rename variables for better readability too

Change-Id: I89b4390e5ebb192ca280fea2c06f991b537a2870
This commit is contained in:
Fabrice Di Meglio
2012-10-02 15:53:00 -07:00
parent 217ca3b0d3
commit 5bb4e29aba

View File

@@ -1055,30 +1055,30 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
if (mChoiceMode == CHOICE_MODE_MULTIPLE ||
(mChoiceMode == CHOICE_MODE_MULTIPLE_MODAL && mChoiceActionMode != null)) {
boolean newValue = !mCheckStates.get(position, false);
mCheckStates.put(position, newValue);
boolean checked = !mCheckStates.get(position, false);
mCheckStates.put(position, checked);
if (mCheckedIdStates != null && mAdapter.hasStableIds()) {
if (newValue) {
if (checked) {
mCheckedIdStates.put(mAdapter.getItemId(position), position);
} else {
mCheckedIdStates.delete(mAdapter.getItemId(position));
}
}
if (newValue) {
if (checked) {
mCheckedItemCount++;
} else {
mCheckedItemCount--;
}
if (mChoiceActionMode != null) {
mMultiChoiceModeCallback.onItemCheckedStateChanged(mChoiceActionMode,
position, id, newValue);
position, id, checked);
dispatchItemClick = false;
}
checkedStateChanged = true;
} else if (mChoiceMode == CHOICE_MODE_SINGLE) {
boolean newValue = !mCheckStates.get(position, false);
if (newValue) {
mCheckStates.clear();
boolean checked = !mCheckStates.get(position, false);
mCheckStates.clear();
if (checked) {
mCheckStates.put(position, true);
if (mCheckedIdStates != null && mAdapter.hasStableIds()) {
mCheckedIdStates.clear();