I want to call a function where drawableprofile is binding as a profile icon. I want to call it when "imageUrl" child doesn't exist.
val uid = firebaseAuth.currentUser?.uid
if (uid != null) {
database.child(uid).get().addOnSuccessListener {
if (it.exists()) {
val fetchimg = it.child("imageUrl").value
Glide.with(this).load(fetchimg).into(binding.profileIcon)
} else if {
database.child(uid).child("imageUrl")
val drawableprofile = resources.getDrawable(R.drawable.ic_person)
Glide.with(this).load(drawableprofile).into(binding.profileIcon)
}
}
}
I can't find any .isNull function etc. Thanks for help
CodePudding user response:
According to your last comment:
I need to do a placeholder until a user chooses his own profile image.
Since you're using Glide for Android to display your images, then you can simply call Glide#placeholder() like this:
Glide
.with(this)
.load(fetchimg) //