From cbc9d6d94115c0f9dc9628ace439d8ee3fcfbd28 Mon Sep 17 00:00:00 2001 From: Tim Su Date: Wed, 28 Apr 2010 22:36:38 -0700 Subject: [PATCH] Merge with latest from Corey's backup branch. ------------------------------------------------------------ Use --include-merges or -n0 to see merged revisions. --- .../astrid/widget/FilePickerBuilder.java | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/com/timsu/astrid/widget/FilePickerBuilder.java b/src/com/timsu/astrid/widget/FilePickerBuilder.java index bd4c5d8e1..b2496ef24 100644 --- a/src/com/timsu/astrid/widget/FilePickerBuilder.java +++ b/src/com/timsu/astrid/widget/FilePickerBuilder.java @@ -3,6 +3,8 @@ package com.timsu.astrid.widget; import android.app.AlertDialog; import android.content.Context; import android.content.DialogInterface; +import android.util.Log; +import com.timsu.astrid.R; import java.io.File; import java.io.FilenameFilter; @@ -30,9 +32,9 @@ public class FilePickerBuilder extends AlertDialog.Builder implements DialogInte return file.isFile(); } }; + this.callback = callback; setTitle(title); setPath(path); - this.callback = callback; } public void setFilter(FilenameFilter filter) { @@ -40,13 +42,18 @@ public class FilePickerBuilder extends AlertDialog.Builder implements DialogInte } private void setPath(File path) { - this.path = path.getAbsolutePath(); - // Reverse the order of the file list so newest timestamped file is first. - List fileList = Arrays.asList(path.list(filter)); - Collections.sort(fileList); - Collections.reverse(fileList); - files = (String[])fileList.toArray(); - setItems(files, this); + if (path != null && path.exists()) { + this.path = path.getAbsolutePath(); + // Reverse the order of the file list so newest timestamped file is first. + List fileList = Arrays.asList(path.list(filter)); + Collections.sort(fileList); + Collections.reverse(fileList); + files = (String[]) fileList.toArray(); + setItems(files, this); + } else { + Log.e("FilePicker", "Cannot access sdcard."); + setMessage(R.string.error_sdcard + "sdcard"); + } } @Override