Fix most critical bugs

This commit is contained in:
Victor Shcherb 2013-05-22 09:57:03 +02:00
parent 024773827c
commit fd904b9c99
3 changed files with 35 additions and 33 deletions

View file

@ -317,33 +317,35 @@ public class TileSourceManager {
public static List<TileSourceTemplate> downloadTileSourceTemplates(String versionAsUrl) {
final List<TileSourceTemplate> templates = new ArrayList<TileSourceTemplate>();
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<String, String> attrs = new LinkedHashMap<String, String>();
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<String, String> attrs = new LinkedHashMap<String, String>();
// 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;
}

View file

@ -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();

View file

@ -48,7 +48,9 @@ public class SuggestExternalDirectoryDialog {
dialog.dismiss();
app.getSettings().setExternalStorageDirectory(extMounts[which]);
app.getResourceManager().resetStoreDirectory();
reloadListener.run();
if(reloadListener != null) {
reloadListener.run();
}
}
}
});