public void handleLongPress(
     final View selectedView, final View anchorView, final View thumbnailView) {
   thumbnailView.setSelected(true);
   final PopupMenu popup = new PopupMenu(mContext, anchorView == null ? selectedView : anchorView);
   mPopup = popup;
   popup.getMenuInflater().inflate(R.menu.recent_popup_menu, popup.getMenu());
   popup.setOnMenuItemClickListener(
       new PopupMenu.OnMenuItemClickListener() {
         public boolean onMenuItemClick(MenuItem item) {
           if (item.getItemId() == R.id.recent_remove_item) {
             mRecentsContainer.removeViewInLayout(selectedView);
           } else if (item.getItemId() == R.id.recent_inspect_item) {
             ViewHolder viewHolder = (ViewHolder) selectedView.getTag();
             if (viewHolder != null && viewHolder.taskDescription != null) {
               final TaskDescription ad = viewHolder.taskDescription;
               startApplicationDetailsActivity(ad.packageName);
               show(false);
             } else {
               throw new IllegalStateException("Oops, no tag on view " + selectedView);
             }
           } else {
             return false;
           }
           return true;
         }
       });
   popup.setOnDismissListener(
       new PopupMenu.OnDismissListener() {
         public void onDismiss(PopupMenu menu) {
           thumbnailView.setSelected(false);
           mPopup = null;
         }
       });
   popup.show();
 }
  /**
   * Show a {@link PopupMenu}.
   *
   * @param reactTag the tag of the anchor view (the PopupMenu is displayed next to this view); this
   *     needs to be the tag of a native view (shadow views can not be anchors)
   * @param items the menu items as an array of strings
   * @param success will be called with the position of the selected item as the first argument, or
   *     no arguments if the menu is dismissed
   */
  public void showPopupMenu(int reactTag, ReadableArray items, Callback success) {
    UiThreadUtil.assertOnUiThread();
    View anchor = mTagsToViews.get(reactTag);
    if (anchor == null) {
      throw new JSApplicationIllegalArgumentException("Could not find view with tag " + reactTag);
    }
    PopupMenu popupMenu = new PopupMenu(getReactContextForView(reactTag), anchor);

    Menu menu = popupMenu.getMenu();
    for (int i = 0; i < items.size(); i++) {
      menu.add(Menu.NONE, Menu.NONE, i, items.getString(i));
    }

    PopupMenuCallbackHandler handler = new PopupMenuCallbackHandler(success);
    popupMenu.setOnMenuItemClickListener(handler);
    popupMenu.setOnDismissListener(handler);

    popupMenu.show();
  }