/**
   * Call this to inflate and show the pop up menu
   *
   * @param view the view to anchor the popup menu against
   * @param position the item that was clicked in the popup menu (or -1 if not relevant)
   */
  public void showPopupMenu(final View view, final int position) {
    // create the popup menu
    PopupMenu popupMenu = new PopupMenu(mActivity, view);
    final Menu menu = popupMenu.getMenu();

    // hook up the click listener
    popupMenu.setOnMenuItemClickListener(this);

    // figure what type of pop up menu it is
    mType = onPreparePopupMenu(position);
    if (mType != null) {
      // inflate the menu
      createPopupMenu(menu);
      // show it
      popupMenu.show();
    }
  }
  @Override
  public void onCreateOptionsMenu(final Menu menu, final MenuInflater inflater) {
    inflater.inflate(R.menu.shuffle_item, menu);
    menu.findItem(R.id.menu_shuffle_item).setTitle(getShuffleTitleId());

    // use the same popup menu to provide actions for smart playlist
    // as is used in the PlaylistFragment
    mActionMenuHelper =
        new PlaylistPopupMenuHelper(
            getActivity(), getChildFragmentManager(), PopupMenuType.SmartPlaylist) {
          public Playlist getPlaylist(int position) {
            SmartPlaylistType type = getSmartPlaylistType();
            return new Playlist(type.mId, getString(type.mTitleId), 0);
          }
        };
    mActionMenuHelper.onPreparePopupMenu(0);
    mActionMenuHelper.createPopupMenu(menu);

    inflater.inflate(R.menu.clear_list, menu);
    super.onCreateOptionsMenu(menu, inflater);
  }