Change some code

This commit is contained in:
Alexander Sytnyk 2017-09-07 10:41:11 +03:00
parent 0173c0b774
commit 28a4bf6d15
2 changed files with 15 additions and 13 deletions

View file

@ -272,6 +272,7 @@ public class MapMarkersHelper {
return list;
}
//todo: rewrite with MapMarkersDbHelper
public void reverseActiveMarkersOrder() {
cancelAddressRequests();
@ -358,13 +359,23 @@ public class MapMarkersHelper {
}
}
public void changeActiveMarkerPositionInDb(int currentPos) {
MapMarker moved = mapMarkers.get(currentPos);
public void changeActiveMarkerPositionInDb(int currentPosInMapMarkers) {
MapMarker moved = mapMarkers.get(currentPosInMapMarkers);
markersDbHelper.changeActiveMarkerPosition(moved,
currentPos == mapMarkers.size() - 1 ? null : mapMarkers.get(currentPos + 1));
currentPosInMapMarkers == mapMarkers.size() - 1 ? null : mapMarkers.get(currentPosInMapMarkers + 1));
loadMarkers();
}
public void moveMarkerToTop(MapMarker marker) {
int i = mapMarkers.indexOf(marker);
if (i != -1 && mapMarkers.size() > 1) {
mapMarkers.remove(i);
markersDbHelper.changeActiveMarkerPosition(marker, mapMarkers.get(0));
loadMarkers();
refresh();
}
}
public void saveMapMarkers(List<MapMarker> markers, List<MapMarker> markersHistory) {
if (markers != null) {
List<LatLon> ls = new ArrayList<>(markers.size());

View file

@ -493,16 +493,7 @@ public class MapMarkersLayer extends OsmandMapLayer implements IContextMenuProvi
@Override
public void setSelectedObject(Object o) {
if (o instanceof MapMarker) {
MapMarkersHelper markersHelper = map.getMyApplication().getMapMarkersHelper();
MapMarker marker = (MapMarker) o;
List<MapMarker> mapMarkers = markersHelper.getMapMarkers();
int i = mapMarkers.indexOf(marker);
if (i != -1) {
mapMarkers.remove(i);
mapMarkers.add(0, marker);
markersHelper.saveMapMarkers(mapMarkers, null);
marker.index = 0;
}
map.getMyApplication().getMapMarkersHelper().moveMarkerToTop((MapMarker) o);
}
}