优化
This commit is contained in:
@@ -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()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user