Created
May 10, 2018 11:02
-
-
Save rohankandwal/a67e92811c5fa605eaedfdf211dff4ac to your computer and use it in GitHub Desktop.
AppModule - Used to inject fragments, service, activities with other modules
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Module(includes = { | |
AndroidInjectionModule.class, RepositoryModule.class, | |
MySharedPreferencesModule.class | |
ViewModelModule.class, LocalRepositoryModule.class, MQTTModule.class | |
}) | |
abstract class AppModule { | |
/* | |
* Singleton annotation isn't necessary since Application instance is unique but is here for | |
* convention. In general, providing Activity, Fragment, BroadcastReceiver, etc does not require | |
* them to be scoped since they are the components being injected and their instance is unique. | |
* | |
* However, having a scope annotation makes the module easier to read. We wouldn't have to look | |
* at what is being provided in order to understand its scope.*/ | |
abstract Application application(SmartHomeApplication app); | |
// Injecting Activities | |
@PerActivity | |
@ContributesAndroidInjector(modules = { ActivityModule.class }) | |
abstract SplashScreenActivity splashScreenActivityInjector(); | |
@PerActivity | |
@ContributesAndroidInjector(modules = { ActivityModule.class }) | |
abstract HomeScreenActivity mainActivityInjector(); | |
@PerActivity | |
@ContributesAndroidInjector(modules = {ActivityModule.class}) | |
abstract LoginActivity loginActivityInjector(); | |
@PerActivity | |
@ContributesAndroidInjector(modules = {ActivityModule.class}) | |
abstract RegistrationActivity registrationActivityInjector(); | |
// Injecting Services | |
@PerService | |
@ContributesAndroidInjector | |
abstract VoiceProcessingService voiceProcessingServiceInjector(); | |
// Injecting Fragments | |
@ContributesAndroidInjector | |
abstract MyFavoritesFragment myFavoritesFragmentInjector(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment