From 3c0b1dea09c414f364fab9c91eae51bb1f1eafea Mon Sep 17 00:00:00 2001 From: Alexander Sytnyk Date: Mon, 19 Mar 2018 19:25:45 +0200 Subject: [PATCH] Add small improvement --- .../src/net/osmand/plus/MapMarkersHelper.java | 18 ++++++++++-------- .../plus/mapmarkers/MapMarkersDbHelper.java | 4 ++-- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/MapMarkersHelper.java b/OsmAnd/src/net/osmand/plus/MapMarkersHelper.java index 76b6894dc8..28d9913b46 100644 --- a/OsmAnd/src/net/osmand/plus/MapMarkersHelper.java +++ b/OsmAnd/src/net/osmand/plus/MapMarkersHelper.java @@ -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(); + } } } diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDbHelper.java b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDbHelper.java index 00a520128d..ee94d83a41 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDbHelper.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDbHelper.java @@ -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(); }