Newer
Older
DevAndroid / app / src / main / java / keijumt / devandroid / di / module / AppModule.kt
  1. package keijumt.devandroid.di.module
  2.  
  3. import android.app.Application
  4. import android.content.Context
  5. import dagger.Module
  6. import dagger.Provides
  7. import keijumt.devandroid.api.PostalCodeApi
  8. import keijumt.devandroid.repository.PostalCodeDataRepository
  9. import keijumt.devandroid.repository.PostalCodeRepository
  10. import javax.inject.Singleton
  11.  
  12. /**
  13. * Module: Application 定義
  14. */
  15. @Module(includes = arrayOf(
  16. ViewModelModule::class
  17. ))
  18. class AppModule {
  19.  
  20. @Singleton
  21. @Provides
  22. fun provideContext(application: Application): Context {
  23. return application.applicationContext
  24. }
  25.  
  26. @Singleton
  27. @Provides
  28. fun providePostalCodeRepository(postalCodeApi: PostalCodeApi): PostalCodeRepository =
  29. PostalCodeDataRepository(postalCodeApi)
  30. }