move sorting method back to its original place for a proper diff!

This commit is contained in:
AndyScherzinger 2018-07-05 18:07:16 +02:00
parent 73fd9d4931
commit fff8aa6a30
No known key found for this signature in database
GPG key ID: 6CADC7E3523C308B

View file

@ -104,53 +104,6 @@ public class SyncedFoldersActivity extends FileActivity implements SyncedFolderA
private String path;
private int type;
/**
* Sorts list of {@link SyncedFolderDisplayItem}s.
*
* @param syncFolderItemList list of items to be sorted
* @return sorted list of items
*/
public static List<SyncedFolderDisplayItem> sortSyncedFolderItems(List<SyncedFolderDisplayItem>
syncFolderItemList) {
Collections.sort(syncFolderItemList, new Comparator<SyncedFolderDisplayItem>() {
public int compare(SyncedFolderDisplayItem f1, SyncedFolderDisplayItem f2) {
if (f1 == null && f2 == null) {
return 0;
} else if (f1 == null) {
return -1;
} else if (f2 == null) {
return 1;
} else if (f1.isEnabled() && f2.isEnabled()) {
return f1.getFolderName().toLowerCase(Locale.getDefault()).compareTo(
f2.getFolderName().toLowerCase(Locale.getDefault()));
} else if (f1.isEnabled()) {
return -1;
} else if (f2.isEnabled()) {
return 1;
} else if (f1.getFolderName() == null && f2.getFolderName() == null) {
return 0;
} else if (f1.getFolderName() == null) {
return -1;
} else if (f2.getFolderName() == null) {
return 1;
}
for (String folder : PRIORITIZED_FOLDERS) {
if (folder.equals(f1.getFolderName()) &&
folder.equals(f2.getFolderName())) {
return 0;
} else if (folder.equals(f1.getFolderName())) {
return -1;
} else if (folder.equals(f2.getFolderName())) {
return 1;
}
}
return f1.getFolderName().toLowerCase(Locale.getDefault()).compareTo(
f2.getFolderName().toLowerCase(Locale.getDefault()));
}
});
return syncFolderItemList;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
@ -296,6 +249,54 @@ public class SyncedFoldersActivity extends FileActivity implements SyncedFolderA
}
}
/**
* Sorts list of {@link SyncedFolderDisplayItem}s.
*
* @param syncFolderItemList list of items to be sorted
* @return sorted list of items
*/
public static List<SyncedFolderDisplayItem> sortSyncedFolderItems(List<SyncedFolderDisplayItem>
syncFolderItemList) {
Collections.sort(syncFolderItemList, new Comparator<SyncedFolderDisplayItem>() {
public int compare(SyncedFolderDisplayItem f1, SyncedFolderDisplayItem f2) {
if (f1 == null && f2 == null) {
return 0;
} else if (f1 == null) {
return -1;
} else if (f2 == null) {
return 1;
} else if (f1.isEnabled() && f2.isEnabled()) {
return f1.getFolderName().toLowerCase(Locale.getDefault()).compareTo(
f2.getFolderName().toLowerCase(Locale.getDefault()));
} else if (f1.isEnabled()) {
return -1;
} else if (f2.isEnabled()) {
return 1;
} else if (f1.getFolderName() == null && f2.getFolderName() == null) {
return 0;
} else if (f1.getFolderName() == null) {
return -1;
} else if (f2.getFolderName() == null) {
return 1;
}
for (String folder : PRIORITIZED_FOLDERS) {
if (folder.equals(f1.getFolderName()) &&
folder.equals(f2.getFolderName())) {
return 0;
} else if (folder.equals(f1.getFolderName())) {
return -1;
} else if (folder.equals(f2.getFolderName())) {
return 1;
}
}
return f1.getFolderName().toLowerCase(Locale.getDefault()).compareTo(
f2.getFolderName().toLowerCase(Locale.getDefault()));
}
});
return syncFolderItemList;
}
/**
* merges two lists of {@link SyncedFolder} and {@link MediaFolder} items into one of SyncedFolderItems.
*