File tree Expand file tree Collapse file tree 3 files changed +8
-7
lines changed
java/me/yifeiyuan/flapdev/testcases
flap/src/main/java/me/yifeiyuan/flap/ext Expand file tree Collapse file tree 3 files changed +8
-7
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import android.graphics.Color
4
4
import android.graphics.drawable.ColorDrawable
5
5
import android.util.Log
6
6
import android.view.View
7
+ import androidx.recyclerview.widget.ItemTouchHelper
7
8
import me.yifeiyuan.flap.FlapAdapter
8
9
import me.yifeiyuan.flap.ext.SwipeDragHelper
9
10
@@ -23,13 +24,13 @@ class SwipeAndDragTestcase : BaseTestcaseFragment() {
23
24
val swipeDragHelper = SwipeDragHelper (adapter)
24
25
.withDragEnable(true )
25
26
.withSwipeEnable(true )
26
- // .withDragFlags()
27
- // .withSwipeFlags()
27
+ .withDragFlags(ItemTouchHelper . UP or ItemTouchHelper . DOWN )
28
+ .withSwipeFlags(ItemTouchHelper . START or ItemTouchHelper . END )
28
29
.withSwipeBackground(ColorDrawable (Color .parseColor(" #ff0000" )))
29
- .doOnItemDismiss {
30
+ .onItemDismiss {
30
31
toast(" 滑动删除了一个 item , position=$it " )
31
32
}
32
- .doOnItemMove { fromPosition, toPosition ->
33
+ .onItemMove { fromPosition, toPosition ->
33
34
toast(" 移动交换了 $fromPosition to $toPosition " )
34
35
}
35
36
.attachToRecyclerView(recyclerView)
Original file line number Diff line number Diff line change 50
50
<item
51
51
android : id =" @+id/nav_dismiss"
52
52
android : icon =" @drawable/ic_menu_camera"
53
- android : title =" SwipeToDismiss " />
53
+ android : title =" Swipe And Drag " />
54
54
<item
55
55
android : id =" @+id/nav_item_decorations"
56
56
android : icon =" @drawable/ic_menu_camera"
Original file line number Diff line number Diff line change @@ -95,7 +95,7 @@ class SwipeDragHelper(private val callback: Callback) : ItemTouchHelper.Callback
95
95
return false
96
96
}
97
97
98
- fun doOnItemMove (block : (fromPosition: Int , toPosition: Int ) -> Unit ): SwipeDragHelper {
98
+ fun onItemMove (block : (fromPosition: Int , toPosition: Int ) -> Unit ): SwipeDragHelper {
99
99
onMove = block
100
100
return this
101
101
}
@@ -106,7 +106,7 @@ class SwipeDragHelper(private val callback: Callback) : ItemTouchHelper.Callback
106
106
callback.onItemDismiss(viewHolder.adapterPosition)
107
107
}
108
108
109
- fun doOnItemDismiss (block : (position: Int ) -> Unit ): SwipeDragHelper {
109
+ fun onItemDismiss (block : (position: Int ) -> Unit ): SwipeDragHelper {
110
110
onDismiss = block
111
111
return this
112
112
}
You can’t perform that action at this time.
0 commit comments