diff options
author | Artur Dryomov <artur.dryomov@gmail.com> | 2013-08-02 00:08:08 +0300 |
---|---|---|
committer | Artur Dryomov <artur.dryomov@gmail.com> | 2013-08-02 03:49:45 +0300 |
commit | d3cef7ed759d8e30f795c3346b5d71d428246c00 (patch) | |
tree | 313d2b90e9701301dbeb77198355735f7702fa4e /android | |
parent | 43dbc8088ba6f4f51ca455b1af41251d69befe86 (diff) |
Add servers sorting.
Change-Id: Idd3d39fcf91fba6d5f7b0615d241f6ad9f46bd5f
Diffstat (limited to 'android')
-rw-r--r-- | android/sdremote/src/org/libreoffice/impressremote/communication/ServersManager.java | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/android/sdremote/src/org/libreoffice/impressremote/communication/ServersManager.java b/android/sdremote/src/org/libreoffice/impressremote/communication/ServersManager.java index 388f48cece56..337c05cf2ae4 100644 --- a/android/sdremote/src/org/libreoffice/impressremote/communication/ServersManager.java +++ b/android/sdremote/src/org/libreoffice/impressremote/communication/ServersManager.java @@ -9,6 +9,8 @@ package org.libreoffice.impressremote.communication; import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; import java.util.HashSet; import java.util.List; @@ -19,7 +21,7 @@ import android.content.Context; import org.libreoffice.impressremote.util.Preferences; -class ServersManager { +class ServersManager implements Comparator<Server> { private final Context mContext; private final ServersFinder mBluetoothServersFinder; @@ -53,7 +55,11 @@ class ServersManager { aServers.addAll(mTcpServersFinder.getServers()); aServers.addAll(getManualAddedTcpServers()); - return filterBlacklistedServers(aServers); + aServers = filterBlacklistedServers(aServers); + + Collections.sort(aServers, this); + + return aServers; } private List<Server> getManualAddedTcpServers() { @@ -89,6 +95,14 @@ class ServersManager { return aFilteredServers; } + @Override + public int compare(Server aFirstServer, Server aSecondServer) { + String aFirstServerName = aFirstServer.getName(); + String aSecondServerName = aSecondServer.getName(); + + return aFirstServerName.compareToIgnoreCase(aSecondServerName); + } + public void addTcpServer(String aAddress, String aName) { Preferences.set(mContext, Preferences.Locations.STORED_SERVERS, aAddress, aName); |