All Projects → afollestad → Drag Select Recyclerview

afollestad / Drag Select Recyclerview

Licence: apache-2.0
👇 Easy Google Photos style multi-selection for RecyclerViews, powered by Kotlin and AndroidX.

Programming Languages

kotlin
9241 projects

Projects that are alternatives of or similar to Drag Select Recyclerview

FancyAdapters
A collection of customizable RecyclerView Adapters for Android, that provide various functionality like item selection, contextual action mode controls, drag&drop and swiping, among other.
Stars: ✭ 49 (-97.3%)
Mutual labels:  recyclerview, selection
Linkage Recyclerview
即使不用饿了么订餐,也请务必收藏好该库!🔥 一行代码即可接入,二级联动订餐列表。
Stars: ✭ 2,970 (+63.37%)
Mutual labels:  recyclerview, androidx
Dragselectrecyclerview
TouchListener that can be attached to any RecyclerView and handles multi selection for you
Stars: ✭ 371 (-79.59%)
Mutual labels:  recyclerview, selection
slush
This library will no longer be updated 😭
Stars: ✭ 26 (-98.57%)
Mutual labels:  recyclerview, androidx
Reel Search Android
Reel Search for Android is a UI/UX design for autocomplete action. It is a beautiful minimalistic addition to any use case.
Stars: ✭ 110 (-93.95%)
Mutual labels:  ux, recyclerview
Overlap
Tiny iOS library to achieve overlap visual effect
Stars: ✭ 133 (-92.68%)
Mutual labels:  ux
Expandablerecyclerview
ExpandableRecyclerView with smoothly animation.
Stars: ✭ 135 (-92.57%)
Mutual labels:  recyclerview
Kotlin Adapter
🔥 RecyclerView,AbsListView适配器, 支持多种视图样式, 支持吸顶、侧滑删除、拖拽效果
Stars: ✭ 132 (-92.74%)
Mutual labels:  recyclerview
Easyrecyclerview
🎞 Easy recyclerview for Android
Stars: ✭ 131 (-92.79%)
Mutual labels:  recyclerview
Material Theme
Material Theme, the most epic theme for Sublime Text 3 by Mattia Astorino
Stars: ✭ 11,093 (+510.18%)
Mutual labels:  ux
Rn Placeholder
🏖️ Display some placeholder stuff before rendering your text or media content in React Native
Stars: ✭ 1,934 (+6.38%)
Mutual labels:  ux
Kaiju
A drag and drop web editor for React components.
Stars: ✭ 135 (-92.57%)
Mutual labels:  ux
Coinverse
Coinverse Open App is the first audiocast app for cryptocurrency news. 🚀
Stars: ✭ 133 (-92.68%)
Mutual labels:  recyclerview
Nativelogin
Authorization form in native iOS style
Stars: ✭ 140 (-92.3%)
Mutual labels:  ux
Omegarecyclerview
Custom RecyclerView with additional functionality. Allow you add divider, itemSpace, emptyView, sticky header and some other features
Stars: ✭ 132 (-92.74%)
Mutual labels:  recyclerview
Android Rv Swipe Delete
RecyclerView swipe to delete example.
Stars: ✭ 143 (-92.13%)
Mutual labels:  recyclerview
Motion
A library used to create beautiful animations and transitions for iOS.
Stars: ✭ 1,726 (-5.06%)
Mutual labels:  ux
Banner
🔥🔥🔥Banner 2.0 来了!Android广告图片轮播控件,内部基于ViewPager2实现,Indicator和UI都可以自定义。
Stars: ✭ 11,682 (+542.57%)
Mutual labels:  androidx
Recyclerviewadapter
A RecyclerView Adapter that support load more and add headerview
Stars: ✭ 141 (-92.24%)
Mutual labels:  recyclerview
Swipeablecards
Stars: ✭ 136 (-92.52%)
Mutual labels:  recyclerview

Drag Select Recycler View

Maven Central Android CI License

This library allows you to implement Google Photos style multi-selection in your apps! You start by long pressing an item in your list, then you drag your finger without letting go to select more.

Range Mode GIF

Sample

You can download a sample APK.


Gradle Dependency

The Gradle dependency is available via jCenter. jCenter is the default Maven repository used by Android Studio.

Dependency

Add the following to your module's build.gradle file:

dependencies {

  implementation 'com.afollestad:drag-select-recyclerview:2.4.0'
}

Introduction

DragSelectTouchListener is the main class of this library.

This library will handle drag interception and auto scroll logic - if you drag to the top of the RecyclerView, the list will scroll up, and vice versa.


DragSelectTouchListener

Basics

DragSelectTouchListener attaches to your RecyclerViews. It intercepts touch events when it's active, and reports to a receiver which handles updating UI

val receiver: DragSelectReceiver = // ...
val touchListener = DragSelectTouchListener.create(context, receiver)

Configuration

There are a few things that you can configure, mainly around auto scroll.

DragSelectTouchListener.create(context, adapter) {
  // Configure the auto-scroll hotspot
  hotspotHeight = resources.getDimensionPixelSize(R.dimen.default_56dp)
  hotspotOffsetTop = 0 // default
  hotspotOffsetBottom = 0 // default
  
  // Listen for auto scroll start/end
  autoScrollListener = { isScrolling -> } 

  // Or instead of the above...
  disableAutoScroll()
  
  // The drag selection mode, RANGE is the default
  mode = RANGE
}

The auto-scroll hotspot is a invisible section at the top and bottom of your RecyclerView, when your finger is in one of those sections, auto scroll is triggered and the list will move up or down until you lift your finger.

If you use PATH as the mode instead of RANGE, the behavior is a bit different:

Path Mode GIF

Compare it to the GIF at the top.


Interaction

A receiver looks like this:

class MyReceiver : DragSelectReceiver {

  override fun setSelected(index: Int, selected: Boolean) {
    // do something to mark this index as selected/unselected
    if(selected && !selectedIndices.contains(index)) {
      selectedIndices.add(index)
    } else if(!selected) {
      selectedIndices.remove(index)
    }
  }
  
  override fun isSelected(index: Int): Boolean {
    // return true if this index is currently selected
    return selectedItems.contains(index)
  }
  
  override fun isIndexSelectable(index: Int): Boolean {
    // if you return false, this index can't be used with setIsActive()
    return true
  }

  override fun getItemCount(): Int {
    // return size of your data set
    return 0
  }
}

In the sample project, our adapter is also our receiver.

To start drag selection, you use setIsActive, which should be triggered from user input such as a long press on a list item.

val recyclerView: RecyclerView = // ...
val receiver: DragSelectReceiver = // ...

val touchListener = DragSelectTouchListener.create(context, receiver)
recyclerView.addOnItemTouchListener(touchListener) // important!!

// true for active = true, 0 is the initial selected index
touchListener.setIsActive(true, 0)
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].