Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Module
- class AppModule(private val app: SeezApp) {
- @Provides
- @Singleton
- fun provideApp() = app
- @Provides
- @Singleton
- fun provideContext(): Context = app.applicationContext
- @Provides
- @Singleton
- fun provideSharedPreferences(): SharedPreferences = app.getSharedPreferences(
- SHARED_PREFERENCES_TITLE,
- Context.MODE_PRIVATE
- )
- //Needs sharedPrefs
- @Provides
- @Singleton
- fun provideApiService() = ApiManager.initApiService(provideSharedPreferences())
- @Provides
- @Singleton
- fun provideNumberFormatter(): NumberFormat = NumberFormat.getInstance(Locale.getDefault())
- @Provides
- @Singleton
- fun providesDBHelper(): AppDatabase = Room.databaseBuilder(
- app,
- AppDatabase::class.java,
- SEEZ_APP_DB_NAME
- )
- .fallbackToDestructiveMigration()
- .build()
- }
Advertisement
Add Comment
Please, Sign In to add comment