From 33190ae3eae15e623783007805e493f5fc5ff50f Mon Sep 17 00:00:00 2001 From: Koitharu Date: Fri, 11 Feb 2022 19:32:38 +0200 Subject: [PATCH] Fix DownloadBinder leak --- .../koitharu/kotatsu/download/ui/service/DownloadService.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/org/koitharu/kotatsu/download/ui/service/DownloadService.kt b/app/src/main/java/org/koitharu/kotatsu/download/ui/service/DownloadService.kt index d44204533..03712d889 100644 --- a/app/src/main/java/org/koitharu/kotatsu/download/ui/service/DownloadService.kt +++ b/app/src/main/java/org/koitharu/kotatsu/download/ui/service/DownloadService.kt @@ -16,7 +16,6 @@ import androidx.lifecycle.lifecycleScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.MutableStateFlow -import kotlinx.coroutines.flow.collect import kotlinx.coroutines.flow.mapLatest import kotlinx.coroutines.isActive import kotlinx.coroutines.launch @@ -79,6 +78,11 @@ class DownloadService : BaseService() { return binder ?: DownloadBinder(this).also { binder = it } } + override fun onUnbind(intent: Intent?): Boolean { + binder = null + return super.onUnbind(intent) + } + override fun onDestroy() { unregisterReceiver(controlReceiver) binder = null