Skip to content

Instantly share code, notes, and snippets.

@kozmi55
Created August 15, 2021 13:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kozmi55/aced21ed387571b16b4b225c6184fa98 to your computer and use it in GitHub Desktop.
Save kozmi55/aced21ed387571b16b4b225c6184fa98 to your computer and use it in GitHub Desktop.
ItemViewModels
interface ItemViewModel {
@get:LayoutRes
val layoutId: Int
val viewType: Int
get() = 0
}
class HeaderViewModel(val title: String) : ItemViewModel {
override val layoutId: Int = R.layout.item_header
override val viewType: Int = CarListViewModel.HEADER_ITEM
}
class CarAdViewModel(val make: String, val model: String, val price: String) : ItemViewModel {
override val layoutId: Int = R.layout.item_car_listing_ad
override val viewType: Int = CarListViewModel.AD_ITEM
}
class CarListingViewModel(val make: String, val model: String, val price: String) : ItemViewModel {
override val layoutId: Int = R.layout.item_car_listing
override val viewType: Int = CarListViewModel.LISTING_ITEM
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment