-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathApp.kt
More file actions
54 lines (51 loc) · 1.78 KB
/
App.kt
File metadata and controls
54 lines (51 loc) · 1.78 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package dev.dimension.flare
import android.app.Application
import android.os.Build
import coil3.ImageLoader
import coil3.PlatformContext
import coil3.SingletonImageLoader
import coil3.gif.AnimatedImageDecoder
import coil3.gif.GifDecoder
import coil3.network.ktor3.KtorNetworkFetcherFactory
import coil3.request.crossfade
import coil3.svg.SvgDecoder
import coil3.video.VideoFrameDecoder
import dev.dimension.flare.common.AnimatedPngDecoder
import dev.dimension.flare.common.AnimatedWebPDecoder
import dev.dimension.flare.di.KoinHelper
import dev.dimension.flare.di.androidModule
import dev.dimension.flare.di.composeUiModule
import io.ktor.client.HttpClient
import org.koin.android.ext.koin.androidContext
import org.koin.core.context.startKoin
class App :
Application(),
SingletonImageLoader.Factory {
override fun onCreate() {
super.onCreate()
startKoin {
androidContext(this@App)
modules(KoinHelper.modules() + androidModule + composeUiModule)
}
}
override fun newImageLoader(context: PlatformContext): ImageLoader =
ImageLoader
.Builder(this)
.components {
if (Build.VERSION.SDK_INT >= 28) {
add(factory = AnimatedImageDecoder.Factory())
} else {
add(GifDecoder.Factory())
}
add(AnimatedPngDecoder.Factory())
add(SvgDecoder.Factory())
add(AnimatedWebPDecoder.Factory())
add(VideoFrameDecoder.Factory())
add(
KtorNetworkFetcherFactory(
httpClient = HttpClient(dev.dimension.flare.data.network.httpClientEngine),
),
)
}.crossfade(true)
.build()
}