feat: 优化

pull/274/head 3.20.070622
gedoor 4 years ago
parent 304785f902
commit 9798f24cc1
  1. 3
      app/src/main/assets/updateLog.md
  2. 12
      app/src/main/java/io/legado/app/service/DownloadService.kt
  3. 2
      app/src/main/java/io/legado/app/service/help/Download.kt

@ -3,6 +3,9 @@
* 请关注公众号[开源阅读]()支持我,同时关注合作公众号[小说拾遗](),阅读公众号小编。
* 新公众号[开源阅读]()已启用,[开源阅读软件]()备用
**2020/07/06**
* 优化下载
**2020/07/05**
* 修复夜间模式底栏颜色调整无效的bug
* 【web看书】加了翻页、排序等 by [Celeter](https://github.com/Celeter)

@ -151,6 +151,7 @@ class DownloadService : BaseService() {
private fun download() {
downloadingCount += 1
Download.addLog("downloadingCount++")
tasks.add(Coroutine.async(this, context = searchPool) {
if (!isActive) return@async
val bookChapter: BookChapter? = synchronized(this@DownloadService) {
@ -184,12 +185,14 @@ class DownloadService : BaseService() {
scope = this,
context = searchPool
).onError {
synchronized(this) {
downloadingList.remove(bookChapter.url)
}
Download.addLog(it.localizedMessage)
}.onSuccess(IO) { content ->
downloadCount[book.bookUrl]?.increaseSuccess()
BookHelp.saveContent(book, bookChapter, content)
}.onFinally(IO) {
synchronized(this@DownloadService) {
downloadCount[book.bookUrl]?.increaseSuccess()
downloadCount[book.bookUrl]?.increaseFinished()
downloadCount[book.bookUrl]?.let {
updateNotification(
@ -210,8 +213,9 @@ class DownloadService : BaseService() {
downloadCount.remove(book.bookUrl)
}
}
}.onFinally(IO) {
postDownloading(true)
}
postDownloading(true)
} else {
//无需下载的,设置为增加成功
downloadCount[book.bookUrl]?.increaseSuccess()
@ -224,6 +228,8 @@ class DownloadService : BaseService() {
private fun postDownloading(hasChapter: Boolean) {
downloadingCount -= 1
Download.addLog("downloadingCount--")
Download.addLog("downloadingCount $downloadingCount")
if (hasChapter) {
download()
} else {

@ -12,7 +12,7 @@ object Download {
fun addLog(log: String?) {
log ?: return
synchronized(this) {
if (logs.size > 30) {
if (logs.size > 1000) {
logs.removeAt(0)
}
logs.add(log)

Loading…
Cancel
Save