优化
This commit is contained in:
@@ -58,6 +58,7 @@ class CacheViewModel(application: Application) : BaseViewModel(application) {
|
|||||||
loadChapterCoroutine?.cancel()
|
loadChapterCoroutine?.cancel()
|
||||||
loadChapterCoroutine = execute {
|
loadChapterCoroutine = execute {
|
||||||
books.forEach { book ->
|
books.forEach { book ->
|
||||||
|
if (!cacheChapters.contains(book.bookUrl)) {
|
||||||
val chapterCaches = hashSetOf<String>()
|
val chapterCaches = hashSetOf<String>()
|
||||||
val cacheNames = BookHelp.getChapterFiles(book)
|
val cacheNames = BookHelp.getChapterFiles(book)
|
||||||
if (cacheNames.isNotEmpty()) {
|
if (cacheNames.isNotEmpty()) {
|
||||||
@@ -69,6 +70,7 @@ class CacheViewModel(application: Application) : BaseViewModel(application) {
|
|||||||
}
|
}
|
||||||
cacheChapters[book.bookUrl] = chapterCaches
|
cacheChapters[book.bookUrl] = chapterCaches
|
||||||
upAdapterLiveData.postValue(book.bookUrl)
|
upAdapterLiveData.postValue(book.bookUrl)
|
||||||
|
}
|
||||||
ensureActive()
|
ensureActive()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user