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