Commits

Bastien Léonard committed 2b2ee8b

Added sorting in MediaFilesActivity.

Also refactored to use the same sorting everywhere (String.CASE_INSENSITIVE_ORDER, currently).

Comments (0)

Files changed (3)

src/net/alwaysdata/bastien_leonard/media_hider/FileListAdapter.java

             }
         }
 
-        sort(new java.util.Comparator<String>()
-             {
-                 public int compare(String a, String b)
-                 {
-                     return a.compareTo(b);
-                 }
-             });
+        sort(Utils.DIRECTORY_COMPARATOR);
         insert(getContext().getString(R.string.go_to_parent_dir), 0);
     }
 

src/net/alwaysdata/bastien_leonard/media_hider/MediaFilesActivity.java

                                   dirInfo.getMediaFilesCount()));
             data.add(map);
         }
+
+        Collections.sort(data,
+                         new Comparator<HashMap<String, String>> ()
+                         {
+                             public int compare(HashMap<String, String> a,
+                                                HashMap<String, String> b)
+                             {
+                                 return Utils.DIRECTORY_COMPARATOR.compare(
+                                     a.get("name"), b.get("name"));
+                             }
+                         });
     }
 
     private void loadMediaFiles(Map<String, DirInfo> directories,

src/net/alwaysdata/bastien_leonard/media_hider/Utils.java

     private static final String TAG = "Utils";
 
     /**
+     * Comparator that should be used for sorting directories.
+     *
+     * Currently it's very dumb, but it may be replaced by something
+     * fancier later.
+     */
+    public static java.util.Comparator<String> DIRECTORY_COMPARATOR =
+        String.CASE_INSENSITIVE_ORDER;
+
+    /**
      * Splits path into an arry [head, tail], where tail is the last
      * component and head is everything leading up to that.
      *