diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2018-08-17 13:43:07 -0700 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2018-09-07 09:44:12 -0700 |
commit | 53c3c327f0ebea276d977f58a59cdb9449165518 (patch) | |
tree | 1315a80a1c24f24dd1cbd4e00cf85083be16ce45 /platform/android/src/geojson/feature.cpp | |
parent | 6806ba5b52129050c0944bd7c8b1fe285baeeddc (diff) | |
download | qtlocation-mapboxgl-53c3c327f0ebea276d977f58a59cdb9449165518.tar.gz |
[android] Upgrade to latest jni.hpp
Diffstat (limited to 'platform/android/src/geojson/feature.cpp')
-rw-r--r-- | platform/android/src/geojson/feature.cpp | 43 |
1 files changed, 18 insertions, 25 deletions
diff --git a/platform/android/src/geojson/feature.cpp b/platform/android/src/geojson/feature.cpp index d8a4e829e2..1e02c756eb 100644 --- a/platform/android/src/geojson/feature.cpp +++ b/platform/android/src/geojson/feature.cpp @@ -7,57 +7,50 @@ namespace android { namespace geojson { mbgl::Feature Feature::convert(jni::JNIEnv& env, jni::Object<Feature> jFeature) { - // Convert - auto jGeometry = geometry(env, jFeature); - auto jProperties = Feature::properties(env, jFeature); + auto jGeometry = jni::SeizeLocal(env, geometry(env, jFeature)); + auto jProperties = jni::SeizeLocal(env, Feature::properties(env, jFeature)); std::experimental::optional<mapbox::geometry::identifier> id; - auto jId = Feature::id(env, jFeature); + auto jId = jni::SeizeLocal(env, Feature::id(env, jFeature)); if (jId) { - id = { jni::Make<std::string>(env, jId) }; + id = { jni::Make<std::string>(env, *jId) }; } - auto feature = mbgl::Feature { - Geometry::convert(env, jGeometry), - gson::JsonObject::convert(env, jProperties), - id + return mbgl::Feature { + Geometry::convert(env, *jGeometry), + gson::JsonObject::convert(env, *jProperties), + id }; - - // Cleanup - jni::DeleteLocalRef(env, jGeometry); - jni::DeleteLocalRef(env, jProperties); - jni::DeleteLocalRef(env, jId); - - return feature; } jni::Object<Geometry> Feature::geometry(jni::JNIEnv& env, jni::Object<Feature> jFeature) { - static auto method = Feature::javaClass.GetMethod<jni::Object<Geometry> ()>(env, "geometry"); + static auto javaClass = jni::Class<Feature>::Singleton(env); + static auto method = javaClass.GetMethod<jni::Object<Geometry> ()>(env, "geometry"); return jFeature.Call(env, method); } jni::Object<gson::JsonObject> Feature::properties(jni::JNIEnv& env, jni::Object<Feature> jFeature) { - static auto method = Feature::javaClass.GetMethod<jni::Object<gson::JsonObject> ()>(env, "properties"); + static auto javaClass = jni::Class<Feature>::Singleton(env); + static auto method = javaClass.GetMethod<jni::Object<gson::JsonObject> ()>(env, "properties"); return jFeature.Call(env, method); } jni::String Feature::id(jni::JNIEnv& env, jni::Object<Feature> jFeature) { - static auto method = Feature::javaClass.GetMethod<jni::String ()>(env, "id"); + static auto javaClass = jni::Class<Feature>::Singleton(env); + static auto method = javaClass.GetMethod<jni::String ()>(env, "id"); return jFeature.Call(env, method); } jni::Object<Feature> Feature::fromGeometry(jni::JNIEnv& env, jni::Object<Geometry> geometry, jni::Object<gson::JsonObject> properties, jni::String id) { - static auto method = Feature::javaClass.GetStaticMethod<jni::Object<Feature> (jni::Object<Geometry>, jni::Object<gson::JsonObject>, jni::String)>(env, "fromGeometry"); - return Feature::javaClass.Call(env, method, geometry, properties, id); + static auto javaClass = jni::Class<Feature>::Singleton(env); + static auto method = javaClass.GetStaticMethod<jni::Object<Feature> (jni::Object<Geometry>, jni::Object<gson::JsonObject>, jni::String)>(env, "fromGeometry"); + return javaClass.Call(env, method, geometry, properties, id); } void Feature::registerNative(jni::JNIEnv& env) { - // Lookup the class - Feature::javaClass = *jni::Class<Feature>::Find(env).NewGlobalRef(env).release(); + jni::Class<Feature>::Singleton(env); } -jni::Class<Feature> Feature::javaClass; - } // namespace geojson } // namespace android } // namespace mbgl
\ No newline at end of file |