|
|
@ -127,19 +127,26 @@ class ArrangeBookAdapter(context: Context, val callBack: CallBack) : |
|
|
|
override fun onMove(srcPosition: Int, targetPosition: Int): Boolean { |
|
|
|
override fun onMove(srcPosition: Int, targetPosition: Int): Boolean { |
|
|
|
Collections.swap(getItems(), srcPosition, targetPosition) |
|
|
|
Collections.swap(getItems(), srcPosition, targetPosition) |
|
|
|
notifyItemMoved(srcPosition, targetPosition) |
|
|
|
notifyItemMoved(srcPosition, targetPosition) |
|
|
|
|
|
|
|
if (getItem(srcPosition)?.order == getItem(targetPosition)?.order) { |
|
|
|
|
|
|
|
for ((index, item) in getItems().withIndex()) { |
|
|
|
|
|
|
|
item.order = index + 1 |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
isMoved = true |
|
|
|
isMoved = true |
|
|
|
return true |
|
|
|
return true |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override fun onClearView(recyclerView: RecyclerView, viewHolder: RecyclerView.ViewHolder) { |
|
|
|
override fun onClearView(recyclerView: RecyclerView, viewHolder: RecyclerView.ViewHolder) { |
|
|
|
if (isMoved) { |
|
|
|
if (isMoved) { |
|
|
|
|
|
|
|
callBack.updateBook(*getItems().toTypedArray()) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
isMoved = false |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
interface CallBack { |
|
|
|
interface CallBack { |
|
|
|
val groupList: List<BookGroup> |
|
|
|
val groupList: List<BookGroup> |
|
|
|
fun upSelectCount() |
|
|
|
fun upSelectCount() |
|
|
|
|
|
|
|
fun updateBook(vararg book: Book) |
|
|
|
fun deleteBook(book: Book) |
|
|
|
fun deleteBook(book: Book) |
|
|
|
fun selectGroup(groupId: Int, requestCode: Int) |
|
|
|
fun selectGroup(groupId: Int, requestCode: Int) |
|
|
|
} |
|
|
|
} |
|
|
|