Last active
December 20, 2017 15:28
-
-
Save regularberry/8d9c4967619daf6c433c593cfd3e3912 to your computer and use it in GitHub Desktop.
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
override fun onBindViewHolder(holder: ViewHolder, | |
position: Int, | |
payloads: MutableList<Any>) { | |
if (!payloads.isEmpty()) { | |
// Because these updates can be batched, | |
// there can be multiple payloads for a single bind | |
when (payloads[0]) { | |
Payload.FAVORITE_CHANGE -> { | |
// Change only the "favorite" icon, | |
// leave background image alone: | |
bindFavoriteIcon(holder, | |
items[position].isFavorited) | |
} | |
} | |
} | |
// When payload list is empty, | |
// or we don't have logic to handle a given type, | |
// default to full bind: | |
super.onBindViewHolder(holder, position, payloads) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment