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

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

Use ns.getEntries() to get both name and Dest, and for filtering

parent 8c288ad5
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;
import net.i2p.data.Destination;
public class AddressEntry { public class AddressEntry {
private final String mHostName; private final String mHostName;
private final Destination mDest;
public AddressEntry(String hostName) { public AddressEntry(String hostName, Destination dest) {
mHostName = hostName; mHostName = hostName;
mDest = dest;
} }
public String getHostName() { public String getHostName() {
return mHostName; return mHostName;
} }
public Destination getDestination() {
return mDest;
}
} }
...@@ -2,12 +2,12 @@ package net.i2p.android.router.loader; ...@@ -2,12 +2,12 @@ package net.i2p.android.router.loader;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Map;
import java.util.Set; import java.util.Properties;
import java.util.TreeSet; import java.util.TreeMap;
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.data.Destination;
import net.i2p.router.RouterContext; import net.i2p.router.RouterContext;
import android.content.Context; import android.content.Context;
...@@ -35,16 +35,17 @@ public class AddressEntryLoader extends AsyncTaskLoader<List<AddressEntry>> { ...@@ -35,16 +35,17 @@ 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>();
Set<String> names = new TreeSet<String>(); Map<String, Destination> names = new TreeMap<String, Destination>();
names.addAll(ns.getNames());
for (String hostName : names) { Properties searchProps = new Properties();
if (mFilter != null && !hostName.toLowerCase(Locale.US).contains( // Needed for HostsTxtNamingService
mFilter.toLowerCase(Locale.US))) searchProps.setProperty("file", mBook);
continue; if (mFilter != null && mFilter.length() > 0)
searchProps.setProperty("search", mFilter);
AddressEntry name = new AddressEntry(hostName);
ret.add(name); names.putAll(ns.getEntries(searchProps));
} for (String hostName : names.keySet())
ret.add(new AddressEntry(hostName, names.get(hostName)));
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