From 0586301002507407784094e1d1b4bbcf057fc013 Mon Sep 17 00:00:00 2001 From: Andreas Schildbach Date: Fri, 21 Dec 2018 18:55:11 +0100 Subject: [PATCH] LocationView: When parsing Geocoder result, extract postal code too. --- .../schildbach/oeffi/directions/LocationView.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/oeffi/src/de/schildbach/oeffi/directions/LocationView.java b/oeffi/src/de/schildbach/oeffi/directions/LocationView.java index a84c649..67f8da7 100644 --- a/oeffi/src/de/schildbach/oeffi/directions/LocationView.java +++ b/oeffi/src/de/schildbach/oeffi/directions/LocationView.java @@ -19,6 +19,7 @@ package de.schildbach.oeffi.directions; import java.util.Locale; +import com.google.common.base.Joiner; import com.google.common.base.Strings; import de.schildbach.oeffi.Constants; @@ -454,14 +455,17 @@ public class LocationView extends FrameLayout implements LocationHelper.Callback final Location location; final int maxAddressLineIndex = address.getMaxAddressLineIndex(); - if (maxAddressLineIndex >= 2 && Strings.emptyToNull(address.getAddressLine(2)) != null) + if (maxAddressLineIndex >= 2 && Strings.emptyToNull(address.getAddressLine(2)) != null) { location = new Location(LocationType.ADDRESS, null, coord, address.getAddressLine(1), address.getAddressLine(0)); - else if (address.getThoroughfare() != null) - location = new Location(LocationType.ADDRESS, null, coord, address.getLocality(), address.getThoroughfare() - + (address.getFeatureName() != null ? " " + address.getFeatureName() : "")); - else + } else if (address.getThoroughfare() != null) { + final Joiner joiner = Joiner.on(' ').skipNulls(); + location = new Location(LocationType.ADDRESS, null, coord, + joiner.join(address.getPostalCode(), address.getLocality()), + joiner.join(address.getThoroughfare(), address.getFeatureName())); + } else { location = new Location(LocationType.ADDRESS, null, coord); + } return location; }