diff options
Diffstat (limited to 'platform/android/src/style')
-rw-r--r-- | platform/android/src/style/sources/custom_geometry_source.cpp | 19 | ||||
-rw-r--r-- | platform/android/src/style/sources/custom_geometry_source.hpp | 1 |
2 files changed, 18 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) { diff --git a/platform/android/src/style/sources/custom_geometry_source.hpp b/platform/android/src/style/sources/custom_geometry_source.hpp index c38926a5b9..801f81b089 100644 --- a/platform/android/src/style/sources/custom_geometry_source.hpp +++ b/platform/android/src/style/sources/custom_geometry_source.hpp @@ -33,6 +33,7 @@ public: void fetchTile(const mbgl::CanonicalTileID& tileID); void cancelTile(const mbgl::CanonicalTileID& tileID); + bool isCancelled(jni::jint z, jni::jint x, jni::jint y); void startThreads(); void releaseThreads(); void setTileData(jni::JNIEnv& env, jni::jint z, jni::jint x, jni::jint y, jni::Object<geojson::FeatureCollection> jf); |