From e6231e2166f08b1e19e080bb690e0fcad3b945e5 Mon Sep 17 00:00:00 2001 From: sergosm Date: Wed, 23 Sep 2020 19:32:25 +0300 Subject: [PATCH] fix "Nearby wikipedia articles" so the settings are applied --- .../plus/mapcontextmenu/MenuBuilder.java | 23 ++++++++----------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java index d197ae51e6..00d0a8cc20 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java @@ -53,6 +53,7 @@ import net.osmand.plus.mapcontextmenu.builders.cards.ImageCard; import net.osmand.plus.mapcontextmenu.builders.cards.ImageCard.GetImageCardsTask; import net.osmand.plus.mapcontextmenu.builders.cards.NoImagesCard; import net.osmand.plus.mapcontextmenu.controllers.TransportStopController; +import net.osmand.plus.poi.PoiUIFilter; import net.osmand.plus.render.RenderingIcons; import net.osmand.plus.transport.TransportStopRoute; import net.osmand.plus.views.layers.POIMapLayer; @@ -992,18 +993,10 @@ public class MenuBuilder { if (showNearestWiki && latLon != null) { QuadRect rect = MapUtils.calculateLatLonBbox( latLon.getLatitude(), latLon.getLongitude(), 250); - nearestWiki = app.getResourceManager().searchAmenities( - new BinaryMapIndexReader.SearchPoiTypeFilter() { - @Override - public boolean accept(PoiCategory type, String subcategory) { - return type != null && type.isWiki(); - } + PoiUIFilter wikiPoiFilter = app.getPoiFilters().getTopWikiPoiFilter(); + + nearestWiki = getAmenities(rect, wikiPoiFilter); - @Override - public boolean isEmpty() { - return false; - } - }, rect.top, rect.left, rect.bottom, rect.right, -1, null); Collections.sort(nearestWiki, new Comparator() { @Override @@ -1016,8 +1009,7 @@ public class MenuBuilder { Long id = objectId; List wikiList = new ArrayList<>(); for (Amenity wiki : nearestWiki) { - String lng = wiki.getContentLanguage("content", preferredMapAppLang, "en"); - if (wiki.getId().equals(id) || (!lng.equals("en") && !lng.equals(preferredMapAppLang))) { + if (wiki.getId().equals(id)) { wikiList.add(wiki); } } @@ -1027,6 +1019,11 @@ public class MenuBuilder { return false; } + private List getAmenities(QuadRect rect, PoiUIFilter wikiPoiFilter) { + return wikiPoiFilter.searchAmenities(rect.top, rect.left, + rect.bottom, rect.right, -1, null); + } + @SuppressWarnings("unchecked") public static

void execute(AsyncTask task, P... requests) { task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, requests);