tumblr / Bookends

A UI widget for adding headers and footers to RecyclerView
539 stars 62 forks source link

Add support for GridLayoutManager #3

Open pushbit opened 9 years ago

pushbit commented 9 years ago

The API looks great, though I would like to use it with GridLayoutManager as well.

KevinTCoughlin commented 9 years ago

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

pushbit commented 9 years ago

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.

KevinTCoughlin commented 9 years ago

I have some concerns before coupling the adapter & layout manager:

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?

mlapadula commented 9 years ago

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