Add small improvement
This commit is contained in:
parent
8f92d40392
commit
3c0b1dea09
2 changed files with 12 additions and 10 deletions
|
@ -393,10 +393,7 @@ public class MapMarkersHelper {
|
||||||
boolean needRefresh = false;
|
boolean needRefresh = false;
|
||||||
for (MapMarker marker : markers) {
|
for (MapMarker marker : markers) {
|
||||||
if (!marker.history) {
|
if (!marker.history) {
|
||||||
// TODO make all changes in once!!!
|
removeMarker(marker, false);
|
||||||
markersDbHelper.removeMarker(marker, false);
|
|
||||||
removeFromMapMarkersList(marker);
|
|
||||||
removeMarkerFromGroup(marker);
|
|
||||||
needRefresh = true;
|
needRefresh = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -474,16 +471,21 @@ public class MapMarkersHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeMarker(MapMarker marker) {
|
public void removeMarker(MapMarker marker) {
|
||||||
|
removeMarker(marker, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void removeMarker(MapMarker marker, boolean refresh) {
|
||||||
if (marker != null) {
|
if (marker != null) {
|
||||||
boolean history = marker.history;
|
markersDbHelper.removeMarker(marker);
|
||||||
markersDbHelper.removeMarker(marker, history);
|
if (marker.history) {
|
||||||
if (history) {
|
|
||||||
removeFromMapMarkersHistoryList(marker);
|
removeFromMapMarkersHistoryList(marker);
|
||||||
} else {
|
} else {
|
||||||
removeFromMapMarkersList(marker);
|
removeFromMapMarkersList(marker);
|
||||||
}
|
}
|
||||||
removeMarkerFromGroup(marker);
|
removeMarkerFromGroup(marker);
|
||||||
refresh();
|
if (refresh) {
|
||||||
|
refresh();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -581,14 +581,14 @@ public class MapMarkersDbHelper {
|
||||||
return markers;
|
return markers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeMarker(MapMarker marker, boolean history) {
|
public void removeMarker(MapMarker marker) {
|
||||||
SQLiteConnection db = openConnection(true);
|
SQLiteConnection db = openConnection(true);
|
||||||
if (db != null) {
|
if (db != null) {
|
||||||
try {
|
try {
|
||||||
db.execSQL("DELETE FROM " + MARKERS_TABLE_NAME +
|
db.execSQL("DELETE FROM " + MARKERS_TABLE_NAME +
|
||||||
" WHERE " + MARKERS_COL_ID + " = ?" +
|
" WHERE " + MARKERS_COL_ID + " = ?" +
|
||||||
" AND " + MARKERS_COL_ACTIVE + " = ?",
|
" AND " + MARKERS_COL_ACTIVE + " = ?",
|
||||||
new Object[]{marker.id, history ? 0 : 1});
|
new Object[]{marker.id, marker.history ? 0 : 1});
|
||||||
} finally {
|
} finally {
|
||||||
db.close();
|
db.close();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue