mirror of
https://github.com/nextcloud/android.git
synced 2024-11-22 13:15:35 +03:00
Merge pull request #302 from ryanwr/master
Sorts favourite files first in list
This commit is contained in:
commit
6ebbf0ce98
1 changed files with 23 additions and 0 deletions
|
@ -247,6 +247,8 @@ public class FileStorageUtils {
|
||||||
files = FileStorageUtils.sortOCFilesBySize(files);
|
files = FileStorageUtils.sortOCFilesBySize(files);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
files = FileStorageUtils.sortOCFilesByFavourite(files);
|
||||||
|
|
||||||
return files;
|
return files;
|
||||||
}
|
}
|
||||||
|
@ -423,6 +425,27 @@ public class FileStorageUtils {
|
||||||
File[] returnArray = new File[files.size()];
|
File[] returnArray = new File[files.size()];
|
||||||
return files.toArray(returnArray);
|
return files.toArray(returnArray);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sorts list by Favourites
|
||||||
|
* @param files files to sort
|
||||||
|
*/
|
||||||
|
public static Vector<OCFile> sortOCFilesByFavourite(Vector<OCFile> files){
|
||||||
|
Collections.sort(files, new Comparator<OCFile>() {
|
||||||
|
public int compare(OCFile o1, OCFile o2) {
|
||||||
|
if (o1.isFavorite() && o2.isFavorite()) {
|
||||||
|
return 0;
|
||||||
|
} else if (o1.isFavorite()) {
|
||||||
|
return -1;
|
||||||
|
} else if (o2.isFavorite()) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return files;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Local Folder size
|
* Local Folder size
|
||||||
|
|
Loading…
Reference in a new issue