From cc97b48a69eb9397219e5f65c43cee55a4ff9e0a Mon Sep 17 00:00:00 2001 From: gedoor Date: Sun, 5 Jul 2020 18:54:34 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E4=B8=8B=E8=BD=BD?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E6=97=A5=E5=BF=97,=E4=BB=8E=E4=B8=8B?= =?UTF-8?q?=E8=BD=BD=E8=8F=9C=E5=8D=95=E6=B5=8F=E8=A7=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/service/DownloadService.kt | 4 +--- app/src/main/java/io/legado/app/service/help/Download.kt | 3 ++- 2 files changed, 3 insertions(+), 4 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 13b55ac13..bbe44141c 100644 --- a/app/src/main/java/io/legado/app/service/DownloadService.kt +++ b/app/src/main/java/io/legado/app/service/DownloadService.kt @@ -184,9 +184,7 @@ class DownloadService : BaseService() { scope = this, context = searchPool ).onError { - it.localizedMessage?.let { - Download.addLog(it) - } + Download.addLog(it.localizedMessage) }.onSuccess(IO) { content -> downloadCount[book.bookUrl]?.increaseSuccess() BookHelp.saveContent(book, bookChapter, content) diff --git a/app/src/main/java/io/legado/app/service/help/Download.kt b/app/src/main/java/io/legado/app/service/help/Download.kt index 844f127b2..d7e99b641 100644 --- a/app/src/main/java/io/legado/app/service/help/Download.kt +++ b/app/src/main/java/io/legado/app/service/help/Download.kt @@ -9,7 +9,8 @@ object Download { val logs = arrayListOf() - fun addLog(log: String) { + fun addLog(log: String?) { + log ?: return synchronized(this) { if (logs.size > 30) { logs.removeAt(0)