@Override
        public void onItemFlingerEnd(
            OnItemFlingerResponder responder,
            AdapterView<?> parent,
            View view,
            int position,
            long id) {

          try {
            // Response if the item can be removed
            SearchResultAdapter adapter = (SearchResultAdapter) parent.getAdapter();
            SearchResult result = adapter.getItem(position);
            if (result != null && result.getFso() != null) {
              DeleteActionPolicy.removeFileSystemObject(
                  SearchActivity.this, result.getFso(), null, SearchActivity.this, responder);
              return;
            }

            // Cancels the flinger operation
            responder.cancel();

          } catch (Exception e) {
            ExceptionUtil.translateException(SearchActivity.this, e, true, false);
            responder.cancel();
          }
        }
  /**
   * Method that returns to previous activity.
   *
   * @param cancelled Indicates if the activity was cancelled
   * @param item The fso
   * @hide
   */
  void back(final boolean cancelled, FileSystemObject item, boolean isChecked) {
    Intent intent = new Intent();
    if (cancelled) {
      if (SearchActivity.this.mDrawingSearchResultTask != null
          && SearchActivity.this.mDrawingSearchResultTask.isRunning()) {
        SearchActivity.this.mDrawingSearchResultTask.cancel(true);
      }
      if (this.mRestoreState != null) {
        intent.putExtra(
            NavigationActivity.EXTRA_SEARCH_LAST_SEARCH_DATA, (Parcelable) this.mRestoreState);
      }
      setResult(RESULT_CANCELED, intent);
    } else {
      // Check that the bookmark exists
      try {
        FileSystemObject fso = item;
        if (!isChecked) {
          fso = CommandHelper.getFileInfo(this, item.getFullPath(), null);
        }
        if (fso != null) {
          if (FileHelper.isDirectory(fso)) {
            intent.putExtra(NavigationActivity.EXTRA_SEARCH_ENTRY_SELECTION, fso);
            intent.putExtra(
                NavigationActivity.EXTRA_SEARCH_LAST_SEARCH_DATA, (Parcelable) createSearchInfo());
            setResult(RESULT_OK, intent);
          } else {
            // Open the file here, so when focus back to the app, the search activity
            // its in top of the stack
            IntentsActionPolicy.openFileSystemObject(this, fso, false, null, null);
            return;
          }
        } else {
          // The fso not exists, delete the fso from the search
          try {
            removeItem(item);
          } catch (Exception ex) {
            /** NON BLOCK* */
          }
        }

      } catch (Exception e) {
        // Capture the exception
        ExceptionUtil.translateException(this, e);
        if (e instanceof NoSuchFileOrDirectory || e instanceof FileNotFoundException) {
          // The fso not exists, delete the fso from the search
          try {
            removeItem(item);
          } catch (Exception ex) {
            /** NON BLOCK* */
          }
        }
        return;
      }
    }
    finish();
  }
 @Override
 public boolean onItemFlingerStart(AdapterView<?> parent, View view, int position, long id) {
   try {
     // Response if the item can be removed
     SearchResultAdapter adapter = (SearchResultAdapter) parent.getAdapter();
     SearchResult result = adapter.getItem(position);
     if (result != null && result.getFso() != null) {
       if (result.getFso() instanceof ParentDirectory) {
         // This is not possible ...
         return false;
       }
       return true;
     }
   } catch (Exception e) {
     ExceptionUtil.translateException(SearchActivity.this, e, true, false);
   }
   return false;
 }
 /** {@inheritDoc} */
 @Override
 public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
   try {
     SearchResult result = ((SearchResultAdapter) parent.getAdapter()).getItem(position);
     FileSystemObject fso = result.getFso();
     if (fso instanceof Directory) {
       back(false, fso, false);
     } else if (fso instanceof Symlink) {
       Symlink symlink = (Symlink) fso;
       if (symlink.getLinkRef() != null && symlink.getLinkRef() instanceof Directory) {
         back(false, symlink.getLinkRef(), false);
       }
     } else {
       // Open the file with the preferred registered app
       back(false, fso, false);
     }
   } catch (Throwable ex) {
     ExceptionUtil.translateException(this.mSearchListView.getContext(), ex);
   }
 }
  /**
   * Method invoked when a request to show the menu associated with an item is started.
   *
   * @param item The item for which the request was started
   */
  public void onRequestMenu(FileSystemObject item) {
    // Prior to show the dialog, refresh the item reference
    FileSystemObject fso = null;
    try {
      fso = CommandHelper.getFileInfo(this, item.getFullPath(), false, null);
      if (fso == null) {
        throw new NoSuchFileOrDirectory(item.getFullPath());
      }

    } catch (Exception e) {
      // Notify the user
      ExceptionUtil.translateException(this, e);

      // Remove the object
      if (e instanceof FileNotFoundException || e instanceof NoSuchFileOrDirectory) {
        removeItem(item);
      }
      return;
    }

    ActionsDialog dialog = new ActionsDialog(this, fso, false, true);
    dialog.setOnRequestRefreshListener(this);
    dialog.show();
  }
 /** {@inheritDoc} */
 @Override
 public void onException(Exception cause) {
   // Capture the exception
   ExceptionUtil.translateException(this, cause);
 }