Created
May 21, 2020 21:24
-
-
Save osama/9bbca5cb46ac9766fceebf46c04f2d67 to your computer and use it in GitHub Desktop.
Server-Driven UI Blog
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
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