fix use a more universal method for adding altitude
This commit is contained in:
parent
a702787f09
commit
066ee38de2
3 changed files with 8 additions and 20 deletions
|
@ -361,6 +361,9 @@ public class FavouritesDbHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean addFavourite(FavouritePoint p, boolean saveImmediately) {
|
public boolean addFavourite(FavouritePoint p, boolean saveImmediately) {
|
||||||
|
if (p.getAltitude() == 0) {
|
||||||
|
p.initAltitude(context);
|
||||||
|
}
|
||||||
if (p.getName().isEmpty() && flatGroups.containsKey(p.getCategory())) {
|
if (p.getName().isEmpty() && flatGroups.containsKey(p.getCategory())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -543,6 +546,9 @@ public class FavouritesDbHelper {
|
||||||
|
|
||||||
private boolean editFavourite(@NonNull FavouritePoint p, double lat, double lon, @Nullable String description) {
|
private boolean editFavourite(@NonNull FavouritePoint p, double lat, double lon, @Nullable String description) {
|
||||||
cancelAddressRequest(p);
|
cancelAddressRequest(p);
|
||||||
|
if (p.getLatitude() != lat && p.getLongitude() != lon) {
|
||||||
|
p.initAltitude(context);
|
||||||
|
}
|
||||||
p.setLatitude(lat);
|
p.setLatitude(lat);
|
||||||
p.setLongitude(lon);
|
p.setLongitude(lon);
|
||||||
if (description != null) {
|
if (description != null) {
|
||||||
|
|
|
@ -39,10 +39,6 @@ class FavoritesImportTask extends BaseLoadAsyncTask<Void, Void, GPXFile> {
|
||||||
for (FavouritePoint favourite : favourites) {
|
for (FavouritePoint favourite : favourites) {
|
||||||
favoritesHelper.deleteFavourite(favourite, false);
|
favoritesHelper.deleteFavourite(favourite, false);
|
||||||
favoritesHelper.addFavourite(favourite, false);
|
favoritesHelper.addFavourite(favourite, false);
|
||||||
double alt = favourite.getAltitude();
|
|
||||||
if (Double.isNaN(alt) || alt == 0) {
|
|
||||||
favourite.initAltitude(app);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
favoritesHelper.sortAll();
|
favoritesHelper.sortAll();
|
||||||
favoritesHelper.saveCurrentPointsIntoFile();
|
favoritesHelper.saveCurrentPointsIntoFile();
|
||||||
|
|
|
@ -41,16 +41,7 @@ public class FavoritePointEditor extends PointEditor {
|
||||||
favorite.setDescription("");
|
favorite.setDescription("");
|
||||||
favorite.setAddress(address.isEmpty() ? title : address);
|
favorite.setAddress(address.isEmpty() ? title : address);
|
||||||
favorite.setOriginObjectName(originObjectName);
|
favorite.setOriginObjectName(originObjectName);
|
||||||
if (Double.isNaN(altitude) || altitude == 0) {
|
FavoritePointEditorFragmentNew.showInstance(mapActivity);
|
||||||
favorite.initAltitude(app, new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
FavoritePointEditorFragmentNew.showInstance(mapActivity);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
FavoritePointEditorFragmentNew.showInstance(mapActivity);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void add(LatLon latLon, String title, String originObjectName, String categoryName, int categoryColor, final boolean autoFill) {
|
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.setDescription("");
|
||||||
favorite.setAddress("");
|
favorite.setAddress("");
|
||||||
favorite.setOriginObjectName(originObjectName);
|
favorite.setOriginObjectName(originObjectName);
|
||||||
favorite.initAltitude(app, new Runnable() {
|
FavoritePointEditorFragmentNew.showAutoFillInstance(mapActivity, autoFill);
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
FavoritePointEditorFragmentNew.showAutoFillInstance(mapActivity, autoFill);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void edit(FavouritePoint favorite) {
|
public void edit(FavouritePoint favorite) {
|
||||||
|
|
Loading…
Reference in a new issue