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

Align module generation and skip configuration by default #26

Merged
merged 4 commits into from
Feb 11, 2020

Conversation

LukasPaczos
Copy link

@LukasPaczos LukasPaczos commented Feb 4, 2020

Closes #14. Closes #18.

This PR consolidates module generation from both Maps and Nav SDKs and ships the provider in the common library.

This removes the separation of the module types - now all of them are under one enum constant. This not only helps to make the provider generic but also will allow us to write simpler docs.

One downside is, that all params providers will need to overwrite all module types, even if particular SDK is not supporting them. For example, Navigation SDKs param provider will look something like:

private fun paramsProvider(type: MapboxModuleType): Array<Pair<Class<*>?, Any?>> {
    return when (type) {
        MapboxModuleType.NavigationRouter -> ...
        MapboxModuleType.NavigationOffboardRouter -> ...
        MapboxModuleType.NavigationOnboardRouter -> ...
        MapboxModuleType.NavigationTripNotification -> ...
        else -> throw RuntimeException("not supported: ${type.name}")
    }
}

however, we'll never hit the else branch, unless we make the mistake ourselves and it should be caught quickly.

@LukasPaczos LukasPaczos added this to the 0.0.1 milestone Feb 4, 2020
@LukasPaczos LukasPaczos requested review from a team February 4, 2020 15:08
/**
* Exposes logger hooks.
*/
CommonLogger("Logger", "com.mapbox.base.common.logger", "Logger"),
Copy link
Author

Choose a reason for hiding this comment

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

This takes #21 into consideration already @Lebedinsky. Depending on which is merged first, we can resolve the conflicts.

Copy link
Member

@tobrun tobrun left a comment

Choose a reason for hiding this comment

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

One downside is, that all params providers will need to overwrite all module types

I'm fine with this as a drawback, maybe some kind of adapter approach would work here.

@LukasPaczos
Copy link
Author

Ready for another round.

@LukasPaczos
Copy link
Author

I added a bunch more of sanity tests, example usage in the docs and cleaned up the code.

val provider = providerField.get(null)

if (provider != null) {
// get module instance from the provider
Copy link
Member

Choose a reason for hiding this comment

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

every time you feel the need to write a comment, you can consider writing a function instead

@LukasPaczos LukasPaczos force-pushed the lp-skip-configuration-by-default branch from acaae3a to dd99a9d Compare February 11, 2020 14:26
@LukasPaczos LukasPaczos merged commit 1ede0e8 into master Feb 11, 2020
@LukasPaczos LukasPaczos deleted the lp-skip-configuration-by-default branch February 11, 2020 15:12
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.

Skip module configuration by default Generic module provider
2 participants