コード例 #1
0
  /** {@inheritDoc} */
  @Override
  public void onRequestRefresh(Object o) {
    // Refresh only the item
    SearchResultAdapter adapter = (SearchResultAdapter) this.mSearchListView.getAdapter();
    if (adapter != null) {
      if (o instanceof FileSystemObject) {

        FileSystemObject fso = (FileSystemObject) o;
        int pos = adapter.getPosition(fso);
        if (pos >= 0) {
          SearchResult sr = adapter.getItem(pos);
          sr.setFso(fso);
        }
      } else if (o == null) {
        // Refresh all
        List<SearchResult> results = adapter.getData();
        this.mResultList = new ArrayList<FileSystemObject>(results.size());
        int cc = results.size();
        for (int i = 0; i < cc; i++) {
          this.mResultList.add(results.get(i).getFso());
        }
        drawResults();
      }
    }
  }
コード例 #2
0
        @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();
          }
        }
コード例 #3
0
  /** {@inheritDoc} */
  @Override
  public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
    // Different actions depending on user preference

    // Get the adapter, the search result and the fso
    SearchResultAdapter adapter = ((SearchResultAdapter) parent.getAdapter());
    SearchResult searchResult = adapter.getItem(position);
    FileSystemObject fso = searchResult.getFso();

    // Open the actions menu
    onRequestMenu(fso);
    return true; // Always consume the event
  }
コード例 #4
0
 @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;
 }
コード例 #5
0
 /** {@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);
   }
 }