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 9be459696..62026ef7b 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 @@ -1,6 +1,7 @@ package io.legado.app.data.entities import android.os.Parcelable +import android.text.TextUtils import androidx.room.* import io.legado.app.App import io.legado.app.constant.AppConst @@ -8,10 +9,7 @@ import io.legado.app.constant.AppConst.userAgent import io.legado.app.constant.BookType import io.legado.app.data.entities.rule.* import io.legado.app.help.JsExtensions -import io.legado.app.utils.ACache -import io.legado.app.utils.GSON -import io.legado.app.utils.fromJsonObject -import io.legado.app.utils.getPrefString +import io.legado.app.utils.* import kotlinx.android.parcel.Parcelize import java.util.* import javax.script.SimpleBindings @@ -105,6 +103,13 @@ data class BookSource( } } + fun removeGroup(group: String) { + bookSourceGroup?.splitNotBlank(",")?.toHashSet()?.let { + it.remove(group) + bookSourceGroup = TextUtils.join(",", it) + } + } + fun getExploreKinds(): ArrayList? { val exploreKinds = arrayListOf() exploreUrl?.let { diff --git a/app/src/main/java/io/legado/app/service/help/CheckSource.kt b/app/src/main/java/io/legado/app/service/help/CheckSource.kt index 45ad0329a..5d8c6876b 100644 --- a/app/src/main/java/io/legado/app/service/help/CheckSource.kt +++ b/app/src/main/java/io/legado/app/service/help/CheckSource.kt @@ -53,6 +53,9 @@ class CheckSource(val source: BookSource) { .onError(Dispatchers.IO) { source.addGroup("失效") App.db.bookSourceDao().update(source) + }.onSuccess(Dispatchers.IO) { + source.removeGroup("失效") + App.db.bookSourceDao().update(source) }.onFinally(Dispatchers.IO) { onNext(source.bookSourceUrl) } 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 c6dc63c8e..c0e255783 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 @@ -158,10 +158,7 @@ class BookSourceViewModel(application: Application) : BaseViewModel(application) execute { val sources = App.db.bookSourceDao().getByGroup(group) sources.map { source -> - source.bookSourceGroup?.splitNotBlank(",")?.toHashSet()?.let { - it.remove(group) - source.bookSourceGroup = TextUtils.join(",", it) - } + source.removeGroup(group) } App.db.bookSourceDao().update(*sources.toTypedArray()) }