-
Notifications
You must be signed in to change notification settings - Fork 319
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add empty waypoint names to HistoryEventMapper#mapNavigationRoute
as old records may not include them
#5627
Conversation
Revert PR mapbox/mapbox-java#1387 |
libnavigation-core/src/main/java/com/mapbox/navigation/core/history/model/HistoryEventMapper.kt
Show resolved
Hide resolved
b4bfddf
to
32e6622
Compare
private fun addWaypointNames(response: String): String { | ||
val gson = GsonBuilder().create() | ||
val jsonObject = gson.fromJson(response, JsonObject::class.java) | ||
val waypoints = jsonObject?.getAsJsonArray(WAYPOINTS_JSON_KEY) | ||
val isNameNotIncluded = waypoints?.get(0)?.asJsonObject?.get(NAME_JSON_KEY) == null | ||
if (isNameNotIncluded) { | ||
waypoints?.forEachIndexed { index, _ -> | ||
jsonObject.getAsJsonArray(WAYPOINTS_JSON_KEY) | ||
.get(index).asJsonObject.addProperty(NAME_JSON_KEY, "") | ||
} | ||
} | ||
return jsonObject.toString() | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private fun addWaypointNames(response: String): String { | |
val gson = GsonBuilder().create() | |
val jsonObject = gson.fromJson(response, JsonObject::class.java) | |
val waypoints = jsonObject?.getAsJsonArray(WAYPOINTS_JSON_KEY) | |
val isNameNotIncluded = waypoints?.get(0)?.asJsonObject?.get(NAME_JSON_KEY) == null | |
if (isNameNotIncluded) { | |
waypoints?.forEachIndexed { index, _ -> | |
jsonObject.getAsJsonArray(WAYPOINTS_JSON_KEY) | |
.get(index).asJsonObject.addProperty(NAME_JSON_KEY, "") | |
} | |
} | |
return jsonObject.toString() | |
} | |
private fun addWaypointNames(response: String): String { | |
val gson = GsonBuilder().create() | |
val jsonObject = gson.fromJson(response, JsonObject::class.java) | |
val waypoints = jsonObject?.getAsJsonArray(WAYPOINTS_JSON_KEY)?.map { it.asJsonObject } | |
waypoints?.forEach { waypoint -> | |
if (!waypoint.has(NAME_JSON_KEY)) { | |
waypoint.addProperty(NAME_JSON_KEY, "") | |
} | |
} | |
return jsonObject.toString() | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Simplifying this a little bit (please double check), otherwise, LGTM.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It worked
… records may not include them causing parsing issues when replaying old history files
32e6622
to
581b0a2
Compare
Description
Adds empty waypoint names to
HistoryEventMapper#mapNavigationRoute
as old records may not include them, causing parsing issues when replaying old history files.Follow up from #5614
This mapbox/mapbox-java#1386 is not needed anymore.
cc @SiarheiFedartsou @danpat @mskurydin