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