|
|
|
@ -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,6 +42,7 @@ 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));
|
|
|
|
@ -47,6 +50,10 @@ public class FilePickerBuilder extends AlertDialog.Builder implements DialogInte
|
|
|
|
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
|
|
|
|
|