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

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

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

    mFile = mStorageManager.getFileByPath(full_path);
    if (mFile != null) {
      Vector<OCFile> files = mStorageManager.getDirectoryContent(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.isDirectory()) {
          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 프로젝트: skn/android
 @Override
 public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
   // click on folder in the list
   Log.d(TAG, "on item click");
   Vector<OCFile> tmpfiles = mStorageManager.getDirectoryContent(mFile);
   if (tmpfiles.size() <= 0) return;
   // filter on dirtype
   Vector<OCFile> files = new Vector<OCFile>();
   for (OCFile f : tmpfiles) if (f.isDirectory()) files.add(f);
   if (files.size() < position) {
     throw new IndexOutOfBoundsException("Incorrect item selected");
   }
   mParents.push(files.get(position).getFileName());
   populateDirectoryList();
 }