From bf451f52a87a7ceb95faa0630cc44818eba2ab2f Mon Sep 17 00:00:00 2001 From: ryanwr Date: Sun, 2 Oct 2016 11:10:46 +0100 Subject: [PATCH] Sorts favourite files first in list --- .../android/utils/FileStorageUtils.java | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/com/owncloud/android/utils/FileStorageUtils.java b/src/com/owncloud/android/utils/FileStorageUtils.java index cc4aaa877b..d64385d3b0 100644 --- a/src/com/owncloud/android/utils/FileStorageUtils.java +++ b/src/com/owncloud/android/utils/FileStorageUtils.java @@ -247,6 +247,8 @@ public class FileStorageUtils { files = FileStorageUtils.sortOCFilesBySize(files); break; } + + files = FileStorageUtils.sortOCFilesByFavourite(files); return files; } @@ -423,6 +425,27 @@ public class FileStorageUtils { File[] returnArray = new File[files.size()]; return files.toArray(returnArray); } + + /** + * Sorts list by Favourites + * @param files files to sort + */ + public static Vector sortOCFilesByFavourite(Vector files){ + Collections.sort(files, new Comparator() { + 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