From 2bdaee2699aa2d414a118ba6c7ff9b48c69c7184 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sun, 4 Aug 2019 21:22:26 +0800 Subject: [PATCH] up --- app/src/main/java/io/legado/app/data/dao/SearchBookDao.kt | 3 +++ app/src/main/java/io/legado/app/data/entities/SearchBook.kt | 4 ++-- app/src/main/java/io/legado/app/ui/search/SearchActivity.kt | 3 ++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/io/legado/app/data/dao/SearchBookDao.kt b/app/src/main/java/io/legado/app/data/dao/SearchBookDao.kt index e7cf630d0..0bde5a81c 100644 --- a/app/src/main/java/io/legado/app/data/dao/SearchBookDao.kt +++ b/app/src/main/java/io/legado/app/data/dao/SearchBookDao.kt @@ -20,4 +20,7 @@ interface SearchBookDao { @Insert(onConflict = OnConflictStrategy.REPLACE) fun insert(vararg searchBook: SearchBook) + + @Insert(onConflict = OnConflictStrategy.REPLACE) + fun insert(searchBook: SearchBook) } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/data/entities/SearchBook.kt b/app/src/main/java/io/legado/app/data/entities/SearchBook.kt index 674671b64..71db1dc8b 100644 --- a/app/src/main/java/io/legado/app/data/entities/SearchBook.kt +++ b/app/src/main/java/io/legado/app/data/entities/SearchBook.kt @@ -42,11 +42,11 @@ data class SearchBook( } private fun initVariableMap() { - if (variableMap == null) { + variableMap?.let { variableMap = if (TextUtils.isEmpty(variable)) { HashMap() } else { - GSON.fromJsonObject>(variable!!) + GSON.fromJsonObject(variable) } } } 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 20ba266ef..1e3db77c5 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 @@ -28,6 +28,7 @@ class SearchActivity : VMBaseActivity(R.layout.activity_search) override fun onActivityCreated(savedInstanceState: Bundle?) { initRecyclerView() initSearchView() + initData(0L) } private fun initSearchView() { @@ -68,7 +69,7 @@ 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 = LivePagedListBuilder(App.db.searchBookDao().observeAll(), 30).build() searchBookData?.observe(this, Observer { adapter.submitList(it) }) }