summaryrefslogtreecommitdiffstats
path: root/src/com/android/browser
diff options
context:
space:
mode:
authorJohn Reck <jreck@google.com>2012-04-13 13:44:36 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2012-04-13 13:44:36 -0700
commit5bd8dd362b73b8a5f45f01ea9ab125118826c317 (patch)
tree64b2ba23eda69b27c1ff1a8e3046233a690b1400 /src/com/android/browser
parente11b9212f201f787652737cab586f7cf28c27dd0 (diff)
parentcca9be466e3de0ac5703bd7bfa4b1d9378240541 (diff)
downloadpackages_apps_Browser-5bd8dd362b73b8a5f45f01ea9ab125118826c317.zip
packages_apps_Browser-5bd8dd362b73b8a5f45f01ea9ab125118826c317.tar.gz
packages_apps_Browser-5bd8dd362b73b8a5f45f01ea9ab125118826c317.tar.bz2
Merge "Sort files & folders in directory list"
Diffstat (limited to 'src/com/android/browser')
-rw-r--r--src/com/android/browser/homepages/RequestHandler.java13
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());