|
|
|
@ -16,7 +16,6 @@ import kotlinx.coroutines.CoroutineScope |
|
|
|
|
import kotlinx.coroutines.Dispatchers.IO |
|
|
|
|
import kotlinx.coroutines.asCoroutineDispatcher |
|
|
|
|
import kotlinx.coroutines.isActive |
|
|
|
|
import kotlinx.coroutines.launch |
|
|
|
|
import java.util.concurrent.Executors |
|
|
|
|
|
|
|
|
|
class SearchViewModel(application: Application) : BaseViewModel(application) { |
|
|
|
@ -34,10 +33,9 @@ class SearchViewModel(application: Application) : BaseViewModel(application) { |
|
|
|
|
* 开始搜索 |
|
|
|
|
*/ |
|
|
|
|
fun search(key: String) { |
|
|
|
|
launch { |
|
|
|
|
task?.cancel() |
|
|
|
|
if (key.isEmpty() && searchKey.isEmpty()) { |
|
|
|
|
return@launch |
|
|
|
|
return |
|
|
|
|
} else if (key.isEmpty()) { |
|
|
|
|
isLoading = true |
|
|
|
|
searchPage++ |
|
|
|
@ -88,7 +86,6 @@ class SearchViewModel(application: Application) : BaseViewModel(application) { |
|
|
|
|
isLoading = false |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 精确搜索处理 |
|
|
|
|