Skip to content
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

Migration from MapboxNavigationProvider to MapboxNavigationApp #129

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

kmadsen
Copy link
Contributor

@kmadsen kmadsen commented Aug 12, 2022

Resolves #128

Some initial ideas

I migrated ShowAlternativeRoutesActivity to the non-experimental apis to get a feel for how the migration will go. I think we should define some extensions because there is a lot of boilerplate.

If we defined MapboxNavigationApp extensions inside the core sdk, that could make it nicer. So I added an idea to the ShowCurrentLocationActivity example. This way your init function looks something like this? Just an idea.

    init {
        MapboxNavigationApp.setup(
            NavigationOptions.Builder(this)
                .accessToken(getString(R.string.mapbox_access_token))
                .build()
        ).attach(this)

        MapboxNavigationApp.attach(
            this,
            onResume = { registerLocationObserver(locationObserver) },
            onPause = { unregisterLocationObserver(locationObserver) },
        )
    }

Copy link
Contributor

@Zayankovsky Zayankovsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also noticed that both of the migrated examples are crashing because of trying to access application context in activity constructor.

@kmadsen
Copy link
Contributor Author

kmadsen commented Aug 25, 2022

I also noticed that both of the migrated examples are crashing because of trying to access application context in activity constructor.

Oh right, meant to use NavigationOptionsProvider so that the context is available by the time it is called

@kmadsen
Copy link
Contributor Author

kmadsen commented Aug 25, 2022

Another example for setting up something like MapboxNavigationApp

https://github.com/mapbox/mapbox-maps-android/tree/main/extension-androidauto#example-session-and-mapscreen

The MapboxCarApp uses a similar "registerObserver"/"unregisterObserver" pattern

@kmadsen kmadsen force-pushed the migrate-MapboxNavigationApp branch from 69592e9 to 0863b04 Compare August 26, 2022 14:26
@kmadsen kmadsen force-pushed the migrate-MapboxNavigationApp branch from 0863b04 to de2eac1 Compare August 30, 2022 18:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Migrate examples from MapboxNavigationProvider to MapboxNavigationApp
3 participants