pull/32/head
kunfei 5 years ago
parent c12a4e03ab
commit 2bdaee2699
  1. 3
      app/src/main/java/io/legado/app/data/dao/SearchBookDao.kt
  2. 4
      app/src/main/java/io/legado/app/data/entities/SearchBook.kt
  3. 3
      app/src/main/java/io/legado/app/ui/search/SearchActivity.kt

@ -20,4 +20,7 @@ interface SearchBookDao {
@Insert(onConflict = OnConflictStrategy.REPLACE) @Insert(onConflict = OnConflictStrategy.REPLACE)
fun insert(vararg searchBook: SearchBook) fun insert(vararg searchBook: SearchBook)
@Insert(onConflict = OnConflictStrategy.REPLACE)
fun insert(searchBook: SearchBook)
} }

@ -42,11 +42,11 @@ data class SearchBook(
} }
private fun initVariableMap() { private fun initVariableMap() {
if (variableMap == null) { variableMap?.let {
variableMap = if (TextUtils.isEmpty(variable)) { variableMap = if (TextUtils.isEmpty(variable)) {
HashMap() HashMap()
} else { } else {
GSON.fromJsonObject<HashMap<String, String>>(variable!!) GSON.fromJsonObject(variable)
} }
} }
} }

@ -28,6 +28,7 @@ class SearchActivity : VMBaseActivity<SearchViewModel>(R.layout.activity_search)
override fun onActivityCreated(savedInstanceState: Bundle?) { override fun onActivityCreated(savedInstanceState: Bundle?) {
initRecyclerView() initRecyclerView()
initSearchView() initSearchView()
initData(0L)
} }
private fun initSearchView() { private fun initSearchView() {
@ -68,7 +69,7 @@ class SearchActivity : VMBaseActivity<SearchViewModel>(R.layout.activity_search)
private fun initData(startTime: Long) { private fun initData(startTime: Long) {
searchBookData?.removeObservers(this) searchBookData?.removeObservers(this)
searchBookData = LivePagedListBuilder(App.db.searchBookDao().observeNew(startTime), 30).build() searchBookData = LivePagedListBuilder(App.db.searchBookDao().observeAll(), 30).build()
searchBookData?.observe(this, Observer { adapter.submitList(it) }) searchBookData?.observe(this, Observer { adapter.submitList(it) })
} }

Loading…
Cancel
Save