|
|
@ -29,16 +29,10 @@ class GroupViewModel(application: Application) : BaseViewModel(application) { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fun delGroup(vararg bookGroup: BookGroup, finally: () -> Unit) { |
|
|
|
fun delGroup(bookGroup: BookGroup, finally: () -> Unit) { |
|
|
|
execute { |
|
|
|
execute { |
|
|
|
appDb.bookGroupDao.delete(*bookGroup) |
|
|
|
appDb.bookGroupDao.delete(bookGroup) |
|
|
|
bookGroup.forEach { group -> |
|
|
|
appDb.bookDao.removeGroup(bookGroup.groupId) |
|
|
|
val books = appDb.bookDao.getBooksByGroup(group.groupId) |
|
|
|
|
|
|
|
books.forEach { |
|
|
|
|
|
|
|
it.group = it.group - group.groupId |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
appDb.bookDao.update(*books.toTypedArray()) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}.onFinally { |
|
|
|
}.onFinally { |
|
|
|
finally() |
|
|
|
finally() |
|
|
|
} |
|
|
|
} |
|
|
|