Skip to content

Commit

Permalink
Address feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisbanes committed Sep 22, 2020
1 parent f24c36c commit de068e9
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ private fun resourceUri(id: Int): Uri {
}

/**
* [MockWebServer] which returns a valid at the path `/image` and a 404 for anything else.
* [MockWebServer] which returns a valid response at the path `/image`, and a 404 for anything else.
* We add a small delay to simulate 'real-world' network conditions.
*/
private fun coilTestWebServer(responseDelayMs: Long = 0): MockWebServer {
Expand Down
28 changes: 14 additions & 14 deletions coil/src/main/java/dev/chrisbanes/accompanist/coil/Coil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ import coil.request.ImageResult
* ```
* CoilImage(
* data = "https://www.image.url",
* ) { state ->
* when (state) {
* ) { imageState ->
* when (imageState) {
* is CoilImageState.Success -> // TODO
* is CoilImageState.Error -> // TODO
* CoilImageState.Loading -> // TODO
Expand All @@ -80,7 +80,7 @@ fun CoilImage(
imageLoader: ImageLoader = Coil.imageLoader(ContextAmbient.current),
shouldRefetchOnSizeChange: (currentResult: CoilImageState, size: IntSize) -> Boolean = defaultRefetchOnSizeChangeLambda,
onRequestCompleted: (CoilImageState) -> Unit = emptySuccessLambda,
content: @Composable (state: CoilImageState) -> Unit
content: @Composable (imageState: CoilImageState) -> Unit
) {
CoilImage(
request = data.toImageRequest(),
Expand All @@ -99,8 +99,8 @@ fun CoilImage(
* ```
* CoilImage(
* request = ImageRequest.Builder(context).data(...).build(),
* ) { state ->
* when (state) {
* ) { imageState ->
* when (imageState) {
* is CoilImageState.Success -> // TODO
* is CoilImageState.Error -> // TODO
* CoilImageState.Loading -> // TODO
Expand All @@ -126,7 +126,7 @@ fun CoilImage(
imageLoader: ImageLoader = Coil.imageLoader(ContextAmbient.current),
shouldRefetchOnSizeChange: (currentResult: CoilImageState, size: IntSize) -> Boolean = defaultRefetchOnSizeChangeLambda,
onRequestCompleted: (CoilImageState) -> Unit = emptySuccessLambda,
content: @Composable (state: CoilImageState) -> Unit
content: @Composable (imageState: CoilImageState) -> Unit
) {
var state by stateFor<CoilImageState>(request) { CoilImageState.Empty }

Expand Down Expand Up @@ -313,18 +313,18 @@ fun CoilImage(
imageLoader = imageLoader,
shouldRefetchOnSizeChange = shouldRefetchOnSizeChange,
onRequestCompleted = onRequestCompleted,
) { state ->
when (state) {
) { imageState ->
when (imageState) {
is CoilImageState.Success -> {
MaterialLoadingImage(
result = state,
result = imageState,
fadeInEnabled = fadeIn,
alignment = alignment,
contentScale = contentScale,
colorFilter = colorFilter
)
}
is CoilImageState.Error -> if (error != null) error(state)
is CoilImageState.Error -> if (error != null) error(imageState)
CoilImageState.Loading -> if (loading != null) loading()
CoilImageState.Empty -> Unit
}
Expand Down Expand Up @@ -363,13 +363,13 @@ private fun CoilRequestActor(
imageLoader
.execute(transformedRequest)
.toResult(size)
.also { state ->
.also { imageState ->
// Tell RenderThread to pre-upload this bitmap. Saves the GPU upload cost on the
// first draw. See https://github.com/square/picasso/issues/1620 for a explanation
// from @ChrisCraik
when (state) {
is CoilImageState.Success -> state.image.prepareToDraw()
is CoilImageState.Error -> state.image?.prepareToDraw()
when (imageState) {
is CoilImageState.Success -> imageState.image.prepareToDraw()
is CoilImageState.Error -> imageState.image?.prepareToDraw()
}
}
.also { state ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,18 +150,18 @@ fun CoilImageWithCrossfade(
shouldRefetchOnSizeChange = shouldRefetchOnSizeChange,
modifier = modifier,
onRequestCompleted = onRequestCompleted,
) { state ->
when (state) {
) { imageState ->
when (imageState) {
is CoilImageState.Success -> {
MaterialLoadingImage(
result = state,
result = imageState,
fadeInEnabled = true,
fadeInDurationMs = crossfadeDuration,
alignment = alignment,
contentScale = contentScale,
)
}
is CoilImageState.Error -> if (error != null) error(state)
is CoilImageState.Error -> if (error != null) error(imageState)
CoilImageState.Loading -> if (loading != null) loading()
CoilImageState.Empty -> Unit
}
Expand Down

0 comments on commit de068e9

Please sign in to comment.