Merge with latest from Corey's backup branch.

------------------------------------------------------------
Use --include-merges or -n0 to see merged revisions.
pull/14/head
Tim Su 16 years ago
parent 5ab900f323
commit cbc9d6d941

@ -3,6 +3,8 @@ package com.timsu.astrid.widget;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.util.Log;
import com.timsu.astrid.R;
import java.io.File; import java.io.File;
import java.io.FilenameFilter; import java.io.FilenameFilter;
@ -30,9 +32,9 @@ public class FilePickerBuilder extends AlertDialog.Builder implements DialogInte
return file.isFile(); return file.isFile();
} }
}; };
this.callback = callback;
setTitle(title); setTitle(title);
setPath(path); setPath(path);
this.callback = callback;
} }
public void setFilter(FilenameFilter filter) { public void setFilter(FilenameFilter filter) {
@ -40,13 +42,18 @@ public class FilePickerBuilder extends AlertDialog.Builder implements DialogInte
} }
private void setPath(File path) { private void setPath(File path) {
if (path != null && path.exists()) {
this.path = path.getAbsolutePath(); this.path = path.getAbsolutePath();
// Reverse the order of the file list so newest timestamped file is first. // Reverse the order of the file list so newest timestamped file is first.
List<String> fileList = Arrays.asList(path.list(filter)); List<String> fileList = Arrays.asList(path.list(filter));
Collections.sort(fileList); Collections.sort(fileList);
Collections.reverse(fileList); Collections.reverse(fileList);
files = (String[])fileList.toArray(); files = (String[]) fileList.toArray();
setItems(files, this); setItems(files, this);
} else {
Log.e("FilePicker", "Cannot access sdcard.");
setMessage(R.string.error_sdcard + "sdcard");
}
} }
@Override @Override

Loading…
Cancel
Save