コード例 #1
0
  /**
   * 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();
  }
コード例 #2
0
 /**
  * Method that returns the supported compression modes
  *
  * @param ctx The current context
  * @param fsos The list of file system objects to compress
  * @return String[] An array with the compression mode labels
  */
 private static String[] getSupportedCompressionModesLabels(
     Context ctx, List<FileSystemObject> fsos) {
   String[] labels = ctx.getResources().getStringArray(R.array.compression_modes_labels);
   if (fsos.size() > 1 || (fsos.size() == 1 && FileHelper.isDirectory(fsos.get(0)))) {
     // If more that a file is requested, compression is not available
     // The same applies if the unique item is a folder
     ArrayList<String> validLabels = new ArrayList<String>();
     CompressionMode[] values = CompressionMode.values();
     int cc = values.length;
     for (int i = 0; i < cc; i++) {
       if (values[i].mArchive) {
         validLabels.add(labels[i]);
       }
     }
     labels = validLabels.toArray(new String[] {});
   }
   return labels;
 }