diff --git a/stream-chat-android-ui-common/src/main/kotlin/io/getstream/chat/android/ui/common/images/StreamImageLoaderFactory.kt b/stream-chat-android-ui-common/src/main/kotlin/io/getstream/chat/android/ui/common/images/StreamImageLoaderFactory.kt index 47eac193416..bd538893a6f 100644 --- a/stream-chat-android-ui-common/src/main/kotlin/io/getstream/chat/android/ui/common/images/StreamImageLoaderFactory.kt +++ b/stream-chat-android-ui-common/src/main/kotlin/io/getstream/chat/android/ui/common/images/StreamImageLoaderFactory.kt @@ -25,6 +25,7 @@ import coil3.gif.AnimatedImageDecoder import coil3.gif.GifDecoder import coil3.intercept.Interceptor import coil3.memory.MemoryCache +import coil3.network.okhttp.OkHttpNetworkFetcherFactory import coil3.request.allowHardware import coil3.request.crossfade import coil3.video.VideoFrameDecoder @@ -82,6 +83,7 @@ public class StreamImageLoaderFactory( } .components { interceptors.forEach { add(it) } + add(OkHttpNetworkFetcherFactory()) if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { add(AnimatedImageDecoder.Factory(enforceMinimumFrameDelay = true)) } else { diff --git a/stream-chat-android-ui-common/src/test/kotlin/io/getstream/chat/android/ui/common/images/StreamImageLoaderFactoryTest.kt b/stream-chat-android-ui-common/src/test/kotlin/io/getstream/chat/android/ui/common/images/StreamImageLoaderFactoryTest.kt index 55966b3b435..5fe1cde18b5 100644 --- a/stream-chat-android-ui-common/src/test/kotlin/io/getstream/chat/android/ui/common/images/StreamImageLoaderFactoryTest.kt +++ b/stream-chat-android-ui-common/src/test/kotlin/io/getstream/chat/android/ui/common/images/StreamImageLoaderFactoryTest.kt @@ -23,6 +23,8 @@ import coil3.disk.DiskCache import coil3.gif.AnimatedImageDecoder import coil3.gif.GifDecoder import coil3.memory.MemoryCache +import coil3.network.NetworkFetcher +import coil3.serviceLoaderEnabled import coil3.video.VideoFrameDecoder import okio.Path.Companion.toOkioPath import org.amshove.kluent.internal.assertEquals @@ -103,6 +105,17 @@ internal class StreamImageLoaderFactoryTest { assertTrue(hasVideoDecoder) } + @Test + fun `newImageLoader registers network fetcher explicitly without relying on ServiceLoader`() { + val sut = StreamImageLoaderFactory(builder = { serviceLoaderEnabled(false) }) + + val imageLoader = sut.newImageLoader(context) + + val hasNetworkFetcher = imageLoader.components.fetcherFactories + .any { (factory, _) -> factory is NetworkFetcher.Factory } + assertTrue(hasNetworkFetcher) + } + @Test fun `newImageLoader applies custom builder lambda`() { var customApplied = false