From 54333ffc4f99e2b261c6d06f2eb1b0ed555680af Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 6 Sep 2019 20:57:14 +0800 Subject: [PATCH] up --- .../app/ui/main/bookshelf/BookshelfViewModel.kt | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfViewModel.kt b/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfViewModel.kt index fae740f80..463c0b015 100644 --- a/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfViewModel.kt @@ -35,8 +35,10 @@ class BookshelfViewModel(application: Application) : BaseViewModel(application) if (book.origin != BookType.local) { val bookSource = App.db.bookSourceDao().getBookSource(book.origin) bookSource?.let { - updateList.add(book.bookUrl) - postEvent(Bus.UP_BOOK, book.bookUrl) + synchronized(this) { + updateList.add(book.bookUrl) + postEvent(Bus.UP_BOOK, book.bookUrl) + } WebBook(bookSource).getChapterList(book).onSuccess(IO) { it?.let { App.db.bookDao().update(book) @@ -45,8 +47,10 @@ class BookshelfViewModel(application: Application) : BaseViewModel(application) } } }.onFinally { - updateList.remove(book.bookUrl) - postEvent(Bus.UP_BOOK, book.bookUrl) + synchronized(this) { + updateList.remove(book.bookUrl) + postEvent(Bus.UP_BOOK, book.bookUrl) + } } } }