Skip to content

Commit

Permalink
Update to Compose SNAPSHOT 7392605 (google#437)
Browse files Browse the repository at this point in the history
Also upgrade to Kotlin 1.5.0 and Coroutines 1.5.0.
  • Loading branch information
chrisbanes authored and jossiwolf committed Aug 1, 2021
1 parent 033d828 commit 1dbf136
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 24 deletions.
14 changes: 6 additions & 8 deletions coil/src/main/java/com/google/accompanist/coil/Coil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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()

Expand Down
18 changes: 5 additions & 13 deletions glide/src/main/java/com/google/accompanist/glide/Glide.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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,
Expand All @@ -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()
}
Expand All @@ -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(),
Expand Down
6 changes: 3 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -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"

Expand Down

0 comments on commit 1dbf136

Please sign in to comment.