From 964f3e28121cc05a36da2cb533a41c43fe51b0c7 Mon Sep 17 00:00:00 2001 From: Dima-1 Date: Fri, 8 Jan 2021 21:46:28 +0200 Subject: [PATCH] Fix links to wikivoyage --- .../plus/wikivoyage/data/TravelObfHelper.java | 23 ++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java index 45a8442614..55180b7ec3 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java @@ -492,7 +492,7 @@ public class TravelObfHelper implements TravelHelper { @Override public TravelArticle getArticleByTitle(@NonNull final String title, @NonNull QuadRect rect, @NonNull final String lang) { TravelArticle article = null; - List amenities = null; + final List amenities = new ArrayList<>(); int x = 0; int y = 0; int left = 0; @@ -510,8 +510,25 @@ public class TravelObfHelper implements TravelHelper { for (BinaryMapIndexReader reader : getReaders()) { try { SearchRequest req = BinaryMapIndexReader.buildSearchPoiRequest( - x, y, title, left, right, top, bottom, getSearchRouteArticleFilter(), null, null); - amenities = reader.searchPoiByName(req); + x, y, title, left, right, top, bottom, getSearchRouteArticleFilter(), + new ResultMatcher() { + boolean done = false; + + @Override + public boolean publish(Amenity amenity) { + if (Algorithms.stringsEqual(title, Algorithms.emptyIfNull(amenity.getName(lang)))) { + amenities.add(amenity); + done = true; + } + return false; + } + + @Override + public boolean isCancelled() { + return done; + } + }, null); + reader.searchPoiByName(req); } catch (IOException e) { LOG.error(e.getMessage()); }