luizgrp / SectionedRecyclerViewAdapter

An Adapter that allows a RecyclerView to be split into Sections with headers and/or footers. Each Section can have its state controlled individually.
MIT License
1.68k stars 372 forks source link

Design suggestion based on the following use case #193

Closed yccheok closed 4 years ago

yccheok commented 4 years ago

Hi,

I would like to know, is SectionedRecyclerViewAdapter a good candidate to implement the following case?

Screenshot_20200422-012340

https://youtu.be/CdNOw4jyD00

My initial design thought is that

Using SectionedRecyclerViewAdapter

  1. Every A, B, C, ... is Section A, Section B, Section C
  2. Section B will has 1 header, 3 content items (B.1, B.2, B.3)
  3. Section A, C, ... will have 1 header, 0 content items.

However, such design might be highly inefficient as, you need to dynamically allocate a lot of Section, add/ remove Section during run-time. Most of the time, the number of Section content item will be 0.

NOT Using SectionedRecyclerViewAdapter

Another approach I can think of, is treating this RecyclerView is only having 1 view type.

A single class data structure will used to hold information A, B, B.1, B.2, B.3, C, ...

During onBindViewHolder, we will then slightly adjust the UI outlook, based on whether the item is B or B.1

Do you have any suggestion what are some other better approaches I can use?

Thank you.

luizgrp commented 4 years ago

Hi @yccheok, I'm afraid I agree with you that this library wouldn't be the best to build that kind of layout. In order to do that efficiently the library would need to support including items that are not sections.

I would recommend you to try Groupie. B and E would be of type ExpandableGroup and the others would be of type Item.