优化
This commit is contained in:
@@ -116,6 +116,6 @@ data class SearchBook(
|
|||||||
variable = variable
|
variable = variable
|
||||||
).apply {
|
).apply {
|
||||||
this.infoHtml = this@SearchBook.infoHtml
|
this.infoHtml = this@SearchBook.infoHtml
|
||||||
this.tocUrl = this@SearchBook.tocUrl
|
this.tocHtml = this@SearchBook.tocHtml
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -138,7 +138,7 @@ object BookList {
|
|||||||
variable: String?
|
variable: String?
|
||||||
): SearchBook? {
|
): SearchBook? {
|
||||||
val book = Book(variable = variable)
|
val book = Book(variable = variable)
|
||||||
book.bookUrl = analyzeUrl.ruleUrl
|
book.bookUrl = NetworkUtils.getAbsoluteURL(analyzeUrl.url, analyzeUrl.ruleUrl)
|
||||||
book.origin = bookSource.bookSourceUrl
|
book.origin = bookSource.bookSourceUrl
|
||||||
book.originName = bookSource.bookSourceName
|
book.originName = bookSource.bookSourceName
|
||||||
book.originOrder = bookSource.customOrder
|
book.originOrder = bookSource.customOrder
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ open class ChangeBookSourceViewModel(application: Application) : BaseViewModel(a
|
|||||||
}.flowOn(IO)
|
}.flowOn(IO)
|
||||||
|
|
||||||
@Volatile
|
@Volatile
|
||||||
private var searchIndex = 0
|
private var searchIndex = -1
|
||||||
|
|
||||||
override fun onCleared() {
|
override fun onCleared() {
|
||||||
super.onCleared()
|
super.onCleared()
|
||||||
@@ -142,7 +142,7 @@ open class ChangeBookSourceViewModel(application: Application) : BaseViewModel(a
|
|||||||
private fun initSearchPool() {
|
private fun initSearchPool() {
|
||||||
searchPool = Executors
|
searchPool = Executors
|
||||||
.newFixedThreadPool(min(threadCount, AppConst.MAX_THREAD)).asCoroutineDispatcher()
|
.newFixedThreadPool(min(threadCount, AppConst.MAX_THREAD)).asCoroutineDispatcher()
|
||||||
searchIndex = 0
|
searchIndex = -1
|
||||||
}
|
}
|
||||||
|
|
||||||
fun refresh(): Boolean {
|
fun refresh(): Boolean {
|
||||||
@@ -195,10 +195,10 @@ open class ChangeBookSourceViewModel(application: Application) : BaseViewModel(a
|
|||||||
|
|
||||||
private fun search() {
|
private fun search() {
|
||||||
val searchIndex = synchronized(this) {
|
val searchIndex = synchronized(this) {
|
||||||
if (searchIndex > bookSourceList.lastIndex) {
|
if (searchIndex >= bookSourceList.lastIndex) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
searchIndex++
|
++searchIndex
|
||||||
}
|
}
|
||||||
val source = bookSourceList[searchIndex]
|
val source = bookSourceList[searchIndex]
|
||||||
bookSourceList[searchIndex] = emptyBookSource
|
bookSourceList[searchIndex] = emptyBookSource
|
||||||
|
|||||||
Reference in New Issue
Block a user