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) {
|
||||
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) {
|
||||
|
|
|
@ -39,10 +39,6 @@ class FavoritesImportTask extends BaseLoadAsyncTask<Void, Void, GPXFile> {
|
|||
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();
|
||||
|
|
|
@ -41,17 +41,8 @@ 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);
|
||||
}
|
||||
}
|
||||
|
||||
public void add(LatLon latLon, String title, String originObjectName, String categoryName, int categoryColor, final boolean autoFill) {
|
||||
final MapActivity mapActivity = getMapActivity();
|
||||
|
@ -73,13 +64,8 @@ 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);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void edit(FavouritePoint favorite) {
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
|
|
Loading…
Reference in a new issue