feat: 优化代码

pull/98/head
kunfei 5 years ago
parent 7819b76acc
commit 30171126e5
  1. 10
      app/src/main/java/io/legado/app/ui/chapterlist/BookmarkFragment.kt

@ -44,7 +44,8 @@ class BookmarkFragment : VMBaseFragment<ChapterListViewModel>(R.layout.fragment_
private fun initData() {
bookmarkLiveData?.removeObservers(viewLifecycleOwner)
bookmarkLiveData = LivePagedListBuilder(App.db.bookmarkDao().observeByBook(viewModel.bookUrl ?: ""), 20).build()
bookmarkLiveData =
LivePagedListBuilder(App.db.bookmarkDao().observeByBook(viewModel.bookUrl), 20).build()
bookmarkLiveData?.observe(viewLifecycleOwner, Observer { adapter.submitList(it) })
}
@ -53,7 +54,12 @@ class BookmarkFragment : VMBaseFragment<ChapterListViewModel>(R.layout.fragment_
initData()
} else {
bookmarkLiveData?.removeObservers(viewLifecycleOwner)
bookmarkLiveData = LivePagedListBuilder(App.db.bookmarkDao().liveDataSearch(viewModel.bookUrl ?: "", newText), 20).build()
bookmarkLiveData = LivePagedListBuilder(
App.db.bookmarkDao().liveDataSearch(
viewModel.bookUrl,
newText
), 20
).build()
bookmarkLiveData?.observe(viewLifecycleOwner, Observer { adapter.submitList(it) })
}
}

Loading…
Cancel
Save