예제 #1
0
파일: Uploader.java 프로젝트: 21347/android
  private void populateDirectoryList() {
    setContentView(R.layout.uploader_layout);

    String full_path = "";
    for (String a : mParents) full_path += a + "/";

    Log_OC.d(TAG, "Populating view with content of : " + full_path);

    mFile = mStorageManager.getFileByPath(full_path);
    if (mFile != null) {
      Vector<OCFile> files = mStorageManager.getFolderContent(mFile);
      List<HashMap<String, Object>> data = new LinkedList<HashMap<String, Object>>();
      for (OCFile f : files) {
        HashMap<String, Object> h = new HashMap<String, Object>();
        if (f.isFolder()) {
          h.put("dirname", f.getFileName());
          data.add(h);
        }
      }
      SimpleAdapter sa =
          new SimpleAdapter(
              this,
              data,
              R.layout.uploader_list_item_layout,
              new String[] {"dirname"},
              new int[] {R.id.textView1});
      setListAdapter(sa);
      Button btn = (Button) findViewById(R.id.uploader_choose_folder);
      btn.setOnClickListener(this);
      getListView().setOnItemClickListener(this);
    }
  }
예제 #2
0
파일: Uploader.java 프로젝트: 21347/android
 @Override
 public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
   // click on folder in the list
   Log_OC.d(TAG, "on item click");
   Vector<OCFile> tmpfiles = mStorageManager.getFolderContent(mFile);
   if (tmpfiles.size() <= 0) return;
   // filter on dirtype
   Vector<OCFile> files = new Vector<OCFile>();
   for (OCFile f : tmpfiles) if (f.isFolder()) files.add(f);
   if (files.size() < position) {
     throw new IndexOutOfBoundsException("Incorrect item selected");
   }
   mParents.push(files.get(position).getFileName());
   populateDirectoryList();
 }
예제 #3
0
  /**
   * Change the adapted directory for a new one
   *
   * @param directory New file to adapt. Can be NULL, meaning "no content to adapt".
   * @param updatedStorageManager Optional updated storage manager; used to replace mStorageManager
   *     if is different (and not NULL)
   */
  public void swapDirectory(OCFile directory, FileDataStorageManager updatedStorageManager) {
    mFile = directory;
    if (updatedStorageManager != null && updatedStorageManager != mStorageManager) {
      mStorageManager = updatedStorageManager;
      mAccount = AccountUtils.getCurrentOwnCloudAccount(mContext);
    }
    if (mStorageManager != null) {
      mFiles = mStorageManager.getFolderContent(mFile);
      mFilesOrig.clear();
      mFilesOrig.addAll(mFiles);

      if (mJustFolders) {
        mFiles = getFolders(mFiles);
      }
    } else {
      mFiles = null;
    }

    mFiles = FileStorageUtils.sortFolder(mFiles);
    notifyDataSetChanged();
  }