diff --git a/OsmAnd/src/net/osmand/plus/views/ContextMenuLayer.java b/OsmAnd/src/net/osmand/plus/views/ContextMenuLayer.java index dcef8a838f..8869e416f6 100644 --- a/OsmAnd/src/net/osmand/plus/views/ContextMenuLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/ContextMenuLayer.java @@ -113,25 +113,30 @@ public class ContextMenuLayer extends OsmandMapLayer { paint = new Paint(); pressedBitmap = BitmapFactory.decodeResource(view.getResources(), R.drawable.map_shield_tap); pressedBitmapSmall = BitmapFactory.decodeResource(view.getResources(), R.drawable.map_shield_tap_small); - - publicTransportTypes = new ArrayList<>(); - List filters = activity.getMyApplication().getPoiTypes().getPoiCategoryByName("transportation").getPoiFilters(); - for (PoiFilter poiFilter : filters) { - if (poiFilter.getKeyName().equals("public_transport")) { - for (PoiType poiType : poiFilter.getPoiTypes()) { - publicTransportTypes.add(poiType.getKeyName()); - for (PoiType poiAdditionalType : poiType.getPoiAdditionals()) { - publicTransportTypes.add(poiAdditionalType.getKeyName()); - } - } - } - } } public boolean isVisible() { return menu.isActive(); } + private List getPublicTransportTypes() { + if (publicTransportTypes == null) { + publicTransportTypes = new ArrayList<>(); + List filters = activity.getMyApplication().getPoiTypes().getPoiCategoryByName("transportation").getPoiFilters(); + for (PoiFilter poiFilter : filters) { + if (poiFilter.getKeyName().equals("public_transport")) { + for (PoiType poiType : poiFilter.getPoiTypes()) { + publicTransportTypes.add(poiType.getKeyName()); + for (PoiType poiAdditionalType : poiType.getPoiAdditionals()) { + publicTransportTypes.add(poiAdditionalType.getKeyName()); + } + } + } + } + } + return publicTransportTypes; + } + @Override public void onDraw(Canvas canvas, RotatedTileBox box, DrawSettings nightMode) { for (LatLon latLon : pressedLatLonSmall) { @@ -681,7 +686,7 @@ public class ContextMenuLayer extends OsmandMapLayer { } } - if (res != null && publicTransportTypes.contains(res.getSubType())) { + if (res != null && getPublicTransportTypes().contains(res.getSubType())) { return findNearestTransportStop(lat, lon) == null ? res : null; }