优化
This commit is contained in:
@@ -191,7 +191,7 @@ object CacheBook {
|
|||||||
private val tasks = CompositeCoroutine()
|
private val tasks = CompositeCoroutine()
|
||||||
private var isStopped = false
|
private var isStopped = false
|
||||||
private var waitingRetry = false
|
private var waitingRetry = false
|
||||||
private var isLoading = true
|
private var isLoading = false
|
||||||
|
|
||||||
val waitCount get() = waitDownloadSet.size
|
val waitCount get() = waitDownloadSet.size
|
||||||
val onDownloadCount get() = onDownloadSet.size
|
val onDownloadCount get() = onDownloadSet.size
|
||||||
@@ -215,11 +215,17 @@ object CacheBook {
|
|||||||
return isLoading
|
return isLoading
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Synchronized
|
||||||
|
fun setLoading() {
|
||||||
|
isLoading = true
|
||||||
|
}
|
||||||
|
|
||||||
@Synchronized
|
@Synchronized
|
||||||
fun stop() {
|
fun stop() {
|
||||||
waitDownloadSet.clear()
|
waitDownloadSet.clear()
|
||||||
tasks.clear()
|
tasks.clear()
|
||||||
isStopped = true
|
isStopped = true
|
||||||
|
isLoading = false
|
||||||
postEvent(EventBus.UP_DOWNLOAD, book.bookUrl)
|
postEvent(EventBus.UP_DOWNLOAD, book.bookUrl)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -106,12 +106,14 @@ class CacheBookService : BaseService() {
|
|||||||
val chapterCount = appDb.bookChapterDao.getChapterCount(bookUrl)
|
val chapterCount = appDb.bookChapterDao.getChapterCount(bookUrl)
|
||||||
val book = cacheBook.book
|
val book = cacheBook.book
|
||||||
if (chapterCount == 0) {
|
if (chapterCount == 0) {
|
||||||
|
cacheBook.setLoading()
|
||||||
mutex.withLock {
|
mutex.withLock {
|
||||||
val name = book.name
|
val name = book.name
|
||||||
if (book.tocUrl.isEmpty()) {
|
if (book.tocUrl.isEmpty()) {
|
||||||
kotlin.runCatching {
|
kotlin.runCatching {
|
||||||
WebBook.getBookInfoAwait(cacheBook.bookSource, book)
|
WebBook.getBookInfoAwait(cacheBook.bookSource, book)
|
||||||
}.onFailure {
|
}.onFailure {
|
||||||
|
removeDownload(bookUrl)
|
||||||
val msg = "《$name》目录为空且加载详情页失败\n${it.localizedMessage}"
|
val msg = "《$name》目录为空且加载详情页失败\n${it.localizedMessage}"
|
||||||
AppLog.put(msg, it, true)
|
AppLog.put(msg, it, true)
|
||||||
return@execute
|
return@execute
|
||||||
@@ -122,6 +124,7 @@ class CacheBookService : BaseService() {
|
|||||||
book.totalChapterNum = 0
|
book.totalChapterNum = 0
|
||||||
book.update()
|
book.update()
|
||||||
}
|
}
|
||||||
|
removeDownload(bookUrl)
|
||||||
val msg = "《$name》目录为空且加载目录失败\n${it.localizedMessage}"
|
val msg = "《$name》目录为空且加载目录失败\n${it.localizedMessage}"
|
||||||
AppLog.put(msg, it, true)
|
AppLog.put(msg, it, true)
|
||||||
return@execute
|
return@execute
|
||||||
|
|||||||
Reference in New Issue
Block a user