-
Notifications
You must be signed in to change notification settings - Fork 319
[AndroidAuto] Migrate CarRouteRequest to MapboxNavigationApp #6372
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
Conversation
8bcb928 to
6962b9b
Compare
Codecov Report
@@ Coverage Diff @@
## main #6372 +/- ##
=========================================
Coverage 68.95% 68.95%
Complexity 4579 4579
=========================================
Files 691 691
Lines 27382 27382
Branches 3191 3191
=========================================
Hits 18881 18881
Misses 7262 7262
Partials 1239 1239 |
| */ | ||
| fun request(placeRecord: PlaceRecord, callback: CarRouteRequestCallback) { | ||
| currentRequestId?.let { mapboxNavigation.cancelRouteRequest(it) } | ||
| val mapboxNavigation = this.mapboxNavigation ?: return |
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.
Should we use !! here?
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.
I thought about this a lot, and established an opinion. I agree with you that there should be a signal that the request did not happen. But I'm hesitant with crashing here. Considering that this is just one new type of many possible failures. I think the error should be sent to CarRouteRequestCallback. So for now it's sending it to onNoRoutesFound
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.
Arguable that this is a developer error so it should crash. But there are other developer errors that will not crash, for example if the interceptor provides impossible parameters.
Also you may want to request routes from things that are not lifecycle aware. The CarRouteRequest is lifecycle aware so the caller does not have to be 🤔
object SomeUtility {
--snip--
fun goToNextDestination(placeRecord) {
MapboxNavigationApp.getObserver(CarRouteRequest::class).request(placeRecord, callback)
}
}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.
And then the reason why it's good to always have a callback respond. Is because otherwise people will build "infinite spinners"
// simplified version of the callback to illustrate the point.
// stopLoading would not be called if the `CarRouteRequest` is detached.
spinner.startLoading()
MapboxNavigationApp.getObserver(CarRouteRequest::class).request(placeRecord) {
spinner.stopLoading()
}6962b9b to
fe95912
Compare
fe95912 to
d6bae3b
Compare
Description
Addressing #6141
This needs to be done before this one #6371
Migrating
CarRouteRequestto useMapboxNavigationObserver