Skip to content

Commit 1fba6ba

Browse files
author
Łukasz Paczos
committed
fixed an issue where DirectionsResponse#waypoints list was cleared after a successful non-EV route refresh
1 parent eefc831 commit 1fba6ba

File tree

4 files changed

+36
-17
lines changed

4 files changed

+36
-17
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ Mapbox welcomes participation and contributions from everyone.
3535
- Fixed an issue where "silent waypoints" (not regular waypoints that define legs) had markers added on the map when route line was drawn with `MapboxRouteLineApi` and `MapboxRouteLineView`. [#6526](https://github.com/mapbox/mapbox-navigation-android/pull/6526)
3636
- Slightly improved performance of updates to the traveled portion of the route in MapboxRouteLineView. [#6528](https://github.com/mapbox/mapbox-navigation-android/pull/6528)
3737
- Fixed an issue with `NavigationView` that caused road label position to not update in some cases. [#6531](https://github.com/mapbox/mapbox-navigation-android/pull/6531)
38+
- Fixed an issue where `DirectionsResponse#waypoints` list was cleared after a successful non-EV route refresh. [#6539](https://github.com/mapbox/mapbox-navigation-android/pull/6539)
3839

3940
## Mapbox Navigation SDK 2.10.0-alpha.1 - 28 October, 2022
4041
### Changelog

instrumentation-tests/src/androidTest/java/com/mapbox/navigation/instrumentation_tests/core/RouteRefreshTest.kt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,14 @@ class RouteRefreshTest : BaseTest<EmptyTestActivity>(EmptyTestActivity::class.ja
265265
refreshedRoutes[1].directionsRoute.legs()!!.first().duration()!!,
266266
0.0001
267267
)
268+
assertEquals(
269+
requestedRoutes[0].directionsResponse.waypoints(),
270+
refreshedRoutes[0].directionsResponse.waypoints()
271+
)
272+
assertEquals(
273+
requestedRoutes[1].directionsResponse.waypoints(),
274+
refreshedRoutes[1].directionsResponse.waypoints()
275+
)
268276
}
269277

270278
@Test
@@ -508,6 +516,16 @@ class RouteRefreshTest : BaseTest<EmptyTestActivity>(EmptyTestActivity::class.ja
508516
),
509517
refreshedRoutes[0].directionsRoute.legs()!![1].closures()
510518
)
519+
520+
// waypoints
521+
assertEquals(
522+
requestedRoutes[0].directionsResponse.waypoints(),
523+
refreshedRoutes[0].directionsResponse.waypoints()
524+
)
525+
assertEquals(
526+
requestedRoutes[1].directionsResponse.waypoints(),
527+
refreshedRoutes[1].directionsResponse.waypoints()
528+
)
511529
}
512530

513531
@Test
@@ -584,6 +602,12 @@ class RouteRefreshTest : BaseTest<EmptyTestActivity>(EmptyTestActivity::class.ja
584602
),
585603
refreshedRoutes[0].directionsRoute.legs()!![1].closures()
586604
)
605+
606+
// waypoints
607+
assertEquals(
608+
requestedRoutes[0].directionsResponse.waypoints(),
609+
refreshedRoutes[0].directionsResponse.waypoints()
610+
)
587611
}
588612

589613
private fun List<Incident>.extract(vararg extractors: Incident.() -> Any?): List<List<Any?>> {

libnavigation-base/src/main/java/com/mapbox/navigation/base/internal/route/NavigationRouteEx.kt

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -198,21 +198,11 @@ private fun DirectionsResponse.Builder.updateWaypoints(
198198
oldWaypoints: List<DirectionsWaypoint>?,
199199
updatedWaypoints: List<DirectionsWaypoint?>?,
200200
): DirectionsResponse.Builder {
201-
if (oldWaypoints == null) {
201+
if (oldWaypoints == null || updatedWaypoints == null) {
202202
return this
203203
}
204-
val newWaypoints = mutableListOf<DirectionsWaypoint>()
205-
if (updatedWaypoints != null) {
206-
oldWaypoints.forEachIndexed { index, oldWaypoint ->
207-
if (index < updatedWaypoints.size) {
208-
val updatedWaypoint = updatedWaypoints[index]
209-
if (updatedWaypoint == null) {
210-
newWaypoints.add(oldWaypoint)
211-
} else {
212-
newWaypoints.add(updatedWaypoint)
213-
}
214-
}
215-
}
204+
val newWaypoints = oldWaypoints.mapIndexed { index, oldWaypoint ->
205+
updatedWaypoints.getOrNull(index) ?: oldWaypoint
216206
}
217207
return waypoints(newWaypoints)
218208
}

libnavigation-base/src/test/java/com/mapbox/navigation/base/internal/route/NavigationRouteExTest.kt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ class NavigationRouteExTest {
350350
listOf(provideDefaultLegAnnotation(), null),
351351
listOf(provideDefaultIncidents(), null),
352352
listOf(provideDefaultClosures(), null),
353-
emptyList(),
353+
waypoints,
354354
0
355355
),
356356
)
@@ -375,7 +375,7 @@ class NavigationRouteExTest {
375375
listOf(provideDefaultLegAnnotation(), null),
376376
listOf(provideDefaultIncidents(), null),
377377
listOf(provideDefaultClosures(), null),
378-
emptyList(),
378+
waypoints,
379379
0
380380
),
381381
)
@@ -404,7 +404,7 @@ class NavigationRouteExTest {
404404
listOf(provideDefaultLegAnnotation(), null),
405405
listOf(provideDefaultIncidents(), null),
406406
listOf(provideDefaultClosures(), null),
407-
listOf(createWaypoint("name3")),
407+
listOf(createWaypoint("name3"), createWaypoint("name2")),
408408
0
409409
),
410410
)
@@ -500,7 +500,6 @@ class NavigationRouteExTest {
500500
),
501501
)
502502
},
503-
504503
run {
505504
val refreshedWaypoints = listOf(
506505
createWaypoint("name11"),
@@ -751,6 +750,11 @@ class NavigationRouteExTest {
751750
result.newWaypoints,
752751
updatedNavRoute.directionsResponse.waypoints()
753752
)
753+
assertEquals(
754+
description,
755+
navRoute.directionsResponse.waypoints()?.size,
756+
updatedNavRoute.directionsResponse.waypoints()?.size
757+
)
754758

755759
val capturedOldAnnotations = mutableListOf<LegAnnotation?>()
756760
val capturedNewAnnotations = mutableListOf<LegAnnotation?>()

0 commit comments

Comments
 (0)