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