|
|
@ -29,8 +29,7 @@ import org.jetbrains.anko.sdk27.listeners.onClick |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class SearchListActivity : VMBaseActivity<SearchListViewModel>(R.layout.activity_search_list), |
|
|
|
class SearchListActivity : VMBaseActivity<SearchListViewModel>(R.layout.activity_search_list), |
|
|
|
SearchListAdapter.Callback, |
|
|
|
SearchListAdapter.Callback { |
|
|
|
SearchListViewModel.SearchListCallBack { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
override val viewModel: SearchListViewModel |
|
|
|
override val viewModel: SearchListViewModel |
|
|
|
get() = getViewModel(SearchListViewModel::class.java) |
|
|
|
get() = getViewModel(SearchListViewModel::class.java) |
|
|
@ -42,7 +41,6 @@ class SearchListActivity : VMBaseActivity<SearchListViewModel>(R.layout.activity |
|
|
|
private var searchResultList: MutableList<SearchResult> = mutableListOf() |
|
|
|
private var searchResultList: MutableList<SearchResult> = mutableListOf() |
|
|
|
|
|
|
|
|
|
|
|
override fun onActivityCreated(savedInstanceState: Bundle?) { |
|
|
|
override fun onActivityCreated(savedInstanceState: Bundle?) { |
|
|
|
viewModel.searchCallBack = this |
|
|
|
|
|
|
|
val bbg = bottomBackground |
|
|
|
val bbg = bottomBackground |
|
|
|
val btc = getPrimaryTextColor(ColorUtils.isColorLight(bbg)) |
|
|
|
val btc = getPrimaryTextColor(ColorUtils.isColorLight(bbg)) |
|
|
|
ll_search_base_info.setBackgroundColor(bbg) |
|
|
|
ll_search_base_info.setBackgroundColor(bbg) |
|
|
@ -68,7 +66,7 @@ class SearchListActivity : VMBaseActivity<SearchListViewModel>(R.layout.activity |
|
|
|
search_view.setOnQueryTextListener(object : SearchView.OnQueryTextListener { |
|
|
|
search_view.setOnQueryTextListener(object : SearchView.OnQueryTextListener { |
|
|
|
override fun onQueryTextSubmit(query: String): Boolean { |
|
|
|
override fun onQueryTextSubmit(query: String): Boolean { |
|
|
|
if (viewModel.lastQuery != query) { |
|
|
|
if (viewModel.lastQuery != query) { |
|
|
|
viewModel.startContentSearch(query) |
|
|
|
startContentSearch(query) |
|
|
|
} |
|
|
|
} |
|
|
|
return false |
|
|
|
return false |
|
|
|
} |
|
|
|
} |
|
|
@ -103,6 +101,9 @@ class SearchListActivity : VMBaseActivity<SearchListViewModel>(R.layout.activity |
|
|
|
viewModel.book?.let { |
|
|
|
viewModel.book?.let { |
|
|
|
initCacheFileNames(it) |
|
|
|
initCacheFileNames(it) |
|
|
|
durChapterIndex = it.durChapterIndex |
|
|
|
durChapterIndex = it.durChapterIndex |
|
|
|
|
|
|
|
intent.getStringExtra("searchWord")?.let { searchWord -> |
|
|
|
|
|
|
|
search_view.setQuery(searchWord, true) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -128,7 +129,7 @@ class SearchListActivity : VMBaseActivity<SearchListViewModel>(R.layout.activity |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@SuppressLint("SetTextI18n") |
|
|
|
@SuppressLint("SetTextI18n") |
|
|
|
override fun startContentSearch(newText: String) { |
|
|
|
fun startContentSearch(newText: String) { |
|
|
|
// 按章节搜索内容 |
|
|
|
// 按章节搜索内容 |
|
|
|
if (!newText.isBlank()) { |
|
|
|
if (!newText.isBlank()) { |
|
|
|
adapter.clearItems() |
|
|
|
adapter.clearItems() |
|
|
|