BookSource.kt:移除添加分组支持多个;修复在没有分组的情况下无法添加分组的bug

pull/1588/head
Xwite 3 years ago
parent 5a437822f1
commit 8ea5b7d6bc
  1. 9
      app/src/main/java/io/legado/app/data/entities/BookSource.kt

@ -118,17 +118,18 @@ data class BookSource(
fun getContentRule() = ruleContent ?: ContentRule() fun getContentRule() = ruleContent ?: ContentRule()
fun addGroup(group: String): BookSource { fun addGroup(groups: String): BookSource {
bookSourceGroup?.splitNotBlank(AppPattern.splitGroupRegex)?.toHashSet()?.let { bookSourceGroup?.splitNotBlank(AppPattern.splitGroupRegex)?.toHashSet()?.let {
it.add(group) it.addAll(groups.splitNotBlank(AppPattern.splitGroupRegex))
bookSourceGroup = TextUtils.join(",", it) bookSourceGroup = TextUtils.join(",", it)
} }
if (bookSourceGroup.isNullOrBlank()) bookSourceGroup = groups
return this return this
} }
fun removeGroup(group: String): BookSource { fun removeGroup(groups: String): BookSource {
bookSourceGroup?.splitNotBlank(AppPattern.splitGroupRegex)?.toHashSet()?.let { bookSourceGroup?.splitNotBlank(AppPattern.splitGroupRegex)?.toHashSet()?.let {
it.remove(group) it.removeAll(groups.splitNotBlank(AppPattern.splitGroupRegex))
bookSourceGroup = TextUtils.join(",", it) bookSourceGroup = TextUtils.join(",", it)
} }
return this return this

Loading…
Cancel
Save