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