diff options
author | John Reck <jreck@google.com> | 2012-04-13 13:40:46 -0700 |
---|---|---|
committer | John Reck <jreck@google.com> | 2012-04-13 13:42:45 -0700 |
commit | cca9be466e3de0ac5703bd7bfa4b1d9378240541 (patch) | |
tree | 647b1b63e5a411facd431dd1b10d6cde0e17c6d0 /src | |
parent | 8cad413fe902010140cf20aad47c2f4e7a51f8d2 (diff) | |
download | packages_apps_browser-cca9be466e3de0ac5703bd7bfa4b1d9378240541.zip packages_apps_browser-cca9be466e3de0ac5703bd7bfa4b1d9378240541.tar.gz packages_apps_browser-cca9be466e3de0ac5703bd7bfa4b1d9378240541.tar.bz2 |
Sort files & folders in directory list
Change-Id: I2eef1c989150d97266659d615d09edfdad322d2e
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/browser/homepages/RequestHandler.java | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/com/android/browser/homepages/RequestHandler.java b/src/com/android/browser/homepages/RequestHandler.java index b3a03b9..13b52e3 100644 --- a/src/com/android/browser/homepages/RequestHandler.java +++ b/src/com/android/browser/homepages/RequestHandler.java @@ -37,6 +37,8 @@ import java.io.InputStream; import java.io.OutputStream;
import java.text.DateFormat;
import java.text.DecimalFormat;
+import java.util.Arrays;
+import java.util.Comparator;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -140,9 +142,20 @@ public class RequestHandler extends Thread { t.write(mOutput);
}
+ private static final Comparator<File> sFileComparator = new Comparator<File>() {
+ @Override
+ public int compare(File lhs, File rhs) {
+ if (lhs.isDirectory() != rhs.isDirectory()) {
+ return lhs.isDirectory() ? -1 : 1;
+ }
+ return lhs.getName().compareTo(rhs.getName());
+ }
+ };
+
void writeFolderIndex() throws IOException {
File f = new File(mUri.getPath());
final File[] files = f.listFiles();
+ Arrays.sort(files, sFileComparator);
Template t = Template.getCachedTemplate(mContext, R.raw.folder_view);
t.assign("path", mUri.getPath());
t.assign("parent_url", f.getParent() != null ? f.getParent() : f.getPath());
|