0

The GlideImage composable in the Landscapist image loading library for Compose is missing the loading, success, and failure parameters, but the GitHub Readme for the library states these parameters are available. Android Studio just throws a compile time error. Do I have to implement them differently with this library?

GlideImage(
  imageModel = imageUrl,
  modifier = modifier,
  // Throws compiler error here
  loading = {
    Box(modifier = Modifier.matchParentSize()) {
      CircularProgressIndicator(
        modifier = Modifier.align(Alignment.Center)
      )
    }
  }
)
Raj Narayanan
  • 2,443
  • 4
  • 24
  • 43

1 Answers1

1

I try replicate but works for me. I using version 1.4.9 of Glide. You can try implement success and failure too.

GlideImage(
     modifier = Modifier
         .size(40.dp)
         .background(Color.Green),
     imageModel = "https://yt3.ggpht.com/ytc/AMLnZu-v-ApUfdP0KinqrJQyNYP5BVd1ke0C7HsoTtkH=s900-c-k-c0x00ffffff-no-rj",
      success = {
         Image(
              painter = rememberDrawablePainter(drawable = it.drawable),
              contentDescription = null
         )
      },
      failure = {
         Image(
             painter = rememberDrawablePainter(drawable = it.errorDrawable),
             contentDescription = null
         )
      },
      loading = {
         Box(modifier = Modifier.matchParentSize()) {
             CircularProgressIndicator(
                  modifier = Modifier.align(Alignment.Center),
                  progress = it.progress
             )
       }
   }
)
  • `Glide` version 1.4.9 is an older version, the latest version which the the `Landscapist` library is using internally is 4.13.2. I want to use the latest version though, and it seems like these parameters aren't included in the latest version. – Raj Narayanan Jul 30 '22 at 00:14
  • @rajndev, can you show the error? Will be very helpful. Because I update the Glide to last version (1.5.2) and still works in my project. – Otávio Moreira Jul 31 '22 at 18:26
  • The error says `Unresolved reference: loading`, and 1.5.2 is not the last version. The last version is 4.13.2 as stated in the library's Github repo page @ https://github.com/bumptech/glide/releases/tag/v4.13.2. Can you show me which dependency you are using in the Gradle file? Thanks. – Raj Narayanan Jul 31 '22 at 21:07
  • My glide dependency is "com.github.skydoves:landscapist-glide:1.5.2". I just remember now. Is a library that use Glide, Fresco e Coil to be a easy implementation with Compose. Here is the link https://github.com/skydoves/landscapist – Otávio Moreira Aug 01 '22 at 18:32
  • I'm using the latest version 1.5.3. I think they removed those parameters in version 1.5.3. – Raj Narayanan Aug 02 '22 at 17:53