Skip to content

Commit fb81c8a

Browse files
committed
Updates readme
1 parent 4217af1 commit fb81c8a

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,6 @@ com_crashlytics_export_strings.xml
5353
# Gradle files
5454
.gradle
5555
/build
56-
/captures
56+
/captures
57+
58+
infer-out/

README.markdown

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
## Another drag and swipe library?
22

3-
There are a bunch of tutorials, libraries, and examples for implementing “drag & drop and swipe-to-dismiss” in Android, using `RecyclerView`. Many of them are still using the old `View.OnDragListener`, and [Roman Nurik’s Swipe-to-Dismiss](https://github.com/romannurik/Android-SwipeToDismiss) approach, even though there are newer (and better) methods available. A few of these solutions use the newer APIs, but often rely on `GestureDetector` and `onInterceptTouchEvent`, or the implementation is overly complex. There’s actually a really simple way to add these features to RecyclerView, and it’s part of the Android Support Library: [ItemTouchHelper](https://developer.android.com/reference/android/support/v7/widget/helper/ItemTouchHelper.html).
3+
This project is an example of basic drag & drop and swipe-to-dismiss with `RecyclerView` using `ItemTouchHelper`. It corresponds with an article series found here:
44

5-
This project is an example of basic drag and swipe using `ItemTouchHelper`. It corresponds with a soon-to-be-published article series exploring the approach.
5+
[Drag and swipe with RecyclerView](https://medium.com/@ipaulpro/drag-and-swipe-with-recyclerview-b9456d2b1aaf)
66

7-
The classes in `co.paulburke.android.itemtouchhelperdemo.helper` can easily be used in other projects.
7+
The classes in [co.paulburke.android.itemtouchhelperdemo.helper](https://github.com/iPaulPro/Android-ItemTouchHelper-Demo/tree/master/app/src/main/java/co/paulburke/android/itemtouchhelperdemo/helper) can easily be used in other projects.
88

99
Download the apk from [releases](https://github.com/ipaulpro/Android-ItemTouchHelper-Demo/releases).
1010

app/src/main/java/co/paulburke/android/itemtouchhelperdemo/RecyclerListAdapter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828

2929
import java.util.ArrayList;
3030
import java.util.Arrays;
31+
import java.util.Collections;
3132
import java.util.List;
3233

3334
import co.paulburke.android.itemtouchhelperdemo.helper.ItemTouchHelperAdapter;
@@ -99,8 +100,7 @@ public void onItemDismiss(int position) {
99100

100101
@Override
101102
public void onItemMove(int fromPosition, int toPosition) {
102-
String prev = mItems.remove(fromPosition);
103-
mItems.add(toPosition > fromPosition ? toPosition - 1 : toPosition, prev);
103+
Collections.swap(mItems, fromPosition, toPosition);
104104
notifyItemMoved(fromPosition, toPosition);
105105
}
106106

0 commit comments

Comments
 (0)