From b0492a2138486a66f66033b19aad7e3f24b94c77 Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 6 Sep 2019 21:47:00 +0800 Subject: [PATCH] up --- .../app/ui/changesource/ChangeSourceViewModel.kt | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/changesource/ChangeSourceViewModel.kt b/app/src/main/java/io/legado/app/ui/changesource/ChangeSourceViewModel.kt index 533813a73..5d7410b5b 100644 --- a/app/src/main/java/io/legado/app/ui/changesource/ChangeSourceViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/changesource/ChangeSourceViewModel.kt @@ -54,16 +54,14 @@ class ChangeSourceViewModel(application: Application) : BaseViewModel(applicatio WebBook(item).searchBook(name, scope = this@execute) .timeout(30000L) .onSuccess(IO) { - it?.let { list -> - for (searchBook in list) { - if (searchBook.name == name && searchBook.author == author) { - if (searchBook.tocUrl.isEmpty()) { - loadBookInfo(searchBook.toBook()) - } else { - loadChapter(searchBook.toBook()) - } - break + it?.forEach { searchBook -> + if (searchBook.name == name && searchBook.author == author) { + if (searchBook.tocUrl.isEmpty()) { + loadBookInfo(searchBook.toBook()) + } else { + loadChapter(searchBook.toBook()) } + return@onSuccess } } }