Skip to content

Commit cbcd909

Browse files
committed
use null navigator for recreation
1 parent abde0eb commit cbcd909

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

libnavigation-core/src/main/java/com/mapbox/navigation/core/MapboxNavigation.kt

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -470,15 +470,7 @@ class MapboxNavigation @VisibleForTesting internal constructor(
470470
tilesVersion = navigationOptions.routingTilesOptions.tilesVersion
471471
),
472472
navigationOptions.accessToken ?: "",
473-
if (moduleRouter.isInternalImplementation()) {
474-
// We pass null to let NN know that default router is used and it can rely
475-
// on implementation details in some cases like offline-online switch.
476-
// Meanwhile platform SDK uses its own instance of native router for
477-
// route requests
478-
null
479-
} else {
480-
RouterInterfaceAdapter(moduleRouter, ::getNavigationRoutes)
481-
},
473+
getRouterInterfaceForNativeNavigator()
482474
)
483475
etcGateAPI = EtcGateApi(navigator.experimental)
484476

@@ -620,6 +612,18 @@ class MapboxNavigation @VisibleForTesting internal constructor(
620612
roadObjectMatcher = RoadObjectMatcher(navigator)
621613
}
622614

615+
private fun getRouterInterfaceForNativeNavigator(): RouterInterface? {
616+
return if (moduleRouter.isInternalImplementation()) {
617+
// We pass null to let NN know that default router is used and it can rely
618+
// on implementation details in some cases like offline-online switch.
619+
// Meanwhile platform SDK uses its own instance of native router for
620+
// route requests
621+
null
622+
} else {
623+
RouterInterfaceAdapter(moduleRouter, ::getNavigationRoutes)
624+
}
625+
}
626+
623627
/**
624628
* Control the location events playback during a replay trip session.
625629
* Start a replay trip session with [startReplayTripSession].
@@ -2033,11 +2037,7 @@ class MapboxNavigation @VisibleForTesting internal constructor(
20332037
historyRecorderHandles.composite,
20342038
createTilesConfig(isFallback, tilesVersion),
20352039
navigationOptions.accessToken ?: "",
2036-
if (moduleRouter.isInternalImplementation()) {
2037-
nativeRouter
2038-
} else {
2039-
RouterInterfaceAdapter(moduleRouter, ::getNavigationRoutes)
2040-
},
2040+
getRouterInterfaceForNativeNavigator()
20412041
)
20422042
etcGateAPI.experimental = navigator.experimental
20432043
assignHistoryRecorders()

libnavigator/src/main/java/com/mapbox/navigation/navigator/internal/MapboxNativeNavigator.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ interface MapboxNativeNavigator {
5353
historyRecorderComposite: HistoryRecorderHandle?,
5454
tilesConfig: TilesConfig,
5555
accessToken: String,
56-
router: RouterInterface,
56+
router: RouterInterface?,
5757
)
5858

5959
suspend fun resetRideSession()

libnavigator/src/main/java/com/mapbox/navigation/navigator/internal/MapboxNativeNavigatorImpl.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ object MapboxNativeNavigatorImpl : MapboxNativeNavigator {
111111
historyRecorderComposite: HistoryRecorderHandle?,
112112
tilesConfig: TilesConfig,
113113
accessToken: String,
114-
router: RouterInterface
114+
router: RouterInterface?
115115
) {
116116
val storeNavSessionState = navigator!!.storeNavigationSession()
117117
create(config, historyRecorderComposite, tilesConfig, accessToken, router)

0 commit comments

Comments
 (0)