Commit e6375048 authored by Kristin Muterspaw's avatar Kristin Muterspaw
Browse files

Fixed the bug where Field Day would crash on 'Note Book' if the root directory...

Fixed the bug where Field Day would crash on 'Note Book' if the root directory didn't exist or have files in it.
parent 7f20cc77
......@@ -65,13 +65,18 @@ public class MyDocumentsActivity extends Activity {
}
});
downloadList = new ArrayList<String>();
dirList = new ArrayList<String>();
localDirList = new ArrayList<File>();
final File rootDir = new File(directory);
localDirList = getFilesInDir(rootDir);
// Check to see if the root directory exists. If it does, get the list of files in it to
// use for the ListView of files
final File rootDir = createDirectory(directory);
if (rootDir.listFiles() != null) {
if (rootDir.listFiles().length == 0) {
localDirList = getFilesInDir(rootDir);
}
}
firstPage = true;
context = this;
......@@ -82,7 +87,7 @@ public class MyDocumentsActivity extends Activity {
filesListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
if (myDocumentsAdapter.getItem(position).isDirectory()){
if (myDocumentsAdapter.getItem(position).isDirectory()) {
File folder = myDocumentsAdapter.getItem(position);
localDirList = getFilesInDir(folder);
if (!folder.equals(rootDir)) {
......@@ -131,11 +136,15 @@ public class MyDocumentsActivity extends Activity {
public ArrayList<File> getFilesInDir(File directory){
ArrayList<File> list = new ArrayList<File>();
for (File f : directory.listFiles()) {
list.add(f);
Log.d("File name", f.getName());
if (directory.listFiles().length == 0) {
return null;
} else {
for (File f : directory.listFiles()) {
list.add(f);
Log.d("File name", f.getName());
}
return list;
}
return list;
}
public File createDirectory(String dirName) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment