pull/32/head
kunfei 5 years ago
parent e324e9ca07
commit 9ce11a5b87
  1. 15
      app/src/main/java/io/legado/app/model/WebBook.kt

@ -13,23 +13,12 @@ import io.legado.app.model.webbook.BookList
class WebBook(private val bookSource: BookSource) { class WebBook(private val bookSource: BookSource) {
fun searchBook(key: String, page: Int?): Coroutine<List<SearchBook>> { fun searchBook(key: String, page: Int?, isSearch: Boolean = true): Coroutine<List<SearchBook>> {
return Coroutine.async { return Coroutine.async {
bookSource.getSearchRule().searchUrl?.let { searchUrl -> bookSource.getSearchRule().searchUrl?.let { searchUrl ->
val analyzeUrl = AnalyzeUrl(searchUrl, key, page, baseUrl = bookSource.bookSourceUrl) val analyzeUrl = AnalyzeUrl(searchUrl, key, page, baseUrl = bookSource.bookSourceUrl)
val response = analyzeUrl.getResponseAsync().await() val response = analyzeUrl.getResponseAsync().await()
return@let BookList.analyzeBookList(response, bookSource, analyzeUrl) return@let BookList.analyzeBookList(response, bookSource, analyzeUrl, isSearch)
}
return@async arrayListOf<SearchBook>()
}
}
fun findBook(key: String, page: Int?): Coroutine<List<SearchBook>> {
return Coroutine.async {
bookSource.getSearchRule().searchUrl?.let { searchUrl ->
val analyzeUrl = AnalyzeUrl(searchUrl, key, page)
val response = analyzeUrl.getResponseAsync().await()
return@let BookList.analyzeBookList(response, bookSource, analyzeUrl, false)
} }
return@async arrayListOf<SearchBook>() return@async arrayListOf<SearchBook>()
} }

Loading…
Cancel
Save