Fix RegionBitmapDecode usage

This commit is contained in:
Koitharu
2024-10-23 09:10:43 +03:00
parent c15a0ece3e
commit 681c80dc3e
3 changed files with 4 additions and 13 deletions

View File

@@ -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)

View File

@@ -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<Boolean>(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
}
}

View File

@@ -63,7 +63,7 @@ fun ImageRequest.Builder.indicator(indicators: List<BaseProgressIndicator<*>>):
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")