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 = execute {
books.forEach { book ->
val chapterCaches = hashSetOf<String>()
val cacheNames = BookHelp.getChapterFiles(book)
if (cacheNames.isNotEmpty()) {
appDb.bookChapterDao.getChapterList(book.bookUrl).forEach { chapter ->
if (cacheNames.contains(chapter.getFileName())) {
chapterCaches.add(chapter.url)
if (!cacheChapters.contains(book.bookUrl)) {
val chapterCaches = hashSetOf<String>()
val cacheNames = BookHelp.getChapterFiles(book)
if (cacheNames.isNotEmpty()) {
appDb.bookChapterDao.getChapterList(book.bookUrl).forEach { chapter ->
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()
}
}

Loading…
Cancel
Save