Bookends
Bookends copied to clipboard
Add support for GridLayoutManager
The API looks great, though I would like to use it with GridLayoutManager
as well.
It works with GridLayoutManager
. The only additional step is to implement GridLayoutManager
's setSpanSizeLookUp
in your view or adapter if necessary for your header & footers so that it spans the # of columns in the grid. I'll provide an example shortly.
https://developer.android.com/reference/android/support/v7/widget/GridLayoutManager.html
What do you think about adding another Bookends
constructor that also takes a GridLayoutManager
and sets a SpanSizeLookup
that causes the headers and footers to span all columns? I imagine that's the most common use case and it would be nice if the client didn't have to think about the headers and footers beyond adding them.
I have some concerns before coupling the adapter & layout manager:
- You'd still have to roll your own if you wanted a header or footer to not span all columns
- Orientation change w/ linear <-> grid managers would be a bit clumsy unless you did a single column grid in portrait instead of linear
- It makes the component a tiny bit less flexible
Constructors that allow for a lookup definition or number of columns may be ok. It's definitely not ideal that this does not work properly w/ grid layouts without a few extra lines of code.
@mlapadula thoughts?
Supporting grid layouts seems sensible -- I know you have a solution that already works, and it'd be cool to make it available because it takes a few hours (at least) to figure out if you're unaware of it.
It does kind of suck that we're coupling the adapter and layout manager, but we're already kind of doing that since this implementation only works with LinearLayoutManager :p