pull/94/head
kunfei 5 years ago
parent 4c60238789
commit 9f5863e80e
  1. 8
      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.android.synthetic.main.fragment_chapter_list.*
import kotlinx.coroutines.Dispatchers.IO import kotlinx.coroutines.Dispatchers.IO
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import org.jetbrains.anko.sdk27.listeners.onClick import org.jetbrains.anko.sdk27.listeners.onClick
class ChapterListFragment : VMBaseFragment<ChapterListViewModel>(R.layout.fragment_chapter_list), class ChapterListFragment : VMBaseFragment<ChapterListViewModel>(R.layout.fragment_chapter_list),
@ -50,9 +51,12 @@ class ChapterListFragment : VMBaseFragment<ChapterListViewModel>(R.layout.fragme
} }
private fun initBook() { private fun initBook() {
launch(IO) { launch {
withContext(IO) {
book = App.db.bookDao().getBook(viewModel.bookUrl) book = App.db.bookDao().getBook(viewModel.bookUrl)
} }
tv_current_chapter_info.text = book?.durChapterTitle
}
} }
private fun initDoc() { private fun initDoc() {
@ -63,7 +67,7 @@ class ChapterListFragment : VMBaseFragment<ChapterListViewModel>(R.layout.fragme
if (it.isEmpty()) return@Observer if (it.isEmpty()) return@Observer
book?.let { book -> book?.let { book ->
durChapterIndex = book.durChapterIndex durChapterIndex = book.durChapterIndex
tv_current_chapter_info.text = it[durChapterIndex()].title tv_current_chapter_info.text = it[durChapterIndex].title
mLayoutManager.scrollToPositionWithOffset(durChapterIndex, 0) mLayoutManager.scrollToPositionWithOffset(durChapterIndex, 0)
} }
}) })

Loading…
Cancel
Save