feat: add RN WeatherRuntime bridge test host
This commit is contained in:
@@ -81,6 +81,14 @@ public final class MapLibreMap {
|
||||
@Nullable
|
||||
private Style style;
|
||||
|
||||
/**
|
||||
* Optional weather facade attached to this concrete map instance. It is deliberately owned by
|
||||
* the map rather than by an application or bridge registry, so a style replacement and a map
|
||||
* teardown cannot accidentally leave a facade pointing at another map.
|
||||
*/
|
||||
@Nullable
|
||||
private WeatherRuntime weatherRuntime;
|
||||
|
||||
private boolean debugActive;
|
||||
private boolean started;
|
||||
|
||||
@@ -171,6 +179,31 @@ public final class MapLibreMap {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces this map's style-scoped weather facade. The caller must have already verified the
|
||||
* configured source and layers in the currently loaded style.
|
||||
*/
|
||||
@NonNull
|
||||
public WeatherRuntime replaceWeatherRuntime(@NonNull WeatherRuntime.Config config) {
|
||||
disposeWeatherRuntime();
|
||||
weatherRuntime = new WeatherRuntime(this, config);
|
||||
return weatherRuntime;
|
||||
}
|
||||
|
||||
/** Returns this map's attached weather facade, or null when no style-ready facade exists. */
|
||||
@Nullable
|
||||
public WeatherRuntime getWeatherRuntime() {
|
||||
return weatherRuntime;
|
||||
}
|
||||
|
||||
/** Disposes and detaches the style-scoped weather facade. Safe to call repeatedly. */
|
||||
public void disposeWeatherRuntime() {
|
||||
if (weatherRuntime != null) {
|
||||
weatherRuntime.dispose();
|
||||
weatherRuntime = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the hosting Activity/Fragment onStart() method is called.
|
||||
*/
|
||||
@@ -1223,6 +1256,9 @@ public final class MapLibreMap {
|
||||
* @see Style
|
||||
*/
|
||||
public void setStyle(Style.Builder builder, final Style.OnStyleLoaded callback) {
|
||||
// A WeatherRuntime only controls objects from one loaded style. Never let it survive a
|
||||
// replacement where identical IDs could refer to newly-created style objects.
|
||||
disposeWeatherRuntime();
|
||||
styleLoadedCallback = callback;
|
||||
locationComponent.onStartLoadingMap();
|
||||
if (style != null) {
|
||||
|
||||
@@ -132,6 +132,8 @@ public final class WeatherRuntime {
|
||||
scheduleCadenceWake();
|
||||
return CommandResult.ACCEPTED;
|
||||
}
|
||||
/** Native-authoritative playback mode for a low-frequency Host snapshot. */
|
||||
public PlaybackState getPlaybackState() { return playbackState; }
|
||||
public TargetFps getTargetFps() { return targetFps; }
|
||||
public CommandResult setWeatherColorStops(@NonNull List<ColorStop> stops) {
|
||||
if (disposed) return CommandResult.REJECTED;
|
||||
|
||||
Reference in New Issue
Block a user