From bc501b609a9436dec44f18e90053feebd3eeffce Mon Sep 17 00:00:00 2001 From: Dima-1 Date: Fri, 11 Dec 2020 10:08:41 +0200 Subject: [PATCH] Fix getArticleId --- .../plus/wikivoyage/data/TravelHelper.java | 2 +- .../plus/wikivoyage/data/TravelObfHelper.java | 16 ++++++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelHelper.java b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelHelper.java index 79df7bdfeb..12976ed666 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelHelper.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelHelper.java @@ -36,7 +36,7 @@ public interface TravelHelper { String getArticleId(String title, String lang); - ArrayList getArticleLangs(String articleId); + ArrayList getArticleLangs(String routeId); String getGPXName(TravelArticle article); diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java index e47a939781..65fe1e88e6 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java @@ -35,10 +35,10 @@ public class TravelObfHelper implements TravelHelper { private final OsmandApplication app; private File selectedTravelBook = null; - private List existingTravelBooks = new ArrayList<>(); + private final List existingTravelBooks = new ArrayList<>(); private List popularArticles = new ArrayList<>(); - private Map cachedArticles; - private TravelLocalDataHelper localDataHelper; + private final Map cachedArticles; + private final TravelLocalDataHelper localDataHelper; public TravelObfHelper(OsmandApplication app) { this.app = app; @@ -264,16 +264,20 @@ public class TravelObfHelper implements TravelHelper { @Override public String getArticleId(String title, String lang) { + for (TravelArticle article : popularArticles) { + if (article.getTitle().equals(title)) { + return article.getRouteId(); + } + } return null; } @Override - public ArrayList getArticleLangs(String articleId) { + public ArrayList getArticleLangs(String routeId) { ArrayList res = new ArrayList<>(); res.add("en"); - for (TravelArticle article : popularArticles) { - if (article.getRouteId() == articleId) { + if (article.getRouteId().equals(routeId)) { res.add(article.getLang()); } }