Does `data class` have problem with huge data? I m...
# android
r
Does
data class
have problem with huge data? I mean, I'm using a
data class
in a
RecyclerView
and this class has some fields (all of them are primitive types) and when applying some animations when the user click in one of the items in the list these animations does not works properly. But if I use a
class
instead of a
data class
, everything works fine and all animations are applied.
a
If your animation triggers an item comparison on the list items you could see problems if the
equals
and
hashcode
methods generated by the
data class
were very expensive.
👍 1
r
This is what happens when I use DC: https://imgur.com/a/CkorJ Normal anim (what should happen): https://imgur.com/a/G60r2
Also, I haven't thought about it, @anthonycr. That could be a good start to solve it, thank you.
a
Looking at those animations, maybe the animation relies on each item being logically different and with
data class
the comparison now it’s checking field equality… so where
class1 != class2
, now maybe
dataClass
== dataClass2`. Might be helpful to wrap your
data class
in a ViewModel/ViewState like class for display in that list.
👍 1