-
-
Save kozmi55/1d6e71466b96d0b832cbd6aaf93043a8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface ItemViewModel { | |
... | |
val bindableProperties: Map<Int, Any> | |
} | |
class CarAdViewModel(val make: String, val model: String, val price: String) : ItemViewModel { | |
... | |
override val bindableProperties: Map<Int, Any> = mapOf( | |
BR.make to make, | |
BR.model to model | |
) | |
} | |
class BindableViewHolder(private val binding: ViewDataBinding) : RecyclerView.ViewHolder(binding.root) { | |
fun bind(itemViewModel: ItemViewModel) { | |
itemViewModel.bindableProperties.entries.forEach { | |
binding.setVariable(it.key, it.value) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment