This commit is contained in:
Victor Shcherb 2020-02-19 19:13:05 +01:00
parent d0c4a5eeb9
commit 5738e34d8f
3 changed files with 17 additions and 6 deletions

View file

@ -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<WorldRegion, BinaryMapDataObject> reg = app.getRegions().getSmallestBinaryMapDataObjectAt(latLons[0]);
if(reg != null) {
return reg.getKey();
}
}
} catch (IOException e) {
// ignore

View file

@ -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<WorldRegion, BinaryMapDataObject> res = osmandRegions.getSmallestBinaryMapDataObjectAt(amenity.getLocation());
if(res != null) {
downloadRegion = res.getKey();
}
} catch (IOException e) {
// ignore
}

View file

@ -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<WorldRegion, BinaryMapDataObject> 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<WorldRegion, BinaryMapDataObject> res = app.getRegions().getSmallestBinaryMapDataObjectAt(selectedObjects);
if (res != null && res.getKey() != null) {
WorldRegion regionData = res.getKey();
DownloadIndexesThread downloadThread = app.getDownloadThread();
List<IndexItem> indexItems = downloadThread.getIndexes().getIndexItems(regionData);
if (indexItems.size() == 0) {