From fb7ae35e323baa5e12f4c05dc2a6558223a6ff89 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Thu, 31 Mar 2011 00:27:19 +0200 Subject: [PATCH] Fix NPE for rendering and Download Index --- .../src/net/osmand/activities/DownloadIndexActivity.java | 5 +++-- OsmAnd/src/net/osmand/render/MapRenderRepositories.java | 8 ++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/OsmAnd/src/net/osmand/activities/DownloadIndexActivity.java b/OsmAnd/src/net/osmand/activities/DownloadIndexActivity.java index b6d593292d..852ab8b162 100644 --- a/OsmAnd/src/net/osmand/activities/DownloadIndexActivity.java +++ b/OsmAnd/src/net/osmand/activities/DownloadIndexActivity.java @@ -565,7 +565,7 @@ public class DownloadIndexActivity extends ListActivity { } - protected final int TRIES_TO_DOWNLOAD = 20; + protected final int TRIES_TO_DOWNLOAD = 15; protected final long TIMEOUT_BETWEEN_DOWNLOADS = 8000; private boolean interruptDownloading = false; @@ -596,7 +596,8 @@ public class DownloadIndexActivity extends ListActivity { } conn.setConnectTimeout(30000); log.info(conn.getResponseMessage() + " " + conn.getResponseCode()); //$NON-NLS-1$ - if (conn.getResponseCode() != HttpURLConnection.HTTP_OK) { + if (conn.getResponseCode() != HttpURLConnection.HTTP_PARTIAL && + conn.getResponseCode() != HttpURLConnection.HTTP_OK) { conn.disconnect(); triesDownload--; continue; diff --git a/OsmAnd/src/net/osmand/render/MapRenderRepositories.java b/OsmAnd/src/net/osmand/render/MapRenderRepositories.java index caab9f620e..8e1e8edc59 100644 --- a/OsmAnd/src/net/osmand/render/MapRenderRepositories.java +++ b/OsmAnd/src/net/osmand/render/MapRenderRepositories.java @@ -196,7 +196,7 @@ public class MapRenderRepositories { return false; } - private boolean loadVectorData(RectF dataBox, final int zoom, BaseOsmandRender renderingType){ + private boolean loadVectorData(RectF dataBox, final int zoom, final BaseOsmandRender renderingType){ double cBottomLatitude = dataBox.bottom; double cTopLatitude = dataBox.top; double cLeftLongitude = dataBox.left; @@ -223,7 +223,7 @@ public class MapRenderRepositories { int bottomY = MapUtils.get31TileNumberY(cBottomLatitude); int topY = MapUtils.get31TileNumberY(cTopLatitude); searchRequest = BinaryMapIndexReader.buildSearchRequest(leftX, rightX, topY, bottomY, zoom); - if (zoom < 15) { + if (zoom < 17) { searchRequest.setSearchFilter(new BinaryMapIndexReader.SearchFilter() { @Override @@ -232,7 +232,7 @@ public class MapRenderRepositories { int type = types.get(j); int mask = type & 3; TagValuePair pair = root.decodeType(type); - if (renderingType.isObjectVisible(pair.tag, pair.value, zoom, mask)) { + if (pair != null && renderingType.isObjectVisible(pair.tag, pair.value, zoom, mask)) { return true; } } @@ -328,7 +328,7 @@ public class MapRenderRepositories { dataBox.top -= hi; dataBox.bottom += hi; } - boolean loaded = loadVectorData(dataBox, requestedBox.getZoom(), MapRenderingTypes.getDefault()); + boolean loaded = loadVectorData(dataBox, requestedBox.getZoom(), renderingType); if (!loaded || checkWhetherInterrupted()) { return; }