@BindingAdapter("imageUrl")
fun loadImage(view: ImageView, url: String) {
Glide.with(view.context).load(url).into(view)
}
@BindingAdapter("textColor")
fun setTextColor(view: TextView, colorResId: Int) {
view.setTextColor(ContextCompat.getColor(view.context, colorResId))
}
@BindingAdapter("visibility")
fun setVisibility(view: View, isVisible: Boolean) {
view.visibility = if (isVisible) View.VISIBLE else View.GONE
}
@BindingAdapter("data")
fun setData(recyclerView: RecyclerView, data: List<Any>) {
(recyclerView.adapter as MyAdapter).setData(data)
}
@BindingAdapter("clickListener")
fun setClickListener(button: Button, listener: View.OnClickListener) {
button.setOnClickListener(listener)
}