mirror of
https://github.com/gedoor/legado.git
synced 2025-08-10 00:52:30 +00:00
优化
This commit is contained in:
@@ -23,6 +23,7 @@ import io.legado.app.ui.book.read.ReadBookActivity
|
||||
import io.legado.app.ui.main.MainViewModel
|
||||
import io.legado.app.utils.*
|
||||
import io.legado.app.utils.viewbindingdelegate.viewBinding
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.flow.catch
|
||||
@@ -103,7 +104,7 @@ class BooksFragment() : BaseFragment(R.layout.fragment_books),
|
||||
|
||||
private fun upRecyclerData() {
|
||||
booksFlowJob?.cancel()
|
||||
booksFlowJob = launch {
|
||||
booksFlowJob = launch(Dispatchers.Default) {
|
||||
when (groupId) {
|
||||
AppConst.bookGroupAllId -> appDb.bookDao.flowAll()
|
||||
AppConst.bookGroupLocalId -> appDb.bookDao.flowLocal()
|
||||
|
||||
@@ -25,6 +25,7 @@ import io.legado.app.ui.book.search.SearchActivity
|
||||
import io.legado.app.ui.main.bookshelf.BaseBookshelfFragment
|
||||
import io.legado.app.utils.*
|
||||
import io.legado.app.utils.viewbindingdelegate.viewBinding
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.flow.catch
|
||||
@@ -116,7 +117,7 @@ class BookshelfFragment2 : BaseBookshelfFragment(R.layout.fragment_bookshelf1),
|
||||
}
|
||||
}
|
||||
booksFlowJob?.cancel()
|
||||
booksFlowJob = launch {
|
||||
booksFlowJob = launch(Dispatchers.Default) {
|
||||
when (groupId) {
|
||||
AppConst.bookGroupAllId -> appDb.bookDao.flowAll()
|
||||
AppConst.bookGroupLocalId -> appDb.bookDao.flowLocal()
|
||||
|
||||
Reference in New Issue
Block a user