Change id for marker

This commit is contained in:
Alexander Sytnyk 2017-09-05 10:20:58 +03:00
parent 802dbde613
commit bf2a7619fe
2 changed files with 7 additions and 6 deletions

View file

@ -29,7 +29,7 @@ public class MapMarkersHelper {
} }
public static class MapMarker implements LocationPoint { public static class MapMarker implements LocationPoint {
public int id; public long id;
public LatLon point; public LatLon point;
private PointDescription pointDescription; private PointDescription pointDescription;
public int colorIndex; public int colorIndex;

View file

@ -1,6 +1,6 @@
package net.osmand.plus.mapmarkers; package net.osmand.plus.mapmarkers;
import android.util.SparseArray; import android.support.v4.util.LongSparseArray;
import net.osmand.data.LatLon; import net.osmand.data.LatLon;
import net.osmand.data.PointDescription; import net.osmand.data.PointDescription;
@ -20,7 +20,7 @@ public class MapMarkersDbHelper {
private static final String DB_NAME = "map_markers_db"; private static final String DB_NAME = "map_markers_db";
private static final String MARKERS_TABLE_NAME = "map_markers"; private static final String MARKERS_TABLE_NAME = "map_markers";
private static final String MARKERS_COL_ID = "_id"; private static final String MARKERS_COL_ID = "marker_id";
private static final String MARKERS_COL_LAT = "marker_latitude"; private static final String MARKERS_COL_LAT = "marker_latitude";
private static final String MARKERS_COL_LON = "marker_longitude"; private static final String MARKERS_COL_LON = "marker_longitude";
private static final String MARKERS_COL_DESCRIPTION = "marker_description"; private static final String MARKERS_COL_DESCRIPTION = "marker_description";
@ -34,6 +34,7 @@ public class MapMarkersDbHelper {
private static final String MARKERS_TABLE_CREATE = "CREATE TABLE IF NOT EXISTS " + private static final String MARKERS_TABLE_CREATE = "CREATE TABLE IF NOT EXISTS " +
MARKERS_TABLE_NAME + " (" + MARKERS_TABLE_NAME + " (" +
MARKERS_COL_ID + " long PRIMARY KEY, " +
MARKERS_COL_LAT + " double, " + MARKERS_COL_LAT + " double, " +
MARKERS_COL_LON + " double, " + MARKERS_COL_LON + " double, " +
MARKERS_COL_DESCRIPTION + " TEXT, " + MARKERS_COL_DESCRIPTION + " TEXT, " +
@ -147,7 +148,7 @@ public class MapMarkersDbHelper {
private void loadMapMarkers() { private void loadMapMarkers() {
SQLiteConnection db = openConnection(true); SQLiteConnection db = openConnection(true);
SparseArray<MapMarker> markers = new SparseArray<>(); LongSparseArray<MapMarker> markers = new LongSparseArray<>();
if (db != null) { if (db != null) {
try { try {
SQLiteCursor query = db.rawQuery(MARKERS_TABLE_SELECT, null); SQLiteCursor query = db.rawQuery(MARKERS_TABLE_SELECT, null);
@ -162,14 +163,14 @@ public class MapMarkersDbHelper {
db.close(); db.close();
} }
for (int i = 0; i < markers.size(); i++) { for (int i = 0; i < markers.size(); i++) {
int key = markers.keyAt(i); long key = markers.keyAt(i);
MapMarker marker = markers.get(key); MapMarker marker = markers.get(key);
} }
} }
} }
private MapMarker readItem(SQLiteCursor query) { private MapMarker readItem(SQLiteCursor query) {
int id = query.getInt(0); long id = query.getLong(0);
double lat = query.getDouble(1); double lat = query.getDouble(1);
double lon = query.getDouble(2); double lon = query.getDouble(2);
String desc = query.getString(3); String desc = query.getString(3);