tomtom-international / tomtom-navigation-android-examples

TomTom Navigation SDK examples
https://developer.tomtom.com/android/navigation/documentation/overview/introduction
Other
22 stars 4 forks source link

Example code uses deprecated `combineWithNext` #97

Closed frankvollebregt closed 4 months ago

frankvollebregt commented 5 months ago

In the Route.mapInstructions method defined in the example app here, the instructions are mapped using the combineWithNext property of each Instruction in each RouteLeg. But this property has been deprecated (as per the change log and my IDE notifying me as such).

private fun Route.mapInstructions(): List<Instruction> {
    val routeInstructions =
        legs.flatMap { routeLeg -> routeLeg.instructions }
    return routeInstructions.map {
        Instruction(
            routeOffset = it.routeOffset,
            combineWithNext = it.combineWithNext // <-- This operation
        )
    }
}

It mentions the following notice:

'combineWithNext: Boolean' is deprecated. This API is deprecated and will be removed with the next major release. Please use GuidanceInstruction.combineWithNext instead.

But how can I do this? Can the example here (and perhaps the tutorial online) be updated s.t. the deprecated method is no longer used?

Edit

The same goes for the deprecated GuidanceOptions. When using the new version, I get an error toast when trying to plan the route. Clarifying this in the example app and/or documentation would go a long way to help. https://github.com/tomtom-international/tomtom-navigation-android-examples/blob/main/tomtom-navigation-core-examples/usecase/src/main/kotlin/com/example/usecase/MainActivity.kt#L245C13-L251C15

BasarAksanli-TomTom commented 5 months ago

Hello @frankvollebregt

Regarding the first question, I think you can implement it as below.

Instruction(
        routeOffset = it.routeOffset,
        combineWithNext = if (it is GuidanceInstruction) (it as GuidanceInstruction).combineWithNext else false
)

Regarding your second question, Guidance Version 2 is buggy at the moment. 0.45.2 is going to be released soon, it will fix that issue.

frankvollebregt commented 4 months ago

Thank you! That does indeed resolve the first issue. I'll upgrade to the new version soon (I think 0.46.0 is out now), and open a new issue if anything comes up.