Skip to content

Instantly share code, notes, and snippets.

@seoft
Last active November 13, 2021 10:41
Show Gist options
  • Save seoft/40df9d620427a8975e71c20db258b35b to your computer and use it in GitHub Desktop.
Save seoft/40df9d620427a8975e71c20db258b35b to your computer and use it in GitHub Desktop.
sealed class AntonioUiModel(
val type: Type,
open val id: Long,
open val price: Int
) : AntonioBindingModel {
enum class Type { MONITOR, MOUSE, PHONE }
override fun bindingVariableId(): Int = BR.item
data class Monitor(override val id: Long, override val price: Int, val inch: Float) :
AntonioUiModel(Type.MONITOR, id, price) {
override fun layoutId(): Int = R.layout.item_antonio_monitor
}
data class Mouse(override val id: Long, override val price: Int, val buttonCount: Int) :
AntonioUiModel(Type.MOUSE, id, price) {
override fun layoutId(): Int = R.layout.item_antonio_mouse
}
data class Phone(override val id: Long, override val price: Int, val os: String) :
AntonioUiModel(Type.PHONE, id, price) {
override fun layoutId(): Int = R.layout.item_antonio_phone
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment