Fixed updating address for marker.

This commit is contained in:
GaidamakUA 2016-05-24 10:48:14 +03:00
parent 26e6c16a08
commit 62a8852071
3 changed files with 35 additions and 6 deletions

View file

@ -397,7 +397,8 @@ public class MapMarkersHelper {
public void moveMapMarker(@Nullable MapMarker marker, LatLon latLon) {
if (marker != null) {
settings.moveMapMarker(new LatLon(marker.getLatitude(), marker.getLongitude()), latLon);
settings.moveMapMarker(new LatLon(marker.getLatitude(), marker.getLongitude()), latLon,
marker.pointDescription, marker.colorIndex, marker.pos, marker.selected);
readFromSettings();
refresh();
}

View file

@ -1877,7 +1877,12 @@ public class OsmandSettings {
}
}
public boolean movePoint(LatLon latLonEx, LatLon latLonNew) {
public boolean movePoint(LatLon latLonEx,
LatLon latLonNew,
PointDescription historyDescription,
int colorIndex,
int pos,
boolean selected) {
List<LatLon> ps = getPoints();
List<String> ds = getPointDescriptions(ps.size());
List<Integer> cs = getColors(ps.size());
@ -1888,6 +1893,21 @@ public class OsmandSettings {
if (ps.size() > index) {
ps.set(index, latLonNew);
}
ds.set(index, PointDescription.serializeToString(historyDescription));
if (cs.size() > index) {
cs.set(index, colorIndex);
}
if (ns.size() > index) {
ns.set(index, pos);
}
if (bs.size() > index) {
bs.set(index, selected);
}
if (historyDescription != null && !historyDescription.isSearchingAddress(ctx)) {
double lat = latLonNew.getLatitude();
double lon = latLonNew.getLongitude();
SearchHistoryHelper.getInstance(ctx).addNewItemToHistory(lat, lon, historyDescription);
}
return savePoints(ps, ds, cs, ns, bs);
} else {
return false;
@ -2156,8 +2176,14 @@ public class OsmandSettings {
pos, selected);
}
public boolean moveMapMarker(LatLon latLonEx, LatLon latLonNew) {
return mapMarkersStorage.movePoint(latLonEx, latLonNew);
public boolean moveMapMarker(LatLon latLonEx,
LatLon latLonNew,
PointDescription historyDescription,
int colorIndex,
int pos,
boolean selected) {
return mapMarkersStorage.movePoint(latLonEx, latLonNew, historyDescription, colorIndex,
pos, selected);
}
public boolean deleteMapMarker(int index) {

View file

@ -518,12 +518,14 @@ public class MapMarkersLayer extends OsmandMapLayer implements IContextMenuProvi
public void applyNewObjectPosition(@NonNull Object o, @NonNull LatLon position,
@Nullable ApplyMovedObjectCallback callback) {
boolean result = false;
Object newObject = null;
MapMarker newObject = null;
if (o instanceof MapMarker) {
MapMarkersHelper markersHelper = map.getMyApplication().getMapMarkersHelper();
MapMarker marker = (MapMarker) o;
int index = markersHelper.getActiveMapMarkers().indexOf(marker);
marker.getOriginalPointDescription().setName(PointDescription.getSearchAddressStr(map));
markersHelper.moveMapMarker(marker, position);
int index = markersHelper.getActiveMapMarkers().indexOf(marker);
if (index != -1) {
newObject = markersHelper.getActiveMapMarkers().get(index);
}