From b756f407b2f540a516bf9bf01811cfb2002aa787 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sun, 27 Feb 2022 00:00:29 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../legado/app/ui/main/bookshelf/style1/books/BooksFragment.kt | 3 ++- .../legado/app/ui/main/bookshelf/style2/BookshelfFragment2.kt | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/main/bookshelf/style1/books/BooksFragment.kt b/app/src/main/java/io/legado/app/ui/main/bookshelf/style1/books/BooksFragment.kt index 3d11c05ce..8f2188d65 100644 --- a/app/src/main/java/io/legado/app/ui/main/bookshelf/style1/books/BooksFragment.kt +++ b/app/src/main/java/io/legado/app/ui/main/bookshelf/style1/books/BooksFragment.kt @@ -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() diff --git a/app/src/main/java/io/legado/app/ui/main/bookshelf/style2/BookshelfFragment2.kt b/app/src/main/java/io/legado/app/ui/main/bookshelf/style2/BookshelfFragment2.kt index 162ff28a8..92fea3232 100644 --- a/app/src/main/java/io/legado/app/ui/main/bookshelf/style2/BookshelfFragment2.kt +++ b/app/src/main/java/io/legado/app/ui/main/bookshelf/style2/BookshelfFragment2.kt @@ -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()