@Override
 public boolean onMenuItemClick(MenuItem item) {
   boolean onMenuItemClick = true;
   switch (item.getItemId()) {
     case MenuActionItem.MENU_DETAILS:
       onMenuItemClick = true;
       ((MainActivity) context).addPropertiesFragment(selectedOptionItems.get(0));
       selectedItems.add(selectedOptionItems.get(0));
       notifyDataSetChanged();
       break;
     case MenuActionItem.MENU_EDIT:
       onMenuItemClick = true;
       NodeActions.edit((Activity) context, (Folder) parentNode, selectedOptionItems.get(0));
       break;
     case MenuActionItem.MENU_DELETE_FOLDER:
       onMenuItemClick = true;
       Fragment fr =
           ((Activity) context)
               .getFragmentManager()
               .findFragmentByTag(ChildrenBrowserFragment.TAG);
       NodeActions.delete((Activity) context, fr, selectedOptionItems.get(0));
       break;
     default:
       onMenuItemClick = false;
       break;
   }
   selectedOptionItems.clear();
   return onMenuItemClick;
 }
 @Override
 public void onStop() {
   if (nActions != null) {
     nActions.finish();
   }
   super.onStop();
 }
  private boolean startSelection(View v, Node item) {
    if (nActions != null) {
      return false;
    }

    // Start the CAB using the ActionMode.Callback defined above
    nActions = new NodeActions(ChildrenBrowserFragment.this, item);
    nActions.setOnFinishModeListerner(
        new onFinishModeListerner() {
          @Override
          public void onFinish() {
            nActions = null;
          }
        });
    getActivity().startActionMode(nActions);
    selectedItems.clear();
    selectedItems.add(item);
    return true;
  }
 public void delete() {
   if (!selectedItems.isEmpty() && selectedItems.size() == 1) {
     NodeActions.delete(getActivity(), this, selectedItems.get(0));
   }
 }
 public void selectAll() {
   if (nActions != null && adapter != null) {
     nActions.selectNodes(((ProgressNodeAdapter) adapter).getNodes());
     adapter.notifyDataSetChanged();
   }
 }
  // //////////////////////////////////////////////////////////////////////
  // LIST ACTIONS
  // //////////////////////////////////////////////////////////////////////
  @Override
  public void onListItemClick(GridView l, View v, int position, long id) {
    Node item = (Node) l.getItemAtPosition(position);

    if (item instanceof NodePlaceHolder) {
      l.setItemChecked(position, false);
      return;
    }

    // In case of import mode, we disable selection of document.
    // It's only possible to select a folder for navigation purpose.
    if (mode == MODE_IMPORT && getActivity() instanceof PublicDispatcherActivity) {
      l.setChoiceMode(GridView.CHOICE_MODE_NONE);
      if (item.isFolder()) {
        ((PublicDispatcherActivity) getActivity()).addNavigationFragment((Folder) item);
      }
      return;
    }

    // In case of pick mode, we allow multiSelection
    if (mode == MODE_PICK && getActivity() instanceof PrivateDialogActivity && item.isDocument()) {
      l.setChoiceMode(GridView.CHOICE_MODE_MULTIPLE);
      if (selectedMapItems.containsKey(item.getIdentifier())) {
        selectedMapItems.remove(item.getIdentifier());
      } else {
        selectedMapItems.put(item.getIdentifier(), (Document) item);
      }
      l.setItemChecked(position, true);
      checkValidationButton();
      return;
    }

    // In other case, listing mode
    Boolean hideDetails = false;
    if (!selectedItems.isEmpty()) {
      hideDetails = selectedItems.get(0).getIdentifier().equals(item.getIdentifier());
    }
    l.setItemChecked(position, true);

    if (nActions != null) {
      nActions.selectNode(item);
      if (selectedItems.size() == 0) {
        hideDetails = true;
      }
    } else {
      selectedItems.clear();
      if (!hideDetails && item.isDocument() && DisplayUtils.hasCentralPane(getActivity())) {
        selectedItems.add(item);
      }
    }

    if (hideDetails) {
      if (DisplayUtils.hasCentralPane(getActivity())) {
        FragmentDisplayer.removeFragment(
            getActivity(), DisplayUtils.getCentralFragmentId(getActivity()));
        FragmentDisplayer.removeFragment(getActivity(), android.R.id.tabcontent);
      }
    } else if (nActions == null) {
      if (item.isFolder()) {
        ((BaseActivity) getActivity())
            .addNavigationFragment(currentSiteParameter, (Folder) item, isShortcut());
      } else {
        // Show properties
        ((MainActivity) getActivity()).addPropertiesFragment(item);
        DisplayUtils.switchSingleOrTwo(getActivity(), true);
      }
    }
  }