Source:
private void openShowOnMapMode() { enableSelectionMode(true); showOnMapMode = true; selectedItems.clear(); selectedGroups.clear(); final Set<GpxInfo> originalSelectedItems = allGpxAdapter.getSelectedGpx(); selectedItems.addAll(originalSelectedItems); gpxTaskListener = new GpxSelectionHelper.SelectGpxTaskListener() { @Override public void onProgressUpdate() { allGpxAdapter.notifyDataSetInvalidated(); } @Override public void onPreExecute() { showProgressBar(); } @Override public void onPostExecute() { hideProgressBar(); allGpxAdapter.refreshSelected(); allGpxAdapter.notifyDataSetChanged(); } }; actionMode = getActionBarActivity().startSupportActionMode(new ActionMode.Callback() { @Override public boolean onCreateActionMode(ActionMode mode, Menu menu) { enableSelectionMode(true); updateSelectionMode(mode); MenuItem it = menu.add(R.string.shared_string_show_on_map); it.setIcon(R.drawable.ic_action_done); MenuItemCompat.setShowAsAction(it, MenuItemCompat.SHOW_AS_ACTION_IF_ROOM | MenuItemCompat.SHOW_AS_ACTION_WITH_TEXT); updateCurrentTrack(); return true; } @Override public boolean onPrepareActionMode(ActionMode mode, Menu menu) { return false; } @Override public boolean onActionItemClicked(ActionMode mode, MenuItem item) { HashMap<String, Boolean> selectedItemsFileNames = new HashMap<>(); originalSelectedItems.addAll(selectedItems); for (GpxInfo gpxInfo : originalSelectedItems) { if (gpxInfo.currentlyRecordingTrack) { selectedItemsFileNames.put(CURRENT_TRACK, true); } else { selectedItemsFileNames.put(gpxInfo.file.getAbsolutePath(), selectedItems.contains(gpxInfo)); } } selectedGpxHelper.runSelection(selectedItemsFileNames, gpxTaskListener); actionMode.finish(); allGpxAdapter.refreshSelected(); allGpxAdapter.notifyDataSetChanged(); return true; } @Override public void onDestroyActionMode(ActionMode mode) { showOnMapMode = false; enableSelectionMode(false); updateCurrentTrack(); allGpxAdapter.notifyDataSetChanged(); } }); allGpxAdapter.notifyDataSetChanged(); }

Target:
private void openShowOnMapMode() { enableSelectionMode(true); showOnMapMode = true; selectedItems.clear(); selectedGroups.clear(); final Set<GpxInfo> originalSelectedItems = allGpxAdapter.getSelectedGpx(); selectedItems.addAll(originalSelectedItems); actionMode = getActionBarActivity().startSupportActionMode(new ActionMode.Callback() { @Override public boolean onCreateActionMode(ActionMode mode, Menu menu) { enableSelectionMode(true); updateSelectionMode(mode); MenuItem it = menu.add(R.string.shared_string_show_on_map); it.setIcon(R.drawable.ic_action_done); MenuItemCompat.setShowAsAction(it, MenuItemCompat.SHOW_AS_ACTION_IF_ROOM | MenuItemCompat.SHOW_AS_ACTION_WITH_TEXT); updateCurrentTrack(); return true; } @Override public boolean onPrepareActionMode(ActionMode mode, Menu menu) { return false; } @Override public boolean onActionItemClicked(ActionMode mode, MenuItem item) { runSelection(originalSelectedItems); actionMode.finish(); allGpxAdapter.refreshSelected(); allGpxAdapter.notifyDataSetChanged(); return true; } @Override public void onDestroyActionMode(ActionMode mode) { showOnMapMode = false; enableSelectionMode(false); updateCurrentTrack(); allGpxAdapter.notifyDataSetChanged(); } }); allGpxAdapter.notifyDataSetChanged(); }