diff --git a/OsmAnd/src/net/osmand/plus/FavouritesDbHelper.java b/OsmAnd/src/net/osmand/plus/FavouritesDbHelper.java index 992a0e42c6..2693d76a93 100644 --- a/OsmAnd/src/net/osmand/plus/FavouritesDbHelper.java +++ b/OsmAnd/src/net/osmand/plus/FavouritesDbHelper.java @@ -361,6 +361,9 @@ public class FavouritesDbHelper { } public boolean addFavourite(FavouritePoint p, boolean saveImmediately) { + if (p.getAltitude() == 0) { + p.initAltitude(context); + } if (p.getName().isEmpty() && flatGroups.containsKey(p.getCategory())) { return true; } @@ -543,6 +546,9 @@ public class FavouritesDbHelper { private boolean editFavourite(@NonNull FavouritePoint p, double lat, double lon, @Nullable String description) { cancelAddressRequest(p); + if (p.getLatitude() != lat && p.getLongitude() != lon) { + p.initAltitude(context); + } p.setLatitude(lat); p.setLongitude(lon); if (description != null) { diff --git a/OsmAnd/src/net/osmand/plus/importfiles/FavoritesImportTask.java b/OsmAnd/src/net/osmand/plus/importfiles/FavoritesImportTask.java index 67f7881eb5..b62de4923c 100644 --- a/OsmAnd/src/net/osmand/plus/importfiles/FavoritesImportTask.java +++ b/OsmAnd/src/net/osmand/plus/importfiles/FavoritesImportTask.java @@ -39,10 +39,6 @@ class FavoritesImportTask extends BaseLoadAsyncTask { for (FavouritePoint favourite : favourites) { favoritesHelper.deleteFavourite(favourite, false); favoritesHelper.addFavourite(favourite, false); - double alt = favourite.getAltitude(); - if (Double.isNaN(alt) || alt == 0) { - favourite.initAltitude(app); - } } favoritesHelper.sortAll(); favoritesHelper.saveCurrentPointsIntoFile(); diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/FavoritePointEditor.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/FavoritePointEditor.java index 5c0b6f8b59..26e83413be 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/FavoritePointEditor.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/FavoritePointEditor.java @@ -41,16 +41,7 @@ public class FavoritePointEditor extends PointEditor { favorite.setDescription(""); favorite.setAddress(address.isEmpty() ? title : address); favorite.setOriginObjectName(originObjectName); - if (Double.isNaN(altitude) || altitude == 0) { - favorite.initAltitude(app, new Runnable() { - @Override - public void run() { - FavoritePointEditorFragmentNew.showInstance(mapActivity); - } - }); - } else { - FavoritePointEditorFragmentNew.showInstance(mapActivity); - } + FavoritePointEditorFragmentNew.showInstance(mapActivity); } public void add(LatLon latLon, String title, String originObjectName, String categoryName, int categoryColor, final boolean autoFill) { @@ -73,12 +64,7 @@ public class FavoritePointEditor extends PointEditor { favorite.setDescription(""); favorite.setAddress(""); favorite.setOriginObjectName(originObjectName); - favorite.initAltitude(app, new Runnable() { - @Override - public void run() { - FavoritePointEditorFragmentNew.showAutoFillInstance(mapActivity, autoFill); - } - }); + FavoritePointEditorFragmentNew.showAutoFillInstance(mapActivity, autoFill); } public void edit(FavouritePoint favorite) {