Add small improvement

This commit is contained in:
Alexander Sytnyk 2018-03-19 19:25:45 +02:00
parent 8f92d40392
commit 3c0b1dea09
2 changed files with 12 additions and 10 deletions

View file

@ -393,10 +393,7 @@ public class MapMarkersHelper {
boolean needRefresh = false;
for (MapMarker marker : markers) {
if (!marker.history) {
// TODO make all changes in once!!!
markersDbHelper.removeMarker(marker, false);
removeFromMapMarkersList(marker);
removeMarkerFromGroup(marker);
removeMarker(marker, false);
needRefresh = true;
}
}
@ -474,16 +471,21 @@ public class MapMarkersHelper {
}
public void removeMarker(MapMarker marker) {
removeMarker(marker, true);
}
private void removeMarker(MapMarker marker, boolean refresh) {
if (marker != null) {
boolean history = marker.history;
markersDbHelper.removeMarker(marker, history);
if (history) {
markersDbHelper.removeMarker(marker);
if (marker.history) {
removeFromMapMarkersHistoryList(marker);
} else {
removeFromMapMarkersList(marker);
}
removeMarkerFromGroup(marker);
refresh();
if (refresh) {
refresh();
}
}
}

View file

@ -581,14 +581,14 @@ public class MapMarkersDbHelper {
return markers;
}
public void removeMarker(MapMarker marker, boolean history) {
public void removeMarker(MapMarker marker) {
SQLiteConnection db = openConnection(true);
if (db != null) {
try {
db.execSQL("DELETE FROM " + MARKERS_TABLE_NAME +
" WHERE " + MARKERS_COL_ID + " = ?" +
" AND " + MARKERS_COL_ACTIVE + " = ?",
new Object[]{marker.id, history ? 0 : 1});
new Object[]{marker.id, marker.history ? 0 : 1});
} finally {
db.close();
}