close actionmode in keylist on loading events (avoid inconsistent state)

This commit is contained in:
Vincent Breitmoser 2014-08-20 21:51:19 +02:00
parent 6ed0f667cd
commit 9122d43d0a

View File

@ -79,6 +79,9 @@ public class KeyListFragment extends LoaderFragment
private KeyListAdapter mAdapter;
private StickyListHeadersListView mStickyList;
// saves the mode object for multiselect, needed for reset at some point
private ActionMode mActionMode = null;
private String mQuery;
private SearchView mSearchView;
// empty list layout
@ -148,6 +151,7 @@ public class KeyListFragment extends LoaderFragment
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
android.view.MenuInflater inflater = getActivity().getMenuInflater();
inflater.inflate(R.menu.key_list_multi, menu);
mActionMode = mode;
return true;
}
@ -193,6 +197,7 @@ public class KeyListFragment extends LoaderFragment
@Override
public void onDestroyActionMode(ActionMode mode) {
mActionMode = null;
mAdapter.clearSelection();
}
@ -288,6 +293,11 @@ public class KeyListFragment extends LoaderFragment
// this view is made visible if no data is available
mStickyList.setEmptyView(getActivity().findViewById(R.id.key_list_empty));
// end action mode, if any
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB && mActionMode != null) {
mActionMode.finish();
}
// The list should now be shown.
if (isResumed()) {
setContentShown(true);