pull/63/head
kunfei 5 years ago
parent 2a9a8df1c0
commit 1466e9dee8
  1. 14
      app/src/main/java/io/legado/app/ui/download/DownloadActivity.kt
  2. 8
      app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfViewModel.kt

@ -10,7 +10,10 @@ import io.legado.app.App
import io.legado.app.R import io.legado.app.R
import io.legado.app.base.BaseActivity import io.legado.app.base.BaseActivity
import io.legado.app.data.entities.Book import io.legado.app.data.entities.Book
import io.legado.app.service.help.Download
import kotlinx.android.synthetic.main.activity_download.* import kotlinx.android.synthetic.main.activity_download.*
import kotlinx.coroutines.Dispatchers.IO
import kotlinx.coroutines.launch
class DownloadActivity : BaseActivity(R.layout.activity_download) { class DownloadActivity : BaseActivity(R.layout.activity_download) {
@ -30,8 +33,15 @@ class DownloadActivity : BaseActivity(R.layout.activity_download) {
override fun onCompatOptionsItemSelected(item: MenuItem): Boolean { override fun onCompatOptionsItemSelected(item: MenuItem): Boolean {
when (item.itemId) { when (item.itemId) {
R.id.menu_download_start -> { R.id.menu_download_start -> launch(IO) {
App.db.bookDao().webBooks.forEach { book ->
Download.start(
this@DownloadActivity,
book.bookUrl,
book.durChapterIndex,
book.totalChapterNum
)
}
} }
} }
return super.onCompatOptionsItemSelected(item) return super.onCompatOptionsItemSelected(item)

@ -4,7 +4,6 @@ import android.app.Application
import io.legado.app.App import io.legado.app.App
import io.legado.app.base.BaseViewModel import io.legado.app.base.BaseViewModel
import io.legado.app.data.entities.BookGroup import io.legado.app.data.entities.BookGroup
import io.legado.app.service.help.Download
class BookshelfViewModel(application: Application) : BaseViewModel(application) { class BookshelfViewModel(application: Application) : BaseViewModel(application) {
@ -33,11 +32,4 @@ class BookshelfViewModel(application: Application) : BaseViewModel(application)
} }
} }
fun downloadAll() {
execute {
App.db.bookDao().webBooks.forEach { book ->
Download.start(context, book.bookUrl, book.durChapterIndex, book.totalChapterNum)
}
}
}
} }

Loading…
Cancel
Save