mirror of
https://github.com/syncthing/syncthing-android.git
synced 2024-12-22 19:01:30 +00:00
Merge branch 'xduugu-sort-by-label'
This commit is contained in:
commit
7181b07281
1 changed files with 7 additions and 1 deletions
|
@ -29,10 +29,16 @@ import java.util.TimerTask;
|
||||||
public class FolderListFragment extends ListFragment implements SyncthingService.OnApiChangeListener,
|
public class FolderListFragment extends ListFragment implements SyncthingService.OnApiChangeListener,
|
||||||
AdapterView.OnItemClickListener, AdapterView.OnItemLongClickListener {
|
AdapterView.OnItemClickListener, AdapterView.OnItemLongClickListener {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compares folders by labels, uses the folder ID as fallback if the label is empty
|
||||||
|
*/
|
||||||
private final static Comparator<RestApi.Folder> FOLDERS_COMPARATOR = new Comparator<RestApi.Folder>() {
|
private final static Comparator<RestApi.Folder> FOLDERS_COMPARATOR = new Comparator<RestApi.Folder>() {
|
||||||
@Override
|
@Override
|
||||||
public int compare(RestApi.Folder lhs, RestApi.Folder rhs) {
|
public int compare(RestApi.Folder lhs, RestApi.Folder rhs) {
|
||||||
return lhs.id.compareTo(rhs.id);
|
String lhsLabel = lhs.label != null && !lhs.label.isEmpty() ? lhs.label : lhs.id;
|
||||||
|
String rhsLabel = rhs.label != null && !rhs.label.isEmpty() ? rhs.label : rhs.id;
|
||||||
|
|
||||||
|
return lhsLabel.compareTo(rhsLabel);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue