I have 32 view types in recycler view. I think its...
# android-architecture
u
I have 32 view types in recycler view. I think its too much. But most of them are variations of the same (like item A with and without header, or item A with big margin left to visualize nesting). Maybe it makes sense to have that be the same view type and visible/gone the header in on bindview? Is there some perf penalty to this? In my head it causes layout, but so does setting text on wrap_content height textview. What would be the heuristic to create a new viewtype if views are like that? (variations of the same?)
m
Sometimes is better to sacrifice some performance for the sake of maintenance ¯\_(ツ)_/¯
t
Performance would be better because then the recycling works more effectively. Facebook had the same problem and created the litho library, which works basically the same as react vdom
u
@tschuchort Better performance with having the header everywhere and gone-ing it?
t
I think so. The recycler view can only recycle when the view type is the exact same, even when they are actually almost identical. Just imagine a RV where every view had a different type. There would be 0 recycling
You can read more about that in the posts about litho
u
yes but I dont think its what they did in litho
afaik they break apart the view with havingg separate viewtype for header only and then viewtype for body
so its unrelated views that only look related
anyways, im with you on the perf (I think its correct), but then you consume more memory having views in evry row you dont ever show)