public boolean onItemLongClick(GridView l, View v, int position, long id) {
    if (nActions != null) {
      return false;
    }

    Cursor cursor = (Cursor) l.getItemAtPosition(position);
    String documentId = cursor.getString(SynchroSchema.COLUMN_NODE_ID_ID);

    selectedItems.clear();
    selectedItems.add(documentId);

    // Start the CAB using the ActionMode.Callback defined above
    nActions = new NodeIdActions(FavoritesSyncFragment.this, selectedItems);
    nActions.setOnFinishModeListerner(
        new onFinishModeListerner() {
          @Override
          public void onFinish() {
            nActions = null;
            selectedItems.clear();
            adapter.notifyDataSetChanged();
            ((FavoriteCursorAdapter) adapter).refresh();
            gv.setAdapter(adapter);
          }
        });
    getActivity().startActionMode(nActions);
    adapter.notifyDataSetChanged();

    return true;
  };
 @Override
 public void onStop() {
   if (nActions != null) {
     nActions.finish();
   }
   super.onStop();
 }
  public boolean onListItemLongClick(GridView l, View v, int position, long id) {
    if (nActions != null || getFolderId() != null) {
      return false;
    }

    Cursor cursor = (Cursor) l.getItemAtPosition(position);
    String documentId = cursor.getString(SyncContentSchema.COLUMN_NODE_ID_ID);

    selectedItems.clear();
    selectedItems.add(documentId);

    // Start the CAB using the ActionMode.Callback defined above
    nActions = new NodeIdActions(SyncFragment.this, selectedItems);
    nActions.setOnFinishModeListener(
        new AbstractActions.onFinishModeListener() {
          @Override
          public void onFinish() {
            nActions = null;
            selectedItems.clear();
            adapter.notifyDataSetChanged();
            ((SyncCursorAdapter) adapter).refresh();
            gv.setAdapter(adapter);
            displayFab(-1, null);
          }
        });

    displayFab(R.drawable.ic_done_all_white, onMultiSelectionFabClickListener());
    getActivity().startActionMode(nActions);
    adapter.notifyDataSetChanged();

    return true;
  }
  // ///////////////////////////////////////////////////////////////////////////
  // LIST ACTIONS
  // ///////////////////////////////////////////////////////////////////////////
  public void onListItemClick(GridView l, View v, int position, long id) {
    Cursor cursor = (Cursor) l.getItemAtPosition(position);
    String nodeId = cursor.getString(SyncContentSchema.COLUMN_NODE_ID_ID);
    String documentName = cursor.getString(SyncContentSchema.COLUMN_TITLE_ID);

    if (DisplayUtils.hasCentralPane(getActivity())) {
      FragmentDisplayer.with(getActivity())
          .remove(DisplayUtils.getCentralFragmentId(getActivity()));
    }

    Boolean hideDetails = false;
    if (!selectedItems.isEmpty()) {
      hideDetails = selectedItems.get(0).equals(nodeId);
    }
    l.setItemChecked(position, true);

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

    if (hideDetails) {
      selectedItems.clear();
      displayTitle();
    } else if (nActions == null) {
      if (SyncContentManager.isFolder(cursor)) {
        selectedItems.clear();
        if (SyncContentManager.getInstance(getActivity()).hasActivateSync(acc)) {
          // GO TO Local subfolder
          SyncFragment.with(getActivity())
              .mode(getMode())
              .folderIdentifier(nodeId)
              .folderName(documentName)
              .display();
        } else {
          DocumentFolderBrowserFragment.with(getActivity())
              .folderIdentifier(nodeId)
              .shortcut(true)
              .display();
        }
      } else {
        if (!ConnectivityUtils.hasInternetAvailable(getActivity())) {
          NodeDetailsFragment.with(getActivity())
              .node(getOfflineNode(nodeId))
              .isFavorite(true)
              .display();
        } else {
          NodeDetailsFragment.with(getActivity()).nodeId(nodeId).isFavorite(true).display();
        }
      }
    }
    adapter.notifyDataSetChanged();
  }
 @Override
 public void selectAll() {
   if (nActions != null && adapter != null) {
     displayFab(R.drawable.ic_close_dark, onCancelMultiSelectionFabClickListener());
     nActions.selectNodes(((SyncCursorAdapter) adapter).getNodes());
     adapter.notifyDataSetChanged();
   }
 }
  // ///////////////////////////////////////////////////////////////////////////
  // LIST ACTIONS
  // ///////////////////////////////////////////////////////////////////////////
  public void onListItemClick(GridView l, View v, int position, long id) {
    Cursor cursor = (Cursor) l.getItemAtPosition(position);
    String nodeId = cursor.getString(SynchroSchema.COLUMN_NODE_ID_ID);
    String documentName = cursor.getString(SynchroSchema.COLUMN_TITLE_ID);

    if (DisplayUtils.hasCentralPane(getActivity())) {
      FragmentDisplayer.removeFragment(
          getActivity(), DisplayUtils.getCentralFragmentId(getActivity()));
    }

    Boolean hideDetails = false;
    if (!selectedItems.isEmpty()) {
      hideDetails = selectedItems.get(0).equals(nodeId);
    }
    l.setItemChecked(position, true);

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

    if (hideDetails) {
      selectedItems.clear();
    } else if (nActions == null) {
      if (SynchroManager.isFolder(cursor)) {
        selectedItems.clear();
        if (SynchroManager.getInstance(getActivity()).hasActivateSync(acc)) {
          // GO TO Local subfolder
          Fragment syncFrag = FavoritesSyncFragment.newInstance(getMode(), nodeId, documentName);
          FragmentDisplayer.replaceFragment(
              getActivity(),
              syncFrag,
              DisplayUtils.getLeftFragmentId(getActivity()),
              FavoritesSyncFragment.TAG,
              true);
        } else {
          ((MainActivity) getActivity()).addNavigationFragmentById(nodeId);
        }
      } else {
        // Show properties
        ((MainActivity) getActivity()).addPropertiesFragment(true, nodeId);
        DisplayUtils.switchSingleOrTwo(getActivity(), true);
      }
    }
    adapter.notifyDataSetChanged();
  }