# ItemTouchHelper.Callback

# ItemTouchHelper.Callback

Artifact:[androidx.recyclerview:recyclerview](https://developer.android.com/jetpack/androidx/releases/recyclerview)  
[View Source](https://cs.android.com/search?q=file:androidx/recyclerview/widget/ItemTouchHelper.java+class:androidx.recyclerview.widget.ItemTouchHelper.Callback)  
Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/recyclerview#1.0.0)

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/recyclerview/widget/ItemTouchHelper.Callback "View this page in Java")

<br />

```
abstract class ItemTouchHelper.Callback
```

<br />

Known direct subclasses  
[ItemTouchHelper.SimpleCallback](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper.SimpleCallback)  

|----------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------|
| [ItemTouchHelper.SimpleCallback](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper.SimpleCallback) | A simple wrapper to the default Callback which you can construct with drag and swipe directions and this class will handle the flag callbacks. |

*** ** * ** ***

This class is the contract between ItemTouchHelper and your application. It lets you control which touch behaviors are enabled per each ViewHolder and also receive callbacks when user performs these actions.

To control which actions user can take on each view, you should override[getMovementFlags](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper.Callback#getMovementFlags(androidx.recyclerview.widget.RecyclerView,androidx.recyclerview.widget.RecyclerView.ViewHolder))and return appropriate set of direction flags. ([LEFT](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper#LEFT()),[RIGHT](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper#RIGHT()),[START](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper#START()),[END](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper#END()),[UP](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper#UP()),[DOWN](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper#DOWN())). You can use[makeMovementFlags](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper.Callback#makeMovementFlags(int,int))to easily construct it. Alternatively, you can use[SimpleCallback](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper.SimpleCallback).

If user drags an item, ItemTouchHelper will call[onMove(recyclerView, dragged, target)](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper.Callback#onMove(androidx.recyclerview.widget.RecyclerView,androidx.recyclerview.widget.RecyclerView.ViewHolder,androidx.recyclerview.widget.RecyclerView.ViewHolder)). Upon receiving this callback, you should move the item from the old position (`dragged.getAdapterPosition()`) to new position (`target.getAdapterPosition()`) in your adapter and also call[notifyItemMoved](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.Adapter#notifyItemMoved(int,int)). To control where a View can be dropped, you can override[canDropOver](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper.Callback#canDropOver(androidx.recyclerview.widget.RecyclerView,androidx.recyclerview.widget.RecyclerView.ViewHolder,androidx.recyclerview.widget.RecyclerView.ViewHolder)). When a dragging View overlaps multiple other views, Callback chooses the closest View with which dragged View might have changed positions. Although this approach works for many use cases, if you have a custom LayoutManager, you can override[chooseDropTarget](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper.Callback#chooseDropTarget(androidx.recyclerview.widget.RecyclerView.ViewHolder,java.util.List<androidx.recyclerview.widget.RecyclerView.ViewHolder>,int,int))to select a custom drop target.

When a View is swiped, ItemTouchHelper animates it until it goes out of bounds, then calls[onSwiped](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper.Callback#onSwiped(androidx.recyclerview.widget.RecyclerView.ViewHolder,int)). At this point, you should update your adapter (e.g. remove the item) and call related Adapter#notify event.

## Summary

|                                    ### Constants                                    |
|-------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [DEFAULT_DRAG_ANIMATION_DURATION](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper.Callback#DEFAULT_DRAG_ANIMATION_DURATION())` = 200`   |
| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [DEFAULT_SWIPE_ANIMATION_DURATION](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper.Callback#DEFAULT_SWIPE_ANIMATION_DURATION())` = 250` |

|                                                     ### Public constructors                                                     |
|---------------------------------------------------------------------------------------------------------------------------------|
| [Callback](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper.Callback#Callback())`()` |

|                                                       ### Public functions                                                        |
|-----------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)                                               | [canDropOver](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper.Callback#canDropOver(androidx.recyclerview.widget.RecyclerView,androidx.recyclerview.widget.RecyclerView.ViewHolder,androidx.recyclerview.widget.RecyclerView.ViewHolder))`(` ` recyclerView: `[RecyclerView](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView)`,` ` current: `[RecyclerView.ViewHolder](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.ViewHolder)`,` ` target: `[RecyclerView.ViewHolder](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.ViewHolder) `)` Return true if the current ViewHolder can be dropped over the the target ViewHolder.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| [RecyclerView.ViewHolder](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.ViewHolder)`!` | [chooseDropTarget](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper.Callback#chooseDropTarget(androidx.recyclerview.widget.RecyclerView.ViewHolder,java.util.List<androidx.recyclerview.widget.RecyclerView.ViewHolder>,int,int))`(` ` selected: `[RecyclerView.ViewHolder](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.ViewHolder)`,` ` dropTargets: (`[Mutable](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html)`)`[List](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html)`<`[RecyclerView.ViewHolder](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.ViewHolder)`!>,` ` curX: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`,` ` curY: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) `)` Called by ItemTouchHelper to select a drop target from the list of ViewHolders that are under the dragged View.                                                                                                                                                                                                                                                                                                      |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                                                     | [clearView](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper.Callback#clearView(androidx.recyclerview.widget.RecyclerView,androidx.recyclerview.widget.RecyclerView.ViewHolder))`(` ` recyclerView: `[RecyclerView](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView)`,` ` viewHolder: `[RecyclerView.ViewHolder](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.ViewHolder) `)` Called by the ItemTouchHelper when the user interaction with an element is over and it also completed its animation.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)                                                       | [convertToAbsoluteDirection](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper.Callback#convertToAbsoluteDirection(int,int))`(flags: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`, layoutDirection: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`)` Converts a given set of flags to absolution direction which means[START](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper#START())and[END](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper#END())are replaced with[LEFT](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper#LEFT())and[RIGHT](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper#RIGHT())depending on the layout direction.                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| `java-static `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)                                         | [convertToRelativeDirection](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper.Callback#convertToRelativeDirection(int,int))`(flags: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`, layoutDirection: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`)` Replaces a movement direction with its relative version by taking layout direction into account.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| [Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)                                                     | [getAnimationDuration](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper.Callback#getAnimationDuration(androidx.recyclerview.widget.RecyclerView,int,float,float))`(` ` recyclerView: `[RecyclerView](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView)`,` ` animationType: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`,` ` animateDx: `[Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)`,` ` animateDy: `[Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html) `)` Called by the ItemTouchHelper when user action finished on a ViewHolder and now the View will be animated to its final position.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)                                                       | [getBoundingBoxMargin](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper.Callback#getBoundingBoxMargin())`()` When finding views under a dragged view, by default, ItemTouchHelper searches for views that overlap with the dragged View.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| `java-static `[ItemTouchUIUtil](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchUIUtil)      | [getDefaultUIUtil](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper.Callback#getDefaultUIUtil())`()` Returns the[ItemTouchUIUtil](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchUIUtil)that is used by the[Callback](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper.Callback)class for visual changes on Views in response to user interactions.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| [Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)                                                   | [getMoveThreshold](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper.Callback#getMoveThreshold(androidx.recyclerview.widget.RecyclerView.ViewHolder))`(viewHolder: `[RecyclerView.ViewHolder](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.ViewHolder)`)` Returns the fraction that the user should move the View to be considered as it is dragged.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| `abstract `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)                                            | [getMovementFlags](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper.Callback#getMovementFlags(androidx.recyclerview.widget.RecyclerView,androidx.recyclerview.widget.RecyclerView.ViewHolder))`(` ` recyclerView: `[RecyclerView](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView)`,` ` viewHolder: `[RecyclerView.ViewHolder](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.ViewHolder) `)` Should return a composite flag which defines the enabled move directions in each state (idle, swiping, dragging).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| [Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)                                                   | [getSwipeEscapeVelocity](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper.Callback#getSwipeEscapeVelocity(float))`(defaultValue: `[Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)`)` Defines the minimum velocity which will be considered as a swipe action by the user.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| [Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)                                                   | [getSwipeThreshold](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper.Callback#getSwipeThreshold(androidx.recyclerview.widget.RecyclerView.ViewHolder))`(viewHolder: `[RecyclerView.ViewHolder](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.ViewHolder)`)` Returns the fraction that the user should move the View to be considered as swiped.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| [Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)                                                   | [getSwipeVelocityThreshold](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper.Callback#getSwipeVelocityThreshold(float))`(defaultValue: `[Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)`)` Defines the maximum velocity ItemTouchHelper will ever calculate for pointer movements.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)                                                       | [interpolateOutOfBoundsScroll](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper.Callback#interpolateOutOfBoundsScroll(androidx.recyclerview.widget.RecyclerView,int,int,int,long))`(` ` recyclerView: `[RecyclerView](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView)`,` ` viewSize: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`,` ` viewSizeOutOfBounds: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`,` ` totalSize: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`,` ` msSinceStartScroll: `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html) `)` Called by the ItemTouchHelper when user is dragging a view out of bounds.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)                                               | [isItemViewSwipeEnabled](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper.Callback#isItemViewSwipeEnabled())`()` Returns whether ItemTouchHelper should start a swipe operation if a pointer is swiped over the View.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)                                               | [isLongPressDragEnabled](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper.Callback#isLongPressDragEnabled())`()` Returns whether ItemTouchHelper should start a drag and drop operation if an item is long pressed.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| `java-static `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)                                         | [makeFlag](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper.Callback#makeFlag(int,int))`(actionState: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`, directions: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`)` Shifts the given direction flags to the offset of the given action state.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| `java-static `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)                                         | [makeMovementFlags](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper.Callback#makeMovementFlags(int,int))`(dragFlags: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`, swipeFlags: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`)` Convenience method to create movement flags.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                                                     | [onChildDraw](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper.Callback#onChildDraw(android.graphics.Canvas,androidx.recyclerview.widget.RecyclerView,androidx.recyclerview.widget.RecyclerView.ViewHolder,float,float,int,boolean))`(` ` c: `[Canvas](https://developer.android.com/reference/android/graphics/Canvas.html)`,` ` recyclerView: `[RecyclerView](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView)`,` ` viewHolder: `[RecyclerView.ViewHolder](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.ViewHolder)`,` ` dX: `[Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)`,` ` dY: `[Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)`,` ` actionState: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`,` ` isCurrentlyActive: `[Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) `)` Called by ItemTouchHelper on RecyclerView's onDraw callback.                                                                                                                                                                                                                                                                       |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                                                     | [onChildDrawOver](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper.Callback#onChildDrawOver(android.graphics.Canvas,androidx.recyclerview.widget.RecyclerView,androidx.recyclerview.widget.RecyclerView.ViewHolder,float,float,int,boolean))`(` ` c: `[Canvas](https://developer.android.com/reference/android/graphics/Canvas.html)`,` ` recyclerView: `[RecyclerView](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView)`,` ` viewHolder: `[RecyclerView.ViewHolder](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.ViewHolder)`!,` ` dX: `[Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)`,` ` dY: `[Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)`,` ` actionState: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`,` ` isCurrentlyActive: `[Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) `)` Called by ItemTouchHelper on RecyclerView's onDraw callback.                                                                                                                                                                                                                                                              |
| `abstract `[Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)                                    | [onMove](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper.Callback#onMove(androidx.recyclerview.widget.RecyclerView,androidx.recyclerview.widget.RecyclerView.ViewHolder,androidx.recyclerview.widget.RecyclerView.ViewHolder))`(` ` recyclerView: `[RecyclerView](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView)`,` ` viewHolder: `[RecyclerView.ViewHolder](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.ViewHolder)`,` ` target: `[RecyclerView.ViewHolder](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.ViewHolder) `)` Called when ItemTouchHelper wants to move the dragged item from its old position to the new position.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                                                     | [onMoved](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper.Callback#onMoved(androidx.recyclerview.widget.RecyclerView,androidx.recyclerview.widget.RecyclerView.ViewHolder,int,androidx.recyclerview.widget.RecyclerView.ViewHolder,int,int,int))`(` ` recyclerView: `[RecyclerView](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView)`,` ` viewHolder: `[RecyclerView.ViewHolder](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.ViewHolder)`,` ` fromPos: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`,` ` target: `[RecyclerView.ViewHolder](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.ViewHolder)`,` ` toPos: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`,` ` x: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`,` ` y: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) `)` Called when[onMove](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper.Callback#onMove(androidx.recyclerview.widget.RecyclerView,androidx.recyclerview.widget.RecyclerView.ViewHolder,androidx.recyclerview.widget.RecyclerView.ViewHolder))returns true. |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                                                     | [onSelectedChanged](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper.Callback#onSelectedChanged(androidx.recyclerview.widget.RecyclerView.ViewHolder,int))`(viewHolder: `[RecyclerView.ViewHolder](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.ViewHolder)`?, actionState: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`)` Called when the ViewHolder swiped or dragged by the ItemTouchHelper is changed.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| `abstract `[Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                                          | [onSwiped](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper.Callback#onSwiped(androidx.recyclerview.widget.RecyclerView.ViewHolder,int))`(viewHolder: `[RecyclerView.ViewHolder](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.ViewHolder)`, direction: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`)` Called when a ViewHolder is swiped by the user.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |

## Constants

### DEFAULT_DRAG_ANIMATION_DURATION

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/recyclerview#1.0.0)  

```
const val DEFAULT_DRAG_ANIMATION_DURATION = 200: Int
```  

### DEFAULT_SWIPE_ANIMATION_DURATION

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/recyclerview#1.0.0)  

```
const val DEFAULT_SWIPE_ANIMATION_DURATION = 250: Int
```  

## Public constructors

### Callback

Added in 1.0.0  

```
Callback()
```  

## Public functions

### canDropOver

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/recyclerview#1.0.0)  

```
fun canDropOver(
    recyclerView: RecyclerView,
    current: RecyclerView.ViewHolder,
    target: RecyclerView.ViewHolder
): Boolean
```

Return true if the current ViewHolder can be dropped over the the target ViewHolder.

This method is used when selecting drop target for the dragged View. After Views are eliminated either via bounds check or via this method, resulting set of views will be passed to[chooseDropTarget](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper.Callback#chooseDropTarget(androidx.recyclerview.widget.RecyclerView.ViewHolder,java.util.List<androidx.recyclerview.widget.RecyclerView.ViewHolder>,int,int)).

Default implementation returns true.  

|                                                                Parameters                                                                 |
|-------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------|
| `recyclerView: `[RecyclerView](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView)                  | The RecyclerView to which ItemTouchHelper is attached to. |
| `current: `[RecyclerView.ViewHolder](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.ViewHolder) | The ViewHolder that user is dragging.                     |
| `target: `[RecyclerView.ViewHolder](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.ViewHolder)  | The ViewHolder which is below the dragged ViewHolder.     |

|                                       Returns                                       |
|-------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------|
| [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) | True if the dragged ViewHolder can be replaced with the target ViewHolder, false otherwise. |

### chooseDropTarget

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/recyclerview#1.0.0)  

```
fun chooseDropTarget(
    selected: RecyclerView.ViewHolder,
    dropTargets: (Mutable)List<RecyclerView.ViewHolder!>,
    curX: Int,
    curY: Int
): RecyclerView.ViewHolder!
```

Called by ItemTouchHelper to select a drop target from the list of ViewHolders that are under the dragged View.

Default implementation filters the View with which dragged item have changed position in the drag direction. For instance, if the view is dragged UP, it compares the`view.getTop()`of the two views before and after drag started. If that value is different, the target view passes the filter.

Among these Views which pass the test, the one closest to the dragged view is chosen.

This method is called on the main thread every time user moves the View. If you want to override it, make sure it does not do any expensive operations.  

|                                                                                                                                                                      Parameters                                                                                                                                                                       |
|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `selected: `[RecyclerView.ViewHolder](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.ViewHolder)                                                                                                                                                                                                            | The ViewHolder being dragged by the user.                                                                                                                                                                                                                            |
| `dropTargets: (`[Mutable](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html)`)`[List](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html)`<`[RecyclerView.ViewHolder](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.ViewHolder)`!>` | The list of ViewHolder that are under the dragged View and candidate as a drop.                                                                                                                                                                                      |
| `curX: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)                                                                                                                                                                                                                                                                   | The updated left value of the dragged View after drag translations are applied. This value does not include margins added by[RecyclerView.ItemDecoration](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.ItemDecoration)s. |
| `curY: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)                                                                                                                                                                                                                                                                   | The updated top value of the dragged View after drag translations are applied. This value does not include margins added by[RecyclerView.ItemDecoration](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.ItemDecoration)s.  |

|                                                              Returns                                                              |
|-----------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------|
| [RecyclerView.ViewHolder](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.ViewHolder)`!` | A ViewHolder to whose position the dragged ViewHolder should be moved to. |

### clearView

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/recyclerview#1.0.0)  

```
fun clearView(
    recyclerView: RecyclerView,
    viewHolder: RecyclerView.ViewHolder
): Unit
```

Called by the ItemTouchHelper when the user interaction with an element is over and it also completed its animation.

This is a good place to clear all changes on the View that was done in[onSelectedChanged](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper.Callback#onSelectedChanged(androidx.recyclerview.widget.RecyclerView.ViewHolder,int)),[onChildDraw](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper.Callback#onChildDraw(android.graphics.Canvas,androidx.recyclerview.widget.RecyclerView,androidx.recyclerview.widget.RecyclerView.ViewHolder,float,float,int,boolean))or[onChildDrawOver](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper.Callback#onChildDrawOver(android.graphics.Canvas,androidx.recyclerview.widget.RecyclerView,androidx.recyclerview.widget.RecyclerView.ViewHolder,float,float,int,boolean)).  

|                                                                  Parameters                                                                  |
|----------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------|
| `recyclerView: `[RecyclerView](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView)                     | The RecyclerView which is controlled by the ItemTouchHelper. |
| `viewHolder: `[RecyclerView.ViewHolder](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.ViewHolder) | The View that was interacted by the user.                    |

### convertToAbsoluteDirection

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/recyclerview#1.0.0)  

```
fun convertToAbsoluteDirection(flags: Int, layoutDirection: Int): Int
```

Converts a given set of flags to absolution direction which means[START](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper#START())and[END](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper#END())are replaced with[LEFT](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper#LEFT())and[RIGHT](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper#RIGHT())depending on the layout direction.  

|                                           Parameters                                           |
|------------------------------------------------------------------------------------------------|-----------------------------------------------------------|
| `flags: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)           | The flag value that include any number of movement flags. |
| `layoutDirection: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | The layout direction of the RecyclerView.                 |

|                                   Returns                                   |
|-----------------------------------------------------------------------------|--------------------------------------------------------------|
| [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | Updated flags which includes only absolute direction values. |

### convertToRelativeDirection

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/recyclerview#1.0.0)  

```
java-static fun convertToRelativeDirection(flags: Int, layoutDirection: Int): Int
```

Replaces a movement direction with its relative version by taking layout direction into account.  

|                                           Parameters                                           |
|------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `flags: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)           | The flag value that include any number of movement flags.                                                                                                                                       |
| `layoutDirection: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | The layout direction of the View. Can be obtained from[getLayoutDirection](https://developer.android.com/reference/kotlin/androidx/core/view/ViewCompat#getLayoutDirection(android.view.View)). |

|                                   Returns                                   |
|-----------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | Updated flags which uses relative flags ([START](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper#START()),[END](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper#END())) instead of[LEFT](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper#LEFT()),[RIGHT](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper#RIGHT()). |

|                                                                                See also                                                                                |
|------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [convertToAbsoluteDirection](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper.Callback#convertToAbsoluteDirection(int,int)) |   |

### getAnimationDuration

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/recyclerview#1.0.0)  

```
fun getAnimationDuration(
    recyclerView: RecyclerView,
    animationType: Int,
    animateDx: Float,
    animateDy: Float
): Long
```

Called by the ItemTouchHelper when user action finished on a ViewHolder and now the View will be animated to its final position.

Default implementation uses ItemAnimator's duration values. If`animationType`is[ANIMATION_TYPE_DRAG](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper#ANIMATION_TYPE_DRAG()), it returns[getMoveDuration](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.ItemAnimator#getMoveDuration()), otherwise, it returns[getRemoveDuration](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.ItemAnimator#getRemoveDuration()). If RecyclerView does not have any[RecyclerView.ItemAnimator](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.ItemAnimator)attached, this method returns`DEFAULT_DRAG_ANIMATION_DURATION`or`DEFAULT_SWIPE_ANIMATION_DURATION`depending on the animation type.  

|                                                        Parameters                                                        |
|--------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `recyclerView: `[RecyclerView](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView) | The RecyclerView to which the ItemTouchHelper is attached to.                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| `animationType: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)                             | The type of animation. Is one of[ANIMATION_TYPE_DRAG](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper#ANIMATION_TYPE_DRAG()),[ANIMATION_TYPE_SWIPE_CANCEL](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper#ANIMATION_TYPE_SWIPE_CANCEL())or[ANIMATION_TYPE_SWIPE_SUCCESS](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper#ANIMATION_TYPE_SWIPE_SUCCESS()). |
| `animateDx: `[Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)                             | The horizontal distance that the animation will offset                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| `animateDy: `[Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)                             | The vertical distance that the animation will offset                                                                                                                                                                                                                                                                                                                                                                                                                                           |

|                                    Returns                                    |
|-------------------------------------------------------------------------------|--------------------------------|
| [Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html) | The duration for the animation |

### getBoundingBoxMargin

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/recyclerview#1.0.0)  

```
fun getBoundingBoxMargin(): Int
```

When finding views under a dragged view, by default, ItemTouchHelper searches for views that overlap with the dragged View. By overriding this method, you can extend or shrink the search box.  

|                                   Returns                                   |
|-----------------------------------------------------------------------------|------------------------------------------------------------------|
| [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | The extra margin to be added to the hit box of the dragged View. |

### getDefaultUIUtil

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/recyclerview#1.0.0)  

```
java-static fun getDefaultUIUtil(): ItemTouchUIUtil
```

Returns the[ItemTouchUIUtil](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchUIUtil)that is used by the[Callback](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper.Callback)class for visual changes on Views in response to user interactions.[ItemTouchUIUtil](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchUIUtil)has different implementations for different platform versions.

By default,[Callback](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper.Callback)applies these changes on[itemView](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.ViewHolder#itemView()).

For example, if you have a use case where you only want the text to move when user swipes over the view, you can do the following:  

```kotlin
    public void clearView(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder){
        getDefaultUIUtil().clearView(((ItemTouchViewHolder) viewHolder).textView);
    }
    public void onSelectedChanged(RecyclerView.ViewHolder viewHolder, int actionState) {
        if (viewHolder != null){
            getDefaultUIUtil().onSelected(((ItemTouchViewHolder) viewHolder).textView);
        }
    }
    public void onChildDraw(Canvas c, RecyclerView recyclerView,
            RecyclerView.ViewHolder viewHolder, float dX, float dY, int actionState,
            boolean isCurrentlyActive) {
        getDefaultUIUtil().onDraw(c, recyclerView,
                ((ItemTouchViewHolder) viewHolder).textView, dX, dY,
                actionState, isCurrentlyActive);
        return true;
    }
    public void onChildDrawOver(Canvas c, RecyclerView recyclerView,
            RecyclerView.ViewHolder viewHolder, float dX, float dY, int actionState,
            boolean isCurrentlyActive) {
        getDefaultUIUtil().onDrawOver(c, recyclerView,
                ((ItemTouchViewHolder) viewHolder).textView, dX, dY,
                actionState, isCurrentlyActive);
        return true;
    }
```  

|                                                    Returns                                                     |
|----------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [ItemTouchUIUtil](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchUIUtil) | The[ItemTouchUIUtil](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchUIUtil)instance that is used by the[Callback](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper.Callback) |

### getMoveThreshold

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/recyclerview#1.0.0)  

```
fun getMoveThreshold(viewHolder: RecyclerView.ViewHolder): Float
```

Returns the fraction that the user should move the View to be considered as it is dragged. After a view is moved this amount, ItemTouchHelper starts checking for Views below it for a possible drop.  

|                                                                  Parameters                                                                  |
|----------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------|
| `viewHolder: `[RecyclerView.ViewHolder](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.ViewHolder) | The ViewHolder that is being dragged. |

|                                     Returns                                     |
|---------------------------------------------------------------------------------|----------------------------------------------------------------------------------|
| [Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html) | A float value that denotes the fraction of the View size. Default value is .5f . |

### getMovementFlags

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/recyclerview#1.0.0)  

```
abstract fun getMovementFlags(
    recyclerView: RecyclerView,
    viewHolder: RecyclerView.ViewHolder
): Int
```

Should return a composite flag which defines the enabled move directions in each state (idle, swiping, dragging).

Instead of composing this flag manually, you can use[makeMovementFlags](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper.Callback#makeMovementFlags(int,int))or[makeFlag](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper.Callback#makeFlag(int,int)).

This flag is composed of 3 sets of 8 bits, where first 8 bits are for IDLE state, next 8 bits are for SWIPE state and third 8 bits are for DRAG state. Each 8 bit sections can be constructed by simply OR'ing direction flags defined in[ItemTouchHelper](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper).

For example, if you want it to allow swiping LEFT and RIGHT but only allow starting to swipe by swiping RIGHT, you can return:  

```kotlin
     makeFlag(ACTION_STATE_IDLE, RIGHT) | makeFlag(ACTION_STATE_SWIPE, LEFT | RIGHT);
```
This means, allow right movement while IDLE and allow right and left movement while swiping.  

|                                                                  Parameters                                                                  |
|----------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------|
| `recyclerView: `[RecyclerView](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView)                     | The RecyclerView to which ItemTouchHelper is attached.          |
| `viewHolder: `[RecyclerView.ViewHolder](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.ViewHolder) | The ViewHolder for which the movement information is necessary. |

|                                   Returns                                   |
|-----------------------------------------------------------------------------|------------------------------------------------------------------|
| [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | flags specifying which movements are allowed on this ViewHolder. |

|                                                                       See also                                                                       |
|------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [makeMovementFlags](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper.Callback#makeMovementFlags(int,int)) |   |
| [makeFlag](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper.Callback#makeFlag(int,int))                   |   |

### getSwipeEscapeVelocity

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/recyclerview#1.0.0)  

```
fun getSwipeEscapeVelocity(defaultValue: Float): Float
```

Defines the minimum velocity which will be considered as a swipe action by the user.

You can increase this value to make it harder to swipe or decrease it to make it easier. Keep in mind that ItemTouchHelper also checks the perpendicular velocity and makes sure current direction velocity is larger then the perpendicular one. Otherwise, user's movement is ambiguous. You can change the threshold by overriding[getSwipeVelocityThreshold](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper.Callback#getSwipeVelocityThreshold(float)).

The velocity is calculated in pixels per second.

The default framework value is passed as a parameter so that you can modify it with a multiplier.  

|                                           Parameters                                            |
|-------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------|
| `defaultValue: `[Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html) | The default value (in pixels per second) used by the ItemTouchHelper. |

|                                     Returns                                     |
|---------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------|
| [Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html) | The minimum swipe velocity. The default implementation returns the`defaultValue`parameter. |

|                                                                                             See also                                                                                              |
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [getSwipeVelocityThreshold](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper.Callback#getSwipeVelocityThreshold(float))                                |   |
| [getSwipeThreshold](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper.Callback#getSwipeThreshold(androidx.recyclerview.widget.RecyclerView.ViewHolder)) |   |

### getSwipeThreshold

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/recyclerview#1.0.0)  

```
fun getSwipeThreshold(viewHolder: RecyclerView.ViewHolder): Float
```

Returns the fraction that the user should move the View to be considered as swiped. The fraction is calculated with respect to RecyclerView's bounds.

Default value is .5f, which means, to swipe a View, user must move the View at least half of RecyclerView's width or height, depending on the swipe direction.  

|                                                                  Parameters                                                                  |
|----------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------|
| `viewHolder: `[RecyclerView.ViewHolder](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.ViewHolder) | The ViewHolder that is being dragged. |

|                                     Returns                                     |
|---------------------------------------------------------------------------------|----------------------------------------------------------------------------------|
| [Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html) | A float value that denotes the fraction of the View size. Default value is .5f . |

### getSwipeVelocityThreshold

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/recyclerview#1.0.0)  

```
fun getSwipeVelocityThreshold(defaultValue: Float): Float
```

Defines the maximum velocity ItemTouchHelper will ever calculate for pointer movements.

To consider a movement as swipe, ItemTouchHelper requires it to be larger than the perpendicular movement. If both directions reach to the max threshold, none of them will be considered as a swipe because it is usually an indication that user rather tried to scroll then swipe.

The velocity is calculated in pixels per second.

You can customize this behavior by changing this method. If you increase the value, it will be easier for the user to swipe diagonally and if you decrease the value, user will need to make a rather straight finger movement to trigger a swipe.  

|                                           Parameters                                            |
|-------------------------------------------------------------------------------------------------|----------------------------------------------------------------------|
| `defaultValue: `[Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html) | The default value(in pixels per second) used by the ItemTouchHelper. |

|                                     Returns                                     |
|---------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------|
| [Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html) | The velocity cap for pointer movements. The default implementation returns the`defaultValue`parameter. |

|                                                                           See also                                                                           |
|--------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [getSwipeEscapeVelocity](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper.Callback#getSwipeEscapeVelocity(float)) |   |

### interpolateOutOfBoundsScroll

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/recyclerview#1.0.0)  

```
fun interpolateOutOfBoundsScroll(
    recyclerView: RecyclerView,
    viewSize: Int,
    viewSizeOutOfBounds: Int,
    totalSize: Int,
    msSinceStartScroll: Long
): Int
```

Called by the ItemTouchHelper when user is dragging a view out of bounds.

You can override this method to decide how much RecyclerView should scroll in response to this action. Default implementation calculates a value based on the amount of View out of bounds and the time it spent there. The longer user keeps the View out of bounds, the faster the list will scroll. Similarly, the larger portion of the View is out of bounds, the faster the RecyclerView will scroll.  

|                                                        Parameters                                                        |
|--------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------|
| `recyclerView: `[RecyclerView](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView) | The RecyclerView instance to which ItemTouchHelper is attached to.                                                        |
| `viewSize: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)                                  | The total size of the View in scroll direction, excluding item decorations.                                               |
| `viewSizeOutOfBounds: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)                       | The total size of the View that is out of bounds. This value is negative if the View is dragged towards left or top edge. |
| `totalSize: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)                                 | The total size of RecyclerView in the scroll direction.                                                                   |
| `msSinceStartScroll: `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)                      | The time passed since View is kept out of bounds.                                                                         |

|                                   Returns                                   |
|-----------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | The amount that RecyclerView should scroll. Keep in mind that this value will be passed to[scrollBy](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView#scrollBy(int,int))method. |

### isItemViewSwipeEnabled

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/recyclerview#1.0.0)  

```
fun isItemViewSwipeEnabled(): Boolean
```

Returns whether ItemTouchHelper should start a swipe operation if a pointer is swiped over the View.

Default value returns true but you may want to disable this if you want to start swiping on a custom view touch using[startSwipe](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper#startSwipe(androidx.recyclerview.widget.RecyclerView.ViewHolder)).  

|                                       Returns                                       |
|-------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------|
| [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) | True if ItemTouchHelper should start swiping an item when user swipes a pointer over the View, false otherwise. Default value is`true`. |

|                                                                                  See also                                                                                  |
|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [startSwipe](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper#startSwipe(androidx.recyclerview.widget.RecyclerView.ViewHolder)) |   |

### isLongPressDragEnabled

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/recyclerview#1.0.0)  

```
fun isLongPressDragEnabled(): Boolean
```

Returns whether ItemTouchHelper should start a drag and drop operation if an item is long pressed.

Default value returns true but you may want to disable this if you want to start dragging on a custom view touch using[startDrag](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper#startDrag(androidx.recyclerview.widget.RecyclerView.ViewHolder)).  

|                                       Returns                                       |
|-------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------|
| [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) | True if ItemTouchHelper should start dragging an item when it is long pressed, false otherwise. Default value is`true`. |

|                                                                                 See also                                                                                 |
|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [startDrag](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper#startDrag(androidx.recyclerview.widget.RecyclerView.ViewHolder)) |   |

### makeFlag

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/recyclerview#1.0.0)  

```
java-static fun makeFlag(actionState: Int, directions: Int): Int
```

Shifts the given direction flags to the offset of the given action state.  

|                                         Parameters                                         |
|--------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `actionState: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | The action state you want to get flags in. Should be one of[ACTION_STATE_IDLE](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper#ACTION_STATE_IDLE()),[ACTION_STATE_SWIPE](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper#ACTION_STATE_SWIPE())or[ACTION_STATE_DRAG](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper#ACTION_STATE_DRAG()).                                                                                                                                                                                                                              |
| `directions: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)  | The direction flags. Can be composed from[UP](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper#UP()),[DOWN](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper#DOWN()),[RIGHT](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper#RIGHT()),[LEFT](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper#LEFT())[START](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper#START())and[END](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper#END()). |

|                                   Returns                                   |
|-----------------------------------------------------------------------------|-------------------------------------------------------------------------------|
| [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | And integer that represents the given directions in the provided actionState. |

### makeMovementFlags

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/recyclerview#1.0.0)  

```
java-static fun makeMovementFlags(dragFlags: Int, swipeFlags: Int): Int
```

Convenience method to create movement flags.

For instance, if you want to let your items be drag \&dropped vertically and swiped left to be dismissed, you can call this method with:`makeMovementFlags(UP | DOWN, LEFT);`  

|                                        Parameters                                         |
|-------------------------------------------------------------------------------------------|--------------------------------------------------|
| `dragFlags: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)  | The directions in which the item can be dragged. |
| `swipeFlags: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | The directions in which the item can be swiped.  |

|                                   Returns                                   |
|-----------------------------------------------------------------------------|----------------------------------------------------------------|
| [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | Returns an integer composed of the given drag and swipe flags. |

### onChildDraw

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/recyclerview#1.0.0)  

```
fun onChildDraw(
    c: Canvas,
    recyclerView: RecyclerView,
    viewHolder: RecyclerView.ViewHolder,
    dX: Float,
    dY: Float,
    actionState: Int,
    isCurrentlyActive: Boolean
): Unit
```

Called by ItemTouchHelper on RecyclerView's onDraw callback.

If you would like to customize how your View's respond to user interactions, this is a good place to override.

Default implementation translates the child by the given`dX`,`dY`. ItemTouchHelper also takes care of drawing the child after other children if it is being dragged. This is done using child re-ordering mechanism. On platforms prior to L, this is achieved via[getChildDrawingOrder](https://developer.android.com/reference/android/view/ViewGroup.html#getChildDrawingOrder(int, int))and on L and after, it changes View's elevation value to be greater than all other children.)  

|                                                                  Parameters                                                                  |
|----------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `c: `[Canvas](https://developer.android.com/reference/android/graphics/Canvas.html)                                                          | The canvas which RecyclerView is drawing its children                                                                                                                                                                                                                                                                       |
| `recyclerView: `[RecyclerView](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView)                     | The RecyclerView to which ItemTouchHelper is attached to                                                                                                                                                                                                                                                                    |
| `viewHolder: `[RecyclerView.ViewHolder](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.ViewHolder) | The ViewHolder which is being interacted by the User or it was interacted and simply animating to its original position                                                                                                                                                                                                     |
| `dX: `[Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)                                                        | The amount of horizontal displacement caused by user's action                                                                                                                                                                                                                                                               |
| `dY: `[Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)                                                        | The amount of vertical displacement caused by user's action                                                                                                                                                                                                                                                                 |
| `actionState: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)                                                   | The type of interaction on the View. Is either[ACTION_STATE_DRAG](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper#ACTION_STATE_DRAG())or[ACTION_STATE_SWIPE](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper#ACTION_STATE_SWIPE()). |
| `isCurrentlyActive: `[Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)                                     | True if this view is currently being controlled by the user or false it is simply animating back to its original state.                                                                                                                                                                                                     |

|                                                                                                                                        See also                                                                                                                                         |
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [onChildDrawOver](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper.Callback#onChildDrawOver(android.graphics.Canvas,androidx.recyclerview.widget.RecyclerView,androidx.recyclerview.widget.RecyclerView.ViewHolder,float,float,int,boolean)) |   |

### onChildDrawOver

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/recyclerview#1.0.0)  

```
fun onChildDrawOver(
    c: Canvas,
    recyclerView: RecyclerView,
    viewHolder: RecyclerView.ViewHolder!,
    dX: Float,
    dY: Float,
    actionState: Int,
    isCurrentlyActive: Boolean
): Unit
```

Called by ItemTouchHelper on RecyclerView's onDraw callback.

If you would like to customize how your View's respond to user interactions, this is a good place to override.

Default implementation translates the child by the given`dX`,`dY`. ItemTouchHelper also takes care of drawing the child after other children if it is being dragged. This is done using child re-ordering mechanism. On platforms prior to L, this is achieved via[getChildDrawingOrder](https://developer.android.com/reference/android/view/ViewGroup.html#getChildDrawingOrder(int, int))and on L and after, it changes View's elevation value to be greater than all other children.)  

|                                                                   Parameters                                                                    |
|-------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `c: `[Canvas](https://developer.android.com/reference/android/graphics/Canvas.html)                                                             | The canvas which RecyclerView is drawing its children                                                                                                                                                                                                                                                                       |
| `recyclerView: `[RecyclerView](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView)                        | The RecyclerView to which ItemTouchHelper is attached to                                                                                                                                                                                                                                                                    |
| `viewHolder: `[RecyclerView.ViewHolder](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.ViewHolder)`!` | The ViewHolder which is being interacted by the User or it was interacted and simply animating to its original position                                                                                                                                                                                                     |
| `dX: `[Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)                                                           | The amount of horizontal displacement caused by user's action                                                                                                                                                                                                                                                               |
| `dY: `[Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)                                                           | The amount of vertical displacement caused by user's action                                                                                                                                                                                                                                                                 |
| `actionState: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)                                                      | The type of interaction on the View. Is either[ACTION_STATE_DRAG](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper#ACTION_STATE_DRAG())or[ACTION_STATE_SWIPE](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper#ACTION_STATE_SWIPE()). |
| `isCurrentlyActive: `[Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)                                        | True if this view is currently being controlled by the user or false it is simply animating back to its original state.                                                                                                                                                                                                     |

|                                                                                                                                        See also                                                                                                                                         |
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [onChildDrawOver](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper.Callback#onChildDrawOver(android.graphics.Canvas,androidx.recyclerview.widget.RecyclerView,androidx.recyclerview.widget.RecyclerView.ViewHolder,float,float,int,boolean)) |   |

### onMove

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/recyclerview#1.0.0)  

```
abstract fun onMove(
    recyclerView: RecyclerView,
    viewHolder: RecyclerView.ViewHolder,
    target: RecyclerView.ViewHolder
): Boolean
```

Called when ItemTouchHelper wants to move the dragged item from its old position to the new position.

If this method returns true, ItemTouchHelper assumes`viewHolder`has been moved to the adapter position of`target`ViewHolder ([ViewHolder#getAdapterPositionInRecyclerView()](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.ViewHolder#getAbsoluteAdapterPosition())).

If you don't support drag \&drop, this method will never be called.  

|                                                                  Parameters                                                                  |
|----------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------|
| `recyclerView: `[RecyclerView](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView)                     | The RecyclerView to which ItemTouchHelper is attached to.             |
| `viewHolder: `[RecyclerView.ViewHolder](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.ViewHolder) | The ViewHolder which is being dragged by the user.                    |
| `target: `[RecyclerView.ViewHolder](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.ViewHolder)     | The ViewHolder over which the currently active item is being dragged. |

|                                       Returns                                       |
|-------------------------------------------------------------------------------------|---------------------------------------------------------------------------|
| [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) | True if the`viewHolder`has been moved to the adapter position of`target`. |

|                                                                                                                                           See also                                                                                                                                           |
|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [onMoved](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper.Callback#onMoved(androidx.recyclerview.widget.RecyclerView,androidx.recyclerview.widget.RecyclerView.ViewHolder,int,androidx.recyclerview.widget.RecyclerView.ViewHolder,int,int,int)) |   |

### onMoved

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/recyclerview#1.0.0)  

```
fun onMoved(
    recyclerView: RecyclerView,
    viewHolder: RecyclerView.ViewHolder,
    fromPos: Int,
    target: RecyclerView.ViewHolder,
    toPos: Int,
    x: Int,
    y: Int
): Unit
```

Called when[onMove](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper.Callback#onMove(androidx.recyclerview.widget.RecyclerView,androidx.recyclerview.widget.RecyclerView.ViewHolder,androidx.recyclerview.widget.RecyclerView.ViewHolder))returns true.

ItemTouchHelper does not create an extra Bitmap or View while dragging, instead, it modifies the existing View. Because of this reason, it is important that the View is still part of the layout after it is moved. This may not work as intended when swapped Views are close to RecyclerView bounds or there are gaps between them (e.g. other Views which were not eligible for dropping over).

This method is responsible to give necessary hint to the LayoutManager so that it will keep the View in visible area. For example, for LinearLayoutManager, this is as simple as calling[scrollToPositionWithOffset](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/LinearLayoutManager#scrollToPositionWithOffset(int,int)). Default implementation calls[scrollToPosition](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView#scrollToPosition(int))if the View's new position is likely to be out of bounds.

It is important to ensure the ViewHolder will stay visible as otherwise, it might be removed by the LayoutManager if the move causes the View to go out of bounds. In that case, drag will end prematurely.  

|                                                                  Parameters                                                                  |
|----------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `recyclerView: `[RecyclerView](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView)                     | The RecyclerView controlled by the ItemTouchHelper.                                                                                                                                                                                                                  |
| `viewHolder: `[RecyclerView.ViewHolder](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.ViewHolder) | The ViewHolder under user's control.                                                                                                                                                                                                                                 |
| `fromPos: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)                                                       | The previous adapter position of the dragged item (before it was moved).                                                                                                                                                                                             |
| `target: `[RecyclerView.ViewHolder](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.ViewHolder)     | The ViewHolder on which the currently active item has been dropped.                                                                                                                                                                                                  |
| `toPos: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)                                                         | The new adapter position of the dragged item.                                                                                                                                                                                                                        |
| `x: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)                                                             | The updated left value of the dragged View after drag translations are applied. This value does not include margins added by[RecyclerView.ItemDecoration](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.ItemDecoration)s. |
| `y: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)                                                             | The updated top value of the dragged View after drag translations are applied. This value does not include margins added by[RecyclerView.ItemDecoration](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.ItemDecoration)s.  |

### onSelectedChanged

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/recyclerview#1.0.0)  

```
fun onSelectedChanged(viewHolder: RecyclerView.ViewHolder?, actionState: Int): Unit
```

Called when the ViewHolder swiped or dragged by the ItemTouchHelper is changed.
If you override this method, you should call super.  

|                                                                   Parameters                                                                    |
|-------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `viewHolder: `[RecyclerView.ViewHolder](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.ViewHolder)`?` | The new ViewHolder that is being swiped or dragged. Might be null if it is cleared.                                                                                                                                                                                                                                                                                                                                      |
| `actionState: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)                                                      | One of[ACTION_STATE_IDLE](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper#ACTION_STATE_IDLE()),[ACTION_STATE_SWIPE](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper#ACTION_STATE_SWIPE())or[ACTION_STATE_DRAG](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper#ACTION_STATE_DRAG()). |

|                                                                                                          See also                                                                                                           |
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [clearView](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper.Callback#clearView(androidx.recyclerview.widget.RecyclerView,androidx.recyclerview.widget.RecyclerView.ViewHolder)) |   |

### onSwiped

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/recyclerview#1.0.0)  

```
abstract fun onSwiped(viewHolder: RecyclerView.ViewHolder, direction: Int): Unit
```

Called when a ViewHolder is swiped by the user.

If you are returning relative directions ([START](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper#START()),[END](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper#END())) from the[getMovementFlags](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper.Callback#getMovementFlags(androidx.recyclerview.widget.RecyclerView,androidx.recyclerview.widget.RecyclerView.ViewHolder))method, this method will also use relative directions. Otherwise, it will use absolute directions.

If you don't support swiping, this method will never be called.

ItemTouchHelper will keep a reference to the View until it is detached from RecyclerView. As soon as it is detached, ItemTouchHelper will call[clearView](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper.Callback#clearView(androidx.recyclerview.widget.RecyclerView,androidx.recyclerview.widget.RecyclerView.ViewHolder)).  

|                                                                  Parameters                                                                  |
|----------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `viewHolder: `[RecyclerView.ViewHolder](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.ViewHolder) | The ViewHolder which has been swiped by the user.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| `direction: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)                                                     | The direction to which the ViewHolder is swiped. It is one of[UP](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper#UP()),[DOWN](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper#DOWN()),[LEFT](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper#LEFT())or[RIGHT](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper#RIGHT()). If your[getMovementFlags](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper.Callback#getMovementFlags(androidx.recyclerview.widget.RecyclerView,androidx.recyclerview.widget.RecyclerView.ViewHolder))method returned relative flags instead of[LEFT](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper#LEFT())/[RIGHT](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper#RIGHT()); \`direction\` will be relative as well. ([START](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper#START())or[END](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper#END())). |