From 99ba127f50cd590b59ac80ff7850b03582d04832 Mon Sep 17 00:00:00 2001 From: vshcherb Date: Tue, 22 Oct 2013 00:52:05 +0200 Subject: [PATCH] Fix exceptions --- .../plus/resources/ResourceManager.java | 19 +++++++++++-------- .../plus/srtmplugin/HillshadeLayer.java | 10 ++++++---- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/resources/ResourceManager.java b/OsmAnd/src/net/osmand/plus/resources/ResourceManager.java index a4ec5b437a..32f3904813 100644 --- a/OsmAnd/src/net/osmand/plus/resources/ResourceManager.java +++ b/OsmAnd/src/net/osmand/plus/resources/ResourceManager.java @@ -12,11 +12,10 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.LinkedHashMap; -import java.util.LinkedHashSet; import java.util.List; import java.util.Map; -import java.util.Set; import java.util.TreeMap; +import java.util.concurrent.ConcurrentHashMap; import net.osmand.AndroidUtils; import net.osmand.GeoidAltitudeCorrection; @@ -26,10 +25,15 @@ import net.osmand.PlatformUtil; import net.osmand.ResultMatcher; import net.osmand.binary.BinaryMapIndexReader; import net.osmand.binary.CachedOsmandIndexes; -import net.osmand.data.*; +import net.osmand.data.Amenity; +import net.osmand.data.AmenityType; +import net.osmand.data.LatLon; +import net.osmand.data.RotatedTileBox; +import net.osmand.data.TransportStop; import net.osmand.map.ITileSource; import net.osmand.map.MapTileDownloader; import net.osmand.map.MapTileDownloader.DownloadRequest; +import net.osmand.map.OsmandRegions; import net.osmand.plus.BusyIndicator; import net.osmand.plus.NameFinderPoiFilter; import net.osmand.plus.OsmandApplication; @@ -64,7 +68,6 @@ import android.graphics.BitmapFactory; import android.os.HandlerThread; import android.util.DisplayMetrics; import android.view.WindowManager; -import net.osmand.map.OsmandRegions; /** * Resource manager is responsible to work with all resources @@ -114,11 +117,11 @@ public class ResourceManager { protected final List transportRepositories = new ArrayList(); - protected final Map indexFileNames = Collections.synchronizedMap(new LinkedHashMap()); + protected final Map indexFileNames = new ConcurrentHashMap(); - protected final Set basemapFileNames = Collections.synchronizedSet(new LinkedHashSet()); + protected final Map basemapFileNames = new ConcurrentHashMap(); - protected final Map routingMapFiles = Collections.synchronizedMap(new LinkedHashMap()); + protected final Map routingMapFiles = new ConcurrentHashMap(); protected final MapRenderRepositories renderer; @@ -647,7 +650,7 @@ public class ResourceManager { warnings.add(MessageFormat.format(context.getString(R.string.version_index_is_not_supported), f.getName())); //$NON-NLS-1$ } else { if (index.isBasemap()) { - basemapFileNames.add(f.getName()); + basemapFileNames.put(f.getName(), f.getName()); } long dateCreated = index.getDateCreated(); if (dateCreated == 0) { diff --git a/OsmAnd/src/net/osmand/plus/srtmplugin/HillshadeLayer.java b/OsmAnd/src/net/osmand/plus/srtmplugin/HillshadeLayer.java index 10b8d9e2c8..6e2be2e77e 100644 --- a/OsmAnd/src/net/osmand/plus/srtmplugin/HillshadeLayer.java +++ b/OsmAnd/src/net/osmand/plus/srtmplugin/HillshadeLayer.java @@ -157,7 +157,7 @@ public class HillshadeLayer extends MapTileLayer { List ts = getTileSource(x, y, zoom); for (String t : ts) { SQLiteTileSource sqLiteTileSource = resources.get(t); - if(sqLiteTileSource.exists(x, y, zoom)) { + if(sqLiteTileSource != null && sqLiteTileSource.exists(x, y, zoom)) { return true; } } @@ -169,9 +169,11 @@ public class HillshadeLayer extends MapTileLayer { List ts = getTileSource(x, y, zoom); for (String t : ts) { SQLiteTileSource sqLiteTileSource = resources.get(t); - Bitmap bmp = sqLiteTileSource.getImage(x, y, zoom, timeHolder); - if(bmp != null) { - return sqLiteTileSource.getImage(x, y, zoom, timeHolder); + if (sqLiteTileSource != null) { + Bitmap bmp = sqLiteTileSource.getImage(x, y, zoom, timeHolder); + if (bmp != null) { + return sqLiteTileSource.getImage(x, y, zoom, timeHolder); + } } } return null;