From b3ca4f92d2b71e66d71221d0544e4ac86fcecb23 Mon Sep 17 00:00:00 2001 From: Pablo Guardiola Date: Thu, 12 Jan 2023 15:47:21 +0100 Subject: [PATCH] fix copilot unrecognized fields serialization --- .../com/mapbox/navigation/copilot/MapboxCopilotImpl.kt | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/libnavigation-copilot/src/main/java/com/mapbox/navigation/copilot/MapboxCopilotImpl.kt b/libnavigation-copilot/src/main/java/com/mapbox/navigation/copilot/MapboxCopilotImpl.kt index 4146ee91c95..d1fab41ef31 100644 --- a/libnavigation-copilot/src/main/java/com/mapbox/navigation/copilot/MapboxCopilotImpl.kt +++ b/libnavigation-copilot/src/main/java/com/mapbox/navigation/copilot/MapboxCopilotImpl.kt @@ -4,8 +4,11 @@ import android.content.pm.ApplicationInfo import androidx.lifecycle.DefaultLifecycleObserver import androidx.lifecycle.LifecycleOwner import androidx.lifecycle.ProcessLifecycleOwner -import com.google.gson.Gson +import com.google.gson.GsonBuilder +import com.mapbox.api.directions.v5.DirectionsAdapterFactory import com.mapbox.common.UploadOptions +import com.mapbox.geojson.Point +import com.mapbox.geojson.PointAsCoordinatesTypeAdapter import com.mapbox.navigation.base.ExperimentalPreviewMapboxNavigationAPI import com.mapbox.navigation.base.route.NavigationRoute import com.mapbox.navigation.copilot.HistoryAttachmentsUtils.copyToAndRemove @@ -397,7 +400,10 @@ internal class MapboxCopilotImpl( internal companion object { - internal val gson = Gson() + internal val gson = GsonBuilder() + .registerTypeAdapterFactory(DirectionsAdapterFactory.create()) + .registerTypeAdapter(Point::class.java, PointAsCoordinatesTypeAdapter()) + .create() internal const val GZ = "gz" internal const val ZIP = "zip" internal const val MEDIA_TYPE_ZIP = "application/zip"