From 57b7081c682fba1a3a521af631eeeb42ea5954a1 Mon Sep 17 00:00:00 2001 From: Alexander Sytnyk Date: Tue, 28 Nov 2017 11:51:38 +0200 Subject: [PATCH] Simplify code --- .../net/osmand/plus/mapmarkers/MapMarkersDbHelper.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDbHelper.java b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDbHelper.java index f99e0bd8f5..6ff93d31ea 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDbHelper.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDbHelper.java @@ -406,7 +406,6 @@ public class MapMarkersDbHelper { } public List getActiveMarkers() { - List res = new LinkedList<>(); HashMap markers = new LinkedHashMap<>(); SQLiteConnection db = openConnection(true); if (db != null) { @@ -423,9 +422,8 @@ public class MapMarkersDbHelper { } finally { db.close(); } - buildLinkedList(markers, res); } - return res; + return buildLinkedList(markers); } private MapMarker readItem(SQLiteCursor query) { @@ -457,12 +455,13 @@ public class MapMarkersDbHelper { return marker; } - private void buildLinkedList(HashMap markers, List res) { + private List buildLinkedList(HashMap markers) { + List res = new LinkedList<>(); int markersCount = markers.size(); for (int i = 0; i < markersCount; i++) { int count = 1; for (MapMarker marker : markers.values()) { - if (!markers.keySet().contains(marker.nextKey) || count == markers.size()) { + if (!markers.containsKey(marker.nextKey) || count == markers.size()) { res.add(0, marker); markers.remove(marker.id); break; @@ -470,6 +469,7 @@ public class MapMarkersDbHelper { count++; } } + return res; } public void updateMarker(MapMarker marker) {