Do not remove disabled markers from history
This commit is contained in:
parent
430add02f9
commit
be74646457
2 changed files with 16 additions and 5 deletions
|
@ -310,6 +310,7 @@ public class MapMarkersHelper {
|
|||
public void syncWithMarkers(@NonNull MapMarkersGroup group) {
|
||||
if (!isGroupSynced(group.getId())) {
|
||||
markersDbHelper.addGroup(group);
|
||||
addHistoryMarkersToGroup(group);
|
||||
addToGroupsList(group);
|
||||
} else if (group.wptCategories != null) {
|
||||
markersDbHelper.updateGroupCategories(group.getId(), group.getWptCategoriesString());
|
||||
|
@ -317,6 +318,15 @@ public class MapMarkersHelper {
|
|||
runSynchronization(group);
|
||||
}
|
||||
|
||||
private void addHistoryMarkersToGroup(@NonNull MapMarkersGroup group) {
|
||||
List<MapMarker> historyMarkers = new ArrayList<>(mapMarkersHistory);
|
||||
for (MapMarker m : historyMarkers) {
|
||||
if (m.groupKey != null && group.getId() != null && m.groupKey.equals(group.getId())) {
|
||||
group.getMarkers().add(m);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void removeMarkersGroup(MapMarkersGroup group) {
|
||||
if (group != null) {
|
||||
markersDbHelper.removeMarkersGroup(group.getId());
|
||||
|
|
|
@ -300,7 +300,8 @@ public class MapMarkersDbHelper {
|
|||
if (db != null) {
|
||||
try {
|
||||
db.execSQL("DELETE FROM " + GROUPS_TABLE_NAME + " WHERE " + GROUPS_COL_DISABLED + " = ? ", new Object[]{1});
|
||||
db.execSQL("DELETE FROM " + MARKERS_TABLE_NAME + " WHERE " + MARKERS_COL_DISABLED + " = ? ", new Object[]{1});
|
||||
db.execSQL("DELETE FROM " + MARKERS_TABLE_NAME
|
||||
+ " WHERE " + MARKERS_COL_DISABLED + " = ? AND " + MARKERS_COL_ACTIVE + " = ?", new Object[]{1, 1});
|
||||
} finally {
|
||||
db.close();
|
||||
}
|
||||
|
@ -408,8 +409,8 @@ public class MapMarkersDbHelper {
|
|||
SQLiteConnection db = openConnection(true);
|
||||
if (db != null) {
|
||||
try {
|
||||
SQLiteCursor query = db.rawQuery(MARKERS_TABLE_SELECT + " WHERE " + MARKERS_COL_ACTIVE + " = ? " + "AND " + MARKERS_COL_DISABLED + " = ?",
|
||||
new String[]{String.valueOf(1), String.valueOf(0)});
|
||||
SQLiteCursor query = db.rawQuery(MARKERS_TABLE_SELECT + " WHERE " + MARKERS_COL_ACTIVE + " = ?",
|
||||
new String[]{String.valueOf(1)});
|
||||
if (query.moveToFirst()) {
|
||||
do {
|
||||
MapMarker marker = readItem(query);
|
||||
|
@ -567,8 +568,8 @@ public class MapMarkersDbHelper {
|
|||
SQLiteConnection db = openConnection(true);
|
||||
if (db != null) {
|
||||
try {
|
||||
SQLiteCursor query = db.rawQuery(MARKERS_TABLE_SELECT + " WHERE " + MARKERS_COL_ACTIVE + " = ? " + "AND " + MARKERS_COL_DISABLED + " = ?",
|
||||
new String[]{String.valueOf(0), String.valueOf(0)});
|
||||
SQLiteCursor query = db.rawQuery(MARKERS_TABLE_SELECT + " WHERE " + MARKERS_COL_ACTIVE + " = ?",
|
||||
new String[]{String.valueOf(0)});
|
||||
if (query.moveToFirst()) {
|
||||
do {
|
||||
markers.add(readItem(query));
|
||||
|
|
Loading…
Reference in a new issue