mirror of
https://gitlab.com/oeffi/public-transport-enabler.git
synced 2025-07-17 15:59:49 +00:00
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:
parent
16376d8947
commit
197202e275
9 changed files with 96 additions and 44 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue