From ef9066692e1d18c87273356137e0b2dc455b0417 Mon Sep 17 00:00:00 2001 From: Fernando Valverde Date: Sun, 8 Nov 2020 18:21:43 -0600 Subject: [PATCH] Checks audioService exists before requesting the context to stop it --- .../to/dev/dev_android/util/AndroidWebViewBridge.kt | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/to/dev/dev_android/util/AndroidWebViewBridge.kt b/app/src/main/java/to/dev/dev_android/util/AndroidWebViewBridge.kt index 7bad1a4..e5378a5 100644 --- a/app/src/main/java/to/dev/dev_android/util/AndroidWebViewBridge.kt +++ b/app/src/main/java/to/dev/dev_android/util/AndroidWebViewBridge.kt @@ -114,10 +114,12 @@ class AndroidWebViewBridge(private val context: Context) { fun terminatePodcast() { timer?.cancel() timer = null - audioService?.pause() - context.unbindService(connection) - audioService = null - context.stopService(Intent(context, AudioService::class.java)) + audioService?.let { + it.pause() + context.unbindService(connection) + context.stopService(Intent(context, AudioService::class.java)) + audioService = null + } } fun podcastTimeUpdate() {