@Override
  public void onResume() {
    super.onResume();

    int titleId = R.string.app_name;
    if (getActivity() instanceof PublicDispatcherActivity) {
      mode = MODE_IMPORT;
      titleId = R.string.import_document_title;
      checkValidationButton();
    } else if (getActivity() instanceof PrivateDialogActivity) {
      mode = MODE_PICK;
      titleId = R.string.picker_document_title;
      checkValidationButton();
    }

    // If the fragment is resumed after user content creation action, we
    // have to check if the file has been modified or not. Depending on
    // result we prompt the upload dialog or we do nothing (no modification
    // / blank file)
    if (createFile != null) {
      if (createFile.length() > 0 && lastModifiedDate < createFile.lastModified()) {
        tmpFile = createFile;
      } else {
        if (!createFile.delete()) {
          Log.w(TAG, createFile.getName() + "is not deleted.");
        }
        createFile = null;
      }
    }

    if (tmpFile != null) {
      importFolder = ((MainActivity) getActivity()).getImportParent();
      createFile(tmpFile);
    }

    if (getActivity().getActionBar() != null) {
      getActivity().getActionBar().setDisplayHomeAsUpEnabled(true);
      getActivity().getActionBar().setDisplayShowCustomEnabled(false);
      getActivity().setTitle(titleId);
      AccessibilityHelper.sendAccessibilityEvent(getActivity());
      if (shortcutAlreadyVisible) {
        displayPathShortcut();
      }
    }

    if (receiver == null) {
      IntentFilter intentFilter = new IntentFilter(IntentIntegrator.ACTION_UPLOAD_COMPLETED);
      intentFilter.addAction(IntentIntegrator.ACTION_UPDATE_COMPLETED);
      intentFilter.addAction(IntentIntegrator.ACTION_DELETE_COMPLETED);
      intentFilter.addAction(IntentIntegrator.ACTION_UPLOAD_STARTED);
      intentFilter.addAction(IntentIntegrator.ACTION_CREATE_FOLDER_COMPLETED);
      intentFilter.addAction(IntentIntegrator.ACTION_UPDATE_COMPLETED);
      intentFilter.addAction(IntentIntegrator.ACTION_FAVORITE_COMPLETED);
      intentFilter.addAction(IntentIntegrator.ACTION_DOWNLOAD_COMPLETED);
      receiver = new TransfertReceiver();
      LocalBroadcastManager.getInstance(getActivity()).registerReceiver(receiver, intentFilter);
    }

    refreshListView();
  }
  // //////////////////////////////////////////////////////////////////////
  // LOADERS
  // //////////////////////////////////////////////////////////////////////
  @Override
  public void onLoadFinished(
      Loader<LoaderResult<PagingResult<Node>>> loader, LoaderResult<PagingResult<Node>> results) {
    if (getActivity() instanceof MainActivity
        && ((MainActivity) getActivity()).getCurrentNode() != null) {
      selectedItems.clear();
      selectedItems.add(((MainActivity) getActivity()).getCurrentNode());
    }

    if (loader instanceof NodeChildrenLoader) {
      parentFolder = ((NodeChildrenLoader) loader).getParentFolder();
      importFolder = parentFolder;
    }

    if (mode == MODE_PICK && adapter == null) {
      selectedMapItems = fragmentPick.retrieveDocumentSelection();
      adapter =
          new ProgressNodeAdapter(
              getActivity(),
              BaseCursorGridAdapterHelper.getDisplayItemLayout(getActivity(), gv, displayMode),
              parentFolder,
              new ArrayList<Node>(0),
              selectedMapItems);
    } else if (adapter == null) {
      adapter =
          new ProgressNodeAdapter(
              getActivity(),
              BaseCursorGridAdapterHelper.getDisplayItemLayout(getActivity(), gv, displayMode),
              parentFolder,
              new ArrayList<Node>(0),
              selectedItems,
              mode);
    }

    if (results.hasException()) {
      if (adapter.getCount() == 0) {
        ev.setVisibility(View.VISIBLE);
      }
      onLoaderException(results.getException());
    } else {
      displayPagingData(results.getData(), loaderId, callback);
    }
    ((NodeAdapter) adapter).setActivateThumbnail(hasActivateThumbnail());
    getActivity().invalidateOptionsMenu();
    displayPathShortcut();
    checkValidationButton();
  }
  // //////////////////////////////////////////////////////////////////////
  // 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);
      }
    }
  }