{"id":19508707,"url":"https://github.com/commit451/aloy","last_synced_at":"2025-04-26T02:34:06.957Z","repository":{"id":83213957,"uuid":"100989377","full_name":"Commit451/Aloy","owner":"Commit451","description":"Create a RecyclerView.Adapter without having to subclass","archived":false,"fork":false,"pushed_at":"2022-06-27T04:22:32.000Z","size":1361,"stargazers_count":8,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-04T07:04:28.487Z","etag":null,"topics":["android","kotlin","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/Commit451.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2017-08-21T20:19:59.000Z","updated_at":"2022-01-15T18:03:40.000Z","dependencies_parsed_at":"2023-03-01T21:00:30.247Z","dependency_job_id":null,"html_url":"https://github.com/Commit451/Aloy","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Commit451%2FAloy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Commit451%2FAloy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Commit451%2FAloy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Commit451%2FAloy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Commit451","download_url":"https://codeload.github.com/Commit451/Aloy/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250922220,"owners_count":21508291,"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","recyclerview"],"created_at":"2024-11-10T23:09:12.281Z","updated_at":"2025-04-26T02:34:06.642Z","avatar_url":"https://github.com/Commit451.png","language":"Kotlin","readme":"# Aloy\n[![](https://jitpack.io/v/Commit451/Aloy.svg)](https://jitpack.io/#Commit451/Aloy)\n\nCreate a RecyclerView.Adapter without having to subclass.\n\n## Usage\nThe idea is to be able to have a valid `RecyclerView.Adapter` without having to create a class for the adapter. We do this by providing lambdas to call for `onCreateViewHolder` and `onBindViewHolder`:\n```kotlin\n//top of file\nlateinit var adapter: AloyAdapter\u003cCheese, CheeseViewHolder\u003e\n//later, in onCreate (Activity) or onViewCreated (Fragment) for example:\nadapter = AloyAdapter(\n    onCreateViewHolder = { parent, viewType -\u003e\n        val holder = CheeseViewHolder.inflate(parent)\n        holder.itemView.setOnClickListener {\n            val cheese = adapter.items[holder.adapterPosition]\n            Snackbar.make(root, \"${cheese.name} clicked\", Snackbar.LENGTH_SHORT)\n                .show()\n        }\n        holder\n    },\n    onBindViewHolder = { viewHolder, position, item -\u003e\n        viewHolder.bind(item)\n    }\n)\n```\nYou can also set the `onCreateViewHolder` and `onBindViewHolder` lambdas after construction, just make sure you do so before the first call to `onCreateViewHolder` or `onBindViewHolder`. This is useful for subclassing.\nSee the sample `app` module for more usage.\n\n## Optional\nYou can optionally override `getItemViewType` if you need to by setting the `onGetItemViewType` on the adapter.\n\nLicense\n--------\n\n    Copyright 2022 Commit 451\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","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcommit451%2Faloy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcommit451%2Faloy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcommit451%2Faloy/lists"}