From 515120c3a3de07390b03749afb9e8e21476d1fcb Mon Sep 17 00:00:00 2001 From: Xwite <1797350009@qq.com> Date: Sat, 29 Jan 2022 10:24:12 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=90=8C=E6=97=B6=E6=A0=A1?= =?UTF-8?q?=E9=AA=8C=E6=90=9C=E7=B4=A2=E5=92=8C=E5=8F=91=E7=8E=B0=E7=9A=84?= =?UTF-8?q?=E6=8F=90=E7=A4=BA=E9=80=BB=E8=BE=91=20=E7=BA=AF=E5=8F=91?= =?UTF-8?q?=E7=8E=B0=E6=BA=90(=E6=90=9C=E7=B4=A2=E9=93=BE=E6=8E=A5?= =?UTF-8?q?=E4=B8=BA=E7=A9=BA)=20=E8=B7=B3=E8=BF=87=E6=A0=A1=E9=AA=8C?= =?UTF-8?q?=E6=90=9C=E7=B4=A2=20=E6=90=9C=E7=B4=A2=E9=93=BE=E6=8E=A5?= =?UTF-8?q?=E4=B8=8D=E4=B8=BA=E7=A9=BA=20=E6=90=9C=E7=B4=A2=E5=A4=B1?= =?UTF-8?q?=E6=95=88=E6=97=B6=E6=9C=80=E7=BB=88=E6=A0=A1=E9=AA=8C=E6=8F=90?= =?UTF-8?q?=E7=A4=BA=E5=A4=B1=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/data/entities/BookSource.kt | 7 +++++++ .../java/io/legado/app/service/CheckSourceService.kt | 10 +++++++--- 2 files changed, 14 insertions(+), 3 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 782eec76b..247dfc379 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 @@ -134,6 +134,13 @@ data class BookSource( return this } + fun hasGroup(group: String): Boolean { + bookSourceGroup?.splitNotBlank(AppPattern.splitGroupRegex)?.toHashSet()?.let { + return if (it.indexOf(group) != -1) true else false + } + return false + } + fun equal(source: BookSource) = equal(bookSourceName, source.bookSourceName) && equal(bookSourceUrl, source.bookSourceUrl) diff --git a/app/src/main/java/io/legado/app/service/CheckSourceService.kt b/app/src/main/java/io/legado/app/service/CheckSourceService.kt index 45c40a395..a7c057b43 100644 --- a/app/src/main/java/io/legado/app/service/CheckSourceService.kt +++ b/app/src/main/java/io/legado/app/service/CheckSourceService.kt @@ -121,8 +121,8 @@ class CheckSourceService : BaseService() { searchWord = it } } - //校验搜索 - if (CheckSource.checkSearch) { + //校验搜索 用户设置校验搜索 并且 搜索链接不为空 + if (CheckSource.checkSearch && !source.searchUrl.isNullOrBlank()) { books = WebBook.searchBookAwait(this, source, searchWord) if (books.isEmpty()) source.addGroup("搜索失效") else source.removeGroup("搜索失效") } @@ -187,7 +187,11 @@ class CheckSourceService : BaseService() { ?.filterNot { it.startsWith("Error: ") }?.joinToString("\n") - Debug.updateFinalMessage(source.bookSourceUrl, "成功") + if (source.hasGroup("搜索失效")) { + Debug.updateFinalMessage(source.bookSourceUrl, "失败") + } else { + Debug.updateFinalMessage(source.bookSourceUrl, "成功") + } }.onFinally(searchCoroutine) { source.respondTime = Debug.getRespondTime(source.bookSourceUrl) appDb.bookSourceDao.update(source)