From 87206525a224615dc9ef4bc1e60ef6e969c6561b Mon Sep 17 00:00:00 2001 From: dmail Date: Wed, 11 Sep 2024 10:06:52 -0700 Subject: [PATCH 1/3] Docs: Adds a Glide snippet for the "Loading Images" Quick Guide at https://developer.android.com/quick-guides/content/load-images?hl=en --- compose/snippets/build.gradle.kts | 1 + .../snippets/images/LoadingImagesSnippets.kt | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/compose/snippets/build.gradle.kts b/compose/snippets/build.gradle.kts index 5d2b661f..da10cf33 100644 --- a/compose/snippets/build.gradle.kts +++ b/compose/snippets/build.gradle.kts @@ -159,5 +159,6 @@ dependencies { androidTestImplementation(libs.androidx.compose.ui.test.junit4) debugImplementation(libs.androidx.compose.ui.test.manifest) + implementation("com.github.bumptech.glide:compose:1.0.0-beta01") } diff --git a/compose/snippets/src/main/java/com/example/compose/snippets/images/LoadingImagesSnippets.kt b/compose/snippets/src/main/java/com/example/compose/snippets/images/LoadingImagesSnippets.kt index 4ca5d70d..f0aee2e6 100644 --- a/compose/snippets/src/main/java/com/example/compose/snippets/images/LoadingImagesSnippets.kt +++ b/compose/snippets/src/main/java/com/example/compose/snippets/images/LoadingImagesSnippets.kt @@ -22,6 +22,8 @@ import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.Preview import coil.compose.AsyncImage +import com.bumptech.glide.integration.compose.ExperimentalGlideComposeApi +import com.bumptech.glide.integration.compose.GlideImage import com.example.compose.snippets.R /* @@ -53,7 +55,7 @@ fun LoadingImageFromDisk() { @Preview @Composable -fun LoadingImageFromInternet() { +fun LoadingImageFromInternetCoil() { // [START android_compose_images_load_internet_coil] AsyncImage( model = "https://example.com/image.jpg", @@ -61,3 +63,16 @@ fun LoadingImageFromInternet() { ) // [END android_compose_images_load_internet_coil] } + +@OptIn(ExperimentalGlideComposeApi::class) +@Preview +@Composable +fun LoadingImageFromInternetGlide() { + // [START android_compose_images_load_internet_glide] + GlideImage( + model = "https://example.com/image.jpg", + contentDescription = "Translated description of what the image contains" + ) + // [END android_compose_images_load_internet_glide] +} + From aaef2d92a50f3bf06672da6de9163304ff275322 Mon Sep 17 00:00:00 2001 From: thedmail Date: Wed, 11 Sep 2024 17:12:53 +0000 Subject: [PATCH 2/3] Apply Spotless --- .../com/example/compose/snippets/images/LoadingImagesSnippets.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/compose/snippets/src/main/java/com/example/compose/snippets/images/LoadingImagesSnippets.kt b/compose/snippets/src/main/java/com/example/compose/snippets/images/LoadingImagesSnippets.kt index f0aee2e6..879b2f9a 100644 --- a/compose/snippets/src/main/java/com/example/compose/snippets/images/LoadingImagesSnippets.kt +++ b/compose/snippets/src/main/java/com/example/compose/snippets/images/LoadingImagesSnippets.kt @@ -75,4 +75,3 @@ fun LoadingImageFromInternetGlide() { ) // [END android_compose_images_load_internet_glide] } - From 39aaf9b57de11c8de7eac22851605afcf890405e Mon Sep 17 00:00:00 2001 From: dmail Date: Wed, 11 Sep 2024 14:54:46 -0700 Subject: [PATCH 3/3] Moves Glide dependency to libs.versions.toml. --- compose/snippets/build.gradle.kts | 3 ++- gradle/libs.versions.toml | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/compose/snippets/build.gradle.kts b/compose/snippets/build.gradle.kts index da10cf33..de47ea8b 100644 --- a/compose/snippets/build.gradle.kts +++ b/compose/snippets/build.gradle.kts @@ -144,6 +144,8 @@ dependencies { implementation(libs.googlemaps.maps) implementation(libs.hilt.android) + implementation(libs.glide.compose) + kapt(libs.hilt.compiler) testImplementation(libs.junit) @@ -159,6 +161,5 @@ dependencies { androidTestImplementation(libs.androidx.compose.ui.test.junit4) debugImplementation(libs.androidx.compose.ui.test.manifest) - implementation("com.github.bumptech.glide:compose:1.0.0-beta01") } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 8649031d..5b8ae659 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -50,6 +50,7 @@ version-catalog-update = "0.8.3" wearComposeFoundation = "1.4.0" wearComposeMaterial = "1.4.0" composeUiTooling = "1.4.0" +glide= "1.0.0-beta01" [libraries] accompanist-adaptive = { module = "com.google.accompanist:accompanist-adaptive", version.ref = "accompanist" } @@ -126,6 +127,7 @@ androidx-media3-exoplayer = { group = "androidx.media3", name = "media3-exoplaye play-services-wearable = { module = "com.google.android.gms:play-services-wearable", version.ref = "playServicesWearable" } compose-ui-tooling = { group = "androidx.wear.compose", name = "compose-ui-tooling", version.ref = "composeUiTooling" } androidx-material-icons-core = { module = "androidx.compose.material:material-icons-core" } +glide-compose = { module = "com.github.bumptech.glide:compose" , version.ref = "glide"} [plugins] android-application = { id = "com.android.application", version.ref = "androidGradlePlugin" }