-
Notifications
You must be signed in to change notification settings - Fork 51
/
AppModule.kt
38 lines (34 loc) · 1023 Bytes
/
AppModule.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/*
* Copyright (C) 2022, Kasem S.M
* All rights reserved.
*/
package kasem.sm.slime.di
import android.content.Context
import coil.ImageLoader
import coil.memory.MemoryCache
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
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.SupervisorJob
@Module
@InstallIn(SingletonComponent::class)
object AppModule {
@Provides
@Singleton
fun provideImageLoader(@ApplicationContext context: Context): ImageLoader {
return ImageLoader.Builder(context)
.memoryCache(MemoryCache.Builder(context).maxSizePercent(0.25).build())
.crossfade(250)
.build()
}
@Singleton
@Provides
fun provideApplicationScope(): CoroutineScope {
return CoroutineScope(SupervisorJob() + Dispatchers.Default)
}
}