I have a viewHolder that loads up an image using Picasso. The DB will return a path of URL as String. So I have my code as below (Using Kotlin)
Picasso.with(context).load(url).error(placeholder).transform(transformation)
.placeholder(placeholder).into(this)
It loads fine. However, sometimes the URL is empty. I'm expecting it to load the placeholder instead. But it crash out as below
java.lang.IllegalArgumentException: Path must not be empty.
at com.squareup.picasso.Picasso.load(Picasso.java:297)
This would force me to explicitly do a check, which is not ideal
if (url == null || url.isEmpty()) {
Picasso.with(context).load(placeholder).transform(transformation).into(this)
} else {
Picasso.with(context).load(url).error(placeholder).transform(transformation)
.placeholder(placeholder).into(this)
}
Is this expected that Picasso will crash when a URL String is empty instead of loading the placeholder?