[Android] Code cleanup

Robert Stone git at videolan.org
Mon Jan 9 07:39:31 UTC 2023


vlc-android | branch: master | Robert Stone <rhstone at gmail.com> | Fri Jan  6 09:38:07 2023 -0800| [683fa50e79b036720643ce69207391c6ea02ccef] | committer: Nicolas Pomepuy

Code cleanup

> https://code.videolan.org/videolan/vlc-android/commit/683fa50e79b036720643ce69207391c6ea02ccef
---

 .../vlc-android/src/org/videolan/vlc/MediaParsingService.kt    |  2 +-
 .../vlc-android/src/org/videolan/vlc/PlaybackService.kt        | 10 +++++-----
 application/vlc-android/src/org/videolan/vlc/StartActivity.kt  |  2 +-
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/application/vlc-android/src/org/videolan/vlc/MediaParsingService.kt b/application/vlc-android/src/org/videolan/vlc/MediaParsingService.kt
index 50db4734de..bc77e3d953 100644
--- a/application/vlc-android/src/org/videolan/vlc/MediaParsingService.kt
+++ b/application/vlc-android/src/org/videolan/vlc/MediaParsingService.kt
@@ -251,7 +251,7 @@ class MediaParsingService : LifecycleService(), DevicesDiscoveryCb {
         if (reload > 0) return
         if (path.isNullOrEmpty()) medialibrary.reload()
         else medialibrary.reload(path)
-        val ctx = this
+        val ctx = this at MediaParsingService
         lifecycleScope.launch(Dispatchers.IO) {
             cleanupWatchNextList(ctx)
         }
diff --git a/application/vlc-android/src/org/videolan/vlc/PlaybackService.kt b/application/vlc-android/src/org/videolan/vlc/PlaybackService.kt
index 4093853982..35cad20530 100644
--- a/application/vlc-android/src/org/videolan/vlc/PlaybackService.kt
+++ b/application/vlc-android/src/org/videolan/vlc/PlaybackService.kt
@@ -552,7 +552,7 @@ class PlaybackService : MediaBrowserServiceCompat(), LifecycleOwner, CoroutineSc
 
     val spuTrack: String
         @MainThread
-        get() = playlistManager.player.getSpuTrack() ?: "-1"
+        get() = playlistManager.player.getSpuTrack()
 
     val spuTracksCount: Int
         @MainThread
@@ -874,7 +874,7 @@ class PlaybackService : MediaBrowserServiceCompat(), LifecycleOwner, CoroutineSc
             val seekInCompactView = settings.getBoolean(SHOW_SEEK_IN_COMPACT_NOTIFICATION, false)
             val playing = isPlaying
             val sessionToken = mediaSession.sessionToken
-            val ctx = this
+            val ctx = this at PlaybackService
             val metaData = mediaSession.controller.metadata
             lifecycleScope.launch(Dispatchers.Default) {
                 delay(100)
@@ -996,7 +996,7 @@ class PlaybackService : MediaBrowserServiceCompat(), LifecycleOwner, CoroutineSc
     private suspend fun updateMetadataInternal() {
         val media = playlistManager.getCurrentMedia() ?: return
         if (!this::mediaSession.isInitialized) initMediaSession()
-        val ctx = this
+        val ctx = this at PlaybackService
         val length = length
         lastLength = length
         val chapterTitle = if (lastChaptersCount > 0) getCurrentChapter(true) else null
@@ -1021,7 +1021,7 @@ class PlaybackService : MediaBrowserServiceCompat(), LifecycleOwner, CoroutineSc
                         ?: MediaUtils.getDisplaySubtitle(ctx, media, currentMediaPosition, mediaListSize))
                 bob.putString(MediaMetadataCompat.METADATA_KEY_DISPLAY_DESCRIPTION, MediaUtils.getMediaAlbum(ctx, media))
             }
-            if (Permissions.canReadStorage(this at PlaybackService) && coverOnLockscreen) {
+            if (Permissions.canReadStorage(ctx) && coverOnLockscreen) {
                 val albumArtUri = when {
                     isSchemeHttpOrHttps(media.artworkMrl) -> {
                         //ArtworkProvider will cache remote images
@@ -1241,7 +1241,7 @@ class PlaybackService : MediaBrowserServiceCompat(), LifecycleOwner, CoroutineSc
         if (isVideoPlaying) return
         if (lifecycleScope.isActive) lifecycleScope.launch(Dispatchers.Default) {
             sendBroadcast(Intent("com.android.music.metachanged")
-                    .putExtra("track", media?.nowPlaying ?: media?.title ?: null)
+                    .putExtra("track", media?.nowPlaying ?: media?.title)
                     .putExtra("artist", if (media != null) MediaUtils.getMediaArtist(this at PlaybackService, media) else null)
                     .putExtra("album", if (media != null) MediaUtils.getMediaAlbum(this at PlaybackService, media) else null)
                     .putExtra("duration", media?.length ?: 0)
diff --git a/application/vlc-android/src/org/videolan/vlc/StartActivity.kt b/application/vlc-android/src/org/videolan/vlc/StartActivity.kt
index 7f25f2798e..c0e6585b61 100644
--- a/application/vlc-android/src/org/videolan/vlc/StartActivity.kt
+++ b/application/vlc-android/src/org/videolan/vlc/StartActivity.kt
@@ -160,7 +160,7 @@ class StartActivity : FragmentActivity() {
                 startApplication(tv, firstRun, upgrade, 0, removeOldDevices)
             else if (path == "/$TV_CHANNEL_PATH_VIDEO") {
                 var id = java.lang.Long.valueOf(data.getQueryParameter(TV_CHANNEL_QUERY_VIDEO_ID)!!)
-                val ctx = this
+                val ctx = this at StartActivity
                 lifecycleScope.launch(Dispatchers.IO) {
                     id = checkWatchNextId(ctx, id)
                     withContext(Dispatchers.Main) {



More information about the Android mailing list