{"id":28737325,"url":"https://github.com/pokk/adaptiverecyclerview","last_synced_at":"2026-04-25T11:32:16.503Z","repository":{"id":52255591,"uuid":"102561440","full_name":"pokk/AdaptiveRecyclerView","owner":"pokk","description":"Adaptive layout view and multiple type viewholder.","archived":false,"fork":false,"pushed_at":"2021-05-03T08:25:36.000Z","size":279,"stargazers_count":3,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-06-16T02:10:01.415Z","etag":null,"topics":["android","kotlin","multitype","recyclerview"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pokk.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-09-06T04:09:08.000Z","updated_at":"2022-05-29T13:08:56.000Z","dependencies_parsed_at":"2022-09-10T22:02:13.965Z","dependency_job_id":null,"html_url":"https://github.com/pokk/AdaptiveRecyclerView","commit_stats":null,"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"purl":"pkg:github/pokk/AdaptiveRecyclerView","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pokk%2FAdaptiveRecyclerView","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pokk%2FAdaptiveRecyclerView/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pokk%2FAdaptiveRecyclerView/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pokk%2FAdaptiveRecyclerView/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pokk","download_url":"https://codeload.github.com/pokk/AdaptiveRecyclerView/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pokk%2FAdaptiveRecyclerView/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260083859,"owners_count":22956409,"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":["android","kotlin","multitype","recyclerview"],"created_at":"2025-06-16T02:10:00.414Z","updated_at":"2026-04-25T11:32:11.480Z","avatar_url":"https://github.com/pokk.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# AdaptiveRecyclerView\n\n[![GitHub release](https://img.shields.io/github/release/pokk/AdaptiveRecyclerView.svg?style=flat-square)](https://github.com/pokk/AdaptiveRecyclerView)\n[![license](https://img.shields.io/github/license/pokk/AdaptiveRecyclerView.svg?style=flat-square)](https://github.com/pokk/AdaptiveRecyclerView)\n\nIn the beginning, my purpose is for the expanding recycler view. For it, I need to make recycler\nview adapt to each of the type of the list children. For this reason, first I open this adaptive\nrecycler view.\n\nThis adaptive recycler view might be not the easiest way to achieve. I'm using the concept of [Visitor\nPattern](http://www.wikiwand.com/en/Visitor_pattern) into this adaptive recycler view. Here there're\nsome roles I have to introduce first.\n\n- **_Visitor_**: `AdaptiveAdapter`\n- **_Visitable (Element)_**: `IVisitable`\n\nWe use them to get each of the type of the elements.\n\n# How to use\n\n#### First create concrete class\n\n1. **RecyclerView.Adaptor**\n2. **ViewHolder**\n3. **Data Model Elements**\n4. **ViewTypeFactory**\n\n#### 🍷 Example\n\nMake two type of the element class.\n\n```kotlin\ndata class ProductTypeOne(var name: String,\n                          override var childItemList: List\u003cIExpandVisitor\u003e = emptyList(),\n                          override var isExpandable: Boolean = false): IVisitable {\n    override fun type(typeFactory: MultiTypeFactory): Int = typeFactory.type(this)\n}\n\ndata class ProductTypeTwo(var name: String,\n                          override var childItemList: List\u003cIExpandVisitor\u003e = emptyList(),\n                          override var isExpandable: Boolean = false): IVisitable {\n    override fun type(typeFactory: MultiTypeFactory): Int = typeFactory.type(this)\n}\n```\n\nCreate a multiple view type factory for providing difference view type and view holder.\n\n```kotlin\nclass MultiTypeFactory: ViewTypeFactory() {\n override var transformMap: MutableMap\u003cInt, Pair\u003cInt, (View) -\u003e ViewHolder\u003e\u003e =\n     mutableMapOf(1 to Pair(R.layout.item_first, { itemView -\u003e FirstViewHolder(itemView) }),\n         2 to Pair(R.layout.item_second, { itemView -\u003e SecondViewHolder(itemView) }))\n\n fun type(typeone: ProductTypeOne): Int = 1\n\n fun type(typetwo: ProductTypeTwo): Int = 2\n}\n```\n\nDepend on the difference layouts, we init in each of view holder. The view holder is like an\n`activity`/`fragment`. I prefer to initial and control the components in the view holder.\n\n```kotlin\nclass TypeOneViewHolder(view: View): AdaptiveViewHolder\u003cMultiTypeFactory, ProductTypeOne\u003e(view) {\n    override fun initView(model: ProductTypeOne, position: Int, adapter: Any) {\n        adapter as YouAdapterClassName\n    }\n}\n\nclass TypeTwoViewHolder(view: View): AdaptiveViewHolder\u003cMultiTypeFactory, ProductTypeTwo\u003e(view) {\n    override fun initView(model: ProductTypeTwo, position: Int, adapter: Any) {\n        adapter as YouAdapterClassName\n    }\n}\n```\n\nAs like original using, it's so easy!\n\n```kotlin\nclass MainActivity: AppCompatActivity() {\n    override fun onCreate(savedInstanceState: Bundle?) {\n        ...\n        val itemList: MutableList\u003cIVisitable\u003e =\n            mutableListOf(ProductTypeTwo(\"iPhone 6 plus\"),\n                ProductTypeOne(\"Google\"),\n                ProductTypeOne(\"HTC\"),\n                ProductTypeTwo(\"iPhone 6\"),\n                ProductTypeTwo(\"iPhone 6s\"),\n                ProductTypeTwo(\"iPhone 7\"),\n                ProductTypeTwo(\"iPhone 6s\"),\n                ProductTypeOne(\"Mi\"),\n                ProductTypeOne(\"Facebook\"))\n\n        recyclerView.layoutManager = LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false)\n        recyclerView.adapter = AdaptiveAdapter(itemList)\n    }\n}\n```\n\nIf you'd like to know more detail or how to implement the expanding recycler view, check the sample project\nplease. There is a simple sample for this library. 😄\n\n## Gradle\n\nIt's very easy to import, you just put them into your gradle file.\n\n```gradle\ncompile \"com.devrapid.jieyi:adaptiverecyclerview:0.0.7\"\n```\n\n## Maven\n\n```maven\n\u003cdependency\u003e\n  \u003cgroupId\u003ecom.devrapid.jieyi\u003c/groupId\u003e\n  \u003cartifactId\u003eadaptiverecyclerview\u003c/artifactId\u003e\n  \u003cversion\u003e0.0.7\u003c/version\u003e\n  \u003ctype\u003epom\u003c/type\u003e\n\u003c/dependency\u003e\n```\n\n# Feature\n\n- [ ] Reduce the inherit classes.\n- [ ] The `adapter` parameter in the `AdaptiveViewHolder` to specific data type.\n\nIf you have any idea about making this library better, please give me an issue.\nThank you very much!\n\n# License\n\n```\nCopyright 2017 Jieyi Wu\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n   http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpokk%2Fadaptiverecyclerview","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpokk%2Fadaptiverecyclerview","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpokk%2Fadaptiverecyclerview/lists"}