autocomplete result object, use ultralite API for MVV

git-svn-id: https://public-transport-enabler.googlecode.com/svn/trunk@123 0924bc21-9374-b0fa-ee44-9ff1593b38f0
This commit is contained in:
andreas.schildbach 2010-09-01 19:34:54 +00:00
parent 16376d8947
commit 197202e275
9 changed files with 96 additions and 44 deletions

View file

@ -57,25 +57,25 @@ public class SbbProvider implements NetworkProvider
+ "(.*?)\n?" //
+ "</a>", Pattern.DOTALL);
public List<String> autoCompleteStationName(final CharSequence constraint) throws IOException
public List<Autocomplete> autocompleteStations(final CharSequence constraint) throws IOException
{
final CharSequence page = ParserUtils.scrape(NAME_URL + ParserUtils.urlEncode(constraint.toString()));
final List<String> names = new ArrayList<String>();
final List<Autocomplete> results = new ArrayList<Autocomplete>();
final Matcher mSingle = P_SINGLE_NAME.matcher(page);
if (mSingle.matches())
{
names.add(ParserUtils.resolveEntities(mSingle.group(1)));
results.add(new Autocomplete(0, ParserUtils.resolveEntities(mSingle.group(1))));
}
else
{
final Matcher mMulti = P_MULTI_NAME.matcher(page);
while (mMulti.find())
names.add(ParserUtils.resolveEntities(mMulti.group(2)));
results.add(new Autocomplete(0, ParserUtils.resolveEntities(mMulti.group(2))));
}
return names;
return results;
}
public List<Station> nearbyStations(final double lat, final double lon, final int maxDistance, final int maxStations) throws IOException