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) {
|
public void syncWithMarkers(@NonNull MapMarkersGroup group) {
|
||||||
if (!isGroupSynced(group.getId())) {
|
if (!isGroupSynced(group.getId())) {
|
||||||
markersDbHelper.addGroup(group);
|
markersDbHelper.addGroup(group);
|
||||||
|
addHistoryMarkersToGroup(group);
|
||||||
addToGroupsList(group);
|
addToGroupsList(group);
|
||||||
} else if (group.wptCategories != null) {
|
} else if (group.wptCategories != null) {
|
||||||
markersDbHelper.updateGroupCategories(group.getId(), group.getWptCategoriesString());
|
markersDbHelper.updateGroupCategories(group.getId(), group.getWptCategoriesString());
|
||||||
|
@ -317,6 +318,15 @@ public class MapMarkersHelper {
|
||||||
runSynchronization(group);
|
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) {
|
public void removeMarkersGroup(MapMarkersGroup group) {
|
||||||
if (group != null) {
|
if (group != null) {
|
||||||
markersDbHelper.removeMarkersGroup(group.getId());
|
markersDbHelper.removeMarkersGroup(group.getId());
|
||||||
|
|
|
@ -300,7 +300,8 @@ public class MapMarkersDbHelper {
|
||||||
if (db != null) {
|
if (db != null) {
|
||||||
try {
|
try {
|
||||||
db.execSQL("DELETE FROM " + GROUPS_TABLE_NAME + " WHERE " + GROUPS_COL_DISABLED + " = ? ", new Object[]{1});
|
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 {
|
} finally {
|
||||||
db.close();
|
db.close();
|
||||||
}
|
}
|
||||||
|
@ -408,8 +409,8 @@ public class MapMarkersDbHelper {
|
||||||
SQLiteConnection db = openConnection(true);
|
SQLiteConnection db = openConnection(true);
|
||||||
if (db != null) {
|
if (db != null) {
|
||||||
try {
|
try {
|
||||||
SQLiteCursor query = db.rawQuery(MARKERS_TABLE_SELECT + " WHERE " + MARKERS_COL_ACTIVE + " = ? " + "AND " + MARKERS_COL_DISABLED + " = ?",
|
SQLiteCursor query = db.rawQuery(MARKERS_TABLE_SELECT + " WHERE " + MARKERS_COL_ACTIVE + " = ?",
|
||||||
new String[]{String.valueOf(1), String.valueOf(0)});
|
new String[]{String.valueOf(1)});
|
||||||
if (query.moveToFirst()) {
|
if (query.moveToFirst()) {
|
||||||
do {
|
do {
|
||||||
MapMarker marker = readItem(query);
|
MapMarker marker = readItem(query);
|
||||||
|
@ -567,8 +568,8 @@ public class MapMarkersDbHelper {
|
||||||
SQLiteConnection db = openConnection(true);
|
SQLiteConnection db = openConnection(true);
|
||||||
if (db != null) {
|
if (db != null) {
|
||||||
try {
|
try {
|
||||||
SQLiteCursor query = db.rawQuery(MARKERS_TABLE_SELECT + " WHERE " + MARKERS_COL_ACTIVE + " = ? " + "AND " + MARKERS_COL_DISABLED + " = ?",
|
SQLiteCursor query = db.rawQuery(MARKERS_TABLE_SELECT + " WHERE " + MARKERS_COL_ACTIVE + " = ?",
|
||||||
new String[]{String.valueOf(0), String.valueOf(0)});
|
new String[]{String.valueOf(0)});
|
||||||
if (query.moveToFirst()) {
|
if (query.moveToFirst()) {
|
||||||
do {
|
do {
|
||||||
markers.add(readItem(query));
|
markers.add(readItem(query));
|
||||||
|
|
Loading…
Reference in a new issue