{"id":13642723,"url":"https://github.com/truizlop/SectionedRecyclerView","last_synced_at":"2025-04-20T20:32:32.742Z","repository":{"id":96196303,"uuid":"39370185","full_name":"truizlop/SectionedRecyclerView","owner":"truizlop","description":"An adapter to create Android RecyclerViews with sections, providing headers and footers.","archived":true,"fork":false,"pushed_at":"2019-04-23T07:56:12.000Z","size":152,"stargazers_count":806,"open_issues_count":19,"forks_count":144,"subscribers_count":29,"default_branch":"master","last_synced_at":"2024-11-09T14:38:29.159Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/truizlop.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2015-07-20T07:45:16.000Z","updated_at":"2024-11-01T03:07:52.000Z","dependencies_parsed_at":null,"dependency_job_id":"8c223c1d-e837-4cc7-ac6c-36bd6adc0503","html_url":"https://github.com/truizlop/SectionedRecyclerView","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/truizlop%2FSectionedRecyclerView","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/truizlop%2FSectionedRecyclerView/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/truizlop%2FSectionedRecyclerView/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/truizlop%2FSectionedRecyclerView/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/truizlop","download_url":"https://codeload.github.com/truizlop/SectionedRecyclerView/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249958961,"owners_count":21351742,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-02T01:01:35.501Z","updated_at":"2025-04-20T20:32:32.062Z","avatar_url":"https://github.com/truizlop.png","language":"Java","funding_links":[],"categories":["RecyclerView","Libs"],"sub_categories":["\u003cA NAME=\"Widget\"\u003e\u003c/A\u003eWidget"],"readme":"⚠ This library is no longer maintained ⚠️\n\n# SectionedRecyclerView [ ![Download](https://api.bintray.com/packages/truizlop/maven/sectionedrecyclerview/images/download.svg) ](https://bintray.com/truizlop/maven/sectionedrecyclerview/_latestVersion) [![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-SectionedRecyclerView-green.svg?style=flat)](https://android-arsenal.com/details/1/2165)\nAn adapter to create Android RecyclerViews with sections, providing headers and footers.\n\n## Usage\n\nIn order to use this library, you need to extend `SectionedRecyclerView\u003cH, VH, F\u003e` where:\n\n- `H` is a class extending `RecyclerView.ViewHolder` to hold the view for section **headers**.\n- `VH` is a class extending `RecyclerView.ViewHolder` to hold the view for the regular **items** in the view.\n- `F` is a class extending `RecyclerView.ViewHolder` to hold the view for section **footers**.\n\nAccording to the sample published in this repository:\n\n- 1. Create a class extending `SectionedRecyclerView`:\n\n```java\npublic class CountSectionAdapter extends SectionedRecyclerViewAdapter\u003cCountHeaderViewHolder,\n        CountItemViewHolder,\n        CountFooterViewHolder\u003e\n```\n\n- 2. Implement the corresponding methods:\n\n```java\n@Override\nprotected int getItemCountForSection(int section) {\n    return section + 1;\n}\n\n@Override\nprotected int getSectionCount() {\n    return 5;\n}\n\n@Override\nprotected boolean hasFooterInSection(int section) {\n    return true;\n}\n\nprotected LayoutInflater getLayoutInflater(){\n    return LayoutInflater.from(context);\n}\n\n@Override\nprotected CountHeaderViewHolder onCreateSectionHeaderViewHolder(ViewGroup parent, int viewType) {\n    View view = getLayoutInflater().inflate(R.layout.view_count_header, parent, false);\n    return new CountHeaderViewHolder(view);\n}\n\n@Override\nprotected CountFooterViewHolder onCreateSectionFooterViewHolder(ViewGroup parent, int viewType) {\n    View view = getLayoutInflater().inflate(R.layout.view_count_footer, parent, false);\n    return new CountFooterViewHolder(view);\n}\n\n@Override\nprotected CountItemViewHolder onCreateItemViewHolder(ViewGroup parent, int viewType) {\n    View view = getLayoutInflater().inflate(R.layout.view_count_item, parent, false);\n    return new CountItemViewHolder(view);\n}\n\n@Override\nprotected void onBindSectionHeaderViewHolder(CountHeaderViewHolder holder, int section) {\n    holder.render(\"Section \" + (section + 1));\n}\n\n@Override\nprotected void onBindSectionFooterViewHolder(CountFooterViewHolder holder, int section) {\n    holder.render(\"Footer \" + (section + 1));\n}\n\nprotected int[] colors = new int[]{0xfff44336, 0xff2196f3, 0xff009688, 0xff8bc34a, 0xffff9800};\n@Override\nprotected void onBindItemViewHolder(CountItemViewHolder holder, int section, int position) {\n    holder.render(String.valueOf(position + 1), colors[section]);\n}\n```\n\n- 3. If you use a `GridLayoutManager`, you need to set it a `SectionedSpanSizeLookup` to make sure that headers and footers span the whole width of the `RecyclerView`:\n\n```java\nGridLayoutManager layoutManager = new GridLayoutManager(this, 2);\nSectionedSpanSizeLookup lookup = new SectionedSpanSizeLookup(adapter, layoutManager);\nlayoutManager.setSpanSizeLookup(lookup);\nrecycler.setLayoutManager(layoutManager);\n```\n\n- 4. Your result will look like this:\n\n![SectionedRecyclerView screenshot][1]\n\n## Even simpler\n\nMost times you will need a simpler version of this adapter, where there are no footers and your headers will only be a title. For those cases, you have `SimpleSectionedAdapter\u003cVH\u003e`, where `VH` is a class extending `ViewHolder` to hold the view of the regular items in your `RecyclerView`.\n\nIn this case, you will have to implement the following methods:\n\n```java\n@Override\nprotected String getSectionHeaderTitle(int section) {\n    return section == 0 ? \"Today\" : \"Tomorrow\";\n}\n\n@Override\nprotected int getSectionCount() {\n    return 2;\n}\n\n@Override\nprotected int getItemCountForSection(int section) {\n    return 3;\n}\n\n@Override\nprotected AgendaItemViewHolder onCreateItemViewHolder(ViewGroup parent, int viewType) {\n    LayoutInflater inflater = LayoutInflater.from(parent.getContext());\n    View view = inflater.inflate(R.layout.view_agenda_item, parent, false);\n    return new AgendaItemViewHolder(view);\n}\n\nprotected String[][] agenda = {{\"Meeting\", \"Phone call\", \"Interview\"},\n            {\"Basket match\", \"Grocery shopping\", \"Taking a nap\"}};\n\n@Override\nprotected void onBindItemViewHolder(AgendaItemViewHolder holder, int section, int position) {\n    holder.render(agenda[section][position]);\n}\n```\n\nYour result will look like this:\n\n![SimpleSectionedAdapter screenshot][2]\n\n## Get it!\n\n`SectionedRecyclerView` is available through JCenter. To be able to use this library in your project, add the following dependency to your `build.gradle` file:\n\n```groovy\ndependencies{\n\tcompile 'com.truizlop.sectionedrecyclerview:library:1.2.0'\n}\n```\n\n## License\n\n\n    Copyright 2015 Tomás Ruiz-López\n\n    Licensed under the Apache License, Version 2.0 (the \"License\");\n    you may not use this file except in compliance with the License.\n    You may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\n    Unless required by applicable law or agreed to in writing, software\n    distributed under the License is distributed on an \"AS IS\" BASIS,\n    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n    See the License for the specific language governing permissions and\n    limitations under the License.\n\n[1]: ./art/screenshot1.png\n[2]: ./art/screenshot2.png\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftruizlop%2FSectionedRecyclerView","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftruizlop%2FSectionedRecyclerView","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftruizlop%2FSectionedRecyclerView/lists"}