From a776a0ae898b4ea5f061c4e5a92ccd540e18e359 Mon Sep 17 00:00:00 2001 From: Andreas Schildbach Date: Mon, 10 Dec 2018 10:53:09 +0100 Subject: [PATCH] AbstractHafasClientInterfaceProvider: Test for OK status of results in jsonTripSearchIdentify(). --- .../AbstractHafasClientInterfaceProvider.java | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/enabler/src/de/schildbach/pte/AbstractHafasClientInterfaceProvider.java b/enabler/src/de/schildbach/pte/AbstractHafasClientInterfaceProvider.java index 1d0edd10..1047f192 100644 --- a/enabler/src/de/schildbach/pte/AbstractHafasClientInterfaceProvider.java +++ b/enabler/src/de/schildbach/pte/AbstractHafasClientInterfaceProvider.java @@ -434,16 +434,20 @@ public abstract class AbstractHafasClientInterfaceProvider extends AbstractHafas if (location.hasId()) return location; if (location.hasName()) { - final List locations = jsonLocMatch(JOINER.join(location.place, location.name), null, 1) - .getLocations(); - if (!locations.isEmpty()) - return locations.get(0); + final SuggestLocationsResult result = jsonLocMatch(JOINER.join(location.place, location.name), null, 1); + if (result.status == SuggestLocationsResult.Status.OK) { + final List locations = result.getLocations(); + if (!locations.isEmpty()) + return locations.get(0); + } } if (location.hasCoord()) { - final List locations = jsonLocGeoPos(EnumSet.allOf(LocationType.class), location.coord, 0, - 1).locations; - if (!locations.isEmpty()) - return locations.get(0); + final NearbyLocationsResult result = jsonLocGeoPos(EnumSet.allOf(LocationType.class), location.coord, 0, 1); + if (result.status == NearbyLocationsResult.Status.OK) { + final List locations = result.locations; + if (!locations.isEmpty()) + return locations.get(0); + } } return null; }