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

#98 Allow resource ID 0 for view holder creation without inflation #99

Closed Philipp91 closed 6 years ago

Philipp91 commented 6 years ago

This is useful for cases when the view (tree) is created programmatically, e.g. because it's just a simple single view, because of dependency injection or for other reasons. The special value 0 was chosen because null already means "no header/footer/...". Passing zero for a layout resource skips the layout inflation and just calls the getXyzViewHolder() function directly. The parent is passed in mostly so that the Section implementation has access to the Context.

While this change does not break any existing use cases, it makes the interface slightly more confusing (should I add documentation?) and slightly less fool-proof (people might accidentally pass 0, though that's unlikely). Let me know what you think.

luizgrp commented 6 years ago

Hi @Philipp91, I wrote some suggestions regarding to the design in #98 👍 Please open future PRs to merge into develop branch, I will close this one for this reason.