{"id":13427926,"url":"https://github.com/mikepenz/FastAdapter","last_synced_at":"2025-03-16T00:32:47.438Z","repository":{"id":40454153,"uuid":"48688603","full_name":"mikepenz/FastAdapter","owner":"mikepenz","description":"The bullet proof, fast and easy to use adapter library, which minimizes developing time to a fraction...","archived":false,"fork":false,"pushed_at":"2024-08-01T23:46:18.000Z","size":19869,"stargazers_count":3839,"open_issues_count":9,"forks_count":494,"subscribers_count":87,"default_branch":"develop","last_synced_at":"2024-10-22T22:16:25.984Z","etag":null,"topics":["adapter","android","android-development","android-library","android-ui","click-listeners","drag-and-drop","fastadapter","hacktoberfest","kotlin","kotlin-android","mikepenz","multi-select","recyclerview","recyclerview-adapter","swipe","viewholder"],"latest_commit_sha":null,"homepage":"https://mikepenz.dev","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/mikepenz.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["mikepenz"]}},"created_at":"2015-12-28T11:05:32.000Z","updated_at":"2024-10-19T14:53:00.000Z","dependencies_parsed_at":"2023-02-08T17:46:13.220Z","dependency_job_id":"e03d0d24-53c6-4cd6-aaa3-05e92684c280","html_url":"https://github.com/mikepenz/FastAdapter","commit_stats":null,"previous_names":[],"tags_count":159,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikepenz%2FFastAdapter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikepenz%2FFastAdapter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikepenz%2FFastAdapter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikepenz%2FFastAdapter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mikepenz","download_url":"https://codeload.github.com/mikepenz/FastAdapter/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221631825,"owners_count":16855014,"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-development","android-library","android-ui","click-listeners","drag-and-drop","fastadapter","hacktoberfest","kotlin","kotlin-android","mikepenz","multi-select","recyclerview","recyclerview-adapter","swipe","viewholder"],"created_at":"2024-07-31T01:00:42.695Z","updated_at":"2024-10-27T05:30:34.772Z","avatar_url":"https://github.com/mikepenz.png","language":"Kotlin","readme":"# FastAdapter\n\nThe FastAdapter is here to simplify creating adapters for RecyclerViews. Don't worry about the adapter anymore. Just write the logic for how your view/item should look like, and you are done.\nIt's blazing fast, minimizing the code you need to write, and is easy to extend.\n\n-------\n\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"#whats-included-\"\u003eWhat's included 🚀\u003c/a\u003e \u0026bull;\n    \u003ca href=\"#setup\"\u003eSetup 🛠️\u003c/a\u003e \u0026bull;\n    \u003ca href=\"MIGRATION.md\"\u003eMigration Guide 🧬\u003c/a\u003e \u0026bull;\n    \u003ca href=\"#used-by\"\u003eUsed by\u003c/a\u003e \u0026bull;\n    \u003ca href=\"https://play.google.com/store/apps/details?id=com.mikepenz.fastadapter.app\"\u003eSample App\u003c/a\u003e\n\u003c/p\u003e\n\n-------\n\n### What's included 🚀\n- Core module 100% in Kotlin\n- Click / Long-Click listeners\n- Selection / Multi-Selection ([MultiselectSample](https://github.com/mikepenz/FastAdapter/blob/develop/app/src/main/java/com/mikepenz/fastadapter/app/MultiselectSampleActivity.kt), [CheckBoxSample](https://github.com/mikepenz/FastAdapter/blob/develop/app/src/main/java/com/mikepenz/fastadapter/app/CheckBoxSampleActivity.kt), [RadioButtonSample](https://github.com/mikepenz/FastAdapter/blob/develop/app/src/main/java/com/mikepenz/fastadapter/app/RadioButtonSampleActivity.kt))\n- Expandable items ([ExpandableSample](https://github.com/mikepenz/FastAdapter/blob/develop/app/src/main/java/com/mikepenz/fastadapter/app/ExpandableSampleActivity.kt), [IconGridSample](https://github.com/mikepenz/FastAdapter/blob/develop/app/src/main/java/com/mikepenz/fastadapter/app/IconGridActivity.kt) ,[AdvancedSample](https://github.com/mikepenz/FastAdapter/blob/develop/app/src/main/java/com/mikepenz/fastadapter/app/AdvancedSampleActivity.kt))\n- Write less code, get better results\n- Highly optimized code\n- Simple Drag \u0026 Drop ([SimpleItemListSample](https://github.com/mikepenz/FastAdapter/blob/develop/app/src/main/java/com/mikepenz/fastadapter/app/SimpleItemListActivity.kt))\n- Headers ([StickyHeaderSample](https://github.com/mikepenz/FastAdapter/blob/develop/app/src/main/java/com/mikepenz/fastadapter/app/StickyHeaderSampleActivity.kt), [AdvancedSample](https://github.com/mikepenz/FastAdapter/blob/develop/app/src/main/java/com/mikepenz/fastadapter/app/AdvancedSampleActivity.kt))\n- Footers\n- Filter ([SimpleItemListSample](https://github.com/mikepenz/FastAdapter/blob/develop/app/src/main/java/com/mikepenz/fastadapter/app/SimpleItemListActivity.kt))\n- Includes suggestions from the Android Team\n- Easily extensible\n- Endless Scroll ([EndlessScrollSample](https://github.com/mikepenz/FastAdapter/blob/develop/app/src/main/java/com/mikepenz/fastadapter/app/EndlessScrollListActivity.kt))\n- \"Leave-Behind\"-Pattern ([SwipeListSample](https://github.com/mikepenz/FastAdapter/blob/develop/app/src/main/java/com/mikepenz/fastadapter/app/SwipeListActivity.kt))\n- Split item view and model ([ModelItem](https://github.com/mikepenz/FastAdapter/blob/develop/app/src/main/java/com/mikepenz/fastadapter/app/ModelItemActivity.kt), [MultiTypeModelItem](https://github.com/mikepenz/FastAdapter/blob/develop/app/src/main/java/com/mikepenz/fastadapter/app/MultiTypeModelItemActivity.kt))\n- Chain other Adapters ([SimpleItemListSample](https://github.com/mikepenz/FastAdapter/blob/develop/app/src/main/java/com/mikepenz/fastadapter/app/SimpleItemListActivity.kt), [StickyHeaderSample](https://github.com/mikepenz/FastAdapter/blob/develop/app/src/main/java/com/mikepenz/fastadapter/app/StickyHeaderSampleActivity.kt))\n- Comes with useful Helpers\n - ActionModeHelper ([MultiselectSample](https://github.com/mikepenz/FastAdapter/blob/develop/app/src/main/java/com/mikepenz/fastadapter/app/MultiselectSampleActivity.kt))\n - UndoHelper ([MultiselectSample](https://github.com/mikepenz/FastAdapter/blob/develop/app/src/main/java/com/mikepenz/fastadapter/app/MultiselectSampleActivity.kt))\n- FastScroller (external lib) ([SimpleItemListSample](https://github.com/mikepenz/FastAdapter/blob/develop/app/src/main/java/com/mikepenz/fastadapter/app/SimpleItemListActivity.kt))\n- Paging (via Jetpack paging lib) ([PagedActivity](https://github.com/mikepenz/FastAdapter/blob/develop/app/src/main/java/com/mikepenz/fastadapter/app/PagedActivity.kt))\n - More to come...\n\n# Preview\n\n## Screenshots 🎉\n![Image](https://raw.githubusercontent.com/mikepenz/FastAdapter/develop/DEV/github/screenshots1.jpg)\n\n# Setup\n\n## Latest releases 🛠\n\n- Kotlin | [v5.7.0](https://github.com/mikepenz/FastAdapter/tree/v5.7.0)\n- [Deprecated] Java \u0026\u0026 AndroidX | [v3.3.1](https://github.com/mikepenz/FastAdapter/tree/v3.3.1)\n- [Deprecated] Java \u0026\u0026 AppCompat | [v3.2.9](https://github.com/mikepenz/FastAdapter/tree/v3.2.9)\n\n## Provide the gradle dependency\n\nThe library is split up into core, commons, and extensions. The core functions are included in the following dependency.\n```gradle\nimplementation \"com.mikepenz:fastadapter:${latestFastAdapterRelease}\"\nimplementation \"androidx.appcompat:appcompat:${androidX}\"\nimplementation \"androidx.recyclerview:recyclerview:${androidX}\"\n```\n\nExpandable support is included and can be added via this\n```gradle\nimplementation \"com.mikepenz:fastadapter-extensions-expandable:${latestFastAdapterRelease}\"\n```\n\nMany helper classes are included in the following dependency.\n```gradle\nimplementation \"com.mikepenz:fastadapter-extensions-binding:${latestFastAdapterRelease}\" // view binding helpers\nimplementation \"com.mikepenz:fastadapter-extensions-diff:${latestFastAdapterRelease}\" // diff util helpers\nimplementation \"com.mikepenz:fastadapter-extensions-drag:${latestFastAdapterRelease}\" // drag support\nimplementation \"com.mikepenz:fastadapter-extensions-paged:${latestFastAdapterRelease}\" // paging support\nimplementation \"com.mikepenz:fastadapter-extensions-scroll:${latestFastAdapterRelease}\" // scroll helpers\nimplementation \"com.mikepenz:fastadapter-extensions-swipe:${latestFastAdapterRelease}\" // swipe support\nimplementation \"com.mikepenz:fastadapter-extensions-ui:${latestFastAdapterRelease}\" // pre-defined ui components\nimplementation \"com.mikepenz:fastadapter-extensions-utils:${latestFastAdapterRelease}\" // needs the `expandable`, `drag` and `scroll` extension.\n\n// required for the ui components and the utils\nimplementation \"com.google.android.material:material:${androidX}\"\n```\n\n## How to use\n### 1. Implement your item\n#### 1a. Implement your item as usual (the easy way)\nJust create a class which extends the `AbstractItem` as shown below. Implement the methods, and your item is ready.\n```kotlin\nopen class SimpleItem : AbstractItem\u003cSimpleItem.ViewHolder\u003e() {\n    var name: String? = null\n    var description: String? = null\n\n    /** defines the type defining this item. must be unique. preferably an id */\n    override val type: Int\n        get() = R.id.fastadapter_sample_item_id\n\n    /** defines the layout which will be used for this item in the list */\n    override val layoutRes: Int\n        get() = R.layout.sample_item\n\n    override fun getViewHolder(v: View): ViewHolder {\n        return ViewHolder(v)\n    }\n\n    class ViewHolder(view: View) : FastAdapter.ViewHolder\u003cSimpleItem\u003e(view) {\n        var name: TextView = view.findViewById(R.id.material_drawer_name)\n        var description: TextView = view.findViewById(R.id.material_drawer_description)\n\n        override fun bindView(item: SimpleItem, payloads: List\u003cAny\u003e) {\n            name.text = item.name\n            description.text = item.name\n        }\n\n        override fun unbindView(item: SimpleItem) {\n            name.text = null\n            description.text = null\n        }\n    }\n}\n\n```\n\n#### 1b. Implement item with ViewBinding (the easiest way)\n\n```kotlin\nclass BindingIconItem : AbstractBindingItem\u003cIconItemBinding\u003e() {\n    var name: String? = null\n\n    override val type: Int\n        get() = R.id.fastadapter_icon_item_id\n\n    override fun bindView(binding: IconItemBinding, payloads: List\u003cAny\u003e) {\n        binding.name.text = name\n    }\n\n    override fun createBinding(inflater: LayoutInflater, parent: ViewGroup?): IconItemBinding {\n        return IconItemBinding.inflate(inflater, parent, false)\n    }\n}\n```\nUse the `binding` extension dependency in your application for this.\n\n### 2. Set the Adapter to the RecyclerView\n```kotlin\n//create the ItemAdapter holding your Items\nval itemAdapter = ItemAdapter\u003cSimpleItem\u003e()\n//create the managing FastAdapter, by passing in the itemAdapter\nval fastAdapter = FastAdapter.with(itemAdapter)\n\n//set our adapters to the RecyclerView\nrecyclerView.setAdapter(fastAdapter)\n\n//set the items to your ItemAdapter\nitemAdapter.add(ITEMS)\n```\n\n### 3. Extensions\n\nBy default the `FastAdapter` only provides basic functionality, which comes with the abstraction of items as `Item` and `Model`. \nAnd the general functionality of adding/removing/modifying elements. To enable *selections*, or *expandables* the provided extensions need to be activated.\n\n#### 3.1. SelectExtension\n\n```kotlin\n// Gets (or creates and attaches if not yet existing) the extension from the given `FastAdapter`\nval selectExtension = fastAdapter.getSelectExtension()\n// configure as needed\nselectExtension.isSelectable = true\nselectExtension.multiSelect = true\nselectExtension.selectOnLongClick = false\n// see the API of this class for more options.\n```\n\n#### 3.2. ExpandableExtension\n\n\u003e This requires the `fastadapter-extensions-expandable` extension.\n\n```kotlin\n// Gets (or creates and attaches if not yet existing) the extension.\nval expandableExtension = fastAdapter.getExpandableExtension()\n// configure as needed\nexpandableExtension.isOnlyOneExpandedItem = true\n```\n\nFor further details scroll down to the `ExpandableItems` (under advanced usage) section.\n\n### 3. Click listener\n```kotlin\nfastAdapter.onClickListener = { view, adapter, item, position -\u003e\n    // Handle click here\n    false\n}\n```\n\n### 4. Click listeners for views inside your item\n```kotlin\n// just add an `EventHook` to your `FastAdapter` by implementing either a `ClickEventHook`, `LongClickEventHook`, `TouchEventHook`, `CustomEventHook`\nfastAdapter.addEventHook(object : ClickEventHook\u003cSimpleImageItem\u003e() {\n    override fun onBind(viewHolder: RecyclerView.ViewHolder): View? {\n        //return the views on which you want to bind this event\n        return if (viewHolder is SimpleImageItem.ViewHolder) {\n            viewHolder.viewWhichReactsOnClick\n        } else {\n\t    null\n\t}\n    }\n\n    override fun onClick(v: View, position: Int, fastAdapter: FastAdapter\u003cSimpleImageItem\u003e, item: SimpleImageItem) {\n        //react on the click event\n    }\n})\n```\n\n### 5. Filter \n\n```kotlin\n// Call this in onQueryTextSubmit() \u0026 onQueryTextChange() when using SearchView\nitemAdapter.filter(\"yourSearchTerm\")\nitemAdapter.itemFilter.filterPredicate = { item: SimpleItem, constraint: CharSequence? -\u003e\n    item.name?.text.toString().contains(constraint.toString(), ignoreCase = true)\n}\n```\n`filter()` should return true for items to be retained and false for items to be removed.\n\n### 6. Drag and drop\n\n\u003e This requires the `fastadapter-extensions-drag` extension.\n\nFirst, attach `ItemTouchHelper` to RecyclerView.\n\n```kotlin\nval dragCallback = SimpleDragCallback()\nval touchHelper = ItemTouchHelper(dragCallback)\ntouchHelper.attachToRecyclerView(recyclerView)\n```\n\nImplement `ItemTouchCallback` interface in your Activity, and override the `itemTouchOnMove()` method.\n\n```kotlin\noverride fun itemTouchOnMove(oldPosition: Int, newPosition: Int): Boolean {\n    DragDropUtil.onMove(fastItemAdapter.itemAdapter, oldPosition, newPosition) // change position\n    return true\n}\n```\n\n### 7. Using different ViewHolders (like HeaderView)\n\nStart by initializing your adapters:\n\n```kotlin\n// Header is a model class for your header\nval headerAdapter = ItemAdapter\u003cHeader\u003e()\n```\n\nInitialize a Model FastAdapter:\n\n```kotlin\nval itemAdapter = GenericItemAdapter()\n```\n\nFinally, set the adapter:\n\n```kotlin\nval fastAdapter: GenericFastAdapter = FastAdapter.with(headerAdapter, itemAdapter) //the order defines in which order the items will show up\n// alternative the super type of both item adapters can be used. e.g.:\nrecyclerView.setAdapter(fastAdapter)\n```\n\n### 8. Infinite (endless) scrolling\n\nCreate a FooterAdapter. We need this to display a loading ProgressBar at the end of our list. (Don't forget to pass it into `FastAdapter.with(..)`)\n\n```kotlin\nval footerAdapter = ItemAdapter\u003cProgressItem\u003e()\n```\nKeep in mind that ProgressItem is provided by FastAdapter’s extensions.\n```kotlin\nrecyclerView.addOnScrollListener(object : EndlessRecyclerOnScrollListener(footerAdapter) {\n     override fun onLoadMore(currentPage: Int) {\n         footerAdapter.clear()\n         footerAdapter.add(ProgressItem())\n         \n\t // Load your items here and add it to FastAdapter\n         itemAdapter.add(NEWITEMS)\n    }\n})\n```\n\nFor the complete tutorial and more features such as multi-select and CAB check out the [sample app](https://github.com/mikepenz/FastAdapter/tree/develop/app).\n\n## Advanced Usage\n### Proguard\n* As of v2.5.0 there are no more known requirements to use the `FastAdapter` with Proguard\n\n### ExpandableItems\nThe `FastAdapter` comes with support for expandable items. After adding the dependency set up the `Expandable` extension via:\n\n```kotlin\nval expandableExtension = fastAdapter.getExpandableExtension()\n```\n\nExpandable items have to implement the `IExpandable` interface, and the sub items the `ISubItem` interface. This allows better support.\nThe sample app provides sample implementations of those. (Those in the sample are kept Model which allows them to be used with different parent / subitems)\n\nAs of the way how `SubItems` and their state are handled it is highly recommended to use the `identifier` based `StateManagement`. Just add `withPositionBasedStateManagement(false)` to your `FastAdapter` setup.\n\nA simple item just needs to extend from the `AbstractExpandableItem` and provide the `ViewHolder` as type.\n```kotlin\nopen class SimpleSubExpandableItem : AbstractExpandableItem\u003cSimpleSubExpandableItem.ViewHolder\u003e() {\n\n    /**\n     * BASIC ITEM IMPLEMENTATION\n     */\n}\n```\n// See the `SimpleSubExpandableItem.kt` of the sample application for more details.\n\n\n## Articles\n- [RecyclerView Adapter made easy](https://blog.iamsuleiman.com/recyclerview-adapter-android-made-fast-easy/) (FastAdapter v2.x)\n\n## Used by\nMike Penz:\n- AboutLibraries https://github.com/mikepenz/AboutLibraries\n- Android-Iconics https://github.com/mikepenz/Android-Iconics\n- ItemAnimators https://github.com/mikepenz/ItemAnimators\n- MaterialDrawer https://github.com/mikepenz/MaterialDrawer\n\n\n# Developed By\n\n- Mike Penz\n  - [mikepenz.dev](https://mikepenz.dev) - [blog.mikepenz.dev](https://blog.mikepenz.dev) - \u003cmikepenz@gmail.com\u003e\n  - [paypal.me/mikepenz](http://paypal.me/mikepenz)\n  - [Automatic changelog generation action](https://github.com/marketplace/actions/release-changelog-builder)\n\n- Fabian Terhorst\n  - [github.com/FabianTerhorst](https://github.com/FabianTerhorst) - \u003cfabian.terhorst@gmail.com\u003e\n  - [paypal.me/fabianterhorst](http://paypal.me/fabianterhorst)\n\n# Contributors\n\nThis free, open source software was also made possible by a group of volunteers that put many hours of hard work into it. See the [CONTRIBUTORS.md](CONTRIBUTORS.md) file for details.\n\n## Special mentions\n\nA special thanks to the very active contributors who added many improvements to this library.\n\n* **[Allan Wang](https://github.com/AllanWang)** \n* **[MFlisar](https://github.com/MFlisar)**\n* **[RobbWatershed](https://github.com/RobbWatershed)**\n\n# License\n\n    Copyright 2021 Mike Penz\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":["https://github.com/sponsors/mikepenz","http://paypal.me/mikepenz","http://paypal.me/fabianterhorst"],"categories":["Libraries","Kotlin","RecyclerView"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmikepenz%2FFastAdapter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmikepenz%2FFastAdapter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmikepenz%2FFastAdapter/lists"}