Skip to content

Commit 0612193

Browse files
committed
Merge remote-tracking branch 'github/master'
2 parents 88351bd + 6656bae commit 0612193

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

README.md

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Android Swipe Actions
2-
This library helps to add swipe actions to a RecyclerView. A swipe action is an action which is performed when a swipe gesture is recognized on an adapter item. This Library implements a delete action with an undo option which makes it usable out of the box. </br></br>
2+
This library helps to add swipe actions to a RecyclerView. A swipe action is an action which is performed when a swipe gesture is recognized on an adapter item. The library contains an delete action with an undo option which makes it usable out of the box. </br></br>
33
![Imgur](https://i.imgur.com/qpULJkM.gif)</br></br>
44
Note: Keep in mind that any action can be implemented!
55

@@ -26,12 +26,12 @@ dependencies {
2626
```
2727

2828
# Usage
29-
To get started with the Library you should first implement your own Action or use the implemented delete Action.
30-
This Chapter will show the usage of the delete Action and the usual Workflow to assign the actions to the RecyclerView.
31-
Custom Actions will be described in the respective Chapter ([Custom Actions](#customAction)).
29+
To get started with the library you should first implement your own action or use the implemented delete action.
30+
This chapter will show the usage of the delete action and the usual workflow to assign the actions to the RecyclerView.
31+
Custom Actions will be described in the respective chapter ([Custom Actions](#customAction)).
3232

3333
## The Delete Action
34-
The Delete Action can be instantiated like this:
34+
The delete action can be instantiated like this:
3535
```kotlin
3636
val pendingDeleteAction = DeleteAction(yourRecyclerView, R.id.container)
3737
val instantDeleteAction = DeleteAction(yourRecyclerView, R.id.container, // necessary
@@ -40,7 +40,7 @@ val instantDeleteAction = DeleteAction(yourRecyclerView, R.id.container, // nece
4040
colorID = R.color.colorInstantDelete, // background color
4141
name = "instantDelete") // name of the action --> use this for debugging! otherwise not used
4242
```
43-
The pendingDeleteAction uses the Undo feature. Every other parameter besides the RecyclerView and SnackBar parent are optional.
43+
The pendingDeleteAction uses the undo feature. Every other parameter besides the RecyclerView and SnackBar parent are optional.
4444
To achieve an instant delete you could just set the undo parameter to false. If you'd like to customize the color and icon of the action you can also do so.
4545

4646
Furthermore you can customize the text of the shown SnackBar and specify a callback when items are deleted.
@@ -74,22 +74,21 @@ SwipeActionSetupHelper.setUpRecyclerView(this@MainActivity, list, pendingDeleteA
7474
You can use alternating Background colors if you want to. To set up the RecyclerView use the SwipeActionSetupHelper
7575
as shown above.
7676

77-
Your used adapter needs to implement the SwipeActionAdapter interface and provide the given Methods.
77+
Your used adapter needs to implement the SwipeActionAdapter interface and provide the given methods.
7878
An example implementation can be found in the sample app. It's important to note that the add and remove methods need to implement
7979
the corresponding notify methods of the adapter.
8080

8181
## <a name=customAction></a>Custom Actions
82-
Android Swipe Actions allows you to implement your own Swipe Actions. Your not limited in what you can do! To get started you need to
83-
extend the SwipeAction abstract class. See the sample for an example implementation. The performAction Method will be called when
82+
Android Swipe Actions allows you to implement your own SwipeActions. Your not limited in what you can do! To get started you need to
83+
extend the SwipeAction abstract class. See the sample for an example implementation. The performAction method will be called when
8484
a swipe is registered.
8585
```kotlin
8686
abstract fun performAction(swipedHolder: RecyclerView.ViewHolder, swipeDirection: Int)
8787
```
8888
Information of the swiped item can be retrieved from the ViewHolder.
89-
Originally the adapter position was used for the method call. This was not accurate because items could change positions. To prevent index errors
89+
Originally the adapter position was used for the method call. This was not accurate because items could change their position in the adapter. To prevent index errors
9090
the ViewHolder of the given item is used. This provides the benefit of accurate indices since the adapterPosition of the ViewHolder is updated.
91-
However there is also the possibility of the ViewHolder being recycled or other magic happening internally. To be save you could make sure
92-
that the adapterPosition makes sense (e.g. not -1 and not higher than the adapter size).
91+
However there is also the possibility of the ViewHolder being recycled or other magic happening internally. To be save you could check if the adapterPosition makes sense (e.g. not -1 and not higher than the adapter size).
9392
</br></br>
9493
And thats all there is to it! Have fun adding those actions to your RecyclerViews!
9594

0 commit comments

Comments
 (0)