mirror of
https://github.com/nextcloud/android.git
synced 2024-11-28 02:06:56 +03:00
move sorting method back to its original place for a proper diff!
This commit is contained in:
parent
73fd9d4931
commit
fff8aa6a30
1 changed files with 48 additions and 47 deletions
|
@ -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.
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue