From f43eecb74acf6cf0fdb4836c63591cb5715b5288 Mon Sep 17 00:00:00 2001 From: Swapnil Tripathi Date: Sat, 14 Aug 2021 20:31:30 +0530 Subject: [PATCH] Refactor the switch statement. --- android/src/org/kde/kasts/KastsActivity.java | 23 ++++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/android/src/org/kde/kasts/KastsActivity.java b/android/src/org/kde/kasts/KastsActivity.java index 414d58bd..b578dc0f 100755 --- a/android/src/org/kde/kasts/KastsActivity.java +++ b/android/src/org/kde/kasts/KastsActivity.java @@ -41,6 +41,7 @@ public class KastsActivity extends QtActivity public long position; public long duration; public float playbackSpeed; + public int state = 2; // add more variables here } @@ -57,6 +58,16 @@ public class KastsActivity extends QtActivity MediaMetadataCompat.Builder metadata = new MediaMetadataCompat.Builder(); + switch(mediaData.state) + { + case 0: + mPBuilder.setState(PlaybackStateCompat.STATE_PLAYING, mediaData.position, mediaData.playbackSpeed); + case 1: + mPBuilder.setState(PlaybackStateCompat.STATE_PAUSED, mediaData.position, mediaData.playbackSpeed); + case 2: + mPBuilder.setState(PlaybackStateCompat.STATE_STOPPED, mediaData.position, mediaData.playbackSpeed); + } + metadata.putString(MediaMetadataCompat.METADATA_KEY_TITLE, "The title"); metadata.putString(MediaMetadataCompat.METADATA_KEY_AUTHOR, "Author"); metadata.putString(MediaMetadataCompat.METADATA_KEY_ARTIST, "Author"); @@ -194,15 +205,9 @@ public class KastsActivity extends QtActivity public static void setSessionState(int state) { //TODO: set state in mediadata - switch(state) - { - case 0: - mPBuilder.setState(PlaybackStateCompat.STATE_PLAYING, mediaData.position, mediaData.playbackSpeed); - case 1: - mPBuilder.setState(PlaybackStateCompat.STATE_PAUSED, mediaData.position, mediaData.playbackSpeed); - case 2: - mPBuilder.setState(PlaybackStateCompat.STATE_STOPPED, mediaData.position, mediaData.playbackSpeed); - } + + mediaData.state = state; + activity.updateNotification(); }