I have a list with 10 different layout type , each type can text comment or not , For example I have an Image layout that can contain text or not , layout here is similar to blog post
Another type is Video that may contain text or not
Must I define 20 different ViewTypes for LayoutProvider ?
Me second question is more complex than first (Please reply both question seperatly)
My 10 different layout types can be combine together can create 100 possible different views for example , We have a Single Image View , Single Image View combined by another Image (second image attached to first and create a complex view that is combined by two image) , Single Image combined by
Video view
But in a long list usually 100 possible views is not used (Only ~12 different views at max and ~5 different views average)
Must I define 100 ViewTypes for LayoutProvider ?
Having 100 view types would definitely hurt recycling if most of these would be present in the list. Since for each type you need atleast one item out of viewport to reuse it. The way I see it is that you should aim to reduce the number of mounts/unmounts.
A simple example, lets say we have a view that looks like this:
Image + Text
And the Text is optional, while recycling if your component renders Text on the basis of whether text is there or not the Text component will see multiple unmounts/mounts. This might lead to drop in performance. A better way would be to simply hide Text (opacity = 0) and let it be there since it might get reused in future.
What I think you should do is come up with fewer types which can serve multiple templates without unmounting and remounting too many elements.
I can convert Image + Text to Image + Hidden Text for multi purpose
But Really it is not possible for Image+Image and Image+Video and other types , Is the following solution good?
| ElementType | ViewType |
|------------- |---------- |
| Image | 0 |
| Video | 1 |
| Audio | 2 |
| Image+Image | 3 |
| Image+Video | 4 |
| Image+Audio | 5 |
| Video+Image | 6 |
| Video+Video | 7 |
| Video+Audio | 8 |
| Audio+Image | 9 |
| Audio+Video | 10 |
| Audio+Audio | 11 |
Usually in a long list all types is not used , For example in 1000 records , we have 500xImage , 300xVideo , 50xAudio , 50xImage+Image and less than 50x Video+Video and Audio+Image
I think if 300x first records is only Image , recycle view is never create a Video ,... , Only 10-15 Image is created and reused , and when first Video is coming to view report its instantiated
Is this a good (or bad) solution? is there any other better solution?
Yeah given your use case this might work. Don't see any unmounts. You should try and see. Frame rate should be fine but also do check memory usage to see it doesn't go too high. Ideally it shouldn't l.
Closing. Please open a new issue incase of any more queries.