From 03ec05297af8a74ca7a0e1b08aebbaeb64f03d91 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sun, 18 Aug 2019 07:16:43 +0800 Subject: [PATCH] up --- .../java/io/legado/app/ui/bookinfo/BookInfoViewModel.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/bookinfo/BookInfoViewModel.kt b/app/src/main/java/io/legado/app/ui/bookinfo/BookInfoViewModel.kt index ac68bea13..6479ce005 100644 --- a/app/src/main/java/io/legado/app/ui/bookinfo/BookInfoViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/bookinfo/BookInfoViewModel.kt @@ -27,6 +27,7 @@ class BookInfoViewModel(application: Application) : BaseViewModel(application) { val chapterList = App.db.bookChapterDao().getChapterList(it) if (chapterList.isNotEmpty()) { chapterListData.postValue(chapterList) + isLoadingData.postValue(false) } else { loadChapter(book) } @@ -45,7 +46,7 @@ class BookInfoViewModel(application: Application) : BaseViewModel(application) { } fun loadBookInfo(book: Book) { - isLoadingData.postValue(false) + isLoadingData.postValue(true) App.db.bookSourceDao().getBookSource(book.origin)?.let { bookSource -> WebBook(bookSource).getBookInfo(book) .onSuccess { @@ -57,7 +58,7 @@ class BookInfoViewModel(application: Application) : BaseViewModel(application) { } fun loadChapter(book: Book) { - isLoadingData.postValue(false) + isLoadingData.postValue(true) App.db.bookSourceDao().getBookSource(book.origin)?.let { bookSource -> WebBook(bookSource).getChapterList(book) .onSuccess(IO) { @@ -67,6 +68,7 @@ class BookInfoViewModel(application: Application) : BaseViewModel(application) { App.db.bookChapterDao().insert(*it.toTypedArray()) } chapterListData.postValue(it) + isLoadingData.postValue(false) } } }.onError {