mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-28 07:50:31 +05:30
refactor: upgrade to Coil3 (#7052)
This commit is contained in:
parent
e45346f412
commit
0025782986
@ -136,6 +136,7 @@ dependencies {
|
|||||||
/* Coil */
|
/* Coil */
|
||||||
coreLibraryDesugaring(libs.desugaring)
|
coreLibraryDesugaring(libs.desugaring)
|
||||||
implementation(libs.coil)
|
implementation(libs.coil)
|
||||||
|
implementation(libs.coil.network.okhttp)
|
||||||
|
|
||||||
/* Room */
|
/* Room */
|
||||||
ksp(libs.room.compiler)
|
ksp(libs.room.compiler)
|
||||||
|
@ -6,12 +6,16 @@ import android.graphics.Color
|
|||||||
import android.graphics.drawable.Drawable
|
import android.graphics.drawable.Drawable
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.widget.ImageView
|
import android.widget.ImageView
|
||||||
import androidx.core.graphics.drawable.toBitmapOrNull
|
|
||||||
import androidx.core.net.toUri
|
import androidx.core.net.toUri
|
||||||
import coil.ImageLoader
|
import coil3.ImageLoader
|
||||||
import coil.disk.DiskCache
|
import coil3.asDrawable
|
||||||
import coil.request.CachePolicy
|
import coil3.disk.DiskCache
|
||||||
import coil.request.ImageRequest
|
import coil3.disk.directory
|
||||||
|
import coil3.network.okhttp.OkHttpNetworkFetcherFactory
|
||||||
|
import coil3.request.CachePolicy
|
||||||
|
import coil3.request.ImageRequest
|
||||||
|
import coil3.request.crossfade
|
||||||
|
import coil3.toBitmap
|
||||||
import com.github.libretube.BuildConfig
|
import com.github.libretube.BuildConfig
|
||||||
import com.github.libretube.constants.PreferenceKeys
|
import com.github.libretube.constants.PreferenceKeys
|
||||||
import com.github.libretube.extensions.toAndroidUri
|
import com.github.libretube.extensions.toAndroidUri
|
||||||
@ -46,8 +50,10 @@ object ImageHelper {
|
|||||||
|
|
||||||
imageLoader = ImageLoader.Builder(context)
|
imageLoader = ImageLoader.Builder(context)
|
||||||
.crossfade(true)
|
.crossfade(true)
|
||||||
.okHttpClient {
|
.components {
|
||||||
httpClient.build()
|
add(
|
||||||
|
OkHttpNetworkFetcherFactory(httpClient.build())
|
||||||
|
)
|
||||||
}
|
}
|
||||||
.apply {
|
.apply {
|
||||||
if (maxCacheSize.isEmpty()) {
|
if (maxCacheSize.isEmpty()) {
|
||||||
@ -110,14 +116,14 @@ object ImageHelper {
|
|||||||
.data(url)
|
.data(url)
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
return imageLoader.execute(request).drawable?.toBitmapOrNull()
|
return imageLoader.execute(request).image?.toBitmap()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getImageWithCallback(context: Context, url: String?, onSuccess: (Drawable) -> Unit) {
|
private fun getImageWithCallback(context: Context, url: String?, onSuccess: (Drawable) -> Unit) {
|
||||||
val request = ImageRequest.Builder(context)
|
val request = ImageRequest.Builder(context)
|
||||||
.data(url)
|
.data(url)
|
||||||
.target { drawable ->
|
.target { drawable ->
|
||||||
onSuccess(drawable)
|
onSuccess(drawable.asDrawable(context.resources))
|
||||||
}
|
}
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ espresso = "3.6.1"
|
|||||||
workRuntime = "2.9.1"
|
workRuntime = "2.9.1"
|
||||||
retrofit = "2.11.0"
|
retrofit = "2.11.0"
|
||||||
desugaring = "2.1.4"
|
desugaring = "2.1.4"
|
||||||
coil = "2.7.0"
|
coil = "3.0.4"
|
||||||
room = "2.6.1"
|
room = "2.6.1"
|
||||||
kotlinxSerialization = "1.6.3"
|
kotlinxSerialization = "1.6.3"
|
||||||
kotlinxDatetime = "0.6.1"
|
kotlinxDatetime = "0.6.1"
|
||||||
@ -62,7 +62,8 @@ newpipeextractor = { module = "com.github.teamnewpipe:NewPipeExtractor", version
|
|||||||
square-retrofit = { group = "com.squareup.retrofit2", name = "retrofit", version.ref = "retrofit" }
|
square-retrofit = { group = "com.squareup.retrofit2", name = "retrofit", version.ref = "retrofit" }
|
||||||
converter-kotlinx-serialization = { group = "com.squareup.retrofit2", name = "converter-kotlinx-serialization", version.ref = "retrofit" }
|
converter-kotlinx-serialization = { group = "com.squareup.retrofit2", name = "converter-kotlinx-serialization", version.ref = "retrofit" }
|
||||||
desugaring = { group = "com.android.tools", name = "desugar_jdk_libs_nio", version.ref = "desugaring" }
|
desugaring = { group = "com.android.tools", name = "desugar_jdk_libs_nio", version.ref = "desugaring" }
|
||||||
coil = { group = "io.coil-kt", name = "coil", version.ref="coil" }
|
coil = { group = "io.coil-kt.coil3", name = "coil", version.ref = "coil" }
|
||||||
|
coil-network-okhttp = { group = "io.coil-kt.coil3", name = "coil-network-okhttp", version.ref = "coil"}
|
||||||
lifecycle-viewmodel = { group = "androidx.lifecycle", name = "lifecycle-viewmodel-ktx", version.ref = "lifecycle" }
|
lifecycle-viewmodel = { group = "androidx.lifecycle", name = "lifecycle-viewmodel-ktx", version.ref = "lifecycle" }
|
||||||
lifecycle-runtime = { group = "androidx.lifecycle", name = "lifecycle-runtime-ktx", version.ref = "lifecycle" }
|
lifecycle-runtime = { group = "androidx.lifecycle", name = "lifecycle-runtime-ktx", version.ref = "lifecycle" }
|
||||||
lifecycle-livedata = { group = "androidx.lifecycle", name = "lifecycle-livedata-ktx", version.ref = "lifecycle" }
|
lifecycle-livedata = { group = "androidx.lifecycle", name = "lifecycle-livedata-ktx", version.ref = "lifecycle" }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user