mirror of
https://github.com/nextcloud/android.git
synced 2024-11-24 06:05:42 +03:00
Merge pull request #2620 from nextcloud/utils-overrides
Minor cleanup of FileSortOrderByName and FileSortOrderBySize
This commit is contained in:
commit
d90c2d99c3
3 changed files with 24 additions and 37 deletions
|
@ -35,7 +35,7 @@ import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
|||
|
||||
public class FileSortOrderByDate extends FileSortOrder {
|
||||
|
||||
public FileSortOrderByDate(String name, boolean ascending) {
|
||||
FileSortOrderByDate(String name, boolean ascending) {
|
||||
super(name, ascending);
|
||||
}
|
||||
|
||||
|
@ -47,13 +47,8 @@ public class FileSortOrderByDate extends FileSortOrder {
|
|||
public List<OCFile> sortCloudFiles(List<OCFile> files) {
|
||||
final int multiplier = mAscending ? 1 : -1;
|
||||
|
||||
Collections.sort(files, new Comparator<OCFile>() {
|
||||
@SuppressFBWarnings(value = "Bx", justification = "Would require stepping up API level")
|
||||
public int compare(OCFile o1, OCFile o2) {
|
||||
Long obj1 = o1.getModificationTimestamp();
|
||||
return multiplier * obj1.compareTo(o2.getModificationTimestamp());
|
||||
}
|
||||
});
|
||||
Collections.sort(files, (o1, o2) ->
|
||||
multiplier * Long.compare(o1.getModificationTimestamp(), o2.getModificationTimestamp()));
|
||||
|
||||
return super.sortCloudFiles(files);
|
||||
}
|
||||
|
@ -67,10 +62,7 @@ public class FileSortOrderByDate extends FileSortOrder {
|
|||
public List<File> sortLocalFiles(List<File> files) {
|
||||
final int multiplier = mAscending ? 1 : -1;
|
||||
|
||||
Collections.sort(files, (o1, o2) -> {
|
||||
Long obj1 = o1.lastModified();
|
||||
return multiplier * obj1.compareTo(o2.lastModified());
|
||||
});
|
||||
Collections.sort(files, (o1, o2) -> multiplier * Long.compare(o1.lastModified(),o2.lastModified()));
|
||||
|
||||
return files;
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ import third_parties.daveKoeller.AlphanumComparator;
|
|||
*/
|
||||
public class FileSortOrderByName extends FileSortOrder {
|
||||
|
||||
public FileSortOrderByName(String name, boolean ascending) {
|
||||
FileSortOrderByName(String name, boolean ascending) {
|
||||
super(name, ascending);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
|
|
@ -35,7 +35,7 @@ import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
|||
|
||||
public class FileSortOrderBySize extends FileSortOrder {
|
||||
|
||||
public FileSortOrderBySize(String name, boolean ascending) {
|
||||
FileSortOrderBySize(String name, boolean ascending) {
|
||||
super(name, ascending);
|
||||
}
|
||||
|
||||
|
@ -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());
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue