Merge branch 'sasha_pasha_branch' of ssh://github.com/osmandapp/Osmand into sasha_pasha_branch
This commit is contained in:
commit
23749c1088
3 changed files with 36 additions and 20 deletions
|
@ -275,13 +275,8 @@ public class MapMarkersHelper {
|
|||
public void reverseActiveMarkersOrder() {
|
||||
cancelAddressRequests();
|
||||
|
||||
List<MapMarker> markers = new ArrayList<>(mapMarkers.size());
|
||||
for (int i = mapMarkers.size() - 1; i >= 0; i--) {
|
||||
MapMarker marker = mapMarkers.get(i);
|
||||
markers.add(marker);
|
||||
}
|
||||
mapMarkers = markers;
|
||||
saveMapMarkers(mapMarkers, null);
|
||||
markersDbHelper.reverseActiveMarkersOrder();
|
||||
loadMarkers();
|
||||
}
|
||||
|
||||
public void removeActiveMarkers() {
|
||||
|
@ -358,13 +353,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());
|
||||
|
|
|
@ -139,6 +139,14 @@ public class MapMarkersDbHelper {
|
|||
}
|
||||
}
|
||||
|
||||
public void reverseActiveMarkersOrder() {
|
||||
List<MapMarker> markers = getActiveMarkers();
|
||||
removeAllActiveMarkers();
|
||||
for (int i = markers.size() - 1; i >= 0; i--) {
|
||||
addMarker(markers.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
public void addMarker(MapMarker marker) {
|
||||
SQLiteConnection db = openConnection(false);
|
||||
if (db != null) {
|
||||
|
@ -271,6 +279,18 @@ public class MapMarkersDbHelper {
|
|||
}
|
||||
}
|
||||
|
||||
private void removeAllActiveMarkers() {
|
||||
SQLiteConnection db = openConnection(true);
|
||||
if (db != null) {
|
||||
try {
|
||||
db.execSQL("DELETE FROM " + MARKERS_TABLE_NAME + " WHERE " + MARKERS_COL_ACTIVE + " = ?",
|
||||
new Object[]{1});
|
||||
} finally {
|
||||
db.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void moveMarkerToHistory(MapMarker marker) {
|
||||
SQLiteConnection db = openConnection(false);
|
||||
if (db != null) {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue