app / sg.edu.ntu.scse.cz2006.gymbuddies.util / SwipeDeleteCallback

SwipeDeleteCallback

class SwipeDeleteCallback : SimpleCallback

Helper class for handling RecyclerView swipe capabilities. Calls the callback when swiped For sg.edu.ntu.scse.cz2006.gymbuddies.util in Gym Buddies!

Author
Kenneth Soh

Since
2019-10-03

Types

ISwipeCallback

Interface that other classes implement to handle swipe callback

interface ISwipeCallback

Constructors

<init>

Generates a callback that will be invoked when a user swipes on the selected recycler view

SwipeDeleteCallback(callback: ISwipeCallback, context: Context, swipeDirection: Int = ItemTouchHelper.LEFT, removeIcon: Int? = null)

Properties

callback

ISwipeCallback The callback used when a valid swipe is detected

var callback: ISwipeCallback

context

Context Application Context

var context: Context

deleteBackground

Int The background color for delete. Set to Color.RED

val deleteBackground: Int

deleteBitmap

Bitmap The delete bitmap to draw. Can pass in your own through removeIcon

val deleteBitmap: Bitmap

iconColor

Paint The icon color, set to Color.WHITE

val iconColor: Paint

removeIcon

Int? A custom delete icon if you wish to implement. Requires a drawable id

var removeIcon: Int?

swipeDirection

Int The direction to swipe. Can be ItemTouchHelper.LEFT, ItemTouchHelper.RIGHT or SWIPE_ANY

var swipeDirection: Int

Functions

onChildDraw

Called by ItemTouchHelper on RecyclerView's onDraw callback.

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

onMove

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

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

onSwiped

Called when a ViewHolder is swiped by the user.

fun onSwiped(viewHolder: ViewHolder, direction: Int): Unit

Companion Object Properties

SWIPE_ANY

Allows swiping from any direction

const val SWIPE_ANY: Int