I'm trying to check if a profile has an image URL set and, if so, load it into an ImageView
:
val hasImage = image != null && image.isNotBlank()
if (hasImage) {
Picasso.with(context).load(image).into(row.image)
}
image
is a nullable string. The problem is that even when hasImage
is false, it still loads the image, as you can see:
However, if I do val hasImage = false
it behaves as expected.
I'm incredibly confused as to what is going on here. Why is the if
condition still executing?
Probably there’s a compilation problem. The screenshot shows an impossible scenario. Where do you start the app? Try to rebuild and then debug again. Also try to add some logs.
It’s not due to the way you chose to check the Boolean expression...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With