From 51eab2457dfb873e7e01aa6fad22ab25d7152cd2 Mon Sep 17 00:00:00 2001 From: eho Date: Fri, 25 May 2018 09:41:44 +0200 Subject: [PATCH] util: Use lambdas where applicable in the FileSortOrderByName/Size classes. --- .../android/utils/FileSortOrderByName.java | 16 ++++++------ .../android/utils/FileSortOrderBySize.java | 25 ++++++++----------- 2 files changed, 18 insertions(+), 23 deletions(-) diff --git a/src/main/java/com/owncloud/android/utils/FileSortOrderByName.java b/src/main/java/com/owncloud/android/utils/FileSortOrderByName.java index a08d583111..1da38f047d 100644 --- a/src/main/java/com/owncloud/android/utils/FileSortOrderByName.java +++ b/src/main/java/com/owncloud/android/utils/FileSortOrderByName.java @@ -49,17 +49,15 @@ public class FileSortOrderByName extends FileSortOrder { public List sortCloudFiles(List files) { final int multiplier = mAscending ? 1 : -1; - Collections.sort(files, new Comparator() { - public int compare(OCFile o1, OCFile o2) { - if (o1.isFolder() && o2.isFolder()) { - return multiplier * new AlphanumComparator().compare(o1, o2); - } else if (o1.isFolder()) { - return -1; - } else if (o2.isFolder()) { - return 1; - } + Collections.sort(files, (o1, o2) -> { + if (o1.isFolder() && o2.isFolder()) { return multiplier * new AlphanumComparator().compare(o1, o2); + } else if (o1.isFolder()) { + return -1; + } else if (o2.isFolder()) { + return 1; } + return multiplier * new AlphanumComparator().compare(o1, o2); }); return super.sortCloudFiles(files); diff --git a/src/main/java/com/owncloud/android/utils/FileSortOrderBySize.java b/src/main/java/com/owncloud/android/utils/FileSortOrderBySize.java index 0c31e13bfc..f5a91833e4 100644 --- a/src/main/java/com/owncloud/android/utils/FileSortOrderBySize.java +++ b/src/main/java/com/owncloud/android/utils/FileSortOrderBySize.java @@ -47,21 +47,18 @@ public class FileSortOrderBySize extends FileSortOrder { public List sortCloudFiles(List files) { final int multiplier = mAscending ? 1 : -1; - Collections.sort(files, new Comparator() { - @SuppressFBWarnings(value = "Bx") - public int compare(OCFile o1, OCFile o2) { - if (o1.isFolder() && o2.isFolder()) { - Long obj1 = o1.getFileLength(); - return multiplier * obj1.compareTo(o2.getFileLength()); - } else if (o1.isFolder()) { - return -1; + Collections.sort(files, (o1, o2) -> { + if (o1.isFolder() && o2.isFolder()) { + Long obj1 = o1.getFileLength(); + return multiplier * obj1.compareTo(o2.getFileLength()); + } else if (o1.isFolder()) { + return -1; - } else if (o2.isFolder()) { - return 1; - } else { - Long obj1 = o1.getFileLength(); - return multiplier * obj1.compareTo(o2.getFileLength()); - } + } else if (o2.isFolder()) { + return 1; + } else { + Long obj1 = o1.getFileLength(); + return multiplier * obj1.compareTo(o2.getFileLength()); } });