Skip to content

Commit

Permalink
better
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyle Madsen committed Mar 23, 2020
1 parent 4a8b8d7 commit e7037a0
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ internal class RouteRefreshController(
fun start(): Job {
stop()
return routerRefreshTimer.startTimer {
val route = tripSession.route?.supportsRefresh()
val legIndex = tripSession.getRouteProgress()?.currentLegProgress()?.legIndex() ?: 0
route?.let { routeSupportsRefresh ->
val route = tripSession.route?.takeIf { supportsRefresh(it) }
route?.let {
val legIndex = tripSession.getRouteProgress()?.currentLegProgress()?.legIndex() ?: 0
directionsSession.requestRouteRefresh(
routeSupportsRefresh,
route,
legIndex,
routeRefreshCallback)
}
Expand All @@ -48,10 +48,10 @@ internal class RouteRefreshController(
routerRefreshTimer.stopJobs()
}

private fun DirectionsRoute?.supportsRefresh(): DirectionsRoute? {
val isTrafficProfile = this?.routeOptions()
private fun supportsRefresh(route: DirectionsRoute?): Boolean {
val isTrafficProfile = route?.routeOptions()
?.profile()?.equals(DirectionsCriteria.PROFILE_DRIVING_TRAFFIC)
return if (isTrafficProfile == true) this else null
return isTrafficProfile == true
}

private val routeRefreshCallback = object : RouteRefreshCallback {
Expand Down

0 comments on commit e7037a0

Please sign in to comment.