Add servers sorting.
Change-Id: Idd3d39fcf91fba6d5f7b0615d241f6ad9f46bd5f
This commit is contained in:
@@ -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);
|
||||
|
Reference in New Issue
Block a user