Skip to content

Instantly share code, notes, and snippets.

@STAR-ZERO
Created October 15, 2020 08:47
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 STAR-ZERO/a0779b8863334d9ca9c59a5d0391aaf3 to your computer and use it in GitHub Desktop.
Save STAR-ZERO/a0779b8863334d9ca9c59a5d0391aaf3 to your computer and use it in GitHub Desktop.
Find an adapter from ConcatAdapter global position.
fun ConcatAdapter.findAdapter(position: Int): RecyclerView.Adapter<*>? {
var totalCount = 0
adapters.forEach { adapter ->
totalCount += adapter.itemCount
if (position < totalCount) {
return adapter
}
}
return null
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment