private void setResultIds(Item item, int index) {
   if (item != null && item instanceof CatalogItem) {
     CatalogItem catalogItem = (CatalogItem) item;
     if (catalogItem.IsChecked) {
       int insertIndex = index <= 0 ? -1 : (index - 1);
       if (mySelectedItems.contains(catalogItem)) {
         mySelectedItems.remove(catalogItem);
       }
       if (insertIndex >= 0) {
         mySelectedItems.add(insertIndex, catalogItem);
       } else {
         mySelectedItems.add(catalogItem);
       }
     } else {
       mySelectedItems.remove(catalogItem);
     }
     final ArrayList<String> ids = new ArrayList<String>();
     for (Item selectedItem : mySelectedItems) {
       if (selectedItem instanceof CatalogItem) {
         final CatalogItem ci = (CatalogItem) selectedItem;
         if (ci.IsChecked) {
           ids.add(ci.Id);
         }
       }
     }
     setResult(
         RESULT_OK,
         new Intent()
             .putStringArrayListExtra(NetworkLibraryActivity.ENABLED_CATALOG_IDS_KEY, ids));
   }
 }
 private Date applyMultiSelect(Date date, Calendar selectedCal) {
   for (MonthCellDescriptor selectedCell : selectedCells) {
     if (selectedCell.getDate().equals(date)) {
       // De-select the currently-selected cell.
       selectedCell.setSelected(false);
       selectedCells.remove(selectedCell);
       date = null;
       break;
     }
   }
   for (Calendar cal : selectedCals) {
     if (sameDate(cal, selectedCal)) {
       selectedCals.remove(cal);
       break;
     }
   }
   return date;
 }
 @Override
 public boolean onContextItemSelected(MenuItem item) {
   final int position = ((AdapterView.AdapterContextMenuInfo) item.getMenuInfo()).position;
   final ListView view = (ListView) getTabHost().getCurrentView();
   final Bookmark bookmark = ((BookmarksAdapter) view.getAdapter()).getItem(position);
   switch (item.getItemId()) {
     case OPEN_ITEM_ID:
       gotoBookmark(bookmark);
       return true;
     case EDIT_ITEM_ID:
       final Intent intent = new Intent(this, BookmarkEditActivity.class);
       startActivityForResult(intent, 1);
       // TODO: implement
       return true;
     case DELETE_ITEM_ID:
       bookmark.delete();
       myThisBookBookmarks.remove(bookmark);
       AllBooksBookmarks.remove(bookmark);
       mySearchResults.remove(bookmark);
       invalidateAllViews();
       return true;
   }
   return super.onContextItemSelected(item);
 }