util: Use lambdas where applicable in the FileSortOrderByName/Size classes.

This commit is contained in:
eho 2018-05-25 09:41:44 +02:00 committed by AndyScherzinger
parent 754419090d
commit 51eab2457d
No known key found for this signature in database
GPG key ID: 6CADC7E3523C308B
2 changed files with 18 additions and 23 deletions

View file

@ -49,17 +49,15 @@ public class FileSortOrderByName extends FileSortOrder {
public List<OCFile> sortCloudFiles(List<OCFile> files) {
final int multiplier = mAscending ? 1 : -1;
Collections.sort(files, new Comparator<OCFile>() {
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);

View file

@ -47,21 +47,18 @@ public class FileSortOrderBySize extends FileSortOrder {
public List<OCFile> sortCloudFiles(List<OCFile> files) {
final int multiplier = mAscending ? 1 : -1;
Collections.sort(files, new Comparator<OCFile>() {
@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());
}
});