|
|
|
@ -20,19 +20,23 @@ class SearchViewModel(application: Application) : BaseViewModel(application) { |
|
|
|
|
val search = WebBook(item).searchBook(key, searchPage) |
|
|
|
|
.onSuccess { searchBookS -> |
|
|
|
|
searchBookS?.let { |
|
|
|
|
for (searchBook in searchBookS) { |
|
|
|
|
when (key) { |
|
|
|
|
searchBook.name -> searchBook.searchOrder = 0 |
|
|
|
|
searchBook.author -> searchBook.searchOrder = 1 |
|
|
|
|
else -> searchBook.searchOrder = 1000 |
|
|
|
|
execute { |
|
|
|
|
for (searchBook in searchBookS) { |
|
|
|
|
when (key) { |
|
|
|
|
searchBook.name -> searchBook.searchOrder = 0 |
|
|
|
|
searchBook.author -> searchBook.searchOrder = 1 |
|
|
|
|
else -> searchBook.searchOrder = 1000 |
|
|
|
|
} |
|
|
|
|
App.db.searchBookDao().insert(searchBook) |
|
|
|
|
} |
|
|
|
|
App.db.searchBookDao().insert(searchBook) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
tasks.add(search) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
}.onError { |
|
|
|
|
it.printStackTrace() |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|