• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

packages/apps/FileManager


Commit MetaInfo

Révision5fb77b20764f6b01bceebbd79b18f1296335d6bd (tree)
l'heure2011-06-20 09:30:42
AuteurJoe Berria <nexesdevelopment@gmai...>
CommiterJoe Berria

Message de Log

improved sorting by type and size

Change Summary

Modification

--- a/src/com/nexes/manager/tablet/FileManager.java
+++ b/src/com/nexes/manager/tablet/FileManager.java
@@ -474,9 +474,10 @@ public class FileManager {
474474 public int compare(String arg0, String arg1) {
475475 String dir = mPathStack.peek();
476476 Long first = new File(dir + "/" + arg0).length();
477- Long second = new File(dir + "/" + arg0).length();
477+ Long second = new File(dir + "/" + arg1).length();
478478
479- return (int) (first - second);
479+ Log.e("FILE MANAGER", "first: " + first + "\nsecond: " + second);
480+ return first.compareTo(second);//(int) (first - second);
480481 }
481482 };
482483
@@ -485,16 +486,21 @@ public class FileManager {
485486 public int compare(String arg0, String arg1) {
486487 String ext = null;
487488 String ext2 = null;
489+ int ret;
488490
489491 try {
490- ext = arg0.substring(arg0.lastIndexOf(".") + 1, arg0.length());
491- ext2 = arg1.substring(arg1.lastIndexOf(".") + 1, arg1.length());
492+ ext = arg0.substring(arg0.lastIndexOf(".") + 1, arg0.length()).toLowerCase();
493+ ext2 = arg1.substring(arg1.lastIndexOf(".") + 1, arg1.length()).toLowerCase();
492494
493495 } catch (IndexOutOfBoundsException e) {
494496 return 0;
495497 }
498+ ret = ext.compareTo(ext2);
496499
497- return ext.compareTo(ext2);
500+ if (ret == 0)
501+ return arg0.toLowerCase().compareTo(arg1.toLowerCase());
502+
503+ return ret;
498504 }
499505 };
500506
@@ -548,14 +554,16 @@ public class FileManager {
548554 break;
549555
550556 case SORT_SIZE:
557+ int index = 0;
551558 Object[] size_ar = mDirContent.toArray();
552559 String dir = mPathStack.peek();
553560
554561 Arrays.sort(size_ar, size);
562+
555563 mDirContent.clear();
556- for (Object a : size_ar){
564+ for (Object a : size_ar) {
557565 if(new File(dir + "/" + (String)a).isDirectory())
558- mDirContent.add(0, (String)a);
566+ mDirContent.add(index++, (String)a);
559567 else
560568 mDirContent.add((String)a);
561569 }
@@ -563,20 +571,17 @@ public class FileManager {
563571
564572 case SORT_TYPE:
565573 int dirindex = 0;
566- int fileindex = dirindex;
567574 Object[] type_ar = mDirContent.toArray();
568575 String current = mPathStack.peek();
569576
570577 Arrays.sort(type_ar, type);
571578 mDirContent.clear();
572579
573- for (Object a : type_ar){
580+ for (Object a : type_ar) {
574581 if(new File(current + "/" + (String)a).isDirectory())
575582 mDirContent.add(dirindex++, (String)a);
576583 else
577- mDirContent.add(fileindex, (String)a);
578-
579- fileindex = dirindex;
584+ mDirContent.add((String)a);
580585 }
581586 break;
582587 }