From e089012a8de8991743d473bad36e0ebaf8144e14 Mon Sep 17 00:00:00 2001 From: Adetunji Dahunsi Date: Tue, 8 Feb 2022 08:46:39 -0500 Subject: [PATCH] Replace module interfaces with objects Change-Id: Ieab7533120e7b8d5a770963e37b9db405e229630 --- .../apps/nowinandroid/di/DaosModule.kt | 36 +++++++++---------- .../apps/nowinandroid/di/DatabaseModule.kt | 22 ++++++------ 2 files changed, 27 insertions(+), 31 deletions(-) diff --git a/app/src/main/java/com/google/samples/apps/nowinandroid/di/DaosModule.kt b/app/src/main/java/com/google/samples/apps/nowinandroid/di/DaosModule.kt index 33c0aab4d..0c07b7ae3 100644 --- a/app/src/main/java/com/google/samples/apps/nowinandroid/di/DaosModule.kt +++ b/app/src/main/java/com/google/samples/apps/nowinandroid/di/DaosModule.kt @@ -28,26 +28,24 @@ import dagger.hilt.components.SingletonComponent @Module @InstallIn(SingletonComponent::class) -interface DaosModule { - companion object { - @Provides - fun providesAuthorDao( - database: NiADatabase, - ): AuthorDao = database.authorDao() +object DaosModule { + @Provides + fun providesAuthorDao( + database: NiADatabase, + ): AuthorDao = database.authorDao() - @Provides - fun providesTopicsDao( - database: NiADatabase, - ): TopicDao = database.topicDao() + @Provides + fun providesTopicsDao( + database: NiADatabase, + ): TopicDao = database.topicDao() - @Provides - fun providesEpisodeDao( - database: NiADatabase, - ): EpisodeDao = database.episodeDao() + @Provides + fun providesEpisodeDao( + database: NiADatabase, + ): EpisodeDao = database.episodeDao() - @Provides - fun providesNewsResourceDao( - database: NiADatabase, - ): NewsResourceDao = database.newsResourceDao() - } + @Provides + fun providesNewsResourceDao( + database: NiADatabase, + ): NewsResourceDao = database.newsResourceDao() } diff --git a/app/src/main/java/com/google/samples/apps/nowinandroid/di/DatabaseModule.kt b/app/src/main/java/com/google/samples/apps/nowinandroid/di/DatabaseModule.kt index a9c134301..1952e64b3 100644 --- a/app/src/main/java/com/google/samples/apps/nowinandroid/di/DatabaseModule.kt +++ b/app/src/main/java/com/google/samples/apps/nowinandroid/di/DatabaseModule.kt @@ -28,16 +28,14 @@ import javax.inject.Singleton @Module @InstallIn(SingletonComponent::class) -interface DatabaseModule { - companion object { - @Provides - @Singleton - fun providesNiADatabase( - @ApplicationContext context: Context, - ): NiADatabase = Room.databaseBuilder( - context, - NiADatabase::class.java, - "nia-database" - ).build() - } +object DatabaseModule { + @Provides + @Singleton + fun providesNiADatabase( + @ApplicationContext context: Context, + ): NiADatabase = Room.databaseBuilder( + context, + NiADatabase::class.java, + "nia-database" + ).build() }