#1449 hack for ZimManageActivity test to present 2 separate application components creating boxStores

This commit is contained in:
Sean Mac Gillicuddy 2019-09-10 16:08:05 +01:00
parent aa61a937bf
commit a629fd8a47

View File

@ -33,8 +33,16 @@ import javax.inject.Singleton
@Module
class DatabaseModule {
@Provides @Singleton fun providesBoxStore(context: Context): BoxStore =
MyObjectBox.builder().androidContext(context.applicationContext).build()
companion object {
var boxStore: BoxStore? = null
}
@Provides @Singleton fun providesBoxStore(context: Context): BoxStore {
if (boxStore == null) {
boxStore = MyObjectBox.builder().androidContext(context.applicationContext).build()
}
return boxStore!!
}
@Provides @Singleton fun providesNewDownloadDao(boxStore: BoxStore): NewDownloadDao =
NewDownloadDao(boxStore.boxFor())