summaryrefslogtreecommitdiff
path: root/platform/android/src/style/sources/raster_dem_source.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'platform/android/src/style/sources/raster_dem_source.cpp')
-rw-r--r--platform/android/src/style/sources/raster_dem_source.cpp21
1 files changed, 10 insertions, 11 deletions
diff --git a/platform/android/src/style/sources/raster_dem_source.cpp b/platform/android/src/style/sources/raster_dem_source.cpp
index 75e0159d7c..f60526a9b7 100644
--- a/platform/android/src/style/sources/raster_dem_source.cpp
+++ b/platform/android/src/style/sources/raster_dem_source.cpp
@@ -12,7 +12,7 @@
namespace mbgl {
namespace android {
- RasterDEMSource::RasterDEMSource(jni::JNIEnv& env, jni::String sourceId, jni::Object<> urlOrTileSet, jni::jint tileSize)
+ RasterDEMSource::RasterDEMSource(jni::JNIEnv& env, const jni::String& sourceId, const jni::Object<>& urlOrTileSet, jni::jint tileSize)
: Source(
env,
std::make_unique<mbgl::style::RasterDEMSource>(
@@ -31,28 +31,27 @@ namespace android {
RasterDEMSource::~RasterDEMSource() = default;
- jni::String RasterDEMSource::getURL(jni::JNIEnv& env) {
+ jni::Local<jni::String> RasterDEMSource::getURL(jni::JNIEnv& env) {
optional<std::string> url = source.as<mbgl::style::RasterDEMSource>()->RasterDEMSource::getURL();
- return url ? jni::Make<jni::String>(env, *url) : jni::String();
+ return url ? jni::Make<jni::String>(env, *url) : jni::Local<jni::String>();
}
- jni::Class<RasterDEMSource> RasterDEMSource::javaClass;
-
- jni::Object<Source> RasterDEMSource::createJavaPeer(jni::JNIEnv& env) {
- static auto constructor = RasterDEMSource::javaClass.template GetConstructor<jni::jlong>(env);
- return jni::Object<Source>(RasterDEMSource::javaClass.New(env, constructor, reinterpret_cast<jni::jlong>(this)).Get());
+ jni::Local<jni::Object<Source>> RasterDEMSource::createJavaPeer(jni::JNIEnv& env) {
+ static auto& javaClass = jni::Class<RasterDEMSource>::Singleton(env);
+ static auto constructor = javaClass.GetConstructor<jni::jlong>(env);
+ return javaClass.New(env, constructor, reinterpret_cast<jni::jlong>(this));
}
void RasterDEMSource::registerNative(jni::JNIEnv& env) {
// Lookup the class
- RasterDEMSource::javaClass = *jni::Class<RasterDEMSource>::Find(env).NewGlobalRef(env).release();
+ static auto& javaClass = jni::Class<RasterDEMSource>::Singleton(env);
#define METHOD(MethodPtr, name) jni::MakeNativePeerMethod<decltype(MethodPtr), (MethodPtr)>(name)
// Register the peer
jni::RegisterNativePeer<RasterDEMSource>(
- env, RasterDEMSource::javaClass, "nativePtr",
- std::make_unique<RasterDEMSource, JNIEnv&, jni::String, jni::Object<>, jni::jint>,
+ env, javaClass, "nativePtr",
+ jni::MakePeer<RasterDEMSource, const jni::String&, const jni::Object<>&, jni::jint>,
"initialize",
"finalize",
METHOD(&RasterDEMSource::getURL, "nativeGetUrl")