This commit is contained in:
Alexander Sytnyk 2017-09-07 15:17:11 +03:00
parent eb89a9791d
commit 535188de5f
2 changed files with 8 additions and 13 deletions

View file

@ -203,9 +203,7 @@ public class MapMarkersHelper {
if (marker != null) {
cancelPointAddressRequests(marker.point);
markersDbHelper.moveMarkerToHistory(marker);
mapMarkers.remove(marker);
marker.history = true;
mapMarkersHistory.add(marker);
loadMarkers();
refresh();
}
}

View file

@ -323,9 +323,6 @@ public class MapMarkersDbHelper {
}
public void restoreMapMarkerFromHistory(MapMarker marker) {
if (!marker.history) {
return;
}
SQLiteConnection db = openConnection(false);
if (db != null) {
try {
@ -333,8 +330,9 @@ public class MapMarkersDbHelper {
db.execSQL("UPDATE " + MARKERS_TABLE_NAME + " SET " +
MARKERS_COL_ACTIVE + " = ?, " +
MARKERS_COL_NEXT_KEY + " = ? " +
"WHERE " + MARKERS_COL_ID + " = ?",
new Object[]{1, active.size() > 0 ? active.get(0).id : TAIL_NEXT_VALUE, marker.id});
"WHERE " + MARKERS_COL_ID + " = ? " +
"AND " + MARKERS_COL_ACTIVE + " = ?",
new Object[]{1, active.size() > 0 ? active.get(0).id : TAIL_NEXT_VALUE, marker.id, 0});
} finally {
db.close();
}
@ -362,14 +360,13 @@ public class MapMarkersDbHelper {
}
public void removeMarkerFromHistory(MapMarker marker) {
if (!marker.history) {
return;
}
SQLiteConnection db = openConnection(true);
if (db != null) {
try {
db.execSQL("DELETE FROM " + MARKERS_TABLE_NAME + " WHERE " + MARKERS_COL_ID + " = ?",
new Object[]{marker.id});
db.execSQL("DELETE FROM " + MARKERS_TABLE_NAME +
" WHERE " + MARKERS_COL_ID + " = ?" +
" AND " + MARKERS_COL_ACTIVE + " = ?",
new Object[]{marker.id, 0});
} finally {
db.close();
}