From 7da832cca23842bdff5c14522d0a503428c175dc Mon Sep 17 00:00:00 2001 From: Horis <821938089@qq.com> Date: Tue, 17 Oct 2023 11:29:42 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/io/legado/app/model/webBook/SearchModel.kt | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/io/legado/app/model/webBook/SearchModel.kt b/app/src/main/java/io/legado/app/model/webBook/SearchModel.kt index c2f088398e0e..1ac0e0c0636c 100644 --- a/app/src/main/java/io/legado/app/model/webBook/SearchModel.kt +++ b/app/src/main/java/io/legado/app/model/webBook/SearchModel.kt @@ -28,7 +28,6 @@ class SearchModel(private val scope: CoroutineScope, private val callBack: CallB private var tasks = CompositeCoroutine() private var bookSourceList = arrayListOf() private var searchBooks = arrayListOf() - private val emptyBookSource = BookSource() @Volatile private var searchIndex = -1 @@ -77,7 +76,6 @@ class SearchModel(private val scope: CoroutineScope, private val callBack: CallB return } searchIndex++ - val searchIndex = searchIndex val source = bookSourceList[searchIndex] val searchPool = searchPool ?: return val task = WebBook.searchBook( @@ -93,7 +91,7 @@ class SearchModel(private val scope: CoroutineScope, private val callBack: CallB onSuccess(searchId, it) } .onFinally { - onFinally(searchId, searchIndex) + onFinally(searchId) } tasks.add(task) } @@ -109,15 +107,12 @@ class SearchModel(private val scope: CoroutineScope, private val callBack: CallB } @Synchronized - private fun onFinally(searchId: Long, index: Int) { + private fun onFinally(searchId: Long) { if (searchIndex < bookSourceList.lastIndex) { search(searchId) } else { searchIndex++ } - if (index <= bookSourceList.lastIndex) { - bookSourceList[index] = emptyBookSource - } if (searchIndex >= bookSourceList.lastIndex + min(bookSourceList.size, threadCount) ) {