From 150e79d5ef3dcb9b7fa8c1064f159e70da39a86e Mon Sep 17 00:00:00 2001 From: Joseph Cooper Date: Mon, 17 Feb 2014 19:28:19 +0100 Subject: [PATCH] Fixes https://github.com/ManuelPeinado/MultiChoiceAdapter/issues/19 --- .../MultiChoiceAdapterHelper.java | 67 ++++++++++--------- 1 file changed, 34 insertions(+), 33 deletions(-) diff --git a/extras/actionbarsherlock/src/com/manuelpeinado/multichoiceadapter/extras/actionbarsherlock/MultiChoiceAdapterHelper.java b/extras/actionbarsherlock/src/com/manuelpeinado/multichoiceadapter/extras/actionbarsherlock/MultiChoiceAdapterHelper.java index cc76985..f16ed74 100644 --- a/extras/actionbarsherlock/src/com/manuelpeinado/multichoiceadapter/extras/actionbarsherlock/MultiChoiceAdapterHelper.java +++ b/extras/actionbarsherlock/src/com/manuelpeinado/multichoiceadapter/extras/actionbarsherlock/MultiChoiceAdapterHelper.java @@ -22,43 +22,44 @@ import com.manuelpeinado.multichoiceadapter.MultiChoiceAdapterHelperBase; public class MultiChoiceAdapterHelper extends MultiChoiceAdapterHelperBase { - private ActionMode actionMode; + private ActionMode actionMode; - protected MultiChoiceAdapterHelper(BaseAdapter owner) { - super(owner); - } + protected MultiChoiceAdapterHelper(BaseAdapter owner) { + super(owner); + } - @Override - protected void startActionMode() { - if (!(adapterView.getContext() instanceof SherlockActivity)) { - throw new IllegalStateException("List view must belong to a SherlockActivity"); - } - if (!(owner instanceof ActionMode.Callback)) { - throw new IllegalStateException("Owner adapter must implement ActionMode.Callback"); - } - SherlockActivity activity = (SherlockActivity) adapterView.getContext(); - actionMode = activity.startActionMode((ActionMode.Callback)owner); - } + @Override + protected void startActionMode() { + if (!(adapterView.getContext() instanceof SherlockActivity) + && !(adapterView.getContext() instanceof SherlockFragmentActivity)) { + throw new IllegalStateException("List view must belong to a SherlockActivity"); + } + if (!(owner instanceof ActionMode.Callback)) { + throw new IllegalStateException("Owner adapter must implement ActionMode.Callback"); + } + SherlockActivity activity = (SherlockActivity) adapterView.getContext(); + actionMode = activity.startActionMode((ActionMode.Callback) owner); + } - @Override - protected void finishActionMode() { - if (actionMode != null) { - actionMode.finish(); - } - } + @Override + protected void finishActionMode() { + if (actionMode != null) { + actionMode.finish(); + } + } - @Override - protected void setActionModeTitle(String title) { - actionMode.setTitle(title); - } + @Override + protected void setActionModeTitle(String title) { + actionMode.setTitle(title); + } - @Override - protected boolean isActionModeStarted() { - return actionMode != null; - } + @Override + protected boolean isActionModeStarted() { + return actionMode != null; + } - @Override - protected void clearActionMode() { - actionMode = null; - } + @Override + protected void clearActionMode() { + actionMode = null; + } }