From 0a31be0817f8c7283b4c9686ef4a6a5ffc1af8c3 Mon Sep 17 00:00:00 2001 From: gedoor Date: Wed, 15 Jul 2020 18:28:57 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=A6=BB=E7=BA=BF=E4=B8=8B?= =?UTF-8?q?=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/io/legado/app/service/DownloadService.kt | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/io/legado/app/service/DownloadService.kt b/app/src/main/java/io/legado/app/service/DownloadService.kt index 20416a677..f7cb27162 100644 --- a/app/src/main/java/io/legado/app/service/DownloadService.kt +++ b/app/src/main/java/io/legado/app/service/DownloadService.kt @@ -126,6 +126,7 @@ class DownloadService : BaseService() { private fun addDownloadData(bookUrl: String?, start: Int, end: Int) { bookUrl ?: return if (downloadMap.containsKey(bookUrl)) { + updateNotification(getString(R.string.already_in_download)) toast(R.string.already_in_download) return } @@ -136,6 +137,8 @@ class DownloadService : BaseService() { val chapters = CopyOnWriteArraySet() chapters.addAll(it) downloadMap[bookUrl] = chapters + } else { + Download.addLog("${getBook(bookUrl)?.name} is empty") } } for (i in 0 until threadCount) { @@ -153,7 +156,7 @@ class DownloadService : BaseService() { private fun download() { downloadingCount += 1 - tasks.add(Coroutine.async(this, context = searchPool) { + val task = Coroutine.async(this, context = searchPool) { if (!isActive) return@async val bookChapter: BookChapter? = synchronized(this@DownloadService) { downloadMap.forEach { @@ -224,7 +227,10 @@ class DownloadService : BaseService() { postDownloading(true) } } - }) + }.onError { + Download.addLog("ERROR:${it.localizedMessage}") + } + tasks.add(task) } private fun postDownloading(hasChapter: Boolean) {