- Notifications
You must be signed in to change notification settings - Fork1
Customizable Android library that helps you to implement swipe-to-delete logic for your RecyclerView's adapters in an easy way!
License
agilie/SwipeToDelete
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
SwipeToDelete is a library you can use to simplify implementation of well-known (I believe for every Android developer :) ) swipe-to-delete behavior for your data lists. The main idea is that user has some time to undo unwanteddelete operation. Swipe twice to remove the row immediately! Also, this library is fully customizable, feel free to use your own UI forundo layer, add extra buttons etc.
- Based on interface implementation;
- Supports pending deletion with bottom layout;
- Full customization of upper layout and bottom layout;
- Easy way to handle deletion. All you need is to callremoveItem(key: K) which should be overriden in your adapter and to invokeswipeToDeleteDelegate.removeItem(key: K) at the end of method's definition.
Add dependency in yourbuild.gradle
file:
compile'com.agilie:swipe2delete:1.0'
Add rependency in your.pom
file:
<dependency> <groupId>com.agilie</groupId> <artifactId>swipe2delete</artifactId> <version>1.0</version> <type>pom</type></dependency>
- ImplementISwipeToDeleteAdapter in your own adapter or another class.
- Make instance ofSwipeToDeleteDelegate in your own adapter
SwipeToDeleteDelegate(context= context, items= mutableList, swipeToDeleteDelegate=this)
- Call corresponding methods in your overrided methods
overridefunonBindViewHolder(holder:Holder,position:Int) { swipeToDeleteDelegate.onBindViewHolder(holder, mutableList[position].name, position) }overridefunremoveItem(key:String) { swipeToDeleteDelegate.removeItem(key) }
- ImplementISwipeToDeleteHolder in your holder. You need to have container with your regular item layout and if you need bottom container too.
- In your holder you need to havevar pendingDelete as false by default and you need to overrideval topContainer
overrideval topContainer:View get()=if (pendingDelete) undoContainerelse itemContaineroverridevar pendingDelete:Boolean=false
- Also you need to make default key in holder by yourself
overridevar key:Int=-1
- If you need bottom container appearence while waiting, simply overrideonBindPendingItem(holder: Holder, key: Int, item: User) method:
overridefunonBindPendingItem(holder:Holder,key:Int,item:User) {...}
- Also you can implementIAnimationUpdateListener andIAnimatorListener to override methods to achieve animation along the axis x with duration which equally deleting duration
UserAdapter(...) : ... , IAnimationUpdateListener {... fun onAnimationUpdated(animation: android.animation.ValueAnimator?, options: ModelOptions<*>) {} fun onAnimationEnd(animation: Animator?, options: ModelOptions<*>) {} fun onAnimationCancel(animation: Animator?, options: ModelOptions<*>) {} fun onAnimationStart(animation: Animator?, options: ModelOptions<*>) {} fun onAnimationRepeat(animation: Animator, options: ModelOptions<*>) {}}
To get more information refer ourusage example. Just clone the project and run this module. Examples are provided inJava andKotlin as well!
Problems? Check theIssues blockto find the solution or create an new issue that we will fix asap. Feel free to contribute.
This library is open-sourced byAgilie Teaminfo@agilie.com
If you have any questions, suggestions or just need a help with web or mobile development, please email us at
android@agilie.com
You can ask us anything from basic to complex questions.
We will continue publishing new open-source projects. Stay with us, more updates will follow!
TheMIT License (MIT) Copyright © 2017Agilie Team
About
Customizable Android library that helps you to implement swipe-to-delete logic for your RecyclerView's adapters in an easy way!
Topics
Resources
License
Stars
Watchers
Forks
Packages0
Languages
- Kotlin76.1%
- Java23.9%