I have created a blinding adapter:
@BindingAdapter("android:profileImage")
fun setProfileImage(imageView: ImageView, profileImage: String) {
Glide.with(imageView.context).load(profileImage)
.placeholder(R.drawable.placeholder)
.into(imageView)
}
And it woks fine. However, when I request the users from a public API, there are some cases in which the profileImage is null. My goal is to use Glide when the profileImage is not null, otherwise use the placeholder that exists in the drawable directory. This what I have tried to my ImageVIew:
android:profileImage="@{user.isProfilePictureNotNull() ? user.profileImage : @drawable.placeholder}"
Where isProfilePictureNotNull() is defined as:
fun isProfilePictureNotNull() = profileImage != null
But Android Studio is complaning with:
'!=', '%', '*', '+', '-', '/', ':', <, <<, <=, '==', '>', '>=', '>>', '>>>' or '[' expected, got ':'.
How to solve this issue?