in app/src/main/java/com/example/android/trackr/ui/tasks/DragAndDropActionsHelper.kt [35:61]
fun execute(position: Int): List<DragAndDropActionInfo> {
try {
previousHeaderPosition = headerPositions.first()
headerPositions.forEach {
if (it < position) {
previousHeaderPosition = it
}
}
nextHeaderPosition = headerPositions.last()
if (nextHeaderPosition < position) { // there is no next header
nextHeaderPosition = items.size
} else {
headerPositions.asReversed().forEach {
if (it > position) {
nextHeaderPosition = it
}
}
}
return obtainDragAndDropActionInfo(position)
} catch (e: NoSuchElementException) {
e.printStackTrace()
// We get here if there are no headers. In that case, there are no actions associated
// with drag and drop.
return emptyList()
}
}