[android] example custom layer - add context lost callback

This commit is contained in:
Ivo van Dongen
2017-09-19 10:57:10 +03:00
committed by Ivo van Dongen
parent d1e69c8baf
commit 779fc8aeee
3 changed files with 10 additions and 0 deletions

View File

@@ -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);
@@ -122,6 +126,10 @@ extern "C" JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *) {
env->GetStaticFieldID(customLayerClass, "RenderFunction", "J"),
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));