0

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.

Alex20280
  • 97
  • 6
  • `if (url == null) ...` – JakeB Sep 07 '22 at 20:43
  • I just realize what is wrong. My URL is always not null because there always exists the first part of the URL (UtilsUi.BASE_URL). I need to check somehow is recyclerViewItem.poster_path is null and if it's null then show a placeholder. But not sure yet how to do it. – Alex20280 Sep 08 '22 at 13:20

0 Answers0