From 69c1e54b229ffdd497a09233f59d493bdd12a032 Mon Sep 17 00:00:00 2001 From: Chris Banes Date: Mon, 24 May 2021 12:22:21 +0100 Subject: [PATCH] Update to Compose SNAPSHOT 7392605 (#437) Also upgrade to Kotlin 1.5.0 and Coroutines 1.5.0. --- .../java/com/google/accompanist/coil/Coil.kt | 14 ++++++-------- .../java/com/google/accompanist/glide/Glide.kt | 18 +++++------------- gradle/libs.versions.toml | 6 +++--- 3 files changed, 14 insertions(+), 24 deletions(-) diff --git a/coil/src/main/java/com/google/accompanist/coil/Coil.kt b/coil/src/main/java/com/google/accompanist/coil/Coil.kt index 2886094cb..3a195aa55 100644 --- a/coil/src/main/java/com/google/accompanist/coil/Coil.kt +++ b/coil/src/main/java/com/google/accompanist/coil/Coil.kt @@ -44,7 +44,7 @@ import com.google.accompanist.imageloading.Loader import com.google.accompanist.imageloading.ShouldRefetchOnSizeChange import com.google.accompanist.imageloading.rememberLoadPainter import kotlinx.coroutines.ExperimentalCoroutinesApi -import kotlinx.coroutines.channels.sendBlocking +import kotlinx.coroutines.channels.trySendBlocking import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.channelFlow @@ -143,14 +143,12 @@ internal class CoilLoader( onStart = { placeholder -> // We need to send blocking, to ensure that Loading is sent // before the execute result below. - if (!isClosedForSend) { - sendBlocking( - ImageLoadState.Loading( - placeholder = placeholder?.let(::DrawablePainter), - request = request - ) + trySendBlocking( + ImageLoadState.Loading( + placeholder = placeholder?.let(::DrawablePainter), + request = request ) - } + ) } ).build() diff --git a/glide/src/main/java/com/google/accompanist/glide/Glide.kt b/glide/src/main/java/com/google/accompanist/glide/Glide.kt index c62491e55..5ddbd4180 100644 --- a/glide/src/main/java/com/google/accompanist/glide/Glide.kt +++ b/glide/src/main/java/com/google/accompanist/glide/Glide.kt @@ -45,7 +45,7 @@ import com.google.accompanist.imageloading.ShouldRefetchOnSizeChange import com.google.accompanist.imageloading.rememberLoadPainter import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.channels.awaitClose -import kotlinx.coroutines.channels.sendBlocking +import kotlinx.coroutines.channels.trySendBlocking import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.callbackFlow @@ -139,9 +139,7 @@ internal class GlideLoader( if (size.height > 0) size.height else Target.SIZE_ORIGINAL ) { override fun onLoadStarted(placeholder: Drawable?) { - if (isClosedForSend) return - - sendBlocking( + trySendBlocking( ImageLoadState.Loading( placeholder = placeholder?.let(::DrawablePainter), request = request @@ -150,9 +148,7 @@ internal class GlideLoader( } override fun onLoadFailed(errorDrawable: Drawable?) { - if (isClosedForSend) return - - sendBlocking( + trySendBlocking( ImageLoadState.Error( result = errorDrawable?.let(::DrawablePainter), request = request, @@ -165,11 +161,9 @@ internal class GlideLoader( } override fun onLoadCleared(resource: Drawable?) { - if (isClosedForSend) return - // Glide wants to free up the resource, so we need to clear // the result, otherwise we might draw a recycled bitmap later. - sendBlocking(ImageLoadState.Empty) + trySendBlocking(ImageLoadState.Empty) // Close the channel[Flow] channel.close() } @@ -183,9 +177,7 @@ internal class GlideLoader( dataSource: com.bumptech.glide.load.DataSource, isFirstResource: Boolean ): Boolean { - if (isClosedForSend) return true - - sendBlocking( + trySendBlocking( ImageLoadState.Success( result = DrawablePainter(drawable), source = dataSource.toDataSource(), diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index efc08b140..3ef79cce4 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,10 +1,10 @@ [versions] compose = "1.0.0-SNAPSHOT" -composesnapshot = "7352378" # a single character = no snapshot +composesnapshot = "7392605" # a single character = no snapshot ktlint = "0.40.0" -kotlin = "1.4.32" -coroutines = "1.4.1" +kotlin = "1.5.0" +coroutines = "1.5.0" okhttp = "3.12.2" coil = "1.1.1"