pull/32/head
kunfei 5 years ago
parent 08fea53d0f
commit f916b66f20
  1. 3
      app/src/main/java/io/legado/app/ui/chapterlist/BookmarkFragment.kt
  2. 1
      app/src/main/java/io/legado/app/ui/chapterlist/ChapterListActivity.kt
  3. 4
      app/src/main/java/io/legado/app/ui/chapterlist/ChapterListFragment.kt

@ -25,6 +25,7 @@ class BookmarkFragment : VMBaseFragment<ChapterListViewModel>(R.layout.fragment_
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
initRecyclerView()
initData()
}
private fun initRecyclerView() {
@ -36,7 +37,7 @@ class BookmarkFragment : VMBaseFragment<ChapterListViewModel>(R.layout.fragment_
private fun initData() {
bookmarkLiveData?.removeObservers(viewLifecycleOwner)
bookmarkLiveData = LivePagedListBuilder(App.db.bookmarkDao().observeByBook(""), 20).build()
bookmarkLiveData = LivePagedListBuilder(App.db.bookmarkDao().observeByBook(viewModel.bookUrl ?: ""), 20).build()
bookmarkLiveData?.observe(viewLifecycleOwner, Observer { adapter.submitList(it) })
}
}

@ -26,6 +26,7 @@ class ChapterListActivity : VMBaseActivity<ChapterListViewModel>(R.layout.activi
override fun onActivityCreated(savedInstanceState: Bundle?) {
setSupportActionBar(toolbar)
viewModel.bookUrl = intent.getStringExtra("bookUrl")
view_pager.adapter = TabFragmentPageAdapter(supportFragmentManager)
tab_layout.setupWithViewPager(view_pager)
}

@ -19,7 +19,7 @@ class ChapterListFragment : VMBaseFragment<ChapterListViewModel>(R.layout.fragme
get() = getViewModelOfActivity(ChapterListViewModel::class.java)
lateinit var adapter: ChapterListAdapter
var liveData: LiveData<PagedList<BookChapter>>? = null
private var liveData: LiveData<PagedList<BookChapter>>? = null
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
@ -35,7 +35,7 @@ class ChapterListFragment : VMBaseFragment<ChapterListViewModel>(R.layout.fragme
private fun initData() {
liveData?.removeObservers(viewLifecycleOwner)
liveData = LivePagedListBuilder(App.db.bookChapterDao().observeByBook(""), 30).build()
liveData = LivePagedListBuilder(App.db.bookChapterDao().observeByBook(viewModel.bookUrl ?: ""), 30).build()
liveData?.observe(viewLifecycleOwner, Observer { adapter.submitList(it) })
}
}
Loading…
Cancel
Save