diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/core/AppModule.kt b/app/src/main/kotlin/org/koitharu/kotatsu/core/AppModule.kt index cd1a77f51..c0133b6e8 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/core/AppModule.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/core/AppModule.kt @@ -28,7 +28,6 @@ import org.koitharu.kotatsu.BuildConfig import org.koitharu.kotatsu.browser.cloudflare.CaptchaNotifier import org.koitharu.kotatsu.core.db.MangaDatabase import org.koitharu.kotatsu.core.image.AvifImageDecoder -import org.koitharu.kotatsu.core.image.RegionBitmapDecoder import org.koitharu.kotatsu.core.network.MangaHttpClient import org.koitharu.kotatsu.core.network.imageproxy.ImageProxyInterceptor import org.koitharu.kotatsu.core.os.AppShortcutManager @@ -82,9 +81,7 @@ interface AppModule { @Singleton fun provideMangaDatabase( @ApplicationContext context: Context, - ): MangaDatabase { - return MangaDatabase(context) - } + ): MangaDatabase = MangaDatabase(context) @Provides @Singleton @@ -122,7 +119,6 @@ interface AppModule { .add(SvgDecoder.Factory()) .add(CbzFetcher.Factory()) .add(AvifImageDecoder.Factory()) - .add(RegionBitmapDecoder.Factory()) .add(FaviconFetcher.Factory(context, okHttpClientLazy, mangaRepositoryFactory)) .add(MangaPageKeyer()) .add(pageFetcherFactory) diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/core/image/RegionBitmapDecoder.kt b/app/src/main/kotlin/org/koitharu/kotatsu/core/image/RegionBitmapDecoder.kt index d55c145a0..bff3abfba 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/core/image/RegionBitmapDecoder.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/core/image/RegionBitmapDecoder.kt @@ -129,7 +129,7 @@ class RegionBitmapDecoder( inPreferredConfig = config } - class Factory : Decoder.Factory { + object Factory : Decoder.Factory { private val parallelismLock = Semaphore(DEFAULT_PARALLELISM) @@ -137,11 +137,7 @@ class RegionBitmapDecoder( result: SourceResult, options: Options, imageLoader: ImageLoader - ): Decoder? = if (options.parameters.value(PARAM_REGION) == true) { - RegionBitmapDecoder(result.source, options, parallelismLock) - } else { - null - } + ): Decoder = RegionBitmapDecoder(result.source, options, parallelismLock) override fun equals(other: Any?) = other is Factory @@ -151,7 +147,6 @@ class RegionBitmapDecoder( companion object { const val PARAM_SCROLL = "scroll" - const val PARAM_REGION = "region" const val SCROLL_UNDEFINED = -1 } } diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/core/util/ext/Coil.kt b/app/src/main/kotlin/org/koitharu/kotatsu/core/util/ext/Coil.kt index 19ffb7481..c50b0daf0 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/core/util/ext/Coil.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/core/util/ext/Coil.kt @@ -63,7 +63,7 @@ fun ImageRequest.Builder.indicator(indicators: List>): fun ImageRequest.Builder.decodeRegion( scroll: Int = RegionBitmapDecoder.SCROLL_UNDEFINED, -): ImageRequest.Builder = setParameter(RegionBitmapDecoder.PARAM_REGION, true) +): ImageRequest.Builder = decoderFactory(RegionBitmapDecoder.Factory) .setParameter(RegionBitmapDecoder.PARAM_SCROLL, scroll) @Suppress("SpellCheckingInspection")