Skip to content

Instantly share code, notes, and snippets.

@pflammertsma
Last active August 7, 2020 12:50
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 pflammertsma/56532ee110ffa7fa85f29c48cd8cb426 to your computer and use it in GitHub Desktop.
Save pflammertsma/56532ee110ffa7fa85f29c48cd8cb426 to your computer and use it in GitHub Desktop.
override fun onBindViewHolder(viewHolder: Presenter.ViewHolder, item: Any) {
val headerItem = (item as ListRow).headerItem
viewHolder.view.apply {
(findViewById<View>(R.id.header_icon) as ImageView).apply {
val drawableResId = when (headerItem.id) {
ID_POPULAR -> R.drawable.ic_popular
ID_EDITOR_PICKS -> R.drawable.ic_editor_picks
...
}
setImageDrawable(resources.getDrawable(drawableResId, null))
}
(findViewById<View>(R.id.header_label) as TextView).text = headerItem.name
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment