{"id":22737079,"url":"https://github.com/kibotu/recyclerviewpresenter","last_synced_at":"2025-04-14T04:31:37.569Z","repository":{"id":54902179,"uuid":"58848593","full_name":"kibotu/RecyclerViewPresenter","owner":"kibotu","description":"RecyclerView Adapter Library with different models and different layouts as convenient as possible.","archived":false,"fork":false,"pushed_at":"2021-10-31T15:09:22.000Z","size":938,"stargazers_count":86,"open_issues_count":0,"forks_count":28,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-03-27T18:21:31.934Z","etag":null,"topics":["adapter","android","android-library","hacktoberfest","hacktoberfest2023","kotlin","kotlin-android","mvvm","recyclerview","recyclerview-adapter","sort","update"],"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/kibotu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"custom":"https://paypal.me/janrabe/5"}},"created_at":"2016-05-15T07:05:35.000Z","updated_at":"2024-03-28T03:40:02.000Z","dependencies_parsed_at":"2022-08-14T06:10:47.572Z","dependency_job_id":null,"html_url":"https://github.com/kibotu/RecyclerViewPresenter","commit_stats":null,"previous_names":[],"tags_count":52,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kibotu%2FRecyclerViewPresenter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kibotu%2FRecyclerViewPresenter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kibotu%2FRecyclerViewPresenter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kibotu%2FRecyclerViewPresenter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kibotu","download_url":"https://codeload.github.com/kibotu/RecyclerViewPresenter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248821704,"owners_count":21166941,"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":["adapter","android","android-library","hacktoberfest","hacktoberfest2023","kotlin","kotlin-android","mvvm","recyclerview","recyclerview-adapter","sort","update"],"created_at":"2024-12-10T22:09:37.785Z","updated_at":"2025-04-14T04:31:37.548Z","avatar_url":"https://github.com/kibotu.png","language":"Kotlin","funding_links":["https://paypal.me/janrabe/5","https://www.paypal.me/janrabe/5"],"categories":[],"sub_categories":[],"readme":"[![Donation](https://img.shields.io/badge/buy%20me%20a%20coffee-brightgreen.svg)](https://www.paypal.me/janrabe/5) [![About Jan Rabe](https://img.shields.io/badge/about-me-green.svg)](https://www.kibotu.net)\n# RecyclerView Presenter [![](https://jitpack.io/v/kibotu/RecyclerViewPresenter.svg)](https://jitpack.io/#kibotu/RecyclerViewPresenter) [![](https://jitpack.io/v/kibotu/RecyclerViewPresenter/month.svg)](https://jitpack.io/#kibotu/RecyclerViewPresenter) [![Hits-of-Code](https://hitsofcode.com/github/kibotu/RecyclerViewPresenter)](https://hitsofcode.com/view/github/kibotu/RecyclerViewPresenter) [![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-RecyclerViewPresenter-green.svg?style=true)](https://android-arsenal.com/details/1/3593) [![appetize.io](https://img.shields.io/badge/appetize.io-Live%20Demo-blue.svg)](https://appetize.io/app/twkuv0xydcy5h8whmkcmx81kur) [![Javadoc](https://img.shields.io/badge/javadoc-SNAPSHOT-green.svg)](https://jitpack.io/com/github/kibotu/RecyclerViewPresenter/master-SNAPSHOT/javadoc/index.html) [![Build Status](https://app.travis-ci.com/kibotu/RecyclerViewPresenter.svg?branch=master)](https://app.travis-ci.com/kibotu/RecyclerViewPresenter)  [![API](https://img.shields.io/badge/API-15%2B-brightgreen.svg?style=flat)](https://android-arsenal.com/api?level=15) [![Gradle Version](https://img.shields.io/badge/gradle-7.2-green.svg)](https://docs.gradle.org/current/release-notes)  [![Kotlin](https://img.shields.io/badge/kotlin-1.5.31-green.svg)](https://kotlinlang.org/) [![GitHub license](https://img.shields.io/badge/license-Apache%202-blue.svg)](https://raw.githubusercontent.com/kibotu/RecyclerViewPresenter/master/LICENSE) [![androidx](https://img.shields.io/badge/androidx-brightgreen.svg)](https://developer.android.com/topic/libraries/support-library/refactor)\n\nConvenience library to handle different view types with different presenters in a single RecyclerView. \n\n[![Screenshot](https://raw.githubusercontent.com/kibotu/RecyclerViewPresenter/master/screenshot.png)](https://raw.githubusercontent.com/kibotu/RecyclerViewPresenter/master/screenshot.png)\n  \n### How to install\n\n```groovy\nrepositories {\n    maven {\n\turl \"https://jitpack.io\"\n    }\n}\n\ndependencies {\n    implementation 'com.github.kibotu:RecyclerViewPresenter:-SNAPSHOT'\n}\n```\n\n### How to use\n\n\n1. Create a presenter, e.g. [PhotoPresenter](app/src/main/kotlin/net/kibotu/android/recyclerviewpresenter/app/screens/kotlin/PhotoPresenter.kt#L21-L51) or [LabelPresenter](app/src/main/kotlin/net/kibotu/android/recyclerviewpresenter/app/screens/kotlin/LabelPresenter.kt#L14-L23)\n\n```kotlin\nclass LabelPresenter : Presenter\u003cString, LabelPresenterItemBinding\u003e(\n    layout = R.layout.label_presenter_item,\n    viewBindingAccessor = LabelPresenterItemBinding::bind\n) {\n\n    override fun bindViewHolder(\n        viewBinding: LabelPresenterItemBinding,\n        viewHolder: RecyclerView.ViewHolder,\n        item: PresenterViewModel\u003cString\u003e,\n        payloads: MutableList\u003cAny\u003e?\n    ) = with(viewBinding) {\n        Logger.v( \"bindViewHolder ${viewHolder.adapterPosition} $item payload=$payloads\" )\n        label.text = \"${item.model}\"\n    }\n}\n```\n\n2. [Add the PresenterAdapter to your RecyclerView](app/src/main/kotlin/net/kibotu/android/recyclerviewpresenter/app/screens/kotlin/PresenterActivity.kt#L26)\n\n```kotlin\nval adapter = PresenterAdapter()\nlist.adapter = adapter\n```\n\n3. [Register Presenter](app/src/main/kotlin/net/kibotu/android/recyclerviewpresenter/app/screens/kotlin/PresenterActivity.kt#L33-L35)\n\n```kotlin\nadapter.registerPresenter(PhotoPresenter())\nadapter.registerPresenter(LabelPresenter())\nadapter.registerPresenter(NumberPresenter())\n```\n\n4. [Submit list of models with presenter matching layout](app/src/main/kotlin/net/kibotu/android/recyclerviewpresenter/app/screens/kotlin/PresenterActivity.kt#L50-L70) to the adapter, e.g.:\n\n```kotlin\nval items = mutableListOf\u003cPresenterViewModel\u003c*\u003e\u003e()\n\nfor (i in 0..99) {\n    items.add(PresenterModel(createRandomImageUrl(), R.layout.photo_presenter_item))\n    items.add(PresenterModel(createRandomImageUrl(), R.layout.label_presenter_item))\n    items.add(PresenterModel(createRandomImageUrl(), R.layout.number_presenter_item))\n}\n\nadapter.submitList(items)\n```\n\n5.1 Add click listener [to adapter](app/src/main/kotlin/net/kibotu/android/recyclerviewpresenter/app/screens/kotlin/PresenterActivity.kt#L37-L40)\n\n```kotlin\nadapter.onItemClick { item, view, position -\u003e\n    snack(\"$position. ${item.model}\")\n}\n```\n\n5.2 or pass [to your RecyclerViewModel](app/src/main/kotlin/net/kibotu/android/recyclerviewpresenter/app/screens/kotlin/PresenterActivity.kt#L65-L67)\n\n```kotlin\nval item = PresenterViewModel(createRandomImageUrl(), R.layout.photo_presenter_item) { item, view, position -\u003e \n\tsnack(\"$position. $item\")\n})\n```\n\n#### [Updating item](app/src/main/kotlin/net/kibotu/android/recyclerviewpresenter/app/screens/kotlin/PresenterActivity.kt#L56)\n\n```kotlin\nadapter.submitList(newItems)\n```\n\n#### [Circular](app/src/main/kotlin/net/kibotu/android/recyclerviewpresenter/app/screens/circular/CircularPresenterActivity.kt#L37)\n\n```kotlin\nadapter.isCircular = true\n\n// Note: use adapter scroll methods for correct scroll position when using circular\nadapter.smoothScrollToPosition(0)\nadapter.scrollToPosition(0)\n```\n\n### Notes\n\nFollow me on Twitter: [![Twitter Follow](https://img.shields.io/twitter/follow/wolkenschauer.svg?style=social)](https://twitter.com/wolkenschauer)\n\nLet me know what you think: [jan.rabe@kibotu.net](mailto:jan.rabe@kibotu.net)\n\nContributions welcome!\n\n### License\n\u003cpre\u003e\nCopyright 2021 Jan Rabe\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\u003c/pre\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkibotu%2Frecyclerviewpresenter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkibotu%2Frecyclerviewpresenter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkibotu%2Frecyclerviewpresenter/lists"}