2023-08-11 10:29:32 -07:00
|
|
|
package com.anthonyla.paperize.di
|
|
|
|
|
|
|
|
|
|
import android.app.Application
|
|
|
|
|
import android.content.Context
|
|
|
|
|
import androidx.room.Room
|
|
|
|
|
import com.anthonyla.paperize.data.settings.SettingsDataStore
|
|
|
|
|
import com.anthonyla.paperize.data.settings.SettingsDataStoreImpl
|
2023-10-09 22:17:36 -07:00
|
|
|
import com.anthonyla.paperize.feature.wallpaper.data.data_source.WallpaperDatabase
|
|
|
|
|
import com.anthonyla.paperize.feature.wallpaper.data.repository.WallpaperRepositoryImpl
|
|
|
|
|
import com.anthonyla.paperize.feature.wallpaper.domain.repository.WallpaperRepository
|
|
|
|
|
import com.anthonyla.paperize.feature.wallpaper.presentation.MainActivity
|
|
|
|
|
import com.anthonyla.paperize.feature.wallpaper.use_case.AddWallpaper
|
|
|
|
|
import com.anthonyla.paperize.feature.wallpaper.use_case.WallpaperUseCases
|
|
|
|
|
import com.anthonyla.paperize.feature.wallpaper.use_case.DeleteWallpaper
|
|
|
|
|
import com.anthonyla.paperize.feature.wallpaper.use_case.GetWallpapers
|
2023-08-11 10:29:32 -07:00
|
|
|
import dagger.Module
|
|
|
|
|
import dagger.Provides
|
|
|
|
|
import dagger.hilt.InstallIn
|
|
|
|
|
import dagger.hilt.android.qualifiers.ApplicationContext
|
|
|
|
|
import dagger.hilt.components.SingletonComponent
|
|
|
|
|
import javax.inject.Singleton
|
|
|
|
|
|
|
|
|
|
@Module
|
|
|
|
|
@InstallIn(SingletonComponent::class)
|
|
|
|
|
object AppModule {
|
|
|
|
|
@Provides
|
|
|
|
|
@Singleton
|
2023-10-09 22:17:36 -07:00
|
|
|
fun provideWallpaperDatabase(app: Application): WallpaperDatabase {
|
2023-08-11 10:29:32 -07:00
|
|
|
return Room.databaseBuilder(
|
|
|
|
|
app,
|
2023-10-09 22:17:36 -07:00
|
|
|
WallpaperDatabase::class.java,
|
|
|
|
|
WallpaperDatabase.DATABASE_NAME
|
2023-08-11 10:29:32 -07:00
|
|
|
).build()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Provides
|
|
|
|
|
@Singleton
|
2023-10-09 22:17:36 -07:00
|
|
|
fun provideWallpaperRepository(
|
|
|
|
|
db: WallpaperDatabase
|
|
|
|
|
): WallpaperRepository {
|
|
|
|
|
return WallpaperRepositoryImpl(db.wallpaperDao)
|
2023-08-11 10:29:32 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Provides
|
|
|
|
|
@Singleton
|
2023-10-09 22:17:36 -07:00
|
|
|
fun provideWallpaperUseCases(
|
|
|
|
|
repository: WallpaperRepository
|
|
|
|
|
): WallpaperUseCases {
|
|
|
|
|
return WallpaperUseCases (
|
|
|
|
|
getWallpapers = GetWallpapers(repository),
|
|
|
|
|
deleteWallpaper = DeleteWallpaper(repository),
|
|
|
|
|
addWallpaper = AddWallpaper(repository),
|
2023-08-11 10:29:32 -07:00
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Provides
|
|
|
|
|
@Singleton
|
|
|
|
|
fun provideSettingsDataStore (
|
|
|
|
|
@ApplicationContext context: Context
|
|
|
|
|
): SettingsDataStore = SettingsDataStoreImpl(context)
|
|
|
|
|
|
|
|
|
|
@Provides
|
|
|
|
|
fun provideContext(
|
|
|
|
|
@ApplicationContext context: Context,
|
|
|
|
|
): Context {
|
|
|
|
|
return context
|
|
|
|
|
}
|
|
|
|
|
}
|