From 444c141c45841416e343d5926ad1afad4754b81a Mon Sep 17 00:00:00 2001 From: kunfei Date: Thu, 19 Mar 2020 22:12:46 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/model/SearchBookModel.kt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/io/legado/app/model/SearchBookModel.kt b/app/src/main/java/io/legado/app/model/SearchBookModel.kt index 9e1ad126b..1f6cac065 100644 --- a/app/src/main/java/io/legado/app/model/SearchBookModel.kt +++ b/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()) {