[android] Put function inverses next to each other
This commit is contained in:
@@ -19,6 +19,21 @@ std::vector<std::string> toVector(JNIEnv& env, jni::Array<jni::String> array) {
|
||||
return vector;
|
||||
}
|
||||
|
||||
jni::Array<jni::String> toArray(JNIEnv& env, const std::vector<std::string>& vector) {
|
||||
static auto clazz = *jni::Class<jni::StringTag>::Find(env).NewGlobalRef(env).release();
|
||||
auto result = jni::Array<jni::String>::New(env, vector.size(), clazz);
|
||||
|
||||
std::size_t index = 0;
|
||||
for (auto&& item : vector) {
|
||||
auto element = jni::Make<jni::String>(env, item);
|
||||
result.Set(env, index, element);
|
||||
DeleteLocalRef(env, element);
|
||||
index++;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ namespace android {
|
||||
namespace conversion {
|
||||
|
||||
std::vector<std::string> toVector(JNIEnv& env, jni::Array<jni::String> array);
|
||||
jni::Array<jni::String> toArray(JNIEnv& env, const std::vector<std::string>&);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <jni/jni.hpp>
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace jni {
|
||||
|
||||
inline Array<String> MakeAnything(ThingToMake<Array<String>>, JNIEnv& env, const std::vector<std::string>& vector)
|
||||
{
|
||||
static auto clazz = *Class<StringTag>::Find(env).NewGlobalRef(env).release();
|
||||
auto result = Array<String>::New(env, vector.size(), clazz);
|
||||
|
||||
std::size_t index = 0;
|
||||
for (auto&& item : vector) {
|
||||
auto element = Make<jni::String>(env, item);
|
||||
result.Set(env, index, element);
|
||||
DeleteLocalRef(env, element);
|
||||
index++;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "map_snapshot.hpp"
|
||||
|
||||
#include "../bitmap.hpp"
|
||||
#include "../jni/collection.hpp"
|
||||
#include "../conversion/collection.hpp"
|
||||
|
||||
#include <memory>
|
||||
|
||||
@@ -40,7 +40,7 @@ jni::Object<MapSnapshot> MapSnapshot::New(JNIEnv& env,
|
||||
// Create the Mapsnapshot peers
|
||||
static auto constructor = javaClass.GetConstructor<jni::jlong, jni::Object<Bitmap>, jni::Array<jni::String>, jni::jboolean>(env);
|
||||
auto nativePeer = std::make_unique<MapSnapshot>(pixelRatio, pointForFn, latLngForFn);
|
||||
return javaClass.New(env, constructor, reinterpret_cast<jlong>(nativePeer.release()), bitmap, jni::Make<jni::Array<jni::String>>(env, attributions), (jni::jboolean) showLogo);
|
||||
return javaClass.New(env, constructor, reinterpret_cast<jlong>(nativePeer.release()), bitmap, conversion::toArray(env, attributions), (jni::jboolean) showLogo);
|
||||
}
|
||||
|
||||
jni::Class<MapSnapshot> MapSnapshot::javaClass;
|
||||
|
||||
Reference in New Issue
Block a user