Using placeholder in Coil when the url is null

Viewed 27

I get some data from database and push it to reciclerview. I use Coil to show images. But there are some urls that are null and I need to use some placeholder in such cases. I tried all the option I saw in the internet but nothing helped.

binding.posterIv.load(UtilsUi.BASE_URL + recyclerViewItem.poster_path){
     placeholder(R.drawable.placeholder_male)
     error(R.drawable.placeholder_male)
     fallback(R.drawable.placeholder_male)
}

When the url is null I just get empty black space.

enter image description here

enter image description here

ImageView looks like this:

<ImageView
   android:id="@+id/actorImageView"
   android:layout_width="50dp"
   android:layout_height="50dp"
   android:src="@drawable/keanuriives" />

Do you have any idea how to fix it? P.S. Coil needs to be used, not Glide or Picasso.

0 Answers
Related