kopia lustrzana https://github.com/ge0rg/aprsdroid
OSM: show error from map loader
rodzic
2041ba3497
commit
106edf8b90
|
@ -21,6 +21,7 @@ import _root_.java.io.File
|
||||||
import _root_.java.util.ArrayList
|
import _root_.java.util.ArrayList
|
||||||
|
|
||||||
import org.mapsforge.v3.android.maps.mapgenerator.{MapGeneratorFactory, MapGeneratorInternal}
|
import org.mapsforge.v3.android.maps.mapgenerator.{MapGeneratorFactory, MapGeneratorInternal}
|
||||||
|
import org.mapsforge.v3.map.reader.header.FileOpenResult
|
||||||
|
|
||||||
// to make scala-style iterating over arraylist possible
|
// to make scala-style iterating over arraylist possible
|
||||||
import scala.collection.JavaConversions._
|
import scala.collection.JavaConversions._
|
||||||
|
@ -116,11 +117,21 @@ class MapAct extends MapActivity with MapMenuHelper {
|
||||||
|
|
||||||
def reloadMapAndTheme() {
|
def reloadMapAndTheme() {
|
||||||
val mapfile = new File(prefs.getString("mapfile", android.os.Environment.getExternalStorageDirectory() + "/aprsdroid.map"))
|
val mapfile = new File(prefs.getString("mapfile", android.os.Environment.getExternalStorageDirectory() + "/aprsdroid.map"))
|
||||||
if (mapfile.exists() && mapfile.canRead())
|
var error = if (mapfile.exists() && mapfile.canRead()) {
|
||||||
mapview.setMapFile(mapfile)
|
val result = mapview.setMapFile(mapfile)
|
||||||
else {
|
// output map loader's error if loading failed
|
||||||
if (prefs.getString("mapfile", null) != null)
|
if (result.isSuccess) null else result.getErrorMessage
|
||||||
Toast.makeText(this, getString(R.string.mapfile_error, mapfile), Toast.LENGTH_SHORT).show()
|
} else if (prefs.getString("mapfile", null) != null) {
|
||||||
|
// output generic error if file was configured but is not loadable
|
||||||
|
getString(R.string.mapfile_error, mapfile)
|
||||||
|
} else {
|
||||||
|
// do not output error if no map file was configured, silently load online osm
|
||||||
|
null
|
||||||
|
}
|
||||||
|
if (error != null)
|
||||||
|
Toast.makeText(this, error, Toast.LENGTH_SHORT).show()
|
||||||
|
// all map file attempts failed, fall back to online
|
||||||
|
if (mapview.getMapFile == null) {
|
||||||
val map_source = MapGeneratorInternal.MAPNIK
|
val map_source = MapGeneratorInternal.MAPNIK
|
||||||
val map_gen = new OsmTileDownloader()
|
val map_gen = new OsmTileDownloader()
|
||||||
map_gen.setUserAgent(getString(R.string.build_version))
|
map_gen.setUserAgent(getString(R.string.build_version))
|
||||||
|
|
Ładowanie…
Reference in New Issue