From 6a4f2a6b9b5ddb27ffa4d1334c158e7791676cd5 Mon Sep 17 00:00:00 2001 From: Andreas Schildbach Date: Wed, 5 Dec 2018 02:23:13 +0100 Subject: [PATCH] VGN: Migrate to JSON stopfinder. --- .../schildbach/pte/AbstractEfaProvider.java | 38 ------------------- .../src/de/schildbach/pte/VgnProvider.java | 8 ---- 2 files changed, 46 deletions(-) diff --git a/enabler/src/de/schildbach/pte/AbstractEfaProvider.java b/enabler/src/de/schildbach/pte/AbstractEfaProvider.java index b5a00b3a..2999d8b0 100644 --- a/enabler/src/de/schildbach/pte/AbstractEfaProvider.java +++ b/enabler/src/de/schildbach/pte/AbstractEfaProvider.java @@ -345,44 +345,6 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider { } } - protected SuggestLocationsResult xmlStopfinderRequest(final Location constraint) throws IOException { - final HttpUrl.Builder url = stopFinderEndpoint.newBuilder(); - appendStopfinderRequestParameters(url, constraint, "XML"); - final AtomicReference result = new AtomicReference<>(); - - final HttpClient.Callback callback = new HttpClient.Callback() { - @Override - public void onSuccessful(final CharSequence bodyPeek, final ResponseBody body) throws IOException { - try { - final XmlPullParser pp = parserFactory.newPullParser(); - pp.setInput(body.byteStream(), null); // Read encoding from XML declaration - final ResultHeader header = enterItdRequest(pp); - - final List locations = new ArrayList<>(); - - XmlPullUtil.enter(pp, "itdStopFinderRequest"); - - processItdOdv(pp, "sf", new ProcessItdOdvCallback() { - @Override - public void location(final String nameState, final Location location, final int matchQuality) { - locations.add(new SuggestedLocation(location, matchQuality)); - } - }); - - XmlPullUtil.skipExit(pp, "itdStopFinderRequest"); - - result.set(new SuggestLocationsResult(header, locations)); - } catch (final XmlPullParserException x) { - throw new ParserException("cannot parse xml: " + bodyPeek, x); - } - } - }; - - httpClient.getInputStream(callback, url.build(), httpReferer); - - return result.get(); - } - protected SuggestLocationsResult mobileStopfinderRequest(final Location constraint) throws IOException { final HttpUrl.Builder url = stopFinderEndpoint.newBuilder(); appendStopfinderRequestParameters(url, constraint, "XML"); diff --git a/enabler/src/de/schildbach/pte/VgnProvider.java b/enabler/src/de/schildbach/pte/VgnProvider.java index c771bf53..a943285b 100644 --- a/enabler/src/de/schildbach/pte/VgnProvider.java +++ b/enabler/src/de/schildbach/pte/VgnProvider.java @@ -17,16 +17,13 @@ package de.schildbach.pte; -import java.io.IOException; import java.util.Date; import javax.annotation.Nullable; import de.schildbach.pte.dto.Line; import de.schildbach.pte.dto.Location; -import de.schildbach.pte.dto.LocationType; import de.schildbach.pte.dto.Product; -import de.schildbach.pte.dto.SuggestLocationsResult; import de.schildbach.pte.dto.TripOptions; import okhttp3.HttpUrl; @@ -63,11 +60,6 @@ public class VgnProvider extends AbstractEfaProvider { return super.parseLine(id, network, mot, symbol, name, longName, trainType, trainNum, trainName); } - @Override - public SuggestLocationsResult suggestLocations(final CharSequence constraint) throws IOException { - return xmlStopfinderRequest(new Location(LocationType.ANY, null, null, constraint.toString())); - } - @Override protected void appendXsltTripRequestParameters(final HttpUrl.Builder url, final Location from, final @Nullable Location via, final Location to, final Date date, final boolean dep,