Conversation
| import com.mapbox.androidauto.screenmanager.MapboxScreenEvent | ||
| import com.mapbox.androidauto.screenmanager.MapboxScreenManager | ||
| import com.mapbox.maps.logI | ||
| import com.mapbox.navigation.base.ExperimentalPreviewMapboxNavigationAPI |
Codecov Report
@@ Coverage Diff @@
## main #6620 +/- ##
============================================
+ Coverage 72.31% 72.33% +0.01%
+ Complexity 5323 5314 -9
============================================
Files 753 754 +1
Lines 29089 29074 -15
Branches 3448 3447 -1
============================================
- Hits 21037 21030 -7
- Misses 6667 6668 +1
+ Partials 1385 1376 -9
|
02c56fd to
ab8463a
Compare
| private companion object { | ||
| private const val DEFAULT_INITIAL_LEG_INDEX = 0 | ||
|
|
||
| private fun SetRoutes.initialLegIndex(): Int = |
There was a problem hiding this comment.
Shouldn't this be in SetRoutesEx?
There was a problem hiding this comment.
it's needed only in the particular class, so we're good to keep it here
| @@ -0,0 +1,20 @@ | |||
| package com.mapbox.navigation.core | |||
|
|
|||
| internal sealed class SetRoutes { | |||
There was a problem hiding this comment.
Is there a specific reason why you replaced SetRoutesInfo with SetRoutes? It looks like it's just doing the same thing differently. But now you have more whens.
There was a problem hiding this comment.
They are doing the same, but they are not the same:
SetRoutesis self-defined, it's not needed to hold StringReason- as it's internal, now classes are data and objects
- leg index is not present by default anymore: it's not needed for CleanUp and Reroute reasons
This is deep refactoring. I wanted to remove one and define another to show up diff explicitly.
Also, IMO (you can disagree with me 😄 ), I prefer nested sealed classes where it's possible, because they are defined under the same prefix, like
sealed class Base {
class Alpha(val value: String) : Base()
object Beta : Base()
}
fun ololo(base: Base) {
when(base) {
is Base.Alpha -> TODO()
Base.Beta -> TODO()
}
}vs
sealed class Base
class AlphaBase(val value: String) : Base()
object BetaBase : Base()
fun ololo(base: Base) {
when(base) {
is AlphaBase -> TODO()
BetaBase -> TODO()
}
}There was a problem hiding this comment.
- Yes, but you still have to perform a
whento convert it to reason. Why not just use a property? - SetRoutesInfo was also internal;
- It's not present anymore by default but now you have to "invent" it for cases where it's not present.
Also, IMO (you can disagree with me 😄 ), I prefer nested sealed classes where it's possible, because they are defined under the same prefix
I don't have a strong preference here.
There was a problem hiding this comment.
Yes, but you still have to perform a when to convert it to reason. Why not just use a property?
Whenever we have string property or not we have to perform when to get the carried data.
SetRoutesInfo was also internal;
yes, so we're good to keep them aka data-object
It's not present anymore by default but now you have to "invent" it for cases where it's not present.
it's actually a gap in our API: we don't need LEG INDEX when it's not needed. The most common sample is CleanUp routes - we don't need a leg index here, but setting it, as API is required it. Seems not setting the leg index in the upper level is safe, to not pass it occasionally
| } | ||
| logD(LOG_CATEGORY, logMessage("- starting")) | ||
|
|
||
| val result = when (setRoutes) { |
There was a problem hiding this comment.
Here you have another when to get initialLegIndex, although you've introduced an extension method for this purpose.
There was a problem hiding this comment.
when is needed not only for the leg index but also to resolve reason. Also, if you have a look at L96-137. It's not just getting the leg index.
There was a problem hiding this comment.
I understand that it's not just about the index. But it's about it as well. And as a result you have 2 places where the logic of getting leg index is implemented.
There was a problem hiding this comment.
discussed: move SetRoutes.initialLegIndex() to SetRoutesEx and cut the NAVAND-910 to address DirectionsSession#initialLegIndex concerns
| "route IDs: ${routes.map { it.id }}) - finished", | ||
| LOG_CATEGORY | ||
| ) | ||
| logD(LOG_CATEGORY, logMessage("- finished")) |
There was a problem hiding this comment.
Why can't you just create a String?
There was a problem hiding this comment.
There might be both. Why do you think one is better than another?
There was a problem hiding this comment.
Why create a lambda that creates a string when you can just create a string? It will be created anyway so I see adding a lambda as an unnecessary complication.
There was a problem hiding this comment.
It's a micro-performance (lazy) upgrade, I would keep it as is. Don't see a real matter to change to the field.
There was a problem hiding this comment.
Oh, I didn't notice you were reusing it. OK then.
| private var routesUpdateReason: String = RoutesExtra.ROUTES_UPDATE_REASON_CLEAN_UP | ||
|
|
||
| override var initialLegIndex = 0 | ||
| override var initialLegIndex = DEFAULT_INITIAL_LEG_INDEX |
There was a problem hiding this comment.
Did you have a chance to create a ticket to do something with this property?
7e33a31 to
03f7e4d
Compare
Description
NavNative: adopt SetRoutesReason