feat: 优化代码

pull/169/head
kunfei 5 years ago
parent e9f40e699e
commit 444c141c45
  1. 8
      app/src/main/java/io/legado/app/model/SearchBookModel.kt

@ -18,10 +18,16 @@ class SearchBookModel(private val scope: CoroutineScope, private val callBack: C
private var searchKey: String = ""
private var task: Coroutine<*>? = null
private fun initSearchPool() {
searchPool =
Executors.newFixedThreadPool(AppConfig.threadCount).asCoroutineDispatcher()
}
fun search(searchId: Long, key: String) {
if (searchId != mSearchId) {
task?.cancel()
callBack.onSearchCancel()
searchPool.close()
initSearchPool()
mSearchId = searchId
searchPage = 1
if (key.isEmpty()) {

Loading…
Cancel
Save