From 1d0e6c254507720cf99bb47d369d5dae70e151ed Mon Sep 17 00:00:00 2001 From: Alexey Kulish Date: Sat, 12 Nov 2016 20:01:03 +0300 Subject: [PATCH] Fix samples app crash --- OsmAndCore-sample/build.gradle | 18 ++++++++++++++++++ .../android/sample1/SampleApplication.java | 10 ++++++---- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/OsmAndCore-sample/build.gradle b/OsmAndCore-sample/build.gradle index cb8400c5f5..e983ff4606 100644 --- a/OsmAndCore-sample/build.gradle +++ b/OsmAndCore-sample/build.gradle @@ -32,6 +32,7 @@ android { jniLibs.srcDirs = ["libs"] java.srcDirs = ["src"] renderscript.srcDirs = ["src"] + resources.srcDirs = ["src"] res.srcDirs = ["res"] assets.srcDirs = ["assets"] } @@ -74,6 +75,23 @@ android { } } +task collectMiscResources(type: Copy) { + into "src/net/osmand/osm" + from("../../resources/poi") { + include "poi_types.xml" + } +} + +task collectRegionsInfoResources(type: Copy) { + from "../../resources/countries-info" + into "src/net/osmand/map" + include "regions.ocbf" +} + +tasks.withType(JavaCompile) { + compileTask -> compileTask.dependsOn << [collectMiscResources, collectRegionsInfoResources] +} + repositories { ivy { name = "OsmAndBinariesIvy" diff --git a/OsmAndCore-sample/src/net/osmand/core/samples/android/sample1/SampleApplication.java b/OsmAndCore-sample/src/net/osmand/core/samples/android/sample1/SampleApplication.java index 16597a8b39..e016b6d568 100644 --- a/OsmAndCore-sample/src/net/osmand/core/samples/android/sample1/SampleApplication.java +++ b/OsmAndCore-sample/src/net/osmand/core/samples/android/sample1/SampleApplication.java @@ -5,8 +5,6 @@ import android.app.Application; import android.content.pm.PackageManager; import android.os.Environment; import android.os.Handler; -import android.os.Message; -import android.support.v4.app.ActivityCompat; import android.support.v4.content.ContextCompat; import net.osmand.core.android.CoreResourcesFromAndroidAssets; @@ -58,8 +56,12 @@ public class SampleApplication extends Application { } public void initPoiTypes() { - - poiTypes.init(Environment.getExternalStorageDirectory() + "/osmand/poi_types.xml"); + File poiTypesFile = new File(Environment.getExternalStorageDirectory() + "/osmand/poi_types.xml"); + if (poiTypesFile.exists()) { + poiTypes.init(poiTypesFile.getAbsolutePath()); + } else { + poiTypes.init(); + } poiTypes.setPoiTranslator(new MapPoiTypes.PoiTranslator() { @Override