From 8e32731ce7cc8e1987a85c5ea269283536dfe7da Mon Sep 17 00:00:00 2001 From: Alexey Kulish Date: Fri, 11 Nov 2016 15:56:36 +0300 Subject: [PATCH] Fix #3256 --- .../src/net/osmand/map/OsmandRegions.java | 6 +++- .../plus/mapcontextmenu/MenuController.java | 33 ++++++++++--------- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/OsmAnd-java/src/net/osmand/map/OsmandRegions.java b/OsmAnd-java/src/net/osmand/map/OsmandRegions.java index 7ab3b606e5..40ded13a8d 100644 --- a/OsmAnd-java/src/net/osmand/map/OsmandRegions.java +++ b/OsmAnd-java/src/net/osmand/map/OsmandRegions.java @@ -384,7 +384,11 @@ public class OsmandRegions { } public WorldRegion getRegionDataByDownloadName(String downloadName) { - return getRegionData(downloadNamesToFullNames.get(downloadName.toLowerCase())); + if (downloadName == null) { + return null; + } else { + return getRegionData(downloadNamesToFullNames.get(downloadName.toLowerCase())); + } } public String getDownloadName(BinaryMapDataObject o) { diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java index cea4c67e6f..e2ae8427af 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java @@ -538,21 +538,24 @@ public abstract class MenuController extends BaseMenuController { String selectedFullName = ""; double smallestArea = -1; for (BinaryMapDataObject o : mapDataObjects) { - boolean downloaded = checkIfObjectDownloaded(rm, osmandRegions.getDownloadName(o)); - if (downloaded) { - downloadMapDataObject = null; - break; - } else { - String fullName = osmandRegions.getFullName(o); - double area = OsmandRegions.getArea(o); - if (smallestArea == -1) { - smallestArea = area; - selectedFullName = fullName; - downloadMapDataObject = o; - } else if (area < smallestArea) { - smallestArea = area; - selectedFullName = fullName; - downloadMapDataObject = o; + String downloadName = osmandRegions.getDownloadName(o); + if (!Algorithms.isEmpty(downloadName)) { + boolean downloaded = checkIfObjectDownloaded(rm, downloadName); + if (downloaded) { + downloadMapDataObject = null; + break; + } else { + String fullName = osmandRegions.getFullName(o); + double area = OsmandRegions.getArea(o); + if (smallestArea == -1) { + smallestArea = area; + selectedFullName = fullName; + downloadMapDataObject = o; + } else if (area < smallestArea) { + smallestArea = area; + selectedFullName = fullName; + downloadMapDataObject = o; + } } } }