Forráskód Böngészése

Merge branch 'master' of ssh://git@gitorious.org/owncloud/android-devel.git

Lennart Rosam 13 éve
szülő
commit
1070273daf

+ 8 - 0
src/eu/alefzero/owncloud/datamodel/FileDataStorageManager.java

@@ -18,6 +18,8 @@
 
 package eu.alefzero.owncloud.datamodel;
 
+import java.io.File;
+import java.util.Collections;
 import java.util.Vector;
 
 import eu.alefzero.owncloud.db.ProviderMeta.ProviderTableMeta;
@@ -205,6 +207,9 @@ public class FileDataStorageManager implements DataStorageManager {
             }
 
             c.close();
+            
+            Collections.sort(ret);
+            
             return ret;
         }
         return null;
@@ -305,6 +310,9 @@ public class FileDataStorageManager implements DataStorageManager {
                                         ProviderTableMeta.FILE_ACCOUNT_OWNER+"=?",
                                         new String[]{mAccount.name});
         }
+        if (file.getStoragePath() != null) {
+            new File(file.getStoragePath()).delete();
+        }
     }
 
 }

+ 12 - 3
src/eu/alefzero/owncloud/datamodel/OCFile.java

@@ -23,7 +23,7 @@ import java.io.File;
 import android.os.Parcel;
 import android.os.Parcelable;
 
-public class OCFile implements Parcelable {
+public class OCFile implements Parcelable, Comparable<OCFile> {
 
     public static final Parcelable.Creator<OCFile> CREATOR = new Parcelable.Creator<OCFile>() {
         @Override
@@ -322,6 +322,17 @@ public class OCFile implements Parcelable {
     }
 
     @Override
+    public int compareTo(OCFile another) {
+        if (isDirectory() && another.isDirectory()) {
+            return getFileName().toLowerCase().compareTo(another.getFileName().toLowerCase());
+        } else if (isDirectory()) {
+            return -1;
+        } else if (another.isDirectory()) {
+            return 1;
+        }
+        return getFileName().toLowerCase().compareTo(another.getFileName().toLowerCase());
+    }
+
     public boolean equals(Object o) {
         OCFile that = (OCFile) o;
         return this.mId == that.mId;
@@ -333,7 +344,5 @@ public class OCFile implements Parcelable {
         asString = String.format(asString, new Long(mId), getFileName(), mMimeType, isDownloaded(), mLocalPath, mRemotePath);
         return asString;
     }
-    
-    
 
 }