From e00907ba334777fea84a569a47990c5c30b7050c Mon Sep 17 00:00:00 2001 From: gedoor Date: Sat, 22 Jan 2022 22:03:17 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/io/legado/app/data/entities/BookSource.kt | 6 ++++-- .../app/ui/book/source/manage/BookSourceViewModel.kt | 7 ++----- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/io/legado/app/data/entities/BookSource.kt b/app/src/main/java/io/legado/app/data/entities/BookSource.kt index db4fedb1f..782eec76b 100644 --- a/app/src/main/java/io/legado/app/data/entities/BookSource.kt +++ b/app/src/main/java/io/legado/app/data/entities/BookSource.kt @@ -118,18 +118,20 @@ data class BookSource( fun getContentRule() = ruleContent ?: ContentRule() - fun addGroup(group: String) { + fun addGroup(group: String): BookSource { bookSourceGroup?.splitNotBlank(AppPattern.splitGroupRegex)?.toHashSet()?.let { it.add(group) bookSourceGroup = TextUtils.join(",", it) } + return this } - fun removeGroup(group: String) { + fun removeGroup(group: String): BookSource { bookSourceGroup?.splitNotBlank(AppPattern.splitGroupRegex)?.toHashSet()?.let { it.remove(group) bookSourceGroup = TextUtils.join(",", it) } + return this } fun equal(source: BookSource) = diff --git a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceViewModel.kt b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceViewModel.kt index ea3c1c4dc..cf1c8535c 100644 --- a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceViewModel.kt @@ -3,7 +3,6 @@ package io.legado.app.ui.book.source.manage import android.app.Application import android.text.TextUtils import io.legado.app.base.BaseViewModel -import io.legado.app.constant.AppPattern import io.legado.app.data.appDb import io.legado.app.data.entities.BookSource import io.legado.app.utils.* @@ -94,8 +93,7 @@ class BookSourceViewModel(application: Application) : BaseViewModel(application) execute { val list = arrayListOf() sources.forEach { source -> - source.addGroup(groups) - list.add(source) + list.add(source.copy().addGroup(groups)) } appDb.bookSourceDao.update(*list.toTypedArray()) } @@ -105,8 +103,7 @@ class BookSourceViewModel(application: Application) : BaseViewModel(application) execute { val list = arrayListOf() sources.forEach { source -> - source.removeGroup(groups) - list.add(source) + list.add(source.copy().removeGroup(groups)) } appDb.bookSourceDao.update(*list.toTypedArray()) } From 2cb23a2ef4d965d7a3a1cbf982b5c6034b3a85eb Mon Sep 17 00:00:00 2001 From: gedoor Date: Sun, 23 Jan 2022 08:07:28 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/ui/book/source/manage/BookSourceViewModel.kt | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceViewModel.kt b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceViewModel.kt index cf1c8535c..68b739f20 100644 --- a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceViewModel.kt @@ -91,21 +91,19 @@ class BookSourceViewModel(application: Application) : BaseViewModel(application) fun selectionAddToGroups(sources: List, groups: String) { execute { - val list = arrayListOf() sources.forEach { source -> - list.add(source.copy().addGroup(groups)) + source.addGroup(groups) } - appDb.bookSourceDao.update(*list.toTypedArray()) + appDb.bookSourceDao.update(*sources.toTypedArray()) } } fun selectionRemoveFromGroups(sources: List, groups: String) { execute { - val list = arrayListOf() sources.forEach { source -> - list.add(source.copy().removeGroup(groups)) + source.removeGroup(groups) } - appDb.bookSourceDao.update(*list.toTypedArray()) + appDb.bookSourceDao.update(*sources.toTypedArray()) } } From ec90372fac33fe0d5f00b22d40c9e2ce867708f9 Mon Sep 17 00:00:00 2001 From: gedoor Date: Sun, 23 Jan 2022 13:27:49 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/web/rssSource/index.html | 7 ++++++- app/src/main/assets/web/rssSource/index.js | 7 ++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/app/src/main/assets/web/rssSource/index.html b/app/src/main/assets/web/rssSource/index.html index 472c511c2..8e5d9161e 100644 --- a/app/src/main/assets/web/rssSource/index.html +++ b/app/src/main/assets/web/rssSource/index.html @@ -107,7 +107,7 @@ placeholder="是否加载url (启用: true 关闭: false (可选,默认true))">
-
启用JS :
+
启用JS :
@@ -148,6 +148,11 @@ +
+
单URL :
+ +