pull/52/head
kunfei 5 years ago
parent b3fc672f57
commit bdfb60c486
  1. 3
      app/src/main/java/io/legado/app/data/dao/BookDao.kt
  2. 3
      app/src/main/java/io/legado/app/ui/main/MainViewModel.kt
  3. 2
      app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfViewModel.kt

@ -32,6 +32,9 @@ interface BookDao {
@Query("SELECT * FROM books WHERE bookUrl = :bookUrl")
fun getBook(bookUrl: String): Book?
@get:Query("SELECT * FROM books where origin <> '${BookType.local}' and type = 0")
val webBooks: List<Book>
@get:Query("SELECT * FROM books where origin <> '${BookType.local}' and canUpdate = 1")
val hasUpdateBooks: List<Book>

@ -3,7 +3,6 @@ package io.legado.app.ui.main
import android.app.Application
import io.legado.app.App
import io.legado.app.base.BaseViewModel
import io.legado.app.constant.BookType
import io.legado.app.constant.Bus
import io.legado.app.model.WebBook
import io.legado.app.utils.postEvent
@ -16,7 +15,6 @@ class MainViewModel(application: Application) : BaseViewModel(application) {
fun upChapterList() {
execute {
App.db.bookDao().hasUpdateBooks.forEach { book ->
if (book.origin != BookType.local) {
if (!updateList.contains(book.bookUrl)) {
App.db.bookSourceDao().getBookSource(book.origin)?.let { bookSource ->
synchronized(this) {
@ -45,7 +43,6 @@ class MainViewModel(application: Application) : BaseViewModel(application) {
}
}
}
}
delay(50)
}
}

@ -35,7 +35,7 @@ class BookshelfViewModel(application: Application) : BaseViewModel(application)
fun downloadAll() {
execute {
App.db.bookDao().hasUpdateBooks.forEach { book ->
App.db.bookDao().webBooks.forEach { book ->
Download.start(context, book.bookUrl, book.durChapterIndex, book.totalChapterNum)
}
}

Loading…
Cancel
Save