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

ursus

05/11/2019, 6:08 AM
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

Miguel

05/11/2019, 6:42 PM
Sometimes is better to sacrifice some performance for the sake of maintenance ¯\_(ツ)_/¯
t

tschuchort

05/12/2019, 1:24 PM
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

ursus

05/12/2019, 2:05 PM
@tschuchort Better performance with having the header everywhere and gone-ing it?
t

tschuchort

05/12/2019, 2:07 PM
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

ursus

05/12/2019, 2:07 PM
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)
4 Views