From 0946f4bdd67eedac0a8b6db9eee55e173318a6b8 Mon Sep 17 00:00:00 2001
From: Adrian Ulrich <adrian@blinkenlights.ch>
Date: Wed, 3 Mar 2021 19:58:00 +0100
Subject: [PATCH] always update notification

Canceled notifications may still stick around a little bit and we want to show the correct state.
---
 .../blinkenlights/android/vanilla/PlaybackService.java | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/app/src/main/java/ch/blinkenlights/android/vanilla/PlaybackService.java b/app/src/main/java/ch/blinkenlights/android/vanilla/PlaybackService.java
index 7d3aa889..f6a582c2 100644
--- a/app/src/main/java/ch/blinkenlights/android/vanilla/PlaybackService.java
+++ b/app/src/main/java/ch/blinkenlights/android/vanilla/PlaybackService.java
@@ -1184,10 +1184,14 @@ public final class PlaybackService extends Service
 
 	private void updateNotification()
 	{
-		if ((mForceNotificationVisible || mNotificationVisibility == VISIBILITY_ALWAYS
-			  || mNotificationVisibility == VISIBILITY_WHEN_PLAYING && (mState & FLAG_PLAYING) != 0) && mCurrentSong != null) {
+		if (mCurrentSong != null) {
+			// We always update the notification, even if we are about to cancel it as it may still stick around
+			// for a few seconds and we want to ensure that we are showing the correct state.
 			mNotificationHelper.notify(NOTIFICATION_ID, createNotification(mCurrentSong, mState, mNotificationVisibility));
-		} else {
+		}
+		if (!(mForceNotificationVisible ||
+			 mNotificationVisibility == VISIBILITY_ALWAYS ||
+			 mNotificationVisibility == VISIBILITY_WHEN_PLAYING && (mState & FLAG_PLAYING) != 0)) {
 			mNotificationHelper.cancel(NOTIFICATION_ID);
 		}
 	}