@Override
  public boolean onContextItemSelected(MenuItem item) {
    super.onContextItemSelected(item);
    AdapterContextMenuInfo menuInfo = (AdapterContextMenuInfo) item.getMenuInfo();
    final int index = menuInfo.position;

    switch (item.getItemId()) {
      case SectionMenuItems.PLAY:
        BooksHelper.playSection(this, book.getUri(), index);
        return true;
      case SectionMenuItems.DELETE:
        final Runnable uiPostDelete =
            new Runnable() {
              @Override
              public void run() {
                sectionsCursor.requery();
              }
            };
        Runnable runnable =
            new Runnable() {
              @Override
              public void run() {
                Book playerBook = Book.read(getContentResolver(), book.getUri());
                File file =
                    FileHelper.getFile(
                        getContentResolver(),
                        playerBook.getId(),
                        index,
                        false,
                        playerBook.getTitle(),
                        playerBook.getLibrivoxId());
                if (file.exists()) {
                  if (!file.delete()) {
                    Toast.makeText(
                        BookViewActivity.this,
                        R.string.errorDeletingSection,
                        LogHelper.TOAST_ERROR_DISPLAY_MS);
                  }
                }
                runOnUiThread(uiPostDelete);
              }
            };
        new Thread(runnable).start();
        return true;
      case SectionMenuItems.DOWNLOAD:
        BooksHelper.downloadSectionIfNeeded(this, book.getUri(), index);
        return true;
      default:
        Toast toast =
            Toast.makeText(
                getApplicationContext(), "Not yet implemented", LogHelper.TOAST_ERROR_DISPLAY_MS);
        toast.show();
    }
    return false;
  }
  private Uri getBookUri(Uri uri) {
    switch (URI_MATCHER.match(uri)) {
      case UriTypes.BOOK_ID:
        return uri;

      case UriTypes.SEARCH_ID:
        {
          return BooksHelper.getBookUriForSearch(this, uri, true);
        }

      default:
        throw new RuntimeException("Unhandled Uri " + uri);
    }
  }