@Override
 public boolean onOptionsItemSelected(MenuItem item) {
   int itemId = item.getItemId();
   if (itemId == R.id.menu_rate_trakt) {
     onRateOnTrakt();
     return true;
   } else if (itemId == R.id.menu_share) {
     fireTrackerEvent("Share");
     onShareEpisode(ShareMethod.OTHER_SERVICES);
     return true;
   } else if (itemId == R.id.menu_manage_lists) {
     fireTrackerEvent("Manage lists");
     ListsDialogFragment.showListsDialog(
         String.valueOf(getEpisodeTvdbId()), ListItemTypes.EPISODE, getFragmentManager());
     return true;
   }
   return super.onOptionsItemSelected(item);
 }
  @Override
  public boolean onContextItemSelected(android.view.MenuItem item) {
    AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();

    switch (item.getItemId()) {
      case CONTEXT_CHECKIN_ID:
        {
          fireTrackerEventContext("Check in");

          Cursor show = (Cursor) mAdapter.getItem(info.position);
          int episodeTvdbId = show.getInt(ShowsQuery.NEXTEPISODE);
          if (episodeTvdbId <= 0) {
            return true;
          }

          // display a check-in dialog
          CheckInDialogFragment f = CheckInDialogFragment.newInstance(getActivity(), episodeTvdbId);
          f.show(getFragmentManager(), "checkin-dialog");

          return true;
        }
      case CONTEXT_FAVORITE_ID:
        {
          onFavoriteShow(String.valueOf(info.id), true);
          return true;
        }
      case CONTEXT_UNFAVORITE_ID:
        {
          onFavoriteShow(String.valueOf(info.id), false);
          return true;
        }
      case CONTEXT_HIDE_ID:
        {
          fireTrackerEventContext("Hide show");

          ContentValues values = new ContentValues();
          values.put(Shows.HIDDEN, true);
          getActivity()
              .getContentResolver()
              .update(Shows.buildShowUri(String.valueOf(info.id)), values, null, null);
          Toast.makeText(getActivity(), getString(R.string.hidden), Toast.LENGTH_SHORT).show();
          return true;
        }
      case CONTEXT_UNHIDE_ID:
        {
          fireTrackerEventContext("Unhide show");

          ContentValues values = new ContentValues();
          values.put(Shows.HIDDEN, false);
          getActivity()
              .getContentResolver()
              .update(Shows.buildShowUri(String.valueOf(info.id)), values, null, null);
          Toast.makeText(getActivity(), getString(R.string.unhidden), Toast.LENGTH_SHORT).show();
          return true;
        }
      case CONTEXT_DELETE_ID:
        if (!SgSyncAdapter.isSyncActive(getActivity(), true)) {
          showDeleteDialog(info.id);
        }

        fireTrackerEventContext("Delete show");
        return true;
      case CONTEXT_UPDATE_ID:
        SgSyncAdapter.requestSync(getActivity(), (int) info.id);

        fireTrackerEventContext("Update show");
        return true;
      case CONTEXT_FLAG_NEXT_ID:
        fireTrackerEventContext("Mark next episode");

        Cursor show = (Cursor) mAdapter.getItem(info.position);
        DBUtils.markNextEpisode(getActivity(), (int) info.id, show.getInt(ShowsQuery.NEXTEPISODE));

        return true;
      case CONTEXT_MANAGE_LISTS_ID:
        {
          fireTrackerEventContext("Manage lists");

          ListsDialogFragment.showListsDialog(
              String.valueOf(info.id), ListItemTypes.SHOW, getFragmentManager());
          return true;
        }
    }
    return super.onContextItemSelected(item);
  }