Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Customizable Android library that helps you to implement swipe-to-delete logic for your RecyclerView's adapters in an easy way!

License

NotificationsYou must be signed in to change notification settings

agilie/SwipeToDelete

 
 

Repository files navigation

Download

What is SwipeToDelete?

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.

Features

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

Usage

Gradle

Add dependency in yourbuild.gradle file:

compile'com.agilie:swipe2delete:1.0'

Maven

Add rependency in your.pom file:

<dependency>  <groupId>com.agilie</groupId>  <artifactId>swipe2delete</artifactId>  <version>1.0</version>  <type>pom</type></dependency>

How does it work?

  • 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!

Troubleshooting

Problems? Check theIssues blockto find the solution or create an new issue that we will fix asap. Feel free to contribute.

Author

This library is open-sourced byAgilie Teaminfo@agilie.com

Contributors

Contact us

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!

License

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

Packages

No packages published

Languages

  • Kotlin76.1%
  • Java23.9%

[8]ページ先頭

©2009-2025 Movatter.jp