Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IllegalStateException: List view must belong to a SherlockActivity #19

Open
ogero opened this issue Nov 24, 2013 · 2 comments
Open

IllegalStateException: List view must belong to a SherlockActivity #19

ogero opened this issue Nov 24, 2013 · 2 comments

Comments

@ogero
Copy link

ogero commented Nov 24, 2013

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);
        }
    }
@ruimateus
Copy link

+1

@ManuelPeinado
Copy link
Owner

Thanks a lot for the report, I'll fix this over the next few days and release a new version of the lib.

grodin pushed a commit to grodin/MultiChoiceAdapter that referenced this issue Feb 17, 2014
grodin pushed a commit to grodin/MultiChoiceAdapter that referenced this issue Feb 21, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants