|
|
@ -7,6 +7,7 @@ import io.legado.app.constant.BookType |
|
|
|
import io.legado.app.constant.Bus |
|
|
|
import io.legado.app.constant.Bus |
|
|
|
import io.legado.app.help.storage.Restore |
|
|
|
import io.legado.app.help.storage.Restore |
|
|
|
import io.legado.app.model.WebBook |
|
|
|
import io.legado.app.model.WebBook |
|
|
|
|
|
|
|
import io.legado.app.utils.LogUtils |
|
|
|
import io.legado.app.utils.postEvent |
|
|
|
import io.legado.app.utils.postEvent |
|
|
|
import kotlinx.coroutines.Dispatchers.IO |
|
|
|
import kotlinx.coroutines.Dispatchers.IO |
|
|
|
import kotlinx.coroutines.delay |
|
|
|
import kotlinx.coroutines.delay |
|
|
@ -25,9 +26,11 @@ class MainViewModel(application: Application) : BaseViewModel(application) { |
|
|
|
execute { |
|
|
|
execute { |
|
|
|
App.db.bookDao().allBooks.forEach { book -> |
|
|
|
App.db.bookDao().allBooks.forEach { book -> |
|
|
|
if (book.origin != BookType.local) { |
|
|
|
if (book.origin != BookType.local) { |
|
|
|
|
|
|
|
if (!updateList.contains(book.bookUrl)) { |
|
|
|
App.db.bookSourceDao().getBookSource(book.origin)?.let { bookSource -> |
|
|
|
App.db.bookSourceDao().getBookSource(book.origin)?.let { bookSource -> |
|
|
|
synchronized(this) { |
|
|
|
synchronized(this) { |
|
|
|
updateList.add(book.bookUrl) |
|
|
|
updateList.add(book.bookUrl) |
|
|
|
|
|
|
|
LogUtils.d("updateAdd", book.name) |
|
|
|
postEvent(Bus.UP_BOOK, book.bookUrl) |
|
|
|
postEvent(Bus.UP_BOOK, book.bookUrl) |
|
|
|
} |
|
|
|
} |
|
|
|
WebBook(bookSource).getChapterList(book) |
|
|
|
WebBook(bookSource).getChapterList(book) |
|
|
@ -41,11 +44,13 @@ class MainViewModel(application: Application) : BaseViewModel(application) { |
|
|
|
.onFinally { |
|
|
|
.onFinally { |
|
|
|
synchronized(this) { |
|
|
|
synchronized(this) { |
|
|
|
updateList.remove(book.bookUrl) |
|
|
|
updateList.remove(book.bookUrl) |
|
|
|
|
|
|
|
LogUtils.d("updateRemove", book.name) |
|
|
|
postEvent(Bus.UP_BOOK, book.bookUrl) |
|
|
|
postEvent(Bus.UP_BOOK, book.bookUrl) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
delay(50) |
|
|
|
delay(50) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|