https://kotlinlang.org logo
#android-architecture
Title
# android-architecture
u

ursus

07/26/2019, 3:49 AM
Hi, I have a margin item decoration which overrides getItemOffsets and for simplicity lets say adds bottom margin X to every 3rd item, and some smaller X/2 margin to others. So my issue is that without invalidating the item decoration, views keep these margins, and when animation recyclerview via notifyItemInserted and friends (via DiffUtil), it causes wrong margin (not big margin every 3rd item) So I google'd, I need to invalidate like this
Copy code
adapter.items = diff.list
diff.result.dispatchUpdatesTo(adapter)
recyclerView.invalidateItemDecorations()
Which does make the margins correct, however this doesn't get calculated into the animations*, and view jump to some incorrect intial position and animate to their end position* Has anyone encountered this? Its very annoying. Do I need to write my own ItemAnimator?
google 1
e

Eugen Martynov

07/26/2019, 1:24 PM
How it is related to Kotlin?
u

ursus

07/26/2019, 3:20 PM
how is android architecture related to kotlin?
no red 1
👏 1
8 Views