@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();
  }
 @Override
 public void onStop() {
   if (nActions != null) {
     nActions.finish();
   }
   super.onStop();
 }
 @Override
 public void onPause() {
   if (receiver != null) {
     LocalBroadcastManager.getInstance(getActivity()).unregisterReceiver(receiver);
     receiver = null;
   }
   super.onPause();
 }
  public void refresh() {
    if (!ConnectivityUtils.hasNetwork((BaseActivity) getActivity())) {
      return;
    }

    if (parentFolder == null) {
      parentFolder = SessionUtils.getSession(getActivity()).getRootFolder();
    }
    super.refresh();
  }
  // //////////////////////////////////////////////////////////////////////
  // LIFE CYCLE
  // //////////////////////////////////////////////////////////////////////
  @Override
  public void onActivityCreated(Bundle savedInstanceState) {
    setRetainInstance(true);
    alfSession = SessionUtils.getSession(getActivity());
    SessionUtils.checkSession(getActivity(), alfSession);
    if (alfSession == null) {

    } else if (RepositoryVersionHelper.isAlfrescoProduct(alfSession)) {
      setActivateThumbnail(true);
    }

    // In case of Import mode, we disable thumbnails.
    if (getActivity() instanceof PublicDispatcherActivity) {
      mode = MODE_IMPORT;
      setActivateThumbnail(false);
    } else if (getActivity() instanceof PrivateDialogActivity) {
      mode = MODE_PICK;
      fragmentPick = ((PrivateDialogActivity) getActivity()).getOnPickDocumentFragment();
    }

    super.onActivityCreated(savedInstanceState);
  }