@@ -49,38 +49,33 @@ GeoJSONSource::GeoJSONSource(jni::JNIEnv& env, const jni::String& sourceId, cons
4949 : Source(env,
5050 std::make_unique<mbgl::style::GeoJSONSource>(jni::Make<std::string>(env, sourceId),
5151 convertGeoJSONOptions (env, options))),
52- converter(std::make_unique<Actor<FeatureConverter>>(Scheduler::GetBackground(),
53- source.as<style::GeoJSONSource>()->impl().getOptions())) {}
52+ converter(std::make_unique<OptionalActor<FeatureConverter>>(
53+ source.as<style::GeoJSONSource>()->isUpdateSynchronous(),
54+ Scheduler::GetBackground(),
55+ source.as<style::GeoJSONSource>()->impl().getOptions()
56+ )) {}
5457
5558GeoJSONSource::GeoJSONSource (jni::JNIEnv& env, mbgl::style::Source& coreSource, AndroidRendererFrontend* frontend)
5659 : Source(env, coreSource, createJavaPeer(env), frontend),
57- converter(std::make_unique<Actor<FeatureConverter>>(Scheduler::GetBackground(),
58- source.as<style::GeoJSONSource>()->impl().getOptions())) {}
60+ converter(std::make_unique<OptionalActor<FeatureConverter>>(
61+ source.as<style::GeoJSONSource>()->isUpdateSynchronous(),
62+ Scheduler::GetBackground(),
63+ source.as<style::GeoJSONSource>()->impl().getOptions()
64+ )) {}
5965
6066GeoJSONSource::~GeoJSONSource () = default ;
6167
6268void GeoJSONSource::setGeoJSONString (jni::JNIEnv& env, const jni::String& jString) {
6369 std::shared_ptr<std::string> json = std::make_shared<std::string>(jni::Make<std::string>(env, jString));
6470
65- ActorRef <FeatureConverter> converterRef = converter->self ();
71+ OptionalActorRef <FeatureConverter> converterRef = converter->self ();
6672 Update::Converter converterFn = [converterRef, json](ActorRef<GeoJSONDataCallback> _callback) {
6773 converterRef.invoke (&FeatureConverter::convertJson, json, _callback);
6874 };
6975
7076 setAsync (converterFn);
7177}
7278
73- void GeoJSONSource::setGeoJSONStringSync (jni::JNIEnv& env, const jni::String& jString) {
74- std::shared_ptr<std::string> json = std::make_shared<std::string>(jni::Make<std::string>(env, jString));
75-
76- ActorRef<FeatureConverter> converterRef = converter->self ();
77- Update::Converter converterFn = [converterRef, json](ActorRef<GeoJSONDataCallback> _callback) {
78- converterRef.ask (&FeatureConverter::convertJson, json, _callback).wait ();
79- };
80-
81- setAsync (converterFn);
82- }
83-
8479void GeoJSONSource::setFeatureCollection (jni::JNIEnv& env, const jni::Object<geojson::FeatureCollection>& jFeatures) {
8580 setCollectionAsync (env, jFeatures);
8681}
@@ -93,19 +88,6 @@ void GeoJSONSource::setGeometry(jni::JNIEnv& env, const jni::Object<geojson::Geo
9388 setCollectionAsync (env, jGeometry);
9489}
9590
96- void GeoJSONSource::setFeatureCollectionSync (jni::JNIEnv& env,
97- const jni::Object<geojson::FeatureCollection>& jFeatures) {
98- setCollectionSync (env, jFeatures);
99- }
100-
101- void GeoJSONSource::setFeatureSync (jni::JNIEnv& env, const jni::Object<geojson::Feature>& jFeature) {
102- setCollectionSync (env, jFeature);
103- }
104-
105- void GeoJSONSource::setGeometrySync (jni::JNIEnv& env, const jni::Object<geojson::Geometry>& jGeometry) {
106- setCollectionSync (env, jGeometry);
107- }
108-
10991void GeoJSONSource::setURL (jni::JNIEnv& env, const jni::String& url) {
11092 // Update the core source
11193 source.as <style::GeoJSONSource>()->setURL (jni::Make<std::string>(env, url));
@@ -195,7 +177,7 @@ void GeoJSONSource::setCollectionAsync(jni::JNIEnv& env, const jni::Object<JNITy
195177 auto global = jni::NewGlobal<jni::EnvAttachingDeleter>(env, jObject);
196178 auto object = std::make_shared<decltype (global)>(std::move (global));
197179
198- ActorRef <FeatureConverter> converterRef = converter->self ();
180+ OptionalActorRef <FeatureConverter> converterRef = converter->self ();
199181 Update::Converter converterFn = [converterRef, object](ActorRef<GeoJSONDataCallback> _callback) {
200182 converterRef.invoke (&FeatureConverter::convertObject<JNIType>, object, _callback);
201183 };
@@ -233,19 +215,6 @@ void GeoJSONSource::setAsync(Update::Converter converterFn) {
233215 update->converterFn (update->callback ->self ());
234216}
235217
236- template <class JNIType >
237- void GeoJSONSource::setCollectionSync (jni::JNIEnv& env, const jni::Object<JNIType>& jObject) {
238- auto global = jni::NewGlobal<jni::EnvAttachingDeleter>(env, jObject);
239- auto object = std::make_shared<decltype (global)>(std::move (global));
240-
241- ActorRef<FeatureConverter> converterRef = converter->self ();
242- Update::Converter converterFn = [converterRef, object](ActorRef<GeoJSONDataCallback> _callback) {
243- converterRef.ask (&FeatureConverter::convertObject<JNIType>, object, _callback).wait ();
244- };
245-
246- setAsync (converterFn);
247- }
248-
249218jboolean GeoJSONSource::isUpdateSynchronous (jni::JNIEnv&) {
250219 return source.as <style::GeoJSONSource>()->isUpdateSynchronous ();
251220}
@@ -268,10 +237,6 @@ void GeoJSONSource::registerNative(jni::JNIEnv& env) {
268237 METHOD (&GeoJSONSource::setFeatureCollection, " nativeSetFeatureCollection" ),
269238 METHOD (&GeoJSONSource::setFeature, " nativeSetFeature" ),
270239 METHOD (&GeoJSONSource::setGeometry, " nativeSetGeometry" ),
271- METHOD (&GeoJSONSource::setGeoJSONStringSync, " nativeSetGeoJsonStringSync" ),
272- METHOD (&GeoJSONSource::setFeatureCollectionSync, " nativeSetFeatureCollectionSync" ),
273- METHOD (&GeoJSONSource::setFeatureSync, " nativeSetFeatureSync" ),
274- METHOD (&GeoJSONSource::setGeometrySync, " nativeSetGeometrySync" ),
275240 METHOD (&GeoJSONSource::setURL, " nativeSetUrl" ),
276241 METHOD (&GeoJSONSource::getURL, " nativeGetUrl" ),
277242 METHOD (&GeoJSONSource::querySourceFeatures, " querySourceFeatures" ),
0 commit comments