diff --git a/app/src/main/java/io/legado/app/service/CheckSourceService.kt b/app/src/main/java/io/legado/app/service/CheckSourceService.kt index bf4a268a8..19d19ca0f 100644 --- a/app/src/main/java/io/legado/app/service/CheckSourceService.kt +++ b/app/src/main/java/io/legado/app/service/CheckSourceService.kt @@ -20,7 +20,7 @@ class CheckSourceService : BaseService() { private var searchPool = Executors.newFixedThreadPool(AppConfig.threadCount).asCoroutineDispatcher() private var task: Coroutine<*>? = null - private val allIds = LinkedHashSet() + private var idsCount = 0 private val unCheckIds = LinkedHashSet() override fun onCreate() { @@ -46,9 +46,8 @@ class CheckSourceService : BaseService() { private fun check(ids: List) { task?.cancel() - allIds.clear() unCheckIds.clear() - allIds.addAll(ids) + idsCount = ids.size unCheckIds.addAll(ids) task = execute { unCheckIds.forEach { sourceUrl -> @@ -60,10 +59,10 @@ class CheckSourceService : BaseService() { App.db.bookSourceDao().update(source) }.onFinally { unCheckIds.remove(sourceUrl) - val checkedCount = allIds.size - unCheckIds.size + val checkedCount = idsCount - unCheckIds.size updateNotification( checkedCount, - getString(R.string.progress_show, checkedCount, unCheckIds.size) + getString(R.string.progress_show, checkedCount, idsCount) ) } } @@ -92,7 +91,7 @@ class CheckSourceService : BaseService() { getString(R.string.cancel), IntentHelp.servicePendingIntent(this, IntentAction.stop) ) - builder.setProgress(allIds.size, state, false) + builder.setProgress(idsCount, state, false) builder.setVisibility(NotificationCompat.VISIBILITY_PUBLIC) val notification = builder.build() startForeground(112202, notification)