diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index 8f2068940..250688fe3 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -2,6 +2,9 @@ * 旧版数据导入教程:先在旧版阅读(2.x)中进行备份,然后在新版阅读(3.x)【我的】->【备份与恢复】,选择【导入旧版本数据】。 * 请关注[开源阅读软件]()支持我,同时关注合作公众号[小说拾遗](),阅读公众号小编。 +**2020/03/14** +* 加载正文无书源时自动换源 + **2020/03/14** * 修改导航栏图标 diff --git a/app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt b/app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt index 3519f3b08..75021a323 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt @@ -157,12 +157,17 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) { private fun autoChangeSource(name: String, author: String) { execute { - App.db.bookSourceDao().allTextEnabled.forEach { + App.db.bookSourceDao().allTextEnabled.forEach { source -> try { - val searchBooks = WebBook(it).searchBookSuspend(name) - + val searchBooks = WebBook(source).searchBookSuspend(name) + searchBooks.getOrNull(0)?.let { + if (it.name == name && (it.author == author || author == "")) { + changeTo(it.toBook()) + return@forEach + } + } } catch (e: Exception) { - + //nothing } } }.onStart {