File tree Expand file tree Collapse file tree 2 files changed +10
-4
lines changed
designsystem/src/main/java/com/google/samples/apps/nowinandroid/core/designsystem/component
ui/src/main/java/com/google/samples/apps/nowinandroid/core/ui Expand file tree Collapse file tree 2 files changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,7 @@ import androidx.compose.ui.Modifier
3131import androidx.compose.ui.graphics.ColorFilter
3232import androidx.compose.ui.graphics.painter.Painter
3333import androidx.compose.ui.layout.ContentScale
34+ import androidx.compose.ui.platform.LocalInspectionMode
3435import androidx.compose.ui.res.painterResource
3536import androidx.compose.ui.unit.dp
3637import coil.compose.AsyncImage
@@ -60,11 +61,12 @@ fun DynamicAsyncImage(
6061 isError = state is Error
6162 },
6263 )
64+ val isLocalInspection = LocalInspectionMode .current
6365 Box (
6466 modifier = modifier,
6567 contentAlignment = Alignment .Center ,
6668 ) {
67- if (isLoading) {
69+ if (isLoading && ! isLocalInspection ) {
6870 // Display a progress bar while loading
6971 CircularProgressIndicator (
7072 modifier = Modifier
@@ -75,10 +77,9 @@ fun DynamicAsyncImage(
7577 }
7678 Image (
7779 contentScale = ContentScale .Crop ,
78- painter = if (isError.not ()) imageLoader else placeholder,
80+ painter = if (isError.not () && ! isLocalInspection ) imageLoader else placeholder,
7981 contentDescription = contentDescription,
8082 colorFilter = if (iconTint != null ) ColorFilter .tint(iconTint) else null ,
81- modifier = modifier,
8283 )
8384 }
8485}
Original file line number Diff line number Diff line change @@ -158,6 +158,7 @@ fun NewsResourceHeaderImage(
158158 isError = state is AsyncImagePainter .State .Error
159159 },
160160 )
161+ val isLocalInspection = LocalInspectionMode .current
161162 Box (
162163 modifier = Modifier
163164 .fillMaxWidth()
@@ -179,7 +180,11 @@ fun NewsResourceHeaderImage(
179180 .fillMaxWidth()
180181 .height(180 .dp),
181182 contentScale = ContentScale .Crop ,
182- painter = if (isError.not ()) imageLoader else painterResource(drawable.ic_placeholder_default),
183+ painter = if (isError.not () && ! isLocalInspection) {
184+ imageLoader
185+ } else {
186+ painterResource(drawable.ic_placeholder_default)
187+ },
183188 // TODO b/226661685: Investigate using alt text of image to populate content description
184189 contentDescription = null , // decorative image,
185190 )
You can’t perform that action at this time.
0 commit comments