pull/2459/head
kunfei 3 years ago
parent b6c0b44516
commit 234c011758
  1. 18
      app/src/main/java/io/legado/app/ui/book/cache/CacheViewModel.kt

@ -58,17 +58,19 @@ class CacheViewModel(application: Application) : BaseViewModel(application) {
loadChapterCoroutine?.cancel() loadChapterCoroutine?.cancel()
loadChapterCoroutine = execute { loadChapterCoroutine = execute {
books.forEach { book -> books.forEach { book ->
val chapterCaches = hashSetOf<String>() if (!cacheChapters.contains(book.bookUrl)) {
val cacheNames = BookHelp.getChapterFiles(book) val chapterCaches = hashSetOf<String>()
if (cacheNames.isNotEmpty()) { val cacheNames = BookHelp.getChapterFiles(book)
appDb.bookChapterDao.getChapterList(book.bookUrl).forEach { chapter -> if (cacheNames.isNotEmpty()) {
if (cacheNames.contains(chapter.getFileName())) { appDb.bookChapterDao.getChapterList(book.bookUrl).forEach { chapter ->
chapterCaches.add(chapter.url) if (cacheNames.contains(chapter.getFileName())) {
chapterCaches.add(chapter.url)
}
} }
} }
cacheChapters[book.bookUrl] = chapterCaches
upAdapterLiveData.postValue(book.bookUrl)
} }
cacheChapters[book.bookUrl] = chapterCaches
upAdapterLiveData.postValue(book.bookUrl)
ensureActive() ensureActive()
} }
} }

Loading…
Cancel
Save