feat: 优化代码

pull/178/head
kunfei 5 years ago
parent 917ad10d43
commit 1053348163
  1. 11
      app/src/main/java/io/legado/app/service/CheckSourceService.kt

@ -7,6 +7,7 @@ import io.legado.app.R
import io.legado.app.base.BaseService import io.legado.app.base.BaseService
import io.legado.app.constant.AppConst import io.legado.app.constant.AppConst
import io.legado.app.constant.IntentAction import io.legado.app.constant.IntentAction
import io.legado.app.data.entities.BookSource
import io.legado.app.help.AppConfig import io.legado.app.help.AppConfig
import io.legado.app.help.IntentHelp import io.legado.app.help.IntentHelp
import io.legado.app.help.coroutine.Coroutine import io.legado.app.help.coroutine.Coroutine
@ -70,6 +71,12 @@ class CheckSourceService : BaseService() {
if (processIndex < allIds.size) { if (processIndex < allIds.size) {
val sourceUrl = allIds[processIndex] val sourceUrl = allIds[processIndex]
App.db.bookSourceDao().getBookSource(sourceUrl)?.let { source -> App.db.bookSourceDao().getBookSource(sourceUrl)?.let { source ->
check(source)
}
}
}
private fun check(source: BookSource) {
val webBook = WebBook(source) val webBook = WebBook(source)
webBook.searchBook("我的", scope = this, context = searchPool) webBook.searchBook("我的", scope = this, context = searchPool)
.onError(IO) { .onError(IO) {
@ -77,7 +84,7 @@ class CheckSourceService : BaseService() {
App.db.bookSourceDao().update(source) App.db.bookSourceDao().update(source)
}.onFinally(IO) { }.onFinally(IO) {
check() check()
checkedIds.add(sourceUrl) checkedIds.add(source.bookSourceUrl)
updateNotification( updateNotification(
checkedIds.size, checkedIds.size,
getString(R.string.progress_show, checkedIds.size, allIds.size) getString(R.string.progress_show, checkedIds.size, allIds.size)
@ -89,8 +96,6 @@ class CheckSourceService : BaseService() {
} }
} }
} }
}
}
/** /**
* 更新通知 * 更新通知

Loading…
Cancel
Save