|
|
@ -94,16 +94,8 @@ class BookSourceViewModel(application: Application) : BaseViewModel(application) |
|
|
|
execute { |
|
|
|
execute { |
|
|
|
val list = arrayListOf<BookSource>() |
|
|
|
val list = arrayListOf<BookSource>() |
|
|
|
sources.forEach { source -> |
|
|
|
sources.forEach { source -> |
|
|
|
val newGroupList = arrayListOf<String>() |
|
|
|
source.addGroup(groups) |
|
|
|
source.bookSourceGroup?.splitNotBlank(AppPattern.splitGroupRegex)?.forEach { |
|
|
|
list.add(source) |
|
|
|
newGroupList.add(it) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
groups.splitNotBlank(",", ";", ",").forEach { |
|
|
|
|
|
|
|
newGroupList.add(it) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
val lh = LinkedHashSet(newGroupList) |
|
|
|
|
|
|
|
val newGroup = ArrayList(lh).joinToString(separator = ",") |
|
|
|
|
|
|
|
list.add(source.copy(bookSourceGroup = newGroup)) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
appDb.bookSourceDao.update(*list.toTypedArray()) |
|
|
|
appDb.bookSourceDao.update(*list.toTypedArray()) |
|
|
|
} |
|
|
|
} |
|
|
@ -113,16 +105,8 @@ class BookSourceViewModel(application: Application) : BaseViewModel(application) |
|
|
|
execute { |
|
|
|
execute { |
|
|
|
val list = arrayListOf<BookSource>() |
|
|
|
val list = arrayListOf<BookSource>() |
|
|
|
sources.forEach { source -> |
|
|
|
sources.forEach { source -> |
|
|
|
val newGroupList = arrayListOf<String>() |
|
|
|
source.removeGroup(groups) |
|
|
|
source.bookSourceGroup?.splitNotBlank(AppPattern.splitGroupRegex)?.forEach { |
|
|
|
list.add(source) |
|
|
|
newGroupList.add(it) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
groups.splitNotBlank(",", ";", ",").forEach { |
|
|
|
|
|
|
|
newGroupList.remove(it) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
val lh = LinkedHashSet(newGroupList) |
|
|
|
|
|
|
|
val newGroup = ArrayList(lh).joinToString(separator = ",") |
|
|
|
|
|
|
|
list.add(source.copy(bookSourceGroup = newGroup)) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
appDb.bookSourceDao.update(*list.toTypedArray()) |
|
|
|
appDb.bookSourceDao.update(*list.toTypedArray()) |
|
|
|
} |
|
|
|
} |
|
|
|