Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a798170f authored by Adam Powell's avatar Adam Powell
Browse files

More detailed error reporting for AbsListView/CHOICE_MODE_MULTIPLE_MODAL

Throw a more descriptive exception when an app has not set a
multi-choice mode listener and an item becomes checked.

Change-Id: Ib682fd7a467a3751bb81dacbd22676aaa4407d36
parent 15525862
Loading
Loading
Loading
Loading
+10 −0
Original line number Original line Diff line number Diff line
@@ -973,6 +973,12 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te


        // Start selection mode if needed. We don't need to if we're unchecking something.
        // Start selection mode if needed. We don't need to if we're unchecking something.
        if (value && mChoiceMode == CHOICE_MODE_MULTIPLE_MODAL && mChoiceActionMode == null) {
        if (value && mChoiceMode == CHOICE_MODE_MULTIPLE_MODAL && mChoiceActionMode == null) {
            if (mMultiChoiceModeCallback == null ||
                    !mMultiChoiceModeCallback.hasWrappedCallback()) {
                throw new IllegalStateException("AbsListView: attempted to start selection mode " +
                        "for CHOICE_MODE_MULTIPLE_MODAL but no choice mode callback was " +
                        "supplied. Call setMultiChoiceModeListener to set a callback.");
            }
            mChoiceActionMode = startActionMode(mMultiChoiceModeCallback);
            mChoiceActionMode = startActionMode(mMultiChoiceModeCallback);
        }
        }


@@ -5945,6 +5951,10 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
            mWrapped = wrapped;
            mWrapped = wrapped;
        }
        }


        public boolean hasWrappedCallback() {
            return mWrapped != null;
        }

        public boolean onCreateActionMode(ActionMode mode, Menu menu) {
        public boolean onCreateActionMode(ActionMode mode, Menu menu) {
            if (mWrapped.onCreateActionMode(mode, menu)) {
            if (mWrapped.onCreateActionMode(mode, menu)) {
                // Initialize checked graphic state?
                // Initialize checked graphic state?