diff options
author | Ivo van Dongen <info@ivovandongen.nl> | 2017-09-19 10:57:10 +0300 |
---|---|---|
committer | Ivo van Dongen <ivovandongen@users.noreply.github.com> | 2017-09-22 23:33:56 +0300 |
commit | 779fc8aeeed7a76022aa4b14e5e72d62745dd2b6 (patch) | |
tree | 46ac6fe2e74ceadb3e833617923f4f02106c7be2 /platform/android | |
parent | d1e69c8bafec2b799fae441be17b79c3566baac3 (diff) | |
download | qtlocation-mapboxgl-779fc8aeeed7a76022aa4b14e5e72d62745dd2b6.tar.gz |
[android] example custom layer - add context lost callback
Diffstat (limited to 'platform/android')
3 files changed, 10 insertions, 0 deletions
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/customlayer/CustomLayerActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/customlayer/CustomLayerActivity.java index dde22db2db..1b49e9e3d6 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/customlayer/CustomLayerActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/customlayer/CustomLayerActivity.java @@ -69,6 +69,7 @@ public class CustomLayerActivity extends AppCompatActivity { ExampleCustomLayer.createContext(), ExampleCustomLayer.InitializeFunction, ExampleCustomLayer.RenderFunction, + ExampleCustomLayer.ContextLostFunction, // Optional ExampleCustomLayer.DeinitializeFunction); mapboxMap.addLayerBelow(customLayer, "building"); fab.setImageResource(R.drawable.ic_layers_clear); diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/customlayer/ExampleCustomLayer.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/customlayer/ExampleCustomLayer.java index 8c049d7730..aaad2f04ab 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/customlayer/ExampleCustomLayer.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/customlayer/ExampleCustomLayer.java @@ -11,5 +11,6 @@ public class ExampleCustomLayer { public static long InitializeFunction; public static long RenderFunction; + public static long ContextLostFunction; public static long DeinitializeFunction; } diff --git a/platform/android/src/example_custom_layer.cpp b/platform/android/src/example_custom_layer.cpp index c55c9c3527..1ed68d0835 100644 --- a/platform/android/src/example_custom_layer.cpp +++ b/platform/android/src/example_custom_layer.cpp @@ -92,6 +92,10 @@ void nativeRender(void *context, const mbgl::style::CustomLayerRenderParameters& reinterpret_cast<ExampleCustomLayer*>(context)->render(); } +void nativeContextLost(void */*context*/) { + mbgl::Log::Info(mbgl::Event::General, "nativeContextLost"); +} + void nativeDenitialize(void *context) { mbgl::Log::Info(mbgl::Event::General, "nativeDeinitialize"); delete reinterpret_cast<ExampleCustomLayer*>(context); @@ -123,6 +127,10 @@ extern "C" JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *) { reinterpret_cast<jlong>(nativeRender)); env->SetStaticLongField(customLayerClass, + env->GetStaticFieldID(customLayerClass, "ContextLostFunction", "J"), + reinterpret_cast<jlong>(nativeContextLost)); + + env->SetStaticLongField(customLayerClass, env->GetStaticFieldID(customLayerClass, "DeinitializeFunction", "J"), reinterpret_cast<jlong>(nativeDenitialize)); |