From e7d404d217c1a330b41f409596bc0c062d8080bb Mon Sep 17 00:00:00 2001 From: kunfei Date: Sun, 4 Aug 2019 17:29:54 +0800 Subject: [PATCH] up --- .../java/io/legado/app/ui/search/SearchActivity.kt | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/io/legado/app/ui/search/SearchActivity.kt b/app/src/main/java/io/legado/app/ui/search/SearchActivity.kt index 89ff581cb..aec7b54a7 100644 --- a/app/src/main/java/io/legado/app/ui/search/SearchActivity.kt +++ b/app/src/main/java/io/legado/app/ui/search/SearchActivity.kt @@ -3,9 +3,15 @@ package io.legado.app.ui.search import android.os.Bundle import android.view.View import androidx.appcompat.widget.SearchView +import androidx.lifecycle.LiveData +import androidx.lifecycle.Observer +import androidx.paging.LivePagedListBuilder +import androidx.paging.PagedList import androidx.recyclerview.widget.LinearLayoutManager +import io.legado.app.App import io.legado.app.R import io.legado.app.base.VMBaseActivity +import io.legado.app.data.entities.SearchBook import io.legado.app.lib.theme.ATH import io.legado.app.utils.getViewModel import kotlinx.android.synthetic.main.activity_search.* @@ -17,6 +23,7 @@ class SearchActivity : VMBaseActivity(R.layout.activity_search) get() = getViewModel(SearchViewModel::class.java) private lateinit var adapter: SearchAdapter + private var searchBookData: LiveData>? = null override fun onActivityCreated(savedInstanceState: Bundle?) { initRecyclerView() @@ -60,7 +67,9 @@ class SearchActivity : VMBaseActivity(R.layout.activity_search) } private fun initData(startTime: Long) { - + searchBookData?.removeObservers(this) + searchBookData = LivePagedListBuilder(App.db.searchBookDao().observeNew(startTime), 30).build() + searchBookData?.observe(this, Observer { adapter.submitList(it) }) } }