Код: Выделить всё
list.observe(viewLifecycleOwner, { updatedList ->
listAdapter.submitList(updatedList)
})
Код: Выделить всё
override fun onMove(
recyclerView: RecyclerView,
viewHolder: RecyclerView.ViewHolder,
target: RecyclerView.ViewHolder
): Boolean {
val from = viewHolder.bindingAdapterPosition
val to = target.bindingAdapterPosition
val list = itemListAdapter.currentList.toMutableList()
Collections.swap(list, from, to)
// does not work for ListAdapter
// itemListAdapter.notifyItemMoved(from, to)
itemListAdapter.submitList(list)
return false
}
< img alt="Запись экрана" src="https://i.sstatic.net/UftHG.gif" />
В чем может быть причина? Как лучше всего реализовать функцию перетаскивания для моего RecyclerView, который использует ListAdapter?
Подробнее здесь: https://stackoverflow.com/questions/684 ... h-diffutil