{"id":13396157,"url":"https://github.com/afollestad/drag-select-recyclerview","last_synced_at":"2025-09-28T20:31:56.491Z","repository":{"id":39614252,"uuid":"44851946","full_name":"afollestad/drag-select-recyclerview","owner":"afollestad","description":"👇 Easy Google Photos style multi-selection for RecyclerViews, powered by Kotlin and AndroidX.","archived":true,"fork":false,"pushed_at":"2022-04-13T08:49:33.000Z","size":29348,"stargazers_count":1975,"open_issues_count":3,"forks_count":232,"subscribers_count":46,"default_branch":"master","last_synced_at":"2024-11-24T17:47:51.302Z","etag":null,"topics":["android","androidx","drag-selection","google-photos","recyclerview","selection","ui","ux"],"latest_commit_sha":null,"homepage":"https://af.codes","language":"Kotlin","has_issues":false,"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/afollestad.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":"afollestad","ko_fi":"afollestad"}},"created_at":"2015-10-24T04:16:42.000Z","updated_at":"2024-11-23T14:57:46.000Z","dependencies_parsed_at":"2022-07-13T01:10:26.743Z","dependency_job_id":null,"html_url":"https://github.com/afollestad/drag-select-recyclerview","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/afollestad%2Fdrag-select-recyclerview","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/afollestad%2Fdrag-select-recyclerview/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/afollestad%2Fdrag-select-recyclerview/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/afollestad%2Fdrag-select-recyclerview/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/afollestad","download_url":"https://codeload.github.com/afollestad/drag-select-recyclerview/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234563123,"owners_count":18853056,"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","androidx","drag-selection","google-photos","recyclerview","selection","ui","ux"],"created_at":"2024-07-30T18:00:41.460Z","updated_at":"2025-09-28T20:31:55.253Z","avatar_url":"https://github.com/afollestad.png","language":"Kotlin","funding_links":["https://github.com/sponsors/afollestad","https://ko-fi.com/afollestad"],"categories":["Index `(light-weight pages)`","Libraries","RecyclerView","Index","Kotlin"],"sub_categories":[],"readme":"# Drag Select Recycler View\n\n[ ![Maven Central](https://img.shields.io/maven-central/v/com.afollestad/drag-select-recyclerview?style=flat\u0026label=Maven+Central) ](https://repo1.maven.org/maven2/com/afollestad/drag-select-recyclerview)\n[![Android CI](https://github.com/afollestad/drag-select-recyclerview/workflows/Android%20CI/badge.svg)](https://github.com/afollestad/drag-select-recyclerview/actions?query=workflow%3A%22Android+CI%22)\n[![License](https://img.shields.io/badge/license-Apache%202-4EB1BA.svg?style=flat-square)](https://www.apache.org/licenses/LICENSE-2.0.html)\n\nThis library allows you to implement Google Photos style multi-selection in your apps! You start\nby long pressing an item in your list, then you drag your finger without letting go to select more.\n\n![Range Mode GIF](https://github.com/afollestad/drag-select-recyclerview/raw/master/art/range.gif)\n\n# Sample\n\nYou can [download a sample APK](https://github.com/afollestad/drag-select-recyclerview/raw/master/sample/sample.apk).\n\n---\n\n# Gradle Dependency\n\nThe Gradle dependency is available via [jCenter](https://bintray.com/drummer-aidan/maven/material-camera/view).\njCenter is the default Maven repository used by Android Studio.\n\n## Dependency\n\nAdd the following to your module's `build.gradle` file:\n\n```Gradle\ndependencies {\n\n  implementation 'com.afollestad:drag-select-recyclerview:2.4.0'\n}\n```\n\n---\n\n# Introduction\n\n`DragSelectTouchListener` is the main class of this library.\n\nThis library will handle drag interception and auto scroll logic - if you drag to the top of the RecyclerView,\nthe list will scroll up, and vice versa.\n\n---\n\n# DragSelectTouchListener\n\n### Basics\n\n`DragSelectTouchListener` attaches to your RecyclerViews. It intercepts touch events\nwhen it's active, and reports to a receiver which handles updating UI\n\n```kotlin\nval receiver: DragSelectReceiver = // ...\nval touchListener = DragSelectTouchListener.create(context, receiver)\n```\n\n### Configuration\n\nThere are a few things that you can configure, mainly around auto scroll.\n\n```kotlin\nDragSelectTouchListener.create(context, adapter) {\n  // Configure the auto-scroll hotspot\n  hotspotHeight = resources.getDimensionPixelSize(R.dimen.default_56dp)\n  hotspotOffsetTop = 0 // default\n  hotspotOffsetBottom = 0 // default\n  \n  // Listen for auto scroll start/end\n  autoScrollListener = { isScrolling -\u003e } \n\n  // Or instead of the above...\n  disableAutoScroll()\n  \n  // The drag selection mode, RANGE is the default\n  mode = RANGE\n}\n```\n\nThe auto-scroll hotspot is a invisible section at the top and bottom of your\nRecyclerView, when your finger is in one of those sections, auto scroll is\ntriggered and the list will move up or down until you lift your finger.\n\nIf you use `PATH` as the mode instead of `RANGE`, the behavior is a bit different:\n\n![Path Mode GIF](https://github.com/afollestad/drag-select-recyclerview/raw/master/art/path.gif)\n\nCompare it to the GIF at the top.\n\n---\n\n# Interaction\n\nA receiver looks like this:\n\n```kotlin\nclass MyReceiver : DragSelectReceiver {\n\n  override fun setSelected(index: Int, selected: Boolean) {\n    // do something to mark this index as selected/unselected\n    if(selected \u0026\u0026 !selectedIndices.contains(index)) {\n      selectedIndices.add(index)\n    } else if(!selected) {\n      selectedIndices.remove(index)\n    }\n  }\n  \n  override fun isSelected(index: Int): Boolean {\n    // return true if this index is currently selected\n    return selectedItems.contains(index)\n  }\n  \n  override fun isIndexSelectable(index: Int): Boolean {\n    // if you return false, this index can't be used with setIsActive()\n    return true\n  }\n\n  override fun getItemCount(): Int {\n    // return size of your data set\n    return 0\n  }\n}\n```\n\nIn the sample project, our adapter is also our receiver.\n\nTo start drag selection, you use `setIsActive`, which should be triggered\nfrom user input such as a long press on a list item.\n\n```kotlin\nval recyclerView: RecyclerView = // ...\nval receiver: DragSelectReceiver = // ...\n\nval touchListener = DragSelectTouchListener.create(context, receiver)\nrecyclerView.addOnItemTouchListener(touchListener) // important!!\n\n// true for active = true, 0 is the initial selected index\ntouchListener.setIsActive(true, 0)\n````\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fafollestad%2Fdrag-select-recyclerview","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fafollestad%2Fdrag-select-recyclerview","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fafollestad%2Fdrag-select-recyclerview/lists"}