Skip to content

Instantly share code, notes, and snippets.

@rmyhal
Created July 27, 2020 06:25
Show Gist options
  • Save rmyhal/223645f0dfb19ec153c4bdebc3960f17 to your computer and use it in GitHub Desktop.
Save rmyhal/223645f0dfb19ec153c4bdebc3960f17 to your computer and use it in GitHub Desktop.
override fun onBindViewHolder(
holder: FragmentViewHolder,
position: Int,
payloads: MutableList<Any>
) {
if (payloads.isNotEmpty()) {
val tag = "f" + holder.itemId
val fragment = activity.supportFragmentManager.findFragmentByTag(tag)
// safe check, but fragment should not be null here
if (fragment != null) {
(fragment as PagerFragment).setValue(items[position].value)
} else {
super.onBindViewHolder(holder, position, payloads)
}
} else {
super.onBindViewHolder(holder, position, payloads)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment