Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to set custom ListSectionAdapter or custom section header layout #7

Closed
wants to merge 3 commits into from

Conversation

michaldarda
Copy link
Contributor

As we speak in #6 I've added the ability to set custom ListSectionAdapter or custom section header layout in the builder.

I've added it to the builder, so you can do it like that:

        final SectionedListAdapter<ListeableAdapter> sectionedAdapter =
                SectionedListAdapter.Builder.create(this, adapter)
                        .setSectionizer(new Sectionizer<Listeable>() {
                            @Override
                            public CharSequence toSection(Listeable item) {
                                return item.getType();
                            }
                        })
                        .setSectionTitleLayout(R.layout.my_custom_list_header)
                        .build();

Or even set your own custom adapter:

        final SectionedListAdapter<ListeableAdapter> sectionedAdapter =
                SectionedListAdapter.Builder.create(this, adapter)
                        .setSectionizer(new Sectionizer<Listeable>() {
                            @Override
                            public CharSequence toSection(Listeable item) {
                                return item.getType();
                            }
                        })
                        .setSectionTitleAdapter(new SectionTitleAdapter(this, R.layout.list_header) {
                            @Override
                            public View getView(int position, View view, ViewGroup parent) {
                                // do your own custom stuff
                            }
                        })
                        .build();

Without all that stuff provided, ListSectionAdapter will instantiate SectionTitleAdapter with R.layout.list_header parameter so nothing changes.

@nolanlawson I would be grateful if you find some time and review this.

Cheers!

User can now set custom SectionTitleAdapter in the builder or just set
the custom layout in the builder
@nolanlawson
Copy link
Owner

That's awesome. I will merge this soon and push out a 1.2 version.

@nolanlawson
Copy link
Owner

Sweet, man. Merged in!

@michaldarda
Copy link
Contributor Author

Thanks for merging, and mentioning me in readme :)

@nolanlawson
Copy link
Owner

No problem, thanks for contributing. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants