|
|
@ -125,11 +125,19 @@ class ArrangeBookAdapter(context: Context, val callBack: CallBack) : |
|
|
|
private var isMoved = false |
|
|
|
private var isMoved = false |
|
|
|
|
|
|
|
|
|
|
|
override fun onMove(srcPosition: Int, targetPosition: Int): Boolean { |
|
|
|
override fun onMove(srcPosition: Int, targetPosition: Int): Boolean { |
|
|
|
|
|
|
|
val srcItem = getItem(srcPosition) |
|
|
|
|
|
|
|
val targetItem = getItem(targetPosition) |
|
|
|
Collections.swap(getItems(), srcPosition, targetPosition) |
|
|
|
Collections.swap(getItems(), srcPosition, targetPosition) |
|
|
|
notifyItemMoved(srcPosition, targetPosition) |
|
|
|
notifyItemMoved(srcPosition, targetPosition) |
|
|
|
if (getItem(srcPosition)?.order == getItem(targetPosition)?.order) { |
|
|
|
if (srcItem != null && targetItem != null) { |
|
|
|
for ((index, item) in getItems().withIndex()) { |
|
|
|
if (srcItem.order == targetItem.order) { |
|
|
|
item.order = index + 1 |
|
|
|
for ((index, item) in getItems().withIndex()) { |
|
|
|
|
|
|
|
item.order = index + 1 |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
val pos = srcItem.order |
|
|
|
|
|
|
|
srcItem.order = targetItem.order |
|
|
|
|
|
|
|
targetItem.order = pos |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
isMoved = true |
|
|
|
isMoved = true |
|
|
|