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.Location;
import net.osmand.StateChangedListener; import net.osmand.StateChangedListener;
import net.osmand.binary.BinaryMapDataObject;
import net.osmand.data.LatLon; import net.osmand.data.LatLon;
import net.osmand.data.RotatedTileBox; import net.osmand.data.RotatedTileBox;
import net.osmand.map.IMapLocationListener; import net.osmand.map.IMapLocationListener;
@ -30,6 +31,7 @@ import net.osmand.util.MapUtils;
import java.io.IOException; import java.io.IOException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Map;
public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLocationListener, public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLocationListener,
OsmAndCompassListener, MapMarkerChangedListener { OsmAndCompassListener, MapMarkerChangedListener {
@ -456,7 +458,10 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc
protected WorldRegion doInBackground(LatLon... latLons) { protected WorldRegion doInBackground(LatLon... latLons) {
try { try {
if (latLons != null && latLons.length > 0) { 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) { } catch (IOException e) {
// ignore // ignore

View file

@ -31,6 +31,7 @@ import net.osmand.Collator;
import net.osmand.CollatorStringMatcher; import net.osmand.CollatorStringMatcher;
import net.osmand.OsmAndCollator; import net.osmand.OsmAndCollator;
import net.osmand.ResultMatcher; import net.osmand.ResultMatcher;
import net.osmand.binary.BinaryMapDataObject;
import net.osmand.binary.BinaryMapIndexReader; import net.osmand.binary.BinaryMapIndexReader;
import net.osmand.binary.BinaryMapIndexReader.SearchRequest; import net.osmand.binary.BinaryMapIndexReader.SearchRequest;
import net.osmand.data.Amenity; import net.osmand.data.Amenity;
@ -61,6 +62,7 @@ import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map;
public class SearchDialogFragment extends DialogFragment implements DownloadEvents, OnItemClickListener { public class SearchDialogFragment extends DialogFragment implements DownloadEvents, OnItemClickListener {
@ -416,7 +418,10 @@ public class SearchDialogFragment extends DialogFragment implements DownloadEven
Amenity amenity = cityItem.getAmenity(); Amenity amenity = cityItem.getAmenity();
WorldRegion downloadRegion = null; WorldRegion downloadRegion = null;
try { 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) { } catch (IOException e) {
// ignore // ignore
} }

View file

@ -251,12 +251,12 @@ public class DownloadedRegionsLayer extends OsmandMapLayer implements IContextMe
if (app.getSettings().SHOW_DOWNLOAD_MAP_DIALOG.get() if (app.getSettings().SHOW_DOWNLOAD_MAP_DIALOG.get()
&& zoom >= ZOOM_MIN_TO_SHOW_DOWNLOAD_DIALOG && zoom <= ZOOM_MAX_TO_SHOW_DOWNLOAD_DIALOG && zoom >= ZOOM_MIN_TO_SHOW_DOWNLOAD_DIALOG && zoom <= ZOOM_MAX_TO_SHOW_DOWNLOAD_DIALOG
&& currentObjects != null) { && currentObjects != null) {
WorldRegion regionData;
Map<WorldRegion, BinaryMapDataObject> selectedObjects = new LinkedHashMap<>(); Map<WorldRegion, BinaryMapDataObject> selectedObjects = new LinkedHashMap<>();
for (int i = 0; i < currentObjects.size(); i++) { for (int i = 0; i < currentObjects.size(); i++) {
final BinaryMapDataObject o = currentObjects.get(i); final BinaryMapDataObject o = currentObjects.get(i);
String fullName = osmandRegions.getFullName(o); String fullName = osmandRegions.getFullName(o);
regionData = osmandRegions.getRegionData(fullName); WorldRegion regionData = osmandRegions.getRegionData(fullName);
if (regionData != null && regionData.isRegionMapDownload()) { if (regionData != null && regionData.isRegionMapDownload()) {
String regionDownloadName = regionData.getRegionDownloadName(); String regionDownloadName = regionData.getRegionDownloadName();
if (regionDownloadName != null) { if (regionDownloadName != null) {
@ -272,8 +272,9 @@ public class DownloadedRegionsLayer extends OsmandMapLayer implements IContextMe
IndexItem indexItem = null; IndexItem indexItem = null;
String name = null; String name = null;
regionData = app.getRegions().getSmallestBinaryMapDataObjectAt(selectedObjects).getKey(); Map.Entry<WorldRegion, BinaryMapDataObject> res = app.getRegions().getSmallestBinaryMapDataObjectAt(selectedObjects);
if (regionData != null) { if (res != null && res.getKey() != null) {
WorldRegion regionData = res.getKey();
DownloadIndexesThread downloadThread = app.getDownloadThread(); DownloadIndexesThread downloadThread = app.getDownloadThread();
List<IndexItem> indexItems = downloadThread.getIndexes().getIndexItems(regionData); List<IndexItem> indexItems = downloadThread.getIndexes().getIndexItems(regionData);
if (indexItems.size() == 0) { if (indexItems.size() == 0) {