mirror of
https://github.com/null2264/yokai.git
synced 2025-06-21 10:44:42 +00:00
refactor: Use App as context
This commit is contained in:
parent
3412806bfc
commit
e32f7225a3
3 changed files with 8 additions and 3 deletions
|
@ -175,7 +175,7 @@ open class App : Application(), DefaultLifecycleObserver, SingletonImageLoader.F
|
|||
}
|
||||
|
||||
override fun newImageLoader(context: PlatformContext): ImageLoader {
|
||||
return CoilSetup.setup(context)
|
||||
return CoilSetup.setup(this@App)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -11,6 +11,8 @@ import coil3.network.okhttp.OkHttpNetworkFetcherFactory
|
|||
import coil3.request.allowHardware
|
||||
import coil3.request.allowRgb565
|
||||
import coil3.request.crossfade
|
||||
import coil3.util.DebugLogger
|
||||
import eu.kanade.tachiyomi.BuildConfig
|
||||
import eu.kanade.tachiyomi.network.NetworkHelper
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
|
@ -32,6 +34,9 @@ class CoilSetup {
|
|||
crossfade(true)
|
||||
allowRgb565(context.getSystemService<ActivityManager>()!!.isLowRamDevice)
|
||||
allowHardware(true)
|
||||
if (BuildConfig.DEBUG) {
|
||||
logger(DebugLogger())
|
||||
}
|
||||
}.build()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -91,8 +91,8 @@ class TachiyomiImageDecoder(private val resources: ImageSource, private val opti
|
|||
class Factory : Decoder.Factory {
|
||||
|
||||
override fun create(result: SourceFetchResult, options: Options, imageLoader: ImageLoader): Decoder? {
|
||||
if (!isApplicable(result.source.source())) return null
|
||||
return TachiyomiImageDecoder(result.source, options)
|
||||
if (isApplicable(result.source.source()) || options.customDecoder) return TachiyomiImageDecoder(result.source, options)
|
||||
return null
|
||||
}
|
||||
|
||||
private fun isApplicable(source: BufferedSource): Boolean {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue