adding support for horizontal item dragging
This commit is contained in:
parent
6b848e58bd
commit
d64473820a
2 changed files with 6 additions and 3 deletions
|
@ -6,7 +6,7 @@ buildscript {
|
|||
propMinSdkVersion = 21
|
||||
propTargetSdkVersion = propCompileSdkVersion
|
||||
propVersionCode = 1
|
||||
propVersionName = '5.31.27'
|
||||
propVersionName = '5.31.28'
|
||||
kotlin_version = '1.4.10'
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ import androidx.recyclerview.widget.ItemTouchHelper
|
|||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.simplemobiletools.commons.adapters.MyRecyclerViewAdapter
|
||||
|
||||
open class ItemMoveCallback(private val mAdapter: ItemTouchHelperContract) : ItemTouchHelper.Callback() {
|
||||
open class ItemMoveCallback(private val mAdapter: ItemTouchHelperContract, private val allowHorizontalDrag: Boolean = false) : ItemTouchHelper.Callback() {
|
||||
override fun isLongPressDragEnabled() = false
|
||||
|
||||
override fun isItemViewSwipeEnabled() = false
|
||||
|
@ -12,7 +12,10 @@ open class ItemMoveCallback(private val mAdapter: ItemTouchHelperContract) : Ite
|
|||
override fun onSwiped(viewHolder: RecyclerView.ViewHolder, i: Int) {}
|
||||
|
||||
override fun getMovementFlags(recyclerView: RecyclerView, viewHolder: RecyclerView.ViewHolder): Int {
|
||||
val dragFlags = ItemTouchHelper.UP or ItemTouchHelper.DOWN
|
||||
var dragFlags = ItemTouchHelper.UP or ItemTouchHelper.DOWN
|
||||
if (allowHorizontalDrag) {
|
||||
dragFlags = dragFlags or ItemTouchHelper.LEFT or ItemTouchHelper.RIGHT
|
||||
}
|
||||
return makeMovementFlags(dragFlags, 0)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue