From 1d5de834f13242ed5203aa243e7f70d918941851 Mon Sep 17 00:00:00 2001 From: Alex Sytnyk Date: Thu, 11 Oct 2018 11:36:34 +0300 Subject: [PATCH] Prevent ConcurrentModificationException --- OsmAnd/src/net/osmand/plus/FavouritesDbHelper.java | 6 +++++- OsmAnd/src/net/osmand/plus/views/FavouritesLayer.java | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/FavouritesDbHelper.java b/OsmAnd/src/net/osmand/plus/FavouritesDbHelper.java index 9744e8a561..4038ce7b73 100644 --- a/OsmAnd/src/net/osmand/plus/FavouritesDbHelper.java +++ b/OsmAnd/src/net/osmand/plus/FavouritesDbHelper.java @@ -50,6 +50,7 @@ public class FavouritesDbHelper { protected static final String HIDDEN = "HIDDEN"; private static final String DELIMETER = "__"; + private boolean favoritesLoaded; public FavouritesDbHelper(OsmandApplication context) { this.context = context; @@ -91,12 +92,15 @@ public class FavouritesDbHelper { saveCurrentPointsIntoFile(); } favouritesUpdated(); - + favoritesLoaded = true; } private void favouritesUpdated() { } + public boolean isFavoritesLoaded() { + return favoritesLoaded; + } private boolean merge(Map source, Map destination) { boolean changed = false; diff --git a/OsmAnd/src/net/osmand/plus/views/FavouritesLayer.java b/OsmAnd/src/net/osmand/plus/views/FavouritesLayer.java index f63581001f..62cab78807 100644 --- a/OsmAnd/src/net/osmand/plus/views/FavouritesLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/FavouritesLayer.java @@ -108,7 +108,7 @@ public class FavouritesLayer extends OsmandMapLayer implements ContextMenuLayer. @Override public void onPrepareBufferImage(Canvas canvas, RotatedTileBox tileBox, DrawSettings settings) { cache.clear(); - if (this.settings.SHOW_FAVORITES.get()) { + if (this.settings.SHOW_FAVORITES.get() && favorites.isFavoritesLoaded()) { if (tileBox.getZoom() >= startZoom) { float iconSize = FavoriteImageDrawable.getOrCreate(view.getContext(), 0, true).getIntrinsicWidth() * 3 / 2.5f;