I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Commit d437f451 authored by str4d's avatar str4d
Browse files

Use TreeSet to sort Addressbook names

parent fc618ad9
No related branches found
No related tags found
No related merge requests found
package net.i2p.android.router.loader; package net.i2p.android.router.loader;
public class AddressEntry implements Comparable<Object> { public class AddressEntry {
private final String mHostName; private final String mHostName;
public AddressEntry(String hostName) { public AddressEntry(String hostName) {
...@@ -10,10 +10,4 @@ public class AddressEntry implements Comparable<Object> { ...@@ -10,10 +10,4 @@ public class AddressEntry implements Comparable<Object> {
public String getHostName() { public String getHostName() {
return mHostName; return mHostName;
} }
public int compareTo(Object another) {
if (another instanceof AddressEntry)
return -1;
return mHostName.compareTo(((AddressEntry) another).getHostName());
}
} }
package net.i2p.android.router.loader; package net.i2p.android.router.loader;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Set;
import java.util.TreeSet;
import net.i2p.android.router.util.Util; import net.i2p.android.router.util.Util;
import net.i2p.client.naming.NamingService; import net.i2p.client.naming.NamingService;
import net.i2p.router.RouterContext; import net.i2p.router.RouterContext;
...@@ -29,11 +31,12 @@ public class AddressEntryLoader extends AsyncTaskLoader<List<AddressEntry>> { ...@@ -29,11 +31,12 @@ public class AddressEntryLoader extends AsyncTaskLoader<List<AddressEntry>> {
Util.i("NamingService: " + ns.getName()); Util.i("NamingService: " + ns.getName());
// After router shutdown we get nothing... why? // After router shutdown we get nothing... why?
List<AddressEntry> ret = new ArrayList<AddressEntry>(); List<AddressEntry> ret = new ArrayList<AddressEntry>();
for (String hostName : ns.getNames()) { Set<String> names = new TreeSet<String>();
names.addAll(ns.getNames());
for (String hostName : names) {
AddressEntry name = new AddressEntry(hostName); AddressEntry name = new AddressEntry(hostName);
ret.add(name); ret.add(name);
} }
Collections.sort(ret);
return ret; return ret;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment