From 9f5863e80eaf746330073620ca457c8b280b0479 Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 7 Feb 2020 15:19:06 +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/chapterlist/ChapterListFragment.kt | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/chapterlist/ChapterListFragment.kt b/app/src/main/java/io/legado/app/ui/chapterlist/ChapterListFragment.kt index 1f6f5dfe2..29cea56a3 100644 --- a/app/src/main/java/io/legado/app/ui/chapterlist/ChapterListFragment.kt +++ b/app/src/main/java/io/legado/app/ui/chapterlist/ChapterListFragment.kt @@ -18,6 +18,7 @@ import io.legado.app.utils.getViewModelOfActivity import kotlinx.android.synthetic.main.fragment_chapter_list.* import kotlinx.coroutines.Dispatchers.IO import kotlinx.coroutines.launch +import kotlinx.coroutines.withContext import org.jetbrains.anko.sdk27.listeners.onClick class ChapterListFragment : VMBaseFragment(R.layout.fragment_chapter_list), @@ -50,8 +51,11 @@ class ChapterListFragment : VMBaseFragment(R.layout.fragme } private fun initBook() { - launch(IO) { - book = App.db.bookDao().getBook(viewModel.bookUrl) + launch { + withContext(IO) { + book = App.db.bookDao().getBook(viewModel.bookUrl) + } + tv_current_chapter_info.text = book?.durChapterTitle } } @@ -63,7 +67,7 @@ class ChapterListFragment : VMBaseFragment(R.layout.fragme if (it.isEmpty()) return@Observer book?.let { book -> durChapterIndex = book.durChapterIndex - tv_current_chapter_info.text = it[durChapterIndex()].title + tv_current_chapter_info.text = it[durChapterIndex].title mLayoutManager.scrollToPositionWithOffset(durChapterIndex, 0) } })