Skip to content
Snippets Groups Projects
Commit 3027e6fa authored by Nicolas Pomepuy's avatar Nicolas Pomepuy
Browse files

Fix the move operation on a LiveDataset

parent 67fb3f3e
No related branches found
No related tags found
1 merge request!517Fix the move operation on a LiveDataset
Pipeline #15141 passed with stage
in 5 minutes and 19 seconds
......@@ -72,11 +72,18 @@ class LiveDataset<T> : MutableLiveData<MutableList<T>>() {
value = internalList.apply { removeAt(position) }
}
fun move(from: Int, to: Int) {
value = internalList.apply { move(from, to) }
fun move(item: T, newIndex: Int) {
move(internalList.indexOf(item), newIndex)
}
fun move (item: T, position: Int) {
value = internalList.apply { move(item, position) }
fun move(from: Int, to: Int) {
value = internalList.apply {
val item = this[from]
removeAt(from)
if (from > to)
add(to, item)
else
add(to - 1, item)
}
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment