Added protection for loading native libraries multiple times
This commit is contained in:
parent
c0f48ea60b
commit
3c6be6e1d1
5 changed files with 28 additions and 10 deletions
|
@ -1,4 +1,4 @@
|
|||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
|
@ -14,4 +14,4 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
</RelativeLayout>
|
||||
</FrameLayout>
|
|
@ -701,6 +701,8 @@ public class OsmandSettings {
|
|||
public final OsmandPreference<Boolean> USE_KALMAN_FILTER_FOR_COMPASS = new BooleanPreference("use_kalman_filter_compass", true).makeGlobal().cache();
|
||||
|
||||
public final OsmandPreference<Boolean> USE_NATIVE_RENDER = new BooleanPreference("use_native_render", false).makeGlobal().cache();
|
||||
|
||||
public final OsmandPreference<Boolean> CPP_RENDER_FAILED = new BooleanPreference("cpp_render_failed", false).makeGlobal().cache();
|
||||
|
||||
public final CommonPreference<Float> TEXT_SCALE = new FloatPreference("text_scale", 1f).makeProfile().cache();
|
||||
{
|
||||
|
|
|
@ -134,9 +134,15 @@ public class MapActivity extends AccessibleActivity {
|
|||
app.checkApplicationIsBeingInitialized(this, startProgressDialog);
|
||||
parseLaunchIntentLocation();
|
||||
|
||||
if (settings.USE_NATIVE_RENDER.get()){
|
||||
//defending user from multiple failures of loading native renderer
|
||||
//if app fails - user will need to manually set USE_NATIVE_RENDER again
|
||||
if (settings.USE_NATIVE_RENDER.get() && !settings.CPP_RENDER_FAILED.get()){
|
||||
settings.CPP_RENDER_FAILED.set(true);
|
||||
settings.USE_NATIVE_RENDER.set(false);
|
||||
setContentView(R.layout.activity_gl);
|
||||
mapViewController = new NativeViewController((GLSurfaceView) findViewById(R.id.glSurfaceView), this);
|
||||
settings.CPP_RENDER_FAILED.set(false);
|
||||
settings.USE_NATIVE_RENDER.set(true);
|
||||
} else {
|
||||
setContentView(R.layout.main);
|
||||
mapViewController = new JavaViewController((OsmandMapTileView) findViewById(R.id.MapView), this);
|
||||
|
@ -605,10 +611,10 @@ public class MapActivity extends AccessibleActivity {
|
|||
|
||||
@Override
|
||||
public void stateChanged(Boolean change) {
|
||||
getMapView().refreshMap(true);
|
||||
mapViewController.refreshMap(true);
|
||||
}
|
||||
});
|
||||
getMapView().refreshMap(true);
|
||||
mapViewController.refreshMap(true);
|
||||
}
|
||||
|
||||
|
||||
|
@ -719,7 +725,7 @@ public class MapActivity extends AccessibleActivity {
|
|||
}
|
||||
|
||||
public void refreshMap() {
|
||||
getMapView().refreshMap();
|
||||
mapViewController.refreshMap(false);
|
||||
}
|
||||
|
||||
public View getLayout() {
|
||||
|
|
|
@ -108,6 +108,6 @@ public abstract class MapViewBaseController {
|
|||
}
|
||||
|
||||
public void destroy(){
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ import net.osmand.plus.activities.MapActivity;
|
|||
import net.osmand.plus.activities.MapActivityLayers;
|
||||
import net.osmand.plus.base.MapViewTrackingUtilities;
|
||||
import net.osmand.plus.helpers.SimpleTwoFingerTapDetector;
|
||||
import net.osmand.plus.render.NativeOsmandLibrary;
|
||||
import net.osmand.plus.views.OsmandMapLayer;
|
||||
import net.osmand.plus.views.OsmandMapTileView;
|
||||
|
||||
|
@ -34,6 +35,15 @@ import java.util.List;
|
|||
* Created by Denis on 01.10.2014.
|
||||
*/
|
||||
public class NativeViewController extends MapViewBaseController {
|
||||
|
||||
static {
|
||||
NativeOsmandLibrary.loadLibrary("gnustl_shared");
|
||||
NativeOsmandLibrary.loadLibrary("Qt5Core");
|
||||
NativeOsmandLibrary.loadLibrary("Qt5Network");
|
||||
NativeOsmandLibrary.loadLibrary("Qt5Sql");
|
||||
NativeOsmandLibrary.loadLibrary("OsmAndCoreWithJNI");
|
||||
}
|
||||
|
||||
private GLSurfaceView glSurfaceView;
|
||||
private OsmandSettings settings;
|
||||
private MapActivity mapActivity;
|
||||
|
@ -156,7 +166,7 @@ public class NativeViewController extends MapViewBaseController {
|
|||
Log.i(NATIVE_TAG, "rasterTileSize = " + rasterTileSize);
|
||||
|
||||
Log.i(NATIVE_TAG, "Initializing core...");
|
||||
coreResources = CoreResourcesFromAndroidAssets.loadFromCurrentApplication(mapActivity);
|
||||
coreResources = CoreResourcesFromAndroidAssets.loadFromCurrentApplication(mapActivity.getMyApplication());
|
||||
OsmAndCore.InitializeCore(coreResources);
|
||||
|
||||
File directory =mapActivity.getMyApplication().getAppPath("");
|
||||
|
@ -396,7 +406,7 @@ public class NativeViewController extends MapViewBaseController {
|
|||
|
||||
@Override
|
||||
public void refreshMap(boolean b) {
|
||||
super.refreshMap(b);
|
||||
updateView();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -431,7 +441,7 @@ public class NativeViewController extends MapViewBaseController {
|
|||
|
||||
@Override
|
||||
public ViewParent getParentView() {
|
||||
return super.getParentView();
|
||||
return glSurfaceView.getParent();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue