diff --git a/src/org/kde/kdeconnect/Plugins/SftpPlugin/SftpPlugin.java b/src/org/kde/kdeconnect/Plugins/SftpPlugin/SftpPlugin.java index 55184686..43907fa3 100644 --- a/src/org/kde/kdeconnect/Plugins/SftpPlugin/SftpPlugin.java +++ b/src/org/kde/kdeconnect/Plugins/SftpPlugin/SftpPlugin.java @@ -42,6 +42,7 @@ import org.kde.kdeconnect_tp.R; import java.io.File; import java.util.ArrayList; import java.util.Collections; +import java.util.Comparator; import java.util.Iterator; import java.util.List; @@ -118,7 +119,7 @@ public class SftpPlugin extends Plugin implements SharedPreferences.OnSharedPref ArrayList pathNames = new ArrayList<>(); List storageInfoList = SftpSettingsFragment.getStorageInfoList(context, this); - Collections.sort(storageInfoList, new StorageInfo.UriNameComparator()); + Collections.sort(storageInfoList, Comparator.comparing(StorageInfo::getUri)); if (storageInfoList.size() > 0) { getPathsAndNamesForStorageInfoList(paths, pathNames, storageInfoList); @@ -306,6 +307,11 @@ public class SftpPlugin extends Plugin implements SharedPreferences.OnSharedPref this.uri = uri; } + @NonNull + Uri getUri() { + return uri; + } + static StorageInfo copy(StorageInfo from) { //Both String and Uri are immutable return new StorageInfo(from.displayName, from.uri); @@ -353,19 +359,5 @@ public class SftpPlugin extends Plugin implements SharedPreferences.OnSharedPref result = 31 * result + uri.hashCode(); return result; } - - static class DisplayNameComparator implements java.util.Comparator { - @Override - public int compare(StorageInfo si1, StorageInfo si2) { - return si1.displayName.compareToIgnoreCase(si2.displayName); - } - } - - static class UriNameComparator implements java.util.Comparator { - @Override - public int compare(StorageInfo si1, StorageInfo si2) { - return si1.uri.compareTo(si2.uri); - } - } } } diff --git a/src/org/kde/kdeconnect/Plugins/SftpPlugin/SftpSettingsFragment.java b/src/org/kde/kdeconnect/Plugins/SftpPlugin/SftpSettingsFragment.java index f3cdec43..6bc72561 100644 --- a/src/org/kde/kdeconnect/Plugins/SftpPlugin/SftpSettingsFragment.java +++ b/src/org/kde/kdeconnect/Plugins/SftpPlugin/SftpSettingsFragment.java @@ -349,7 +349,7 @@ public class SftpSettingsFragment } private void sortStorageInfoListOnDisplayName() { - Collections.sort(storageInfoList, new SftpPlugin.StorageInfo.DisplayNameComparator()); + Collections.sort(storageInfoList, (si1, si2) -> si1.displayName.compareToIgnoreCase(si2.displayName)); } @NonNull