Skip to content

IllegalStateException: List view must belong to a SherlockActivity #19

@ogero

Description

@ogero

When AdapterView belongs to SherlockFragmentActivity instead of SherlockActivity, an exception is thrown.

MultiChoiceAdapterHelper from package "com.manuelpeinado.multichoiceadapter.extras.actionbarsherlock" only checks if adapterview context is an instance of SherlockActivity.

**For a quick fix, change startActionMode method to:

    @Override
    protected void startActionMode() {
        if (!(adapterView.getContext() instanceof SherlockActivity)
                && !(adapterView.getContext() instanceof SherlockFragmentActivity)) {
            throw new IllegalStateException("List view must belong to a SherlockActivity or a SherlockFragmentActivity");
        }
        if (!(owner instanceof ActionMode.Callback)) {
            throw new IllegalStateException("Owner adapter must implement ActionMode.Callback");
        }
        if (adapterView.getContext() instanceof SherlockActivity) {
        }
        if ((adapterView.getContext() instanceof SherlockActivity)) {
            SherlockActivity activity = (SherlockActivity) adapterView.getContext();
            actionMode = activity.startActionMode((ActionMode.Callback) owner);
        } else {
            SherlockFragmentActivity activity = (SherlockFragmentActivity) adapterView.getContext();
            actionMode = activity.startActionMode((ActionMode.Callback) owner);
        }
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions