diff options
author | Kevin Li <kevin.li@mapbox.com> | 2020-02-24 18:47:16 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-24 18:47:16 +0800 |
commit | 43c1aac7e800d5f1695fd08639a2db5c1e1dd1af (patch) | |
tree | 1df90cb848f2fbe69010fe863b9008b835c01755 | |
parent | 5fcc6cf24f6fc7606cf033e3b76363d0924e273b (diff) | |
download | qtlocation-mapboxgl-43c1aac7e800d5f1695fd08639a2db5c1e1dd1af.tar.gz |
[android] add jni binding for source zoom delta (#16221)
* [android] and jni interface for source zoom delta
* handle nullopt in setter and getter
* Use jni::Integer
-rw-r--r-- | platform/android/src/style/sources/source.cpp | 27 | ||||
-rw-r--r-- | platform/android/src/style/sources/source.hpp | 4 |
2 files changed, 27 insertions, 4 deletions
diff --git a/platform/android/src/style/sources/source.cpp b/platform/android/src/style/sources/source.cpp index 786e5cb586..fda0f0084c 100644 --- a/platform/android/src/style/sources/source.cpp +++ b/platform/android/src/style/sources/source.cpp @@ -93,6 +93,22 @@ namespace android { return attribution ? jni::Make<jni::String>(env, attribution.value()) : jni::Make<jni::String>(env,""); } + void Source::setPrefetchZoomDelta(jni::JNIEnv& env, jni::Integer& delta) { + if (!delta) { + source.setPrefetchZoomDelta(nullopt); + } else { + source.setPrefetchZoomDelta(jni::Unbox(env, delta)); + } + } + + jni::Local<jni::Integer> Source::getPrefetchZoomDelta(jni::JNIEnv& env) { + auto delta = source.getPrefetchZoomDelta(); + if (delta.has_value()) { + return jni::Box(env, jni::jint(delta.value())); + } + return jni::Local<jni::Integer>(env, nullptr); + } + void Source::addToMap(JNIEnv& env, const jni::Object<Source>& obj, mbgl::Map& map, AndroidRendererFrontend& frontend) { // Check to see if we own the source first if (!ownedSource) { @@ -149,10 +165,13 @@ namespace android { #define METHOD(MethodPtr, name) jni::MakeNativePeerMethod<decltype(MethodPtr), (MethodPtr)>(name) // Register the peer - jni::RegisterNativePeer<Source>(env, javaClass, "nativePtr", - METHOD(&Source::getId, "nativeGetId"), - METHOD(&Source::getAttribution, "nativeGetAttribution") - ); + jni::RegisterNativePeer<Source>(env, + javaClass, + "nativePtr", + METHOD(&Source::getId, "nativeGetId"), + METHOD(&Source::getAttribution, "nativeGetAttribution"), + METHOD(&Source::setPrefetchZoomDelta, "nativeSetPrefetchZoomDelta"), + METHOD(&Source::getPrefetchZoomDelta, "nativeGetPrefetchZoomDelta")); // Register subclasses GeoJSONSource::registerNative(env); diff --git a/platform/android/src/style/sources/source.hpp b/platform/android/src/style/sources/source.hpp index 93b706425a..91e31ea8e2 100644 --- a/platform/android/src/style/sources/source.hpp +++ b/platform/android/src/style/sources/source.hpp @@ -43,6 +43,10 @@ public: jni::Local<jni::String> getAttribution(jni::JNIEnv&); + void setPrefetchZoomDelta(jni::JNIEnv& env, jni::Integer& delta); + + jni::Local<jni::Integer> getPrefetchZoomDelta(jni::JNIEnv&); + protected: // Set on newly created sources until added to the map. std::unique_ptr<mbgl::style::Source> ownedSource; |