some fixes
This commit is contained in:
parent
0f81841c79
commit
a702787f09
5 changed files with 26 additions and 30 deletions
|
@ -59,6 +59,7 @@ public class FavouritePoint implements Serializable, LocationPoint {
|
|||
name = "";
|
||||
}
|
||||
this.name = name;
|
||||
timestamp = System.currentTimeMillis();
|
||||
initPersonalType();
|
||||
}
|
||||
|
||||
|
@ -71,7 +72,7 @@ public class FavouritePoint implements Serializable, LocationPoint {
|
|||
}
|
||||
this.name = name;
|
||||
this.altitude = altitude;
|
||||
this.timestamp = timestamp;
|
||||
this.timestamp = timestamp != 0 ? timestamp : System.currentTimeMillis();
|
||||
initPersonalType();
|
||||
}
|
||||
|
||||
|
@ -102,6 +103,10 @@ public class FavouritePoint implements Serializable, LocationPoint {
|
|||
}
|
||||
}
|
||||
|
||||
public void initAltitude(final OsmandApplication app) {
|
||||
initAltitude(app, null);
|
||||
}
|
||||
|
||||
public void initAltitude(final OsmandApplication app, final Runnable callback) {
|
||||
app.getLocationProvider().getRouteSegment(new Location("", latitude, longitude), null, false, new ResultMatcher<RouteDataObject>() {
|
||||
|
||||
|
@ -110,9 +115,10 @@ public class FavouritePoint implements Serializable, LocationPoint {
|
|||
if (routeDataObject != null) {
|
||||
routeDataObject.calculateHeightArray(new LatLon(latitude, longitude));
|
||||
altitude = routeDataObject.heightByCurrentLocation;
|
||||
} else {
|
||||
}
|
||||
callback.run();
|
||||
if (callback != null) {
|
||||
callback.run();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ class FavoritesImportTask extends BaseLoadAsyncTask<Void, Void, GPXFile> {
|
|||
private boolean forceImportFavourites;
|
||||
|
||||
public FavoritesImportTask(@NonNull FragmentActivity activity, @NonNull GPXFile gpxFile,
|
||||
@NonNull String fileName, boolean forceImportFavourites) {
|
||||
@NonNull String fileName, boolean forceImportFavourites) {
|
||||
super(activity);
|
||||
this.gpxFile = gpxFile;
|
||||
this.fileName = fileName;
|
||||
|
@ -39,6 +39,10 @@ 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();
|
||||
|
|
|
@ -687,7 +687,7 @@ public class ImportHelper {
|
|||
} else {
|
||||
fpCat = p.category;
|
||||
}
|
||||
final FavouritePoint point = new FavouritePoint(p.lat, p.lon, p.name, fpCat, p.ele, p.time);
|
||||
final FavouritePoint point = new FavouritePoint(p.lat, p.lon, p.name, fpCat, p.ele, 0);
|
||||
if (p.desc != null) {
|
||||
point.setDescription(p.desc);
|
||||
}
|
||||
|
@ -698,17 +698,7 @@ public class ImportHelper {
|
|||
point.setIconIdFromName(app, iconName);
|
||||
}
|
||||
point.setBackgroundType(BackgroundType.getByTypeName(p.getBackgroundType(), DEFAULT_BACKGROUND_TYPE));
|
||||
if (Double.isNaN(p.ele) || p.ele == 0) {
|
||||
point.initAltitude(app, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
favourites.add(point);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
favourites.add(point);
|
||||
}
|
||||
favourites.add(point);
|
||||
}
|
||||
}
|
||||
return favourites;
|
||||
|
|
|
@ -37,7 +37,7 @@ public class FavoritePointEditor extends PointEditor {
|
|||
if (!Algorithms.isEmpty(lastCategory) && !app.getFavorites().groupExists(lastCategory)) {
|
||||
lastCategory = "";
|
||||
}
|
||||
favorite = new FavouritePoint(latLon.getLatitude(), latLon.getLongitude(), title, lastCategory, (float) altitude, timestamp);
|
||||
favorite = new FavouritePoint(latLon.getLatitude(), latLon.getLongitude(), title, lastCategory, altitude, timestamp);
|
||||
favorite.setDescription("");
|
||||
favorite.setAddress(address.isEmpty() ? title : address);
|
||||
favorite.setOriginObjectName(originObjectName);
|
||||
|
@ -53,7 +53,7 @@ public class FavoritePointEditor extends PointEditor {
|
|||
}
|
||||
}
|
||||
|
||||
public void add(LatLon latLon, String title, String originObjectName, String categoryName, int categoryColor, final boolean autoFill, double altitude, long timestamp) {
|
||||
public void add(LatLon latLon, String title, String originObjectName, String categoryName, int categoryColor, final boolean autoFill) {
|
||||
final MapActivity mapActivity = getMapActivity();
|
||||
if (latLon == null || mapActivity == null) {
|
||||
return;
|
||||
|
@ -69,20 +69,16 @@ public class FavoritePointEditor extends PointEditor {
|
|||
categoryName = "";
|
||||
}
|
||||
|
||||
favorite = new FavouritePoint(latLon.getLatitude(), latLon.getLongitude(), title, categoryName, (float) altitude, timestamp);
|
||||
favorite = new FavouritePoint(latLon.getLatitude(), latLon.getLongitude(), title, categoryName);
|
||||
favorite.setDescription("");
|
||||
favorite.setAddress("");
|
||||
favorite.setOriginObjectName(originObjectName);
|
||||
if (Double.isNaN(altitude) || altitude == 0) {
|
||||
favorite.initAltitude(app, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
FavoritePointEditorFragmentNew.showAutoFillInstance(mapActivity, autoFill);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
FavoritePointEditorFragmentNew.showAutoFillInstance(mapActivity, autoFill);
|
||||
}
|
||||
favorite.initAltitude(app, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
FavoritePointEditorFragmentNew.showAutoFillInstance(mapActivity, autoFill);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void edit(FavouritePoint favorite) {
|
||||
|
|
|
@ -119,7 +119,7 @@ public class FavoriteAction extends QuickAction {
|
|||
FavoritePointEditor favoritePointEditor = mapActivity.getContextMenu().getFavoritePointEditor();
|
||||
if (favoritePointEditor != null) {
|
||||
favoritePointEditor.add(latLon, title, "", getParams().get(KEY_CATEGORY_NAME),
|
||||
Integer.valueOf(getParams().get(KEY_CATEGORY_COLOR)), autoFill, 0, 0);
|
||||
Integer.valueOf(getParams().get(KEY_CATEGORY_COLOR)), autoFill);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue