|
|
@ -30,13 +30,16 @@ class SearchViewModel(application: Application) : BaseViewModel(application), |
|
|
|
* 开始搜索 |
|
|
|
* 开始搜索 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
fun search(key: String) { |
|
|
|
fun search(key: String) { |
|
|
|
if ((searchKey != key && key.isEmpty()) || key.isNotEmpty()) { |
|
|
|
if ((searchKey == key) || key.isNotEmpty()) { |
|
|
|
searchBookModel.cancelSearch() |
|
|
|
searchBookModel.cancelSearch() |
|
|
|
searchBooks.clear() |
|
|
|
searchBooks.clear() |
|
|
|
searchBookLiveData.postValue(searchBooks) |
|
|
|
searchBookLiveData.postValue(searchBooks) |
|
|
|
searchID = System.currentTimeMillis() |
|
|
|
searchID = System.currentTimeMillis() |
|
|
|
searchKey = key |
|
|
|
searchKey = key |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (searchKey.isEmpty()) { |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
searchBookModel.search(searchID, searchKey) |
|
|
|
searchBookModel.search(searchID, searchKey) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -111,7 +114,7 @@ class SearchViewModel(application: Application) : BaseViewModel(application), |
|
|
|
&& item.author == searchBook.author |
|
|
|
&& item.author == searchBook.author |
|
|
|
) { |
|
|
|
) { |
|
|
|
hasSame = true |
|
|
|
hasSame = true |
|
|
|
searchBook.addOrigin(item.bookUrl) |
|
|
|
searchBook.addOrigin(item.origin) |
|
|
|
break |
|
|
|
break |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|