diff --git a/OsmAnd/src/net/osmand/plus/base/MapViewTrackingUtilities.java b/OsmAnd/src/net/osmand/plus/base/MapViewTrackingUtilities.java index d9985350e9..d02b3ffb74 100644 --- a/OsmAnd/src/net/osmand/plus/base/MapViewTrackingUtilities.java +++ b/OsmAnd/src/net/osmand/plus/base/MapViewTrackingUtilities.java @@ -7,6 +7,7 @@ import android.view.WindowManager; import net.osmand.Location; import net.osmand.StateChangedListener; +import net.osmand.binary.BinaryMapDataObject; import net.osmand.data.LatLon; import net.osmand.data.RotatedTileBox; import net.osmand.map.IMapLocationListener; @@ -30,6 +31,7 @@ import net.osmand.util.MapUtils; import java.io.IOException; import java.text.SimpleDateFormat; +import java.util.Map; public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLocationListener, OsmAndCompassListener, MapMarkerChangedListener { @@ -456,7 +458,10 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc protected WorldRegion doInBackground(LatLon... latLons) { try { if (latLons != null && latLons.length > 0) { - return app.getRegions().getSmallestBinaryMapDataObjectAt(latLons[0]).getKey(); + Map.Entry reg = app.getRegions().getSmallestBinaryMapDataObjectAt(latLons[0]); + if(reg != null) { + return reg.getKey(); + } } } catch (IOException e) { // ignore diff --git a/OsmAnd/src/net/osmand/plus/download/ui/SearchDialogFragment.java b/OsmAnd/src/net/osmand/plus/download/ui/SearchDialogFragment.java index 0d9834a351..7da8f572be 100644 --- a/OsmAnd/src/net/osmand/plus/download/ui/SearchDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/download/ui/SearchDialogFragment.java @@ -31,6 +31,7 @@ import net.osmand.Collator; import net.osmand.CollatorStringMatcher; import net.osmand.OsmAndCollator; import net.osmand.ResultMatcher; +import net.osmand.binary.BinaryMapDataObject; import net.osmand.binary.BinaryMapIndexReader; import net.osmand.binary.BinaryMapIndexReader.SearchRequest; import net.osmand.data.Amenity; @@ -61,6 +62,7 @@ import java.util.Collections; import java.util.Comparator; import java.util.LinkedList; import java.util.List; +import java.util.Map; public class SearchDialogFragment extends DialogFragment implements DownloadEvents, OnItemClickListener { @@ -416,7 +418,10 @@ public class SearchDialogFragment extends DialogFragment implements DownloadEven Amenity amenity = cityItem.getAmenity(); WorldRegion downloadRegion = null; try { - downloadRegion = osmandRegions.getSmallestBinaryMapDataObjectAt(amenity.getLocation()).getKey(); + Map.Entry res = osmandRegions.getSmallestBinaryMapDataObjectAt(amenity.getLocation()); + if(res != null) { + downloadRegion = res.getKey(); + } } catch (IOException e) { // ignore } diff --git a/OsmAnd/src/net/osmand/plus/views/DownloadedRegionsLayer.java b/OsmAnd/src/net/osmand/plus/views/DownloadedRegionsLayer.java index b87c36a30e..f9a23bc7d3 100644 --- a/OsmAnd/src/net/osmand/plus/views/DownloadedRegionsLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/DownloadedRegionsLayer.java @@ -251,12 +251,12 @@ public class DownloadedRegionsLayer extends OsmandMapLayer implements IContextMe if (app.getSettings().SHOW_DOWNLOAD_MAP_DIALOG.get() && zoom >= ZOOM_MIN_TO_SHOW_DOWNLOAD_DIALOG && zoom <= ZOOM_MAX_TO_SHOW_DOWNLOAD_DIALOG && currentObjects != null) { - WorldRegion regionData; + Map selectedObjects = new LinkedHashMap<>(); for (int i = 0; i < currentObjects.size(); i++) { final BinaryMapDataObject o = currentObjects.get(i); String fullName = osmandRegions.getFullName(o); - regionData = osmandRegions.getRegionData(fullName); + WorldRegion regionData = osmandRegions.getRegionData(fullName); if (regionData != null && regionData.isRegionMapDownload()) { String regionDownloadName = regionData.getRegionDownloadName(); if (regionDownloadName != null) { @@ -272,8 +272,9 @@ public class DownloadedRegionsLayer extends OsmandMapLayer implements IContextMe IndexItem indexItem = null; String name = null; - regionData = app.getRegions().getSmallestBinaryMapDataObjectAt(selectedObjects).getKey(); - if (regionData != null) { + Map.Entry res = app.getRegions().getSmallestBinaryMapDataObjectAt(selectedObjects); + if (res != null && res.getKey() != null) { + WorldRegion regionData = res.getKey(); DownloadIndexesThread downloadThread = app.getDownloadThread(); List indexItems = downloadThread.getIndexes().getIndexItems(regionData); if (indexItems.size() == 0) {