Giter Site home page Giter Site logo

muxi166 / dragselectrecyclerview Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mflisar/dragselectrecyclerview

0.0 1.0 0.0 52.74 MB

TouchListener that can be attached to any RecyclerView and handles multi selection for you

License: Apache License 2.0

Java 100.00%

dragselectrecyclerview's Introduction

###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" }
    }
  2. add the compile statement to your module's build.gradle:

    dependencies {
        compile 'com.github.MFlisar:DragSelectRecyclerView:0.2'
    }

Usage

  1. Create the a touch listener like following

    mDragSelectTouchListener = new DragSelectTouchListener()
    	.withSelectListener(new DragSelectTouchListener.OnDragSelectListener() {
    		@Override
    		public void onSelectChange(int start, int end, boolean isSelected) {
    			// update your selection
    			// range is inclusive start/end positions
    		}
    	})
    	// 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;
    
  2. attach it to the RecyclerView

    recyclerView.addOnItemTouchListener(mDragSelectTouchListener);
    
  3. 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);
    

###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

dragselectrecyclerview's People

Contributors

mflisar avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.