|
|
@ -113,9 +113,9 @@ class MainViewModel(application: Application) : BaseViewModel(application) { |
|
|
|
waitUpTocBooks.remove(book.bookUrl) |
|
|
|
waitUpTocBooks.remove(book.bookUrl) |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
waitUpTocBooks.remove(book.bookUrl) |
|
|
|
waitUpTocBooks.remove(bookUrl) |
|
|
|
onUpTocBooks.add(book.bookUrl) |
|
|
|
onUpTocBooks.add(bookUrl) |
|
|
|
postEvent(EventBus.UP_BOOKSHELF, book.bookUrl) |
|
|
|
postEvent(EventBus.UP_BOOKSHELF, bookUrl) |
|
|
|
execute(context = upTocPool) { |
|
|
|
execute(context = upTocPool) { |
|
|
|
val preUpdateJs = source.ruleToc?.preUpdateJs |
|
|
|
val preUpdateJs = source.ruleToc?.preUpdateJs |
|
|
|
if (!preUpdateJs.isNullOrBlank()) { |
|
|
|
if (!preUpdateJs.isNullOrBlank()) { |
|
|
@ -125,15 +125,22 @@ class MainViewModel(application: Application) : BaseViewModel(application) { |
|
|
|
WebBook.getBookInfoAwait(this, source, book) |
|
|
|
WebBook.getBookInfoAwait(this, source, book) |
|
|
|
} |
|
|
|
} |
|
|
|
val toc = WebBook.getChapterListAwait(this, source, book).getOrThrow() |
|
|
|
val toc = WebBook.getChapterListAwait(this, source, book).getOrThrow() |
|
|
|
appDb.bookDao.update(book) |
|
|
|
if (book.bookUrl == bookUrl) { |
|
|
|
|
|
|
|
appDb.bookDao.update(book) |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
onUpTocBooks.add(book.bookUrl) |
|
|
|
|
|
|
|
appDb.bookDao.insert(book) |
|
|
|
|
|
|
|
} |
|
|
|
appDb.bookChapterDao.delByBook(book.bookUrl) |
|
|
|
appDb.bookChapterDao.delByBook(book.bookUrl) |
|
|
|
appDb.bookChapterDao.insert(*toc.toTypedArray()) |
|
|
|
appDb.bookChapterDao.insert(*toc.toTypedArray()) |
|
|
|
addDownload(source, book) |
|
|
|
addDownload(source, book) |
|
|
|
}.onError(upTocPool) { |
|
|
|
}.onError(upTocPool) { |
|
|
|
AppLog.put("${book.name} 更新目录失败\n${it.localizedMessage}", it) |
|
|
|
AppLog.put("${book.name} 更新目录失败\n${it.localizedMessage}", it) |
|
|
|
}.onCancel(upTocPool) { |
|
|
|
}.onCancel(upTocPool) { |
|
|
|
|
|
|
|
upTocCancel(bookUrl) |
|
|
|
upTocCancel(book.bookUrl) |
|
|
|
upTocCancel(book.bookUrl) |
|
|
|
}.onFinally(upTocPool) { |
|
|
|
}.onFinally(upTocPool) { |
|
|
|
|
|
|
|
upTocFinally(bookUrl) |
|
|
|
upTocFinally(book.bookUrl) |
|
|
|
upTocFinally(book.bookUrl) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|