|
|
|
@ -17,7 +17,6 @@ class SearchViewModel(application: Application) : BaseViewModel(application) { |
|
|
|
|
private val searchModel = SearchModel(viewModelScope) |
|
|
|
|
var isSearchLiveData = MutableLiveData<Boolean>() |
|
|
|
|
var searchKey: String = "" |
|
|
|
|
var isLoading = false |
|
|
|
|
private var searchID = 0L |
|
|
|
|
|
|
|
|
|
val searchDataFlow = callbackFlow { |
|
|
|
@ -25,21 +24,18 @@ class SearchViewModel(application: Application) : BaseViewModel(application) { |
|
|
|
|
val callback = object : SearchModel.CallBack { |
|
|
|
|
override fun onSearchStart() { |
|
|
|
|
isSearchLiveData.postValue(true) |
|
|
|
|
isLoading = true |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun onSearchSuccess(searchBooks: ArrayList<SearchBook>) { |
|
|
|
|
trySend(ArrayList(searchBooks)) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun onSearchFinish() { |
|
|
|
|
override fun onSearchFinish(isEmpty: Boolean) { |
|
|
|
|
isSearchLiveData.postValue(false) |
|
|
|
|
isLoading = false |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun onSearchCancel() { |
|
|
|
|
isSearchLiveData.postValue(false) |
|
|
|
|
isLoading = false |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|