Fix RegionBitmapDecode usage
This commit is contained in:
@@ -28,7 +28,6 @@ import org.koitharu.kotatsu.BuildConfig
|
|||||||
import org.koitharu.kotatsu.browser.cloudflare.CaptchaNotifier
|
import org.koitharu.kotatsu.browser.cloudflare.CaptchaNotifier
|
||||||
import org.koitharu.kotatsu.core.db.MangaDatabase
|
import org.koitharu.kotatsu.core.db.MangaDatabase
|
||||||
import org.koitharu.kotatsu.core.image.AvifImageDecoder
|
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.MangaHttpClient
|
||||||
import org.koitharu.kotatsu.core.network.imageproxy.ImageProxyInterceptor
|
import org.koitharu.kotatsu.core.network.imageproxy.ImageProxyInterceptor
|
||||||
import org.koitharu.kotatsu.core.os.AppShortcutManager
|
import org.koitharu.kotatsu.core.os.AppShortcutManager
|
||||||
@@ -82,9 +81,7 @@ interface AppModule {
|
|||||||
@Singleton
|
@Singleton
|
||||||
fun provideMangaDatabase(
|
fun provideMangaDatabase(
|
||||||
@ApplicationContext context: Context,
|
@ApplicationContext context: Context,
|
||||||
): MangaDatabase {
|
): MangaDatabase = MangaDatabase(context)
|
||||||
return MangaDatabase(context)
|
|
||||||
}
|
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
@@ -122,7 +119,6 @@ interface AppModule {
|
|||||||
.add(SvgDecoder.Factory())
|
.add(SvgDecoder.Factory())
|
||||||
.add(CbzFetcher.Factory())
|
.add(CbzFetcher.Factory())
|
||||||
.add(AvifImageDecoder.Factory())
|
.add(AvifImageDecoder.Factory())
|
||||||
.add(RegionBitmapDecoder.Factory())
|
|
||||||
.add(FaviconFetcher.Factory(context, okHttpClientLazy, mangaRepositoryFactory))
|
.add(FaviconFetcher.Factory(context, okHttpClientLazy, mangaRepositoryFactory))
|
||||||
.add(MangaPageKeyer())
|
.add(MangaPageKeyer())
|
||||||
.add(pageFetcherFactory)
|
.add(pageFetcherFactory)
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ class RegionBitmapDecoder(
|
|||||||
inPreferredConfig = config
|
inPreferredConfig = config
|
||||||
}
|
}
|
||||||
|
|
||||||
class Factory : Decoder.Factory {
|
object Factory : Decoder.Factory {
|
||||||
|
|
||||||
private val parallelismLock = Semaphore(DEFAULT_PARALLELISM)
|
private val parallelismLock = Semaphore(DEFAULT_PARALLELISM)
|
||||||
|
|
||||||
@@ -137,11 +137,7 @@ class RegionBitmapDecoder(
|
|||||||
result: SourceResult,
|
result: SourceResult,
|
||||||
options: Options,
|
options: Options,
|
||||||
imageLoader: ImageLoader
|
imageLoader: ImageLoader
|
||||||
): Decoder? = if (options.parameters.value<Boolean>(PARAM_REGION) == true) {
|
): Decoder = RegionBitmapDecoder(result.source, options, parallelismLock)
|
||||||
RegionBitmapDecoder(result.source, options, parallelismLock)
|
|
||||||
} else {
|
|
||||||
null
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun equals(other: Any?) = other is Factory
|
override fun equals(other: Any?) = other is Factory
|
||||||
|
|
||||||
@@ -151,7 +147,6 @@ class RegionBitmapDecoder(
|
|||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
const val PARAM_SCROLL = "scroll"
|
const val PARAM_SCROLL = "scroll"
|
||||||
const val PARAM_REGION = "region"
|
|
||||||
const val SCROLL_UNDEFINED = -1
|
const val SCROLL_UNDEFINED = -1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ fun ImageRequest.Builder.indicator(indicators: List<BaseProgressIndicator<*>>):
|
|||||||
|
|
||||||
fun ImageRequest.Builder.decodeRegion(
|
fun ImageRequest.Builder.decodeRegion(
|
||||||
scroll: Int = RegionBitmapDecoder.SCROLL_UNDEFINED,
|
scroll: Int = RegionBitmapDecoder.SCROLL_UNDEFINED,
|
||||||
): ImageRequest.Builder = setParameter(RegionBitmapDecoder.PARAM_REGION, true)
|
): ImageRequest.Builder = decoderFactory(RegionBitmapDecoder.Factory)
|
||||||
.setParameter(RegionBitmapDecoder.PARAM_SCROLL, scroll)
|
.setParameter(RegionBitmapDecoder.PARAM_SCROLL, scroll)
|
||||||
|
|
||||||
@Suppress("SpellCheckingInspection")
|
@Suppress("SpellCheckingInspection")
|
||||||
|
|||||||
Reference in New Issue
Block a user