[android] jni.hpp 4.0.0
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
namespace mbgl {
|
||||
namespace android {
|
||||
|
||||
CustomLayer::CustomLayer(jni::JNIEnv& env, jni::String layerId, jni::jlong host)
|
||||
CustomLayer::CustomLayer(jni::JNIEnv& env, const jni::String& layerId, jni::jlong host)
|
||||
: Layer(env, std::make_unique<mbgl::style::CustomLayer>(
|
||||
jni::Make<std::string>(env, layerId),
|
||||
std::unique_ptr<mbgl::style::CustomLayerHost>(reinterpret_cast<mbgl::style::CustomLayerHost*>(host)))
|
||||
@@ -33,22 +33,22 @@ namespace android {
|
||||
}
|
||||
}
|
||||
|
||||
jni::jobject* CustomLayer::createJavaPeer(jni::JNIEnv& env) {
|
||||
static auto javaClass = jni::Class<CustomLayer>::Singleton(env);
|
||||
jni::Local<jni::Object<Layer>> CustomLayer::createJavaPeer(jni::JNIEnv& env) {
|
||||
static auto& javaClass = jni::Class<CustomLayer>::Singleton(env);
|
||||
static auto constructor = javaClass.GetConstructor<jni::jlong>(env);
|
||||
return javaClass.New(env, constructor, reinterpret_cast<jni::jlong>(this));
|
||||
}
|
||||
|
||||
void CustomLayer::registerNative(jni::JNIEnv& env) {
|
||||
// Lookup the class
|
||||
static auto javaClass = jni::Class<CustomLayer>::Singleton(env);
|
||||
static auto& javaClass = jni::Class<CustomLayer>::Singleton(env);
|
||||
|
||||
#define METHOD(MethodPtr, name) jni::MakeNativePeerMethod<decltype(MethodPtr), (MethodPtr)>(name)
|
||||
|
||||
// Register the peer
|
||||
jni::RegisterNativePeer<CustomLayer>(
|
||||
env, javaClass, "nativePtr",
|
||||
std::make_unique<CustomLayer, JNIEnv&, jni::String, jni::jlong>,
|
||||
jni::MakePeer<CustomLayer, const jni::String&, jni::jlong>,
|
||||
"initialize",
|
||||
"finalize",
|
||||
METHOD(&CustomLayer::update, "nativeUpdate"));
|
||||
|
||||
Reference in New Issue
Block a user