Skip to content

Instantly share code, notes, and snippets.

@osama
Created May 21, 2020 21:24
Show Gist options
  • Save osama/9bbca5cb46ac9766fceebf46c04f2d67 to your computer and use it in GitHub Desktop.
Save osama/9bbca5cb46ac9766fceebf46c04f2d67 to your computer and use it in GitHub Desktop.
Server-Driven UI Blog
class HomeController(
val onSmallNavigationClick: (SmallNavigationSection, Int) -> Unit,
) : PagedListEpoxyController<HomeSection>() {
override fun buildItemModel(
currentPosition: Int,
item: HomeSection?
): EpoxyModel<*> = when (item) {
is SmallNavigationSection -> buildSmallNav(
item,
currentPosition
)
else -> throw IllegalStateException("This controller does not support placeholders")
}
private fun buildSmallNav(item: SmallNavigationSection, verticalPosition: Int): EpoxyModel<*> =
SmallNavigationSectionViewModel_()
.id(item.id)
.heading(item.heading)
.subheading(item.subheading)
.image(item.image)
.onClick {
onSmallNavigationClick(item, verticalPosition)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment