summaryrefslogtreecommitdiff
path: root/platform/android/src/style/sources/custom_geometry_source.cpp
diff options
context:
space:
mode:
authorAsheem Mamoowala <asheem.mamoowala@mapbox.com>2017-11-13 16:06:26 -0800
committerAsheem Mamoowala <asheem.mamoowala@mapbox.com>2017-11-21 17:25:06 -0800
commit4e73963c5c85b32f1aa1f45a78f37ba671bcf987 (patch)
treeb61e25ce32fbdf394d131f15372a6226471cdef1 /platform/android/src/style/sources/custom_geometry_source.cpp
parent321e6ebf8d613d2a2ab30574f710be3104ac1d6e (diff)
downloadqtlocation-mapboxgl-4e73963c5c85b32f1aa1f45a78f37ba671bcf987.tar.gz
[android] Reuse Java Source objects by holding on to a strong reference in the C++ peer.
Diffstat (limited to 'platform/android/src/style/sources/custom_geometry_source.cpp')
-rw-r--r--platform/android/src/style/sources/custom_geometry_source.cpp10
1 files changed, 8 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 e647975e4d..205fe55ed9 100644
--- a/platform/android/src/style/sources/custom_geometry_source.cpp
+++ b/platform/android/src/style/sources/custom_geometry_source.cpp
@@ -46,6 +46,12 @@ namespace android {
javaPeer(_obj.NewGlobalRef(env)) {
}
+ CustomGeometrySource::CustomGeometrySource(jni::JNIEnv& env,
+ mbgl::style::Source& coreSource,
+ AndroidRendererFrontend& frontend)
+ : Source(env, coreSource, createJavaPeer(env), frontend) {
+ }
+
CustomGeometrySource::~CustomGeometrySource() = default;
void CustomGeometrySource::fetchTile (const mbgl::CanonicalTileID& tileID) {
@@ -94,9 +100,9 @@ namespace android {
jni::Class<CustomGeometrySource> CustomGeometrySource::javaClass;
- jni::jobject* CustomGeometrySource::createJavaPeer(jni::JNIEnv& env) {
+ jni::Object<Source> CustomGeometrySource::createJavaPeer(jni::JNIEnv& env) {
static auto constructor = CustomGeometrySource::javaClass.template GetConstructor<jni::jlong>(env);
- return CustomGeometrySource::javaClass.New(env, constructor, reinterpret_cast<jni::jlong>(this));
+ return jni::Object<Source>(CustomGeometrySource::javaClass.New(env, constructor, reinterpret_cast<jni::jlong>(this)).Get());
}
void CustomGeometrySource::registerNative(jni::JNIEnv& env) {