From 67afb552b68131259f12ccf9eed62d864df4590e Mon Sep 17 00:00:00 2001 From: kunfei Date: Mon, 26 Aug 2019 21:49:03 +0800 Subject: [PATCH] up --- .../io/legado/app/ui/readbook/ReadBookViewModel.kt | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/readbook/ReadBookViewModel.kt b/app/src/main/java/io/legado/app/ui/readbook/ReadBookViewModel.kt index 767bd0849..b95ff61ff 100644 --- a/app/src/main/java/io/legado/app/ui/readbook/ReadBookViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/readbook/ReadBookViewModel.kt @@ -137,14 +137,20 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) { private fun download(book: Book, chapter: BookChapter) { webBook?.getContent(book, chapter, scope = this) ?.onSuccess(IO) { content -> - content?.let { - BookHelp.saveContent(book, chapter, it) - callBack?.contentLoadFinish(chapter, it) + if (content.isNullOrEmpty()) { + callBack?.contentLoadFinish(chapter, context.getString(R.string.content_empty)) + synchronized(loadingLock) { + loadingChapters.remove(chapter.index) + } + } else { + BookHelp.saveContent(book, chapter, content) + callBack?.contentLoadFinish(chapter, content) synchronized(loadingLock) { loadingChapters.remove(chapter.index) } } }?.onError { + callBack?.contentLoadFinish(chapter, it.localizedMessage) synchronized(loadingLock) { loadingChapters.remove(chapter.index) }