All Projects → MFlisar → Dragselectrecyclerview

MFlisar / Dragselectrecyclerview

Licence: apache-2.0
TouchListener that can be attached to any RecyclerView and handles multi selection for you

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Dragselectrecyclerview

Dragdropswiperecyclerview
Kotlin Android library that extends RecyclerView to support gestures like drag & drop and swipe, among others. It works with vertical, horizontal and grid lists.
Stars: ✭ 469 (+26.42%)
Mutual labels:  recyclerview, drag
Fullrecyclerview
This is a compilation of different kinds and actions in recyclerView
Stars: ✭ 127 (-65.77%)
Mutual labels:  recyclerview, drag
Ninaselectionview
Way to select your buttons.
Stars: ✭ 87 (-76.55%)
Mutual labels:  drag, selection
Drag Select Recyclerview
👇 Easy Google Photos style multi-selection for RecyclerViews, powered by Kotlin and AndroidX.
Stars: ✭ 1,818 (+390.03%)
Mutual labels:  recyclerview, selection
Selectable
Touch enabled selectable plugin inspired by the jQuery UI widget.
Stars: ✭ 131 (-64.69%)
Mutual labels:  drag, selection
Recyclerviewevent
RecyclerView onItemClick、onItemLongClick、drag、swipe、divider、reuse disorder RecyclerView 梳理:点击&长按事件、分割线、拖曳排序、滑动删除、优雅解决 EditText 和 CheckBox 复用错乱问题
Stars: ✭ 265 (-28.57%)
Mutual labels:  recyclerview, drag
Recyclerviewhelper
📃 [Android Library] Giving powers to RecyclerView
Stars: ✭ 643 (+73.32%)
Mutual labels:  recyclerview, drag
Dsladapter
🔥 Kotlin时代的Adapter, Dsl 的形式使用 RecyclerView.Adapter, 支持折叠展开, 树结构,悬停,情感图状态切换, 加载更多, 多类型Item,侧滑菜单等
Stars: ✭ 231 (-37.74%)
Mutual labels:  recyclerview, drag
XamarinItemTouchHelper
Basic example of using ItemTouchHelper to add drag & drop and swipe-to-dismiss to RecyclerView for Xamarin
Stars: ✭ 35 (-90.57%)
Mutual labels:  recyclerview, drag
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 (-86.79%)
Mutual labels:  recyclerview, selection
Boardview
A draggable boardview for java android (Kanban style)
Stars: ✭ 309 (-16.71%)
Mutual labels:  recyclerview, drag
Extended text
A powerful extended official text for Flutter, which supports Speical Text(Image,@somebody), Custom Background, Custom overFlow, Text Selection.
Stars: ✭ 345 (-7.01%)
Mutual labels:  selection
Recycler View Divider
A library which configures a divider for a RecyclerView.
Stars: ✭ 338 (-8.89%)
Mutual labels:  recyclerview
Vue Drag Tree
🌴🌳a Vue's drag and drop tree component || 🌾Demo
Stars: ✭ 337 (-9.16%)
Mutual labels:  drag
Horizontalpicker
A simple, customizable and easy to use picker where centre view is scaled up
Stars: ✭ 337 (-9.16%)
Mutual labels:  recyclerview
Multichoicerecyclerview
Multi choice selection applied on recycler view make life easier
Stars: ✭ 361 (-2.7%)
Mutual labels:  recyclerview
Brv
Android上最强大的RecyclerView库
Stars: ✭ 345 (-7.01%)
Mutual labels:  recyclerview
Flexibleadapter
Fast and versatile Adapter for RecyclerView which regroups several features into one library to considerably improve the user experience :-)
Stars: ✭ 3,482 (+838.54%)
Mutual labels:  recyclerview
Persei
Animated top menu for UITableView / UICollectionView / UIScrollView written in Swift
Stars: ✭ 3,395 (+815.09%)
Mutual labels:  drag
Android Gif Example
Gif RecyclerView in MVP using Dagger 2 + Retrofit 2 + Moshi + RxJava 2 + Glide 4 with JUnit and Espresso tests written in Kotlin + Kotlin DSL!
Stars: ✭ 334 (-9.97%)
Mutual labels:  recyclerview

DragSelectRecyclerView Release Android Arsenal

What is it / What does it do?

It's a simple one class TouchListener that can be attached to any RecyclerView and handles multi selection in google photos style via long pressing on an item and moving the finger up/down to select more items (it even scrolls if you reach the edges of the RecyclerView)

Demo

Gradle (via JitPack.io)

  1. add jitpack to your project's build.gradle:
repositories {
	maven { url "https://jitpack.io" }
}
  1. add the compile statement to your module's build.gradle:
dependencies {
	compile 'com.github.MFlisar:DragSelectRecyclerView:0.3'
}

Usage - General

  1. Create the a touch listener like following
mDragSelectTouchListener = new DragSelectTouchListener()
	// check region OnDragSelectListener for more infos
	.withSelectListener(onDragSelectionListener)
	// following is all optional
	.withMaxScrollDistance(distance)    // default: 16; 	defines the speed of the auto scrolling
	.withTopOffset(toolbarHeight)       // default: 0; 		set an offset for the touch region on top of the RecyclerView
	.withBottomOffset(toolbarHeight)    // default: 0; 		set an offset for the touch region on bottom of the RecyclerView
	.withScrollAboveTopRegion(enabled)  // default: true; 	enable auto scrolling, even if the finger is moved above the top region
	.withScrollBelowTopRegion(enabled)  // default: true; 	enable auto scrolling, even if the finger is moved below the top region
	.withDebug(enabled);                // default: false;
  1. attach it to the RecyclerView
recyclerView.addOnItemTouchListener(mDragSelectTouchListener);
  1. on item long press, inform the listener so that it can start doing it's magic
// if one item is long pressed, we start the drag selection like following:
// we just call this function and pass in the position of the first selected item
mDragSelectTouchListener.startDragSelection(position);

Usage - OnDragSelectListener

You have 3 options:

  • use a simple DragSelectTouchListener.OnDragSelectListener => you get notified over which items the user dragged or dragged back

       onDragSelectionListener = new DragSelectTouchListener.OnDragSelectListener() {
     	@Override
     	public void onSelectChange(int start, int end, boolean isSelected) {
     		// update your selection
     		// range is inclusive start/end positions
     	}
       }
    
  • use a DragSelectTouchListener.OnAdvancedDragSelectListener => this is an extended version of the DragSelectTouchListener.OnDragSelectListener which will notify you about the start and end of the drag selection as well

     onDragSelectionListener = new DragSelectTouchListener.OnAdvancedDragSelectListener()
     {
     	@Override
     	public void onSelectChange(int start, int end, boolean isSelected) {
     		// update your selection
     		// range is inclusive start/end positions
     	}
    
     	@Override
     	public void onSelectionStarted(int start) {
     		// drag selection was started at index start
     	}
    
     	@Override
     	public void onSelectionFinished(int end) {
     		// drag selection was finished at index start
     	}
     };
    
  • Preferred option: use the DragSelectionProcessor, it implements the above mentioned interface and can be set up with 4 modes:

    • Simple: simply selects each item you go by and unselects on move back
    • ToggleAndUndo: toggles each items original state, reverts to the original state on move back
    • FirstItemDependent: toggles the first item and applies the same state to each item you go by and applies inverted state on move back
    • FirstItemDependentToggleAndUndo: toggles the item and applies the same state to each item you go by and reverts to the original state on move back

The DragSelectionProcessor will take care to transform each event to the correct select/deselect event that must be handled by you afterwards. Therefore you must provide a ISelectionHandler in it's constructor. Just implement it's 3 simple functions and you're done.

onDragSelectionListener = new DragSelectionProcessor(new DragSelectionProcessor.ISelectionHandler() {
	@Override
	public Set<Integer> getSelection() {
		// return a set of all currently selected indizes
		return selection;
	}

	@Override
	public boolean isSelected(int index) {
		// return the current selection state of the index
		return selected;
	}

	@Override
	public void updateSelection(int start, int end, boolean isSelected, boolean calledFromOnStart) {
		// update your selection
		// range is inclusive start/end positions
		// and the processor has already converted all events according to it'smode
	}
})
	// pass in one of the 4 modes, simple mode is selected by default otherwise
	.withMode(DragSelectionProcessor.Mode.FirstItemDependentToggleAndUndo);

A demo can be found here: MainActivity.java

TODO

  • support horizontal RecyclerViews... should be quite simple, but is not yet implemented

Credits

This library is heavily inspired and based on https://github.com/weidongjian/AndroidDragSelect-SimulateGooglePhoto

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].