How can I get my ItemDecoration
to \"update\" the item offsets for other views when I remove a given view from my adapter and the
ListAdapter solution:
listAdapter.submitList(newList) {
handler.post { // or just "post" if you're inside View
recyclerView.invalidateItemDecorations()
}
}
The key is new submitList(list, commitCallback)
method from latest RecyclerView release. It allows you to call invalidateItemDecorations()
after ListAdapter will apply all changes to RecyclerView.
I also had to add post {}
call to make it work - without it decorations invalidated too early, and nothing happens.