Rewrite method reverseActiveMarkersOrder with MapMarkersDbHelper
This commit is contained in:
parent
28a4bf6d15
commit
b62f07a3f9
2 changed files with 22 additions and 8 deletions
|
@ -272,17 +272,11 @@ public class MapMarkersHelper {
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
//todo: rewrite with MapMarkersDbHelper
|
|
||||||
public void reverseActiveMarkersOrder() {
|
public void reverseActiveMarkersOrder() {
|
||||||
cancelAddressRequests();
|
cancelAddressRequests();
|
||||||
|
|
||||||
List<MapMarker> markers = new ArrayList<>(mapMarkers.size());
|
markersDbHelper.reverseActiveMarkersOrder();
|
||||||
for (int i = mapMarkers.size() - 1; i >= 0; i--) {
|
loadMarkers();
|
||||||
MapMarker marker = mapMarkers.get(i);
|
|
||||||
markers.add(marker);
|
|
||||||
}
|
|
||||||
mapMarkers = markers;
|
|
||||||
saveMapMarkers(mapMarkers, null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeActiveMarkers() {
|
public void removeActiveMarkers() {
|
||||||
|
|
|
@ -139,6 +139,14 @@ public class MapMarkersDbHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void reverseActiveMarkersOrder() {
|
||||||
|
List<MapMarker> markers = getActiveMarkers();
|
||||||
|
removeAllActiveMarkers();
|
||||||
|
for (int i = markers.size() - 1; i >= 0; i--) {
|
||||||
|
addMarker(markers.get(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void addMarker(MapMarker marker) {
|
public void addMarker(MapMarker marker) {
|
||||||
SQLiteConnection db = openConnection(false);
|
SQLiteConnection db = openConnection(false);
|
||||||
if (db != null) {
|
if (db != null) {
|
||||||
|
@ -271,6 +279,18 @@ public class MapMarkersDbHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void removeAllActiveMarkers() {
|
||||||
|
SQLiteConnection db = openConnection(true);
|
||||||
|
if (db != null) {
|
||||||
|
try {
|
||||||
|
db.execSQL("DELETE FROM " + MARKERS_TABLE_NAME + " WHERE " + MARKERS_COL_ACTIVE + " = ?",
|
||||||
|
new Object[]{1});
|
||||||
|
} finally {
|
||||||
|
db.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void moveMarkerToHistory(MapMarker marker) {
|
public void moveMarkerToHistory(MapMarker marker) {
|
||||||
SQLiteConnection db = openConnection(false);
|
SQLiteConnection db = openConnection(false);
|
||||||
if (db != null) {
|
if (db != null) {
|
||||||
|
|
Loading…
Reference in a new issue