Fix samples app crash

This commit is contained in:
Alexey Kulish 2016-11-12 20:01:03 +03:00
parent ec3cf64047
commit 1d0e6c2545
2 changed files with 24 additions and 4 deletions

View file

@ -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"

View file

@ -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