{"id":15459124,"url":"https://github.com/nisrulz/recyclerviewhelper","last_synced_at":"2025-04-04T22:07:43.788Z","repository":{"id":57721803,"uuid":"53742904","full_name":"nisrulz/recyclerviewhelper","owner":"nisrulz","description":":page_with_curl: [Android Library] Giving powers to RecyclerView ","archived":false,"fork":false,"pushed_at":"2020-06-13T22:50:35.000Z","size":2987,"stargazers_count":637,"open_issues_count":13,"forks_count":60,"subscribers_count":19,"default_branch":"develop","last_synced_at":"2024-10-30T06:58:42.263Z","etag":null,"topics":["android","android-library","divide","drag","drop","helper","recyclerview","swipe"],"latest_commit_sha":null,"homepage":"","language":"Java","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/nisrulz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"ko_fi":"nisrulz","liberapay":"nisrulz","custom":"https://www.paypal.me/nisrulz/5usd"}},"created_at":"2016-03-12T17:01:02.000Z","updated_at":"2024-10-24T14:52:26.000Z","dependencies_parsed_at":"2022-09-26T21:51:39.802Z","dependency_job_id":null,"html_url":"https://github.com/nisrulz/recyclerviewhelper","commit_stats":null,"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nisrulz%2Frecyclerviewhelper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nisrulz%2Frecyclerviewhelper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nisrulz%2Frecyclerviewhelper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nisrulz%2Frecyclerviewhelper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nisrulz","download_url":"https://codeload.github.com/nisrulz/recyclerviewhelper/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247256112,"owners_count":20909240,"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","android-library","divide","drag","drop","helper","recyclerview","swipe"],"created_at":"2024-10-01T23:04:48.204Z","updated_at":"2025-04-04T22:07:43.771Z","avatar_url":"https://github.com/nisrulz.png","language":"Java","funding_links":["https://ko-fi.com/nisrulz","https://liberapay.com/nisrulz","https://www.paypal.me/nisrulz/5usd"],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n  \u003cimg src=\"img/github_banner.png\" /\u003e\n\u003c/div\u003e\n\u003ch1 align=\"center\"\u003e\u003ca href=\"https://twitter.com/intent/tweet?text=Checkout%20RecyclerViewHelper%3A%20Android%20library%20giving%20powers%20to%20RecyclerView%20%F0%9F%98%8E\u0026url=https://github.com/nisrulz/recyclerviewhelper\u0026via=nisrulz\u0026hashtags=AndroidDev\"\u003e\n        \u003cimg src=\"https://img.shields.io/twitter/url/http/shields.io.svg?style=social\"/\u003e\n    \u003c/a\u003e\u003c/h1\u003e\n\n\u003cdiv align=\"center\"\u003e\n  \u003cstrong\u003eAndroid library that provides most common functions around recycler-view like Swipe to dismiss, Drag and Drop, Divider in the ui, events for when item selected and when not selected, on-click listener for items.\u003c/strong\u003e\n\u003c/div\u003e\n\u003cbr/\u003e\n\u003cdiv align=\"center\"\u003e\n    \u003c!-- Bintray --\u003e\n    \u003ca href=\"https://bintray.com/nisrulz/maven/com.github.nisrulz%3Arecyclerviewhelper/_latestVersion\"\u003e\n        \u003cimg src=\"https://api.bintray.com/packages/nisrulz/maven/com.github.nisrulz%3Arecyclerviewhelper/images/download.svg\"/\u003e\n    \u003c/a\u003e\n    \u003c!-- API --\u003e\n    \u003ca href=\"https://android-arsenal.com/api?level=14\"\u003e\n        \u003cimg src=\"https://img.shields.io/badge/API-14%2B-orange.svg?style=flat\"/\u003e\n    \u003c/a\u003e\n    \u003c!-- Android Arsenal --\u003e\n    \u003ca href=\"https://android-arsenal.com/details/1/3572\"\u003e\n        \u003cimg src=\"https://img.shields.io/badge/Android%20Arsenal-RecyclerViewHelper-green.svg?style=true\"/\u003e\n    \u003c/a\u003e\n     \u003c!-- Android Dev Digest --\u003e\n    \u003ca href=\"https://www.androiddevdigest.com/digest-99/\"\u003e\n        \u003cimg src=\"https://img.shields.io/badge/AndroidDev%20Digest-%2399-blue.svg\"/\u003e\n    \u003c/a\u003e\n      \u003c!-- Android Weekly --\u003e\n    \u003ca href=\"http://androidweekly.net/issues/issue-221\"\u003e\n        \u003cimg src=\"https://img.shields.io/badge/Android%20Weekly-%23221-blue.svg\"/\u003e\n    \u003c/a\u003e\n    \u003c!-- GitHub stars --\u003e\n    \u003ca href=\"https://github.com/nisrulz/recyclerviewhelper\"\u003e\n        \u003cimg src=\"https://img.shields.io/github/stars/nisrulz/recyclerviewhelper.svg?style=social\u0026label=Star\"/\u003e\n    \u003c/a\u003e\n    \u003c!-- GitHub forks --\u003e\n    \u003ca href=\"https://github.com/nisrulz/recyclerviewhelper/fork\"\u003e\n        \u003cimg src=\"hhttps://img.shields.io/github/forks/nisrulz/recyclerviewhelper.svg?style=social\u0026label=Fork\"/\u003e\n    \u003c/a\u003e\n    \u003c!-- GitHub watchers --\u003e\n    \u003ca href=\"https://github.com/nisrulz/recyclerviewhelper\"\u003e\n        \u003cimg src=\"https://img.shields.io/github/watchers/nisrulz/recyclerviewhelper.svg?style=social\u0026label=Watch\"/\u003e\n    \u003c/a\u003e\n    \u003c!-- Say Thanks! --\u003e\n    \u003ca href=\"https://saythanks.io/to/nisrulz\"\u003e\n        \u003cimg src=\"https://img.shields.io/badge/Say%20Thanks-!-1EAEDB.svg\"/\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://www.paypal.me/nisrulz/5usd\"\u003e\n        \u003cimg src=\"https://img.shields.io/badge/$-donate-ff69b4.svg?maxAge=2592000\u0026amp;style=flat\"\u003e\n    \u003c/a\u003e\n    \u003cbr/\u003e\n     \u003c!-- GitHub followers --\u003e\n    \u003ca href=\"https://github.com/nisrulz/recyclerviewhelper\"\u003e\n        \u003cimg src=\"https://img.shields.io/github/followers/nisrulz.svg?style=social\u0026label=Follow%20@nisrulz\"/\u003e\n    \u003c/a\u003e\n    \u003c!-- Twitter Follow --\u003e\n    \u003ca href=\"https://twitter.com/nisrulz\"\u003e\n        \u003cimg src=\"https://img.shields.io/twitter/follow/nisrulz.svg?style=social\"/\u003e\n    \u003c/a\u003e\n\u003c/div\u003e\n\n\u003cdiv align=\"center\"\u003e\n    \u003ca href=\"https://android.libhunt.com/newsletter/21\"\u003e\n        Also featured in Awesome Android Newsletter #Issue 21\n    \u003c/a\u003e\n\u003c/div\u003e\n\n\u003cdiv align=\"center\"\u003e\n  \u003csub\u003eBuilt with ❤︎ by\n  \u003ca href=\"https://twitter.com/nisrulz\"\u003eNishant Srivastava\u003c/a\u003e and\n  \u003ca href=\"https://github.com/nisrulz/recyclerviewhelper/graphs/contributors\"\u003e\n    contributors\n  \u003c/a\u003e\n\u003c/div\u003e\n\u003cbr/\u003e\n\u003cbr/\u003e\n\n\n\u003e Note: Development for pre-androidx version of this library has stopped. If you are looking for [pre-androidx version, then checkout this branch.](https://github.com/nisrulz/recyclerviewhelper/tree/archive/pre-androidx)\n\u003e Library is compatible with AndroidX version only.\n\n# Integration\nRecyclerViewHelper is available in the Jcenter, so getting it as simple as adding it as a dependency\n```gradle\ndef recyclerViewVersion=\"{latest version}\"\n// Required\nimplementation \"androidx.recyclerview:recyclerview:${recyclerViewVersion}\"\n\n// RecyclerViewHelper\nimplementation \"com.github.nisrulz:recyclerviewhelper:x${recyclerViewVersion}\"\n```\nwhere `{latest version}` corresponds to published version in [ ![Download](https://api.bintray.com/packages/nisrulz/maven/com.github.nisrulz%3Arecyclerviewhelper/images/download.svg) ](https://bintray.com/nisrulz/maven/com.github.nisrulz%3Arecyclerviewhelper/_latestVersion) without the prepended `x`.\n This is done to distinguish between library using andoirdx vs pre-androidx.\n\nUsage Example:\n```gradle\ndef recyclerViewVersion=\"1.1.0\"\n// Required\nimplementation \"androidx.recyclerview:recyclerview:${recyclerViewVersion}\"\n\n// RecyclerViewHelper\nimplementation \"com.github.nisrulz:recyclerviewhelper:x${recyclerViewVersion}\"\n```\n\n\u003e NOTE : The version here corresponds to the version of recyclerview dependency.\n\n##### Make sure that the google's maven repo is declared in your projects `build.gradle` file as below\n\n  ```gradle\n  allprojects {\n    repositories {\n      google()\n      jcenter()\n    }\n  }\n  ```\n\n# Usage\n+ Implement the `RHVAdapter` in your recycler view adapter and `RHVViewHolder` in your ItemViewHolder \n```java\n\n    public class MyAdapter extends RecyclerView.Adapter\u003cMyAdapter.ItemViewHolder\u003e implements RVHAdapter {\n    \n         ...\n    \n        @Override\n        public boolean onItemMove(int fromPosition, int toPosition) {\n            swap(fromPosition, toPosition);\n            return false;\n        }\n    \n        @Override\n        public void onItemDismiss(int position, int direction) {\n            remove(position);\n        }\n    \n        public class ItemViewHolder extends RecyclerView.ViewHolder implements RVHViewHolder {\n            ...\n               \n            @Override\n            public void onItemSelected(int actionstate) {\n                System.out.println(\"Item is selected\");\n            }\n    \n            @Override\n            public void onItemClear() {\n                System.out.println(\"Item is unselected\");\n    \n            }\n        }\n    \n        // Helper functions you might want to implement to make changes in the list as an event is fired\n        private void remove(int position) {\n            dataList.remove(position);\n            notifyItemRemoved(position);\n        }\n    \n        private void swap(int firstPosition, int secondPosition) {\n            Collections.swap(dataList, firstPosition, secondPosition);\n            notifyItemMoved(firstPosition, secondPosition);\n        }\n    }\n\n```\n\n+ Then implement your recycler view\n```java\n\n   public class MainActivity extends AppCompatActivity {\n   \n   \n       RecyclerView myrecyclerview;\n       ArrayList\u003cString\u003e data;\n       MyAdapter adapter;\n   \n       @Override\n       protected void onCreate(Bundle savedInstanceState) {\n           super.onCreate(savedInstanceState);\n           setContentView(R.layout.activity_main);\n   \n           myrecyclerview = (RecyclerView) findViewById(R.id.rv_fruits);\n   \n           data = new ArrayList\u003c\u003e();\n           data.add(\"Apple\");\n           ...\n           data.add(\"Fig\");\n   \n           // Setup your adapter\n           adapter = new MyAdapter(data);\n           // Setup \n           myrecyclerview.hasFixedSize();\n           myrecyclerview.setLayoutManager(new LinearLayoutManager(this));\n           myrecyclerview.setAdapter(adapter);\n   \n   \n           // Setup onItemTouchHandler to enable drag and drop , swipe left or right\n           ItemTouchHelper.Callback callback = new RVHItemTouchHelperCallback(adapter, true, true,\n                   true);\n           ItemTouchHelper helper = new ItemTouchHelper(callback);\n           helper.attachToRecyclerView(myrecyclerview);\n   \n           // Set the divider in the recyclerview\n           myrecyclerview.addItemDecoration(new RVHItemDividerDecoration(this, LinearLayoutManager.VERTICAL));\n   \n           // Set On Click Listener\n           myrecyclerview.addOnItemTouchListener(new RVHItemClickListener(this, new RVHItemClickListener.OnItemClickListener() {\n               @Override\n               public void onItemClick(View view, int position) {\n                   String value = \"Clicked Item \" + data.get(position) + \" at \" + position;\n   \n                   Log.d(\"TAG\", value);\n                   Toast.makeText(MainActivity.this, value, Toast.LENGTH_SHORT).show();\n               }\n           }));\n   \n       }\n   }\n\n\n```\n\n### Demo\n\n![Walkthrough](img/walkthrough1.gif)\n\n# Pull Requests\nI welcome and encourage all pull requests. It usually will take me within 24-48 hours to respond to any issue or request. Here are some basic rules to follow to ensure timely addition of your request:\n  1. Match coding style (braces, spacing, etc.) This is best achieved using CMD+Option+L (Reformat code) on Mac (not sure for Windows) with Android Studio defaults. This project uses a [modified version of Grandcentrix's code style](https://github.com/nisrulz/AndroidCodeStyle/tree/nishant-config), so please use the same when editing this project.\n  2. If its a feature, bugfix, or anything please only change code to what you specify.\n  3. Please keep PR titles easy to read and descriptive of changes, this will make them easier to merge :)\n  4. Pull requests _must_ be made against `develop` branch. Any other branch (unless specified by the maintainers) will get rejected.\n  5. Check for existing [issues](https://github.com/nisrulz/recyclerviewhelper/issues) first, before filing an issue.\n  6. Have fun!\n\n\n## License\nLicensed under the Apache License, Version 2.0, [click here for the full license](/LICENSE.txt).\n\n## Author \u0026 support\nThis project was created by [Nishant Srivastava](https://github.com/nisrulz/nisrulz.github.io#nishant-srivastava) but hopefully developed and maintained by many others. See the [the list of contributors here](https://github.com/nisrulz/recyclerviewhelper/graphs/contributors).\n\n\u003eSpecial Credits to Paul Burke and his [article](https://medium.com/@ipaulpro/drag-and-swipe-with-recyclerview-b9456d2b1aaf) which got me thinking\n\u003e\n\u003eThis library contains a modified version of his implementations of ItemTouchHelper.\n\u003cbr/\u003e\n\nIf you appreciate my work, consider [buying me](https://www.paypal.me/nisrulz/5usd) a cup of :coffee: to keep me recharged :metal: [[PayPal](https://www.paypal.me/nisrulz/5usd)]\n\n\u003cimg src=\"http://forthebadge.com/images/badges/built-for-android.svg\" /\u003e","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnisrulz%2Frecyclerviewhelper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnisrulz%2Frecyclerviewhelper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnisrulz%2Frecyclerviewhelper/lists"}