From fd904b9c99440ff0fcc8c723fafcca1247d8cf46 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Wed, 22 May 2013 09:57:03 +0200 Subject: [PATCH] Fix most critical bugs --- .../src/net/osmand/map/TileSourceManager.java | 56 ++++++++++--------- .../osmand/plus/activities/MapActivity.java | 8 +-- .../base/SuggestExternalDirectoryDialog.java | 4 +- 3 files changed, 35 insertions(+), 33 deletions(-) diff --git a/OsmAnd-java/src/net/osmand/map/TileSourceManager.java b/OsmAnd-java/src/net/osmand/map/TileSourceManager.java index d374e00d8f..1e613066ee 100644 --- a/OsmAnd-java/src/net/osmand/map/TileSourceManager.java +++ b/OsmAnd-java/src/net/osmand/map/TileSourceManager.java @@ -317,33 +317,35 @@ public class TileSourceManager { public static List downloadTileSourceTemplates(String versionAsUrl) { final List templates = new ArrayList(); - try { - URLConnection connection = new URL("http://download.osmand.net//tile_sources.php?" + versionAsUrl).openConnection(); - XmlPullParser parser = PlatformUtil.newXMLPullParser(); - parser.setInput(connection.getInputStream(), "UTF-8"); - int tok; - while ((tok = parser.next()) != XmlPullParser.END_DOCUMENT) { - if (tok == XmlPullParser.START_TAG) { - String name = parser.getName(); - if (name.equals("tile_source")) { - Map attrs = new LinkedHashMap(); - for(int i=0; i< parser.getAttributeCount(); i++) { - attrs.put(parser.getAttributeName(i), parser.getAttributeValue(i)); - } - TileSourceTemplate template = createTileSourceTemplate(attrs); - if (template != null) { - templates.add(template); - } - } - } - } - } catch (IOException e) { - log.error("Exception while downloading tile sources", e); - return null; - } catch (XmlPullParserException e) { - log.error("Exception while downloading tile sources", e); - return null; - } + // FIXME android.os.NetworkOnMainThreadException +// at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1118) +// try { +// URLConnection connection = new URL("http://download.osmand.net//tile_sources.php?" + versionAsUrl).openConnection(); +// XmlPullParser parser = PlatformUtil.newXMLPullParser(); +// parser.setInput(connection.getInputStream(), "UTF-8"); +// int tok; +// while ((tok = parser.next()) != XmlPullParser.END_DOCUMENT) { +// if (tok == XmlPullParser.START_TAG) { +// String name = parser.getName(); +// if (name.equals("tile_source")) { +// Map attrs = new LinkedHashMap(); +// for(int i=0; i< parser.getAttributeCount(); i++) { +// attrs.put(parser.getAttributeName(i), parser.getAttributeValue(i)); +// } +// TileSourceTemplate template = createTileSourceTemplate(attrs); +// if (template != null) { +// templates.add(template); +// } +// } +// } +// } +// } catch (IOException e) { +// log.error("Exception while downloading tile sources", e); +// return null; +// } catch (XmlPullParserException e) { +// log.error("Exception while downloading tile sources", e); +// return null; +// } return templates; } diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java index 6007d82f4b..d467a13c74 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java @@ -159,16 +159,14 @@ public class MapActivity extends AccessibleActivity { } }); createProgressBarForRouting(); + mapLayers.createLayers(mapView); // This situtation could be when navigation suddenly crashed and after restarting // it tries to continue the last route - if(settings.FOLLOW_THE_ROUTE.get() && !app.getRoutingHelper().isRouteCalculated() && - !app.getRoutingHelper().isRouteBeingCalculated()){ + if (settings.FOLLOW_THE_ROUTE.get() && !app.getRoutingHelper().isRouteCalculated() + && !app.getRoutingHelper().isRouteBeingCalculated()) { FailSafeFuntions.restoreRoutingMode(this); } - - mapLayers.createLayers(mapView); - if(!settings.isLastKnownMapLocation()){ // show first time when application ran net.osmand.Location location = app.getLocationProvider().getFirstTimeRunDefaultLocation(); diff --git a/OsmAnd/src/net/osmand/plus/base/SuggestExternalDirectoryDialog.java b/OsmAnd/src/net/osmand/plus/base/SuggestExternalDirectoryDialog.java index fda501fac5..0888e636b7 100644 --- a/OsmAnd/src/net/osmand/plus/base/SuggestExternalDirectoryDialog.java +++ b/OsmAnd/src/net/osmand/plus/base/SuggestExternalDirectoryDialog.java @@ -48,7 +48,9 @@ public class SuggestExternalDirectoryDialog { dialog.dismiss(); app.getSettings().setExternalStorageDirectory(extMounts[which]); app.getResourceManager().resetStoreDirectory(); - reloadListener.run(); + if(reloadListener != null) { + reloadListener.run(); + } } } });