pull/32/head
gedoor 6 years ago
parent 1d7410e22f
commit ddfc7a97d2
  1. 14
      app/src/main/java/io/legado/app/ui/main/booksource/BookSourceFragment.kt

@ -55,7 +55,12 @@ class BookSourceFragment : BaseFragment(R.layout.fragment_book_source), BookSour
private fun initRecyclerView() {
recycler_view.layoutManager = LinearLayoutManager(context)
recycler_view.addItemDecoration(DividerItemDecoration(context, LinearLayoutManager.VERTICAL))
recycler_view.addItemDecoration(
DividerItemDecoration(
context,
LinearLayoutManager.VERTICAL
)
)
adapter = BookSourceAdapter()
adapter.callBack = this
recycler_view.adapter = adapter
@ -76,9 +81,10 @@ class BookSourceFragment : BaseFragment(R.layout.fragment_book_source), BookSour
private fun initDataObserve(searchKey: String = "") {
bookSourceLiveDate?.removeObservers(viewLifecycleOwner)
val dataFactory =
if (searchKey.isEmpty()) App.db.bookSourceDao().observeAll() else App.db.bookSourceDao().observeSearch(
searchKey
)
if (searchKey.isEmpty())
App.db.bookSourceDao().observeAll()
else
App.db.bookSourceDao().observeSearch(searchKey)
bookSourceLiveDate = LivePagedListBuilder(dataFactory, 30).build()
bookSourceLiveDate?.observe(viewLifecycleOwner, Observer { adapter.submitList(it) })
}

Loading…
Cancel
Save