[android] jni.hpp 4.0.0
This commit is contained in:
@@ -8,18 +8,18 @@ namespace geojson {
|
||||
|
||||
using namespace gson;
|
||||
|
||||
mbgl::Feature Feature::convert(jni::JNIEnv& env, jni::Object<Feature> jFeature) {
|
||||
static auto javaClass = jni::Class<Feature>::Singleton(env);
|
||||
mbgl::Feature Feature::convert(jni::JNIEnv& env, const jni::Object<Feature>& jFeature) {
|
||||
static auto& javaClass = jni::Class<Feature>::Singleton(env);
|
||||
static auto id = javaClass.GetMethod<jni::String ()>(env, "id");
|
||||
static auto geometry = javaClass.GetMethod<jni::Object<Geometry> ()>(env, "geometry");
|
||||
static auto properties = javaClass.GetMethod<jni::Object<gson::JsonObject> ()>(env, "properties");
|
||||
|
||||
auto jId = jni::SeizeLocal(env, jFeature.Call(env, id));
|
||||
auto jId = jFeature.Call(env, id);
|
||||
|
||||
return mbgl::Feature {
|
||||
Geometry::convert(env, *jni::SeizeLocal(env, jFeature.Call(env, geometry))),
|
||||
JsonObject::convert(env, *jni::SeizeLocal(env, jFeature.Call(env, properties))),
|
||||
jId ? std::experimental::optional<mapbox::geometry::identifier>(jni::Make<std::string>(env, *jId))
|
||||
Geometry::convert(env, jFeature.Call(env, geometry)),
|
||||
JsonObject::convert(env, jFeature.Call(env, properties)),
|
||||
jId ? std::experimental::optional<mapbox::geometry::identifier>(jni::Make<std::string>(env, jId))
|
||||
: std::experimental::nullopt
|
||||
};
|
||||
}
|
||||
@@ -43,21 +43,21 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
jni::Object<Feature> convertFeature(jni::JNIEnv& env, const mbgl::Feature& value) {
|
||||
static auto javaClass = jni::Class<Feature>::Singleton(env);
|
||||
jni::Local<jni::Object<Feature>> convertFeature(jni::JNIEnv& env, const mbgl::Feature& value) {
|
||||
static auto& javaClass = jni::Class<Feature>::Singleton(env);
|
||||
static auto method = javaClass.GetStaticMethod<jni::Object<Feature> (jni::Object<Geometry>, jni::Object<JsonObject>, jni::String)>(env, "fromGeometry");
|
||||
|
||||
return javaClass.Call(env, method,
|
||||
*jni::SeizeLocal(env, Geometry::New(env, value.geometry)),
|
||||
*jni::SeizeLocal(env, JsonObject::New(env, value.properties)),
|
||||
*jni::SeizeLocal(env, jni::Make<jni::String>(env, value.id ? value.id.value().match(FeatureIdVisitor()) : "")));
|
||||
Geometry::New(env, value.geometry),
|
||||
JsonObject::New(env, value.properties),
|
||||
jni::Make<jni::String>(env, value.id ? value.id.value().match(FeatureIdVisitor()) : ""));
|
||||
}
|
||||
|
||||
jni::Array<jni::Object<Feature>> Feature::convert(jni::JNIEnv& env, const std::vector<mbgl::Feature>& value) {
|
||||
jni::Local<jni::Array<jni::Object<Feature>>> Feature::convert(jni::JNIEnv& env, const std::vector<mbgl::Feature>& value) {
|
||||
auto features = jni::Array<jni::Object<Feature>>::New(env, value.size());
|
||||
|
||||
for (size_t i = 0; i < value.size(); i = i + 1) {
|
||||
features.Set(env, i, *jni::SeizeLocal(env, convertFeature(env, value.at(i))));
|
||||
features.Set(env, i, convertFeature(env, value.at(i)));
|
||||
}
|
||||
|
||||
return features;
|
||||
|
||||
Reference in New Issue
Block a user