|
|
|
@ -48,6 +48,7 @@ class MainViewModel(application: Application) : BaseViewModel(application) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
fun upToc(books: List<Book>) { |
|
|
|
|
execute { |
|
|
|
|
books.filter { |
|
|
|
|
it.origin != BookType.local && it.canUpdate |
|
|
|
|
}.forEach { |
|
|
|
@ -60,17 +61,18 @@ class MainViewModel(application: Application) : BaseViewModel(application) { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private fun updateToc() { |
|
|
|
|
execute { |
|
|
|
|
synchronized(this) { |
|
|
|
|
bookMap.forEach { bookEntry -> |
|
|
|
|
if (!updateList.contains(bookEntry.key)) { |
|
|
|
|
val book = bookEntry.value |
|
|
|
|
App.db.bookSourceDao().getBookSource(book.origin)?.let { bookSource -> |
|
|
|
|
synchronized(this) { |
|
|
|
|
updateList.add(book.bookUrl) |
|
|
|
|
postEvent(EventBus.UP_BOOK, book.bookUrl) |
|
|
|
|
} |
|
|
|
|
App.db.bookSourceDao().getBookSource(book.origin)?.let { bookSource -> |
|
|
|
|
WebBook(bookSource).getChapterList(book, context = upTocPool) |
|
|
|
|
.timeout(300000) |
|
|
|
|
.onSuccess(IO) { |
|
|
|
@ -91,6 +93,8 @@ class MainViewModel(application: Application) : BaseViewModel(application) { |
|
|
|
|
} |
|
|
|
|
} ?: synchronized(this) { |
|
|
|
|
bookMap.remove(bookEntry.key) |
|
|
|
|
updateList.remove(book.bookUrl) |
|
|
|
|
postEvent(EventBus.UP_BOOK, book.bookUrl) |
|
|
|
|
upNext() |
|
|
|
|
} |
|
|
|
|
return@forEach |
|
|
|
|