Mapbox: Ensure we have the required class loader in place when converting types

This commit is contained in:
Marvin W 2020-10-19 13:16:08 +02:00
parent 93636a704d
commit 14dfd3e794
No known key found for this signature in database
GPG Key ID: 072E9235DB996F2A

View File

@ -51,6 +51,8 @@ fun ICancelableCallback.toMapbox(): MapboxMap.CancelableCallback =
fun Bundle.toMapbox(): Bundle { fun Bundle.toMapbox(): Bundle {
val newBundle = Bundle(this) val newBundle = Bundle(this)
val oldLoader = newBundle.classLoader
newBundle.classLoader = GmsLatLng::class.java.classLoader
for (key in newBundle.keySet()) { for (key in newBundle.keySet()) {
val value = newBundle.get(key) val value = newBundle.get(key)
when (value) { when (value) {
@ -60,6 +62,7 @@ fun Bundle.toMapbox(): Bundle {
is Bundle -> newBundle.putBundle(key, value.toMapbox()) is Bundle -> newBundle.putBundle(key, value.toMapbox())
} }
} }
newBundle.classLoader = oldLoader
return newBundle return newBundle
} }
@ -72,6 +75,8 @@ fun CameraPosition.toGms(): GmsCameraPosition =
fun Bundle.toGms(): Bundle { fun Bundle.toGms(): Bundle {
val newBundle = Bundle(this) val newBundle = Bundle(this)
val oldLoader = newBundle.classLoader
newBundle.classLoader = LatLng::class.java.classLoader
for (key in newBundle.keySet()) { for (key in newBundle.keySet()) {
val value = newBundle.get(key) val value = newBundle.get(key)
when (value) { when (value) {
@ -81,8 +86,9 @@ fun Bundle.toGms(): Bundle {
is Bundle -> newBundle.putBundle(key, value.toGms()) is Bundle -> newBundle.putBundle(key, value.toGms())
} }
} }
newBundle.classLoader = oldLoader
return newBundle return newBundle
} }
fun VisibleRegion.toGms(): GmsVisibleRegion = fun VisibleRegion.toGms(): GmsVisibleRegion =
GmsVisibleRegion(nearLeft.toGms(), nearRight.toGms(), farLeft.toGms(), farRight.toGms(), latLngBounds.toGms()) GmsVisibleRegion(nearLeft.toGms(), nearRight.toGms(), farLeft.toGms(), farRight.toGms(), latLngBounds.toGms())