dispatchDraw gets invoked when all the child views are about to be drawn. By overriding this method, the hover cell (BitmapDrawable) can be drawn over the listview’s items whenever the listview is redrawn.

This method determines whether the hover cell has been shifted far enough to invoke a cell swap. If so, then the respective cell swap candidate is determined and the data set is changed. Upon posting a notification of the data set change, a layout is invoked to place the cells in the right place. Using a ViewTreeObserver and a corresponding OnPreDrawListener, we can offset the cell being swapped to where it previously was and then animate it to its new position.

This method is in charge of determining if the hover cell is above or below the bounds of the listview. If so, the listview does an appropriate upward or downward smooth scroll so as to reveal new items.

This method is in charge of invoking 1 of 2 actions. Firstly, if the listview is in a state of scrolling invoked by the hover cell being outside the bounds of the listview, then this scrolling event is continued. Secondly, if the hover cell has already been released, this invokes the animation for the hover cell to return to its correct position after the listview has entered an idle scroll state.

Stores a reference to the views above and below the item currently corresponding to the hover cell. It is important to note that if this item is either at the top or bottom of the list, mAboveItemId or mBelowItemId may be invalid.