|
|
@ -157,12 +157,17 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) { |
|
|
|
|
|
|
|
|
|
|
|
private fun autoChangeSource(name: String, author: String) { |
|
|
|
private fun autoChangeSource(name: String, author: String) { |
|
|
|
execute { |
|
|
|
execute { |
|
|
|
App.db.bookSourceDao().allTextEnabled.forEach { |
|
|
|
App.db.bookSourceDao().allTextEnabled.forEach { source -> |
|
|
|
try { |
|
|
|
try { |
|
|
|
val searchBooks = WebBook(it).searchBookSuspend(name) |
|
|
|
val searchBooks = WebBook(source).searchBookSuspend(name) |
|
|
|
|
|
|
|
searchBooks.getOrNull(0)?.let { |
|
|
|
|
|
|
|
if (it.name == name && (it.author == author || author == "")) { |
|
|
|
|
|
|
|
changeTo(it.toBook()) |
|
|
|
|
|
|
|
return@forEach |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} catch (e: Exception) { |
|
|
|
} catch (e: Exception) { |
|
|
|
|
|
|
|
//nothing |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}.onStart { |
|
|
|
}.onStart { |
|
|
|