Add some code

This commit is contained in:
Alexander Sytnyk 2017-09-05 14:26:31 +03:00
parent 2d7a4ac74f
commit f53590ef14

View file

@ -199,7 +199,25 @@ public class MapMarkersDbHelper {
}
}
public void move(MapMarker moved, @Nullable MapMarker next) {
public void updateMapMarker(MapMarker marker) {
SQLiteConnection db = openConnection(false);
if (db != null) {
try {
db.execSQL("UPDATE " + MARKERS_TABLE_NAME + " SET " +
MARKERS_COL_LAT + " = ?, " +
MARKERS_COL_LON + " = ?, " +
MARKERS_COL_DESCRIPTION + " = ?, " +
MARKERS_COL_COLOR + " = ? " +
"WHERE " + MARKERS_COL_ID + " = ?",
new Object[]{marker.getLatitude(), marker.getLongitude(), marker.getName(context), //fixme
marker.colorIndex, marker.id});
} finally {
db.close();
}
}
}
public void moveMapMarker(MapMarker moved, @Nullable MapMarker next) {
SQLiteConnection db = openConnection(false);
if (db != null) {
try {
@ -232,6 +250,24 @@ public class MapMarkersDbHelper {
}
}
public void restoreMarkerFromHistory(MapMarker marker) {
if (!marker.history) {
return;
}
SQLiteConnection db = openConnection(false);
if (db != null) {
try {
db.execSQL("UPDATE " + MARKERS_TABLE_NAME + " SET " +
MARKERS_COL_ACTIVE + " = ?, " +
MARKERS_COL_NEXT_KEY + " = ? " +
"WHERE " + MARKERS_COL_ID + " = ?",
new Object[]{1, getMapMarkers().get(0).id, marker.id});
} finally {
db.close();
}
}
}
public List<MapMarker> getMapMarkersHistory() {
List<MapMarker> markers = new LinkedList<>();
SQLiteConnection db = openConnection(true);