优化
This commit is contained in:
@@ -200,7 +200,7 @@ open class ChangeBookSourceViewModel(application: Application) : BaseViewModel(a
|
|||||||
}
|
}
|
||||||
++searchIndex
|
++searchIndex
|
||||||
}
|
}
|
||||||
val source = bookSourceList[searchIndex]
|
val source = bookSourceList.getOrNull(searchIndex) ?: return
|
||||||
bookSourceList[searchIndex] = emptyBookSource
|
bookSourceList[searchIndex] = emptyBookSource
|
||||||
val task = execute(
|
val task = execute(
|
||||||
context = searchPool!!,
|
context = searchPool!!,
|
||||||
@@ -227,9 +227,11 @@ open class ChangeBookSourceViewModel(application: Application) : BaseViewModel(a
|
|||||||
}
|
}
|
||||||
}.timeout(60000L)
|
}.timeout(60000L)
|
||||||
.onError {
|
.onError {
|
||||||
|
ensureActive()
|
||||||
nextSearch()
|
nextSearch()
|
||||||
}
|
}
|
||||||
.onSuccess {
|
.onSuccess {
|
||||||
|
ensureActive()
|
||||||
nextSearch()
|
nextSearch()
|
||||||
}
|
}
|
||||||
task.start()
|
task.start()
|
||||||
@@ -298,8 +300,9 @@ open class ChangeBookSourceViewModel(application: Application) : BaseViewModel(a
|
|||||||
searchCallback?.searchSuccess(searchBook)
|
searchCallback?.searchSuccess(searchBook)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Synchronized
|
||||||
private fun nextSearch() {
|
private fun nextSearch() {
|
||||||
synchronized(this) {
|
kotlin.runCatching {
|
||||||
if (searchIndex < bookSourceList.lastIndex) {
|
if (searchIndex < bookSourceList.lastIndex) {
|
||||||
search()
|
search()
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user