|
|
@ -9,8 +9,13 @@ class GroupViewModel(application: Application) : BaseViewModel(application) { |
|
|
|
|
|
|
|
|
|
|
|
fun addGroup(groupName: String) { |
|
|
|
fun addGroup(groupName: String) { |
|
|
|
execute { |
|
|
|
execute { |
|
|
|
|
|
|
|
var id = 1 |
|
|
|
|
|
|
|
val idsCount = App.db.bookGroupDao().idsCount |
|
|
|
|
|
|
|
while (id and idsCount != 0) { |
|
|
|
|
|
|
|
id *= 2 |
|
|
|
|
|
|
|
} |
|
|
|
val bookGroup = BookGroup( |
|
|
|
val bookGroup = BookGroup( |
|
|
|
groupId = App.db.bookGroupDao().maxId.plus(1), |
|
|
|
groupId = id, |
|
|
|
groupName = groupName, |
|
|
|
groupName = groupName, |
|
|
|
order = App.db.bookGroupDao().maxOrder.plus(1) |
|
|
|
order = App.db.bookGroupDao().maxOrder.plus(1) |
|
|
|
) |
|
|
|
) |
|
|
|