diff --git a/app/src/main/java/io/legado/app/data/dao/BookDao.kt b/app/src/main/java/io/legado/app/data/dao/BookDao.kt index 2a356e933..71a8651b3 100644 --- a/app/src/main/java/io/legado/app/data/dao/BookDao.kt +++ b/app/src/main/java/io/legado/app/data/dao/BookDao.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}'") + val webBooks: List + @get:Query("SELECT * FROM books") val allBooks: List 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 c50e441b0..7f116694e 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 @@ -4,6 +4,7 @@ import android.app.Application import io.legado.app.App import io.legado.app.base.BaseViewModel import io.legado.app.data.entities.BookGroup +import io.legado.app.service.help.Download class BookshelfViewModel(application: Application) : BaseViewModel(application) { @@ -34,8 +35,8 @@ class BookshelfViewModel(application: Application) : BaseViewModel(application) fun downloadAll() { execute { - App.db.bookDao().allBooks.forEach { book -> - + App.db.bookDao().webBooks.forEach { book -> + Download.start(context, book.bookUrl, book.durChapterIndex, book.totalChapterNum) } } }