feat: 优化代码

pull/159/head
kunfei 5 years ago
parent 4928bd9233
commit ba0937e243
  1. 3
      app/src/main/assets/updateLog.md
  2. 13
      app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt

@ -2,6 +2,9 @@
* 旧版数据导入教程:先在旧版阅读(2.x)中进行备份,然后在新版阅读(3.x)【我的】->【备份与恢复】,选择【导入旧版本数据】。
* 请关注[开源阅读软件]()支持我,同时关注合作公众号[小说拾遗](),阅读公众号小编。
**2020/03/14**
* 加载正文无书源时自动换源
**2020/03/14**
* 修改导航栏图标

@ -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 {

Loading…
Cancel
Save