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;
|
||||
}
|
||||
|
||||
//todo: rewrite with MapMarkersDbHelper
|
||||
public void reverseActiveMarkersOrder() {
|
||||
cancelAddressRequests();
|
||||
|
||||
List<MapMarker> markers = new ArrayList<>(mapMarkers.size());
|
||||
for (int i = mapMarkers.size() - 1; i >= 0; i--) {
|
||||
MapMarker marker = mapMarkers.get(i);
|
||||
markers.add(marker);
|
||||
}
|
||||
mapMarkers = markers;
|
||||
saveMapMarkers(mapMarkers, null);
|
||||
markersDbHelper.reverseActiveMarkersOrder();
|
||||
loadMarkers();
|
||||
}
|
||||
|
||||
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) {
|
||||
SQLiteConnection db = openConnection(false);
|
||||
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) {
|
||||
SQLiteConnection db = openConnection(false);
|
||||
if (db != null) {
|
||||
|
|
Loading…
Reference in a new issue