remove unused variable saveExisting

This commit is contained in:
Nazar-Kutz 2020-05-12 14:23:50 +03:00
parent 9f4d9e74d2
commit 7906b9e632

View file

@ -284,7 +284,7 @@ public class MapMarkersDbHelper {
if (db != null) { if (db != null) {
try { try {
for (MapMarker marker : markers) { for (MapMarker marker : markers) {
insertLast(db, marker, false); insertLast(db, marker);
} }
} finally { } finally {
db.close(); db.close();
@ -293,36 +293,24 @@ public class MapMarkersDbHelper {
} }
public void addMarker(MapMarker marker) { public void addMarker(MapMarker marker) {
addMarker(marker, false);
}
private void addMarker(MapMarker marker, boolean saveExisting) {
SQLiteConnection db = openConnection(false); SQLiteConnection db = openConnection(false);
if (db != null) { if (db != null) {
try { try {
insertLast(db, marker, saveExisting); insertLast(db, marker);
} finally { } finally {
db.close(); db.close();
} }
} }
} }
private void insertLast(SQLiteConnection db, MapMarker marker, boolean saveExisting) { private void insertLast(SQLiteConnection db, MapMarker marker) {
long currentTime; long currentTime = System.currentTimeMillis();
if (saveExisting) {
Calendar cal = Calendar.getInstance();
cal.add(Calendar.MONTH, -1);
currentTime = cal.getTimeInMillis();
} else {
currentTime = System.currentTimeMillis();
}
if (marker.id == null) { if (marker.id == null) {
marker.id = String.valueOf(currentTime) + String.valueOf(new Random().nextInt(900) + 100); marker.id = String.valueOf(currentTime) + String.valueOf(new Random().nextInt(900) + 100);
} }
marker.creationDate = currentTime; marker.creationDate = currentTime;
String descr = PointDescription.serializeToString(marker.getOriginalPointDescription()); String descr = PointDescription.serializeToString(marker.getOriginalPointDescription());
int active = marker.history ? 0 : 1; int active = marker.history ? 0 : 1;
long visited = saveExisting ? currentTime : marker.visitedDate;
PointDescription pointDescription = marker.getOriginalPointDescription(); PointDescription pointDescription = marker.getOriginalPointDescription();
if (pointDescription != null && !pointDescription.isSearchingAddress(context)) { if (pointDescription != null && !pointDescription.isSearchingAddress(context)) {
@ -352,7 +340,7 @@ public class MapMarkersDbHelper {
MARKERS_COL_MAP_OBJECT_NAME + ") " + MARKERS_COL_MAP_OBJECT_NAME + ") " +
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
new Object[]{marker.id, marker.getLatitude(), marker.getLongitude(), descr, active, new Object[]{marker.id, marker.getLatitude(), marker.getLongitude(), descr, active,
currentTime, visited, marker.groupName, marker.groupKey, marker.colorIndex, currentTime, marker.visitedDate, marker.groupName, marker.groupKey, marker.colorIndex,
marker.history ? HISTORY_NEXT_VALUE : TAIL_NEXT_VALUE, 0, 0, marker.mapObjectName}); marker.history ? HISTORY_NEXT_VALUE : TAIL_NEXT_VALUE, 0, 0, marker.mapObjectName});
} }