From 676dccea011cd097a6e57f12678b09a733713c51 Mon Sep 17 00:00:00 2001 From: Andreas Schildbach Date: Mon, 14 Jun 2021 22:32:17 +0200 Subject: [PATCH] AbstractHafasClientInterfaceProvider: Fix parsing of locations without type. --- .../pte/AbstractHafasClientInterfaceProvider.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/de/schildbach/pte/AbstractHafasClientInterfaceProvider.java b/src/de/schildbach/pte/AbstractHafasClientInterfaceProvider.java index cd99b1d3..3dc6d8f7 100644 --- a/src/de/schildbach/pte/AbstractHafasClientInterfaceProvider.java +++ b/src/de/schildbach/pte/AbstractHafasClientInterfaceProvider.java @@ -1017,15 +1017,20 @@ public abstract class AbstractHafasClientInterfaceProvider extends AbstractHafas private List parseLocList(final JSONArray locList, final JSONArray crdSysList) throws JSONException { final List locations = new ArrayList<>(locList.length()); - for (int iLoc = 0; iLoc < locList.length(); iLoc++) - locations.add(parseLoc(locList, iLoc, new HashSet(), crdSysList)); + for (int iLoc = 0; iLoc < locList.length(); iLoc++) { + final Location location = parseLoc(locList, iLoc, new HashSet(), crdSysList); + if (location != null) + locations.add(location); + } return locations; } private Location parseLoc(final JSONArray locList, final int locListIndex, @Nullable Set previousLocListIndexes, final JSONArray crdSysList) throws JSONException { final JSONObject loc = locList.getJSONObject(locListIndex); - final String type = loc.getString("type"); + final String type = loc.optString("type", null); + if (type == null) + return null; final LocationType locationType; final String id;