diff options
Diffstat (limited to 'platform/android/src/style/sources/custom_geometry_source.cpp')
-rw-r--r-- | platform/android/src/style/sources/custom_geometry_source.cpp | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/platform/android/src/style/sources/custom_geometry_source.cpp b/platform/android/src/style/sources/custom_geometry_source.cpp index 9c51f70ab5..e9a530f75b 100644 --- a/platform/android/src/style/sources/custom_geometry_source.cpp +++ b/platform/android/src/style/sources/custom_geometry_source.cpp @@ -102,6 +102,19 @@ namespace android { peer.Call(*_env, releaseThreads); }; + bool CustomGeometrySource::isCancelled(jni::jint z, + jni::jint x, + jni::jint y) { + android::UniqueEnv _env = android::AttachEnv(); + + static auto isCancelled = javaClass.GetMethod<jboolean (jni::jint, jni::jint, jni::jint)>(*_env, "isCancelled"); + + assert(javaPeer); + + auto peer = jni::Cast(*_env, *javaPeer, javaClass); + return peer.Call(*_env, isCancelled, z, x, y); + }; + void CustomGeometrySource::setTileData(jni::JNIEnv& env, jni::jint z, jni::jint x, @@ -112,8 +125,10 @@ namespace android { // Convert the jni object auto geometry = geojson::FeatureCollection::convert(env, jFeatures); - // Update the core source - source.as<mbgl::style::CustomGeometrySource>()->CustomGeometrySource::setTileData(CanonicalTileID(z, x, y), GeoJSON(geometry)); + // Update the core source if not cancelled + if (!isCancelled(z, x ,y)) { + source.as<mbgl::style::CustomGeometrySource>()->CustomGeometrySource::setTileData(CanonicalTileID(z, x, y), GeoJSON(geometry)); + } } void CustomGeometrySource::invalidateTile(jni::JNIEnv&, jni::jint z, jni::jint x, jni::jint y) { |