|
|
@ -56,7 +56,7 @@ class SearchActivity : VMBaseActivity<SearchViewModel>(R.layout.activity_book_se |
|
|
|
initRecyclerView() |
|
|
|
initRecyclerView() |
|
|
|
initSearchView() |
|
|
|
initSearchView() |
|
|
|
initOtherView() |
|
|
|
initOtherView() |
|
|
|
initData() |
|
|
|
initLiveData() |
|
|
|
initIntent() |
|
|
|
initIntent() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -169,7 +169,7 @@ class SearchActivity : VMBaseActivity<SearchViewModel>(R.layout.activity_book_se |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private fun initData() { |
|
|
|
private fun initLiveData() { |
|
|
|
App.db.bookSourceDao().liveGroupEnabled().observe(this, Observer { |
|
|
|
App.db.bookSourceDao().liveGroupEnabled().observe(this, Observer { |
|
|
|
groups.clear() |
|
|
|
groups.clear() |
|
|
|
it.map { group -> |
|
|
|
it.map { group -> |
|
|
@ -178,13 +178,14 @@ class SearchActivity : VMBaseActivity<SearchViewModel>(R.layout.activity_book_se |
|
|
|
upGroupMenu() |
|
|
|
upGroupMenu() |
|
|
|
}) |
|
|
|
}) |
|
|
|
viewModel.searchBookLiveData.observe(this, Observer { |
|
|
|
viewModel.searchBookLiveData.observe(this, Observer { |
|
|
|
setSearchItems(it) |
|
|
|
upSearchItems(it, false) |
|
|
|
}) |
|
|
|
}) |
|
|
|
viewModel.isSearchLiveData.observe(this, Observer { |
|
|
|
viewModel.isSearchLiveData.observe(this, Observer { |
|
|
|
if (it) { |
|
|
|
if (it) { |
|
|
|
startSearch() |
|
|
|
startSearch() |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
searchFinally() |
|
|
|
searchFinally() |
|
|
|
|
|
|
|
upSearchItems(viewModel.searchBooks, true) |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
@ -263,8 +264,8 @@ class SearchActivity : VMBaseActivity<SearchViewModel>(R.layout.activity_book_se |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Synchronized |
|
|
|
@Synchronized |
|
|
|
private fun setSearchItems(items: List<SearchBook>) { |
|
|
|
private fun upSearchItems(items: List<SearchBook>, isMandatoryUpdate: Boolean) { |
|
|
|
if (System.currentTimeMillis() - refreshTime < 1000) { |
|
|
|
if (!isMandatoryUpdate && System.currentTimeMillis() - refreshTime < 1000) { |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
refreshTime = System.currentTimeMillis() |
|
|
|
refreshTime = System.currentTimeMillis() |
|
|
|