Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
b993982
Create README.md
akotsuba May 22, 2017
4ea2712
migrate to Kotlin
May 22, 2017
09e97a2
migrate to Kotlin
May 22, 2017
18d323d
delete .idea directory
May 22, 2017
19b651d
delete .idea directory
May 22, 2017
3ddb589
Make separate package for library. Make major changes in new package.
May 22, 2017
6e114ce
Make SwipeToDeleteHolder interface.
May 22, 2017
9c0ae26
Base implementation of lib. OnSwipe not work`s properly
May 23, 2017
404de4a
Base implementation of lib. OnSwipe does not work properly
May 23, 2017
f723392
Merge branch 'custom_layout_ver' of https://github.com/agilie/SwipeTo…
May 24, 2017
8eaf899
Fix delete on swipe. Some improvements and cleanup. Added callbacks t…
May 24, 2017
322c75a
Delete unused classes from sample
May 24, 2017
6d1471f
Improve example. Make Java and basic Kotlin examples
May 25, 2017
ca3c13a
Improved example. Made interfaces instead values in custom adapter fo…
May 25, 2017
f039dd2
Code cleanup. Package refactoring
May 25, 2017
6fa7990
Add custom pending support
May 25, 2017
0b4c477
Change base pending time as 0. Support SwipeToDelete with no any bott…
May 25, 2017
cca84ca
Improvement of removeItem method.
May 25, 2017
09932b4
Update README.md
RomanKapshuk May 25, 2017
b43aeeb
Update README.md
RomanKapshuk May 25, 2017
ad55195
Deletion callback improvement. Minor cleanup
May 25, 2017
595b535
Merge remote-tracking branch 'origin/custom_layout_ver' into custom_l…
May 25, 2017
4539ff0
Code style cleanup.
May 25, 2017
9c7976c
Update README.md
RomanKapshuk May 25, 2017
1b73412
minor change.
May 25, 2017
a7ed3aa
Update README.md
akotsuba May 26, 2017
891c2a5
Code cleanup
May 26, 2017
32f1e05
Cleanup
May 26, 2017
58d635c
Code cleanup. Package refactoring. Minor optimization.
May 26, 2017
4b2f05b
Package refactoring.
May 26, 2017
50fde1e
Merge pull request #1 from agilie/custom_layout_ver
akotsuba May 30, 2017
a0f0999
Improve example.
May 30, 2017
e05e759
Code cleanup
May 30, 2017
30489ac
Fixed: bug with undo animation before item has been drawn
May 31, 2017
c144df9
Merge pull request #2 from agilie/custom_layout_ver
akotsuba Jun 1, 2017
5aaf423
code cleanup
akotsuba Jun 2, 2017
3e5a40b
Improve example. Code cleanup. Added native support of pending
Jun 2, 2017
9b3c724
code cleanup
akotsuba Jun 6, 2017
c9cb621
Update README.md
akotsuba Jun 6, 2017
9b15bd4
Update README.md
RomanKapshuk Jun 6, 2017
be40e1f
bintray support added
Jun 6, 2017
fd53120
Merge remote-tracking branch 'origin/master'
Jun 6, 2017
94cde22
bintray change
Jun 6, 2017
62db283
Change dependency
Jun 7, 2017
f54aa48
Update README.md
akotsuba Jun 7, 2017
55f5817
Create LICENSE.MD
akotsuba Jun 7, 2017
ee60689
Update README.md
akotsuba Jun 7, 2017
311c2b7
Update README.md
akotsuba Jun 7, 2017
8259f92
Update LICENSE.MD
akotsuba Jun 8, 2017
e3c33cb
Create README.md
akotsuba Jun 8, 2017
85774ee
Create README.md
akotsuba Jun 8, 2017
7edc1bb
Create README.md
akotsuba Jun 8, 2017
4325f59
Create README.md
akotsuba Jun 8, 2017
43dcfe0
Merge branch 'master' of https://github.com/agilie/SwipeToDelete
Jun 9, 2017
bdfd303
Update README.md
akotsuba Jun 19, 2017
eeb09cd
List of user for sample was changed
Jun 23, 2017
6a9055d
Merge remote-tracking branch 'origin/master'
Jun 23, 2017
4cf46d7
Merge pull request #4 from agilie/GMEG-82
akotsuba Jun 24, 2017
3723eaf
Update README.md
akotsuba Jun 24, 2017
83693b2
Launcher icon added
Jun 27, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures
.externalNativeBuild

/.idea/
build/
23 changes: 0 additions & 23 deletions .idea/compiler.xml

This file was deleted.

3 changes: 0 additions & 3 deletions .idea/copyright/profiles_settings.xml

This file was deleted.

3 changes: 0 additions & 3 deletions .idea/dictionaries/AlexZandR.xml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/encodings.xml

This file was deleted.

18 changes: 0 additions & 18 deletions .idea/gradle.xml

This file was deleted.

91 changes: 0 additions & 91 deletions .idea/misc.xml

This file was deleted.

9 changes: 0 additions & 9 deletions .idea/modules.xml

This file was deleted.

12 changes: 0 additions & 12 deletions .idea/runConfigurations.xml

This file was deleted.

21 changes: 21 additions & 0 deletions LICENSE.MD
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2017 [Agilie Team](https://agilie.com/en/index)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
126 changes: 126 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
# SwipeToDelete

[ ![Download](https://api.bintray.com/packages/agilie/maven/Swipe2Delete/images/download.svg) ](https://bintray.com/agilie/maven/Swipe2Delete/_latestVersion)

<img src="https://user-images.githubusercontent.com/1777595/27508401-815a208a-58ec-11e7-838a-5ef06a1c4482.gif" width="32%">

# 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 unwanted *delete* operation. Swipe twice to remove the row immediately! Also, this library is fully customizable, feel free to use your own UI for *undo* 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 call **removeItem(key: K)** which should be overriden in your adapter and to invoke **swipeToDeleteDelegate.removeItem(key: K)** at the end of method's definition.

# Usage

### Gradle

Add dependency in your `build.gradle` file:
````gradle
compile 'com.agilie:swipe2delete:1.0'
````

### Maven
Add rependency in your `.pom` file:
````xml
<dependency>
<groupId>com.agilie</groupId>
<artifactId>swipe2delete</artifactId>
<version>1.0</version>
<type>pom</type>
</dependency>
````

### How does it work?

* Implement **ISwipeToDeleteAdapter** in your own adapter or another class.
* Make instance of **SwipeToDeleteDelegate** in your own adapter

```kotlin
SwipeToDeleteDelegate(context = context, items = mutableList, swipeToDeleteDelegate = this)
```

* Call corresponding methods in your overrided methods

```kotlin
override fun onBindViewHolder(holder: Holder, position: Int) {
swipeToDeleteDelegate.onBindViewHolder(holder, mutableList[position].name, position)
}

override fun removeItem(key: String) {
swipeToDeleteDelegate.removeItem(key)
}
```


* Implement **ISwipeToDeleteHolder** 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 have **var pendingDelete** as false by default and you need to override **val topContainer**

```kotlin
override val topContainer: View
get() =
if (pendingDelete) undoContainer
else itemContainer

override var pendingDelete: Boolean = false
```


* Also you need to make default key in holder by yourself

```kotlin
override var key: Int = -1
```


* If you need bottom container appearence while waiting, simply override **onBindPendingItem(holder: Holder, key: Int, item: User)** method:

```kotlin
override fun onBindPendingItem(holder: Holder, key: Int, item: User) {
...
}
```
* Also you can implement **IAnimationUpdateListener** and **IAnimatorListener** 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 our [usage example](app/). Just clone the project and run this module. Examples are provided in [Java](app/src/main/java/agilie/example/swipe2delete/java/) and [Kotlin](app/src/main/java/agilie/example/swipe2delete/kotlin/) as well!

## Troubleshooting
Problems? Check the [Issues](https://github.com/agilie/SwipeToDelete/issues) block
to find the solution or create an new issue that we will fix asap. Feel free to contribute.

## Author

This library is open-sourced by [Agilie Team](https://www.agilie.com) <info@agilie.com>

## Contributors

- [Alexander Nekrasov](https://github.com/TermLog)
- [Roman Kapshuk](https://github.com/RomanKapshuk)

## Contact us
If you have any questions, suggestions or just need a help with web or mobile development, please email us at<br/> <android@agilie.com><br/>
You can ask us anything from basic to complex questions. <br/>
We will continue publishing new open-source projects. Stay with us, more updates will follow!<br/>

## License

The [MIT](LICENSE.MD) License (MIT) Copyright © 2017 [Agilie Team](https://www.agilie.com)

2 changes: 1 addition & 1 deletion app/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
/build
/build
11 changes: 10 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
compileSdkVersion 25
Expand All @@ -20,12 +22,19 @@ android {
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})

// compile project(':swipe2delete')
compile 'com.agilie:swipe2delete:1.0'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:design:25.3.1'
testCompile 'junit:junit:4.12'
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
}
repositories {
mavenCentral()
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import org.junit.Test;
import org.junit.runner.RunWith;

import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;

/**
* Instrumentation test, which will execute on an Android device.
Expand Down
Loading