[android] example custom layer - add context lost callback
This commit is contained in:
committed by
Ivo van Dongen
parent
d1e69c8baf
commit
779fc8aeee
@@ -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);
|
||||
|
||||
@@ -11,5 +11,6 @@ public class ExampleCustomLayer {
|
||||
|
||||
public static long InitializeFunction;
|
||||
public static long RenderFunction;
|
||||
public static long ContextLostFunction;
|
||||
public static long DeinitializeFunction;
|
||||
}
|
||||
|
||||
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user