mirror of
https://github.com/gedoor/legado.git
synced 2024-07-04 23:36:56 +08:00
优化
This commit is contained in:
parent
d70c2b3829
commit
15258abc09
|
@ -364,6 +364,10 @@ data class Book(
|
|||
}
|
||||
}
|
||||
|
||||
fun update() {
|
||||
appDb.bookDao.update(this)
|
||||
}
|
||||
|
||||
fun delete() {
|
||||
if (ReadBook.book?.bookUrl == bookUrl) {
|
||||
ReadBook.book = null
|
||||
|
|
|
@ -171,7 +171,7 @@ object AudioPlay {
|
|||
book.getUseReplaceRule()
|
||||
)
|
||||
}
|
||||
book.save()
|
||||
book.update()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,10 +26,12 @@ import io.legado.app.utils.stackTraceStr
|
|||
import io.legado.app.utils.toastOnUi
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers.IO
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.MainScope
|
||||
import kotlinx.coroutines.SupervisorJob
|
||||
import kotlinx.coroutines.cancelChildren
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.ensureActive
|
||||
import kotlinx.coroutines.flow.collect
|
||||
import kotlinx.coroutines.flow.receiveAsFlow
|
||||
import kotlinx.coroutines.launch
|
||||
|
@ -64,7 +66,7 @@ object ReadBook : CoroutineScope by MainScope() {
|
|||
/* web端阅读进度记录 */
|
||||
var webBookProgress: BookProgress? = null
|
||||
|
||||
var preDownloadTask: Coroutine<*>? = null
|
||||
var preDownloadTask: Job? = null
|
||||
val downloadedChapters = hashSetOf<Int>()
|
||||
val downloadFailChapters = hashMapOf<Int, Int>()
|
||||
var contentProcessor: ContentProcessor? = null
|
||||
|
@ -169,9 +171,10 @@ object ReadBook : CoroutineScope by MainScope() {
|
|||
|
||||
fun uploadProgress() {
|
||||
book?.let {
|
||||
Coroutine.async {
|
||||
launch(IO) {
|
||||
AppWebDav.uploadBookProgress(it)
|
||||
it.save()
|
||||
ensureActive()
|
||||
it.update()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -651,7 +654,7 @@ object ReadBook : CoroutineScope by MainScope() {
|
|||
return@execute
|
||||
}
|
||||
preDownloadTask?.cancel()
|
||||
preDownloadTask = Coroutine.async(executeContext = IO) {
|
||||
preDownloadTask = launch(IO) {
|
||||
//预下载
|
||||
launch {
|
||||
val maxChapterIndex =
|
||||
|
|
|
@ -119,7 +119,7 @@ class CacheBookService : BaseService() {
|
|||
WebBook.getChapterListAwait(cacheBook.bookSource, book).onFailure {
|
||||
if (book.totalChapterNum > 0) {
|
||||
book.totalChapterNum = 0
|
||||
book.save()
|
||||
book.update()
|
||||
}
|
||||
val msg = "《$name》目录为空且加载目录失败\n${it.localizedMessage}"
|
||||
AppLog.put(msg, it, true)
|
||||
|
@ -127,7 +127,7 @@ class CacheBookService : BaseService() {
|
|||
}.getOrNull()?.let { toc ->
|
||||
appDb.bookChapterDao.insert(*toc.toTypedArray())
|
||||
}
|
||||
book.save()
|
||||
book.update()
|
||||
}
|
||||
}
|
||||
val end2 = if (end < 0) {
|
||||
|
|
|
@ -122,6 +122,7 @@ import io.legado.app.utils.visible
|
|||
import kotlinx.coroutines.Dispatchers.IO
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.ensureActive
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
|
||||
|
@ -1439,7 +1440,8 @@ class ReadBookActivity : BaseReadBookActivity(),
|
|||
delay(300000)
|
||||
ReadBook.book?.let {
|
||||
AppWebDav.uploadBookProgress(it)
|
||||
it.save()
|
||||
ensureActive()
|
||||
it.update()
|
||||
Backup.autoBack(this@ReadBookActivity)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user