[Android] Services: code cleaning
Geoffrey Métais
git at videolan.org
Fri Feb 14 14:03:13 CET 2020
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Thu Feb 13 17:42:21 2020 +0100| [1a8932f5775678724d10f2b46a8ec3a01771c864] | committer: Geoffrey Métais
Services: code cleaning
> https://code.videolan.org/videolan/vlc-android/commit/1a8932f5775678724d10f2b46a8ec3a01771c864
---
.../vlc-android/src/org/videolan/vlc/MediaParsingService.kt | 2 +-
.../vlc-android/src/org/videolan/vlc/PlaybackService.kt | 12 ++++--------
2 files changed, 5 insertions(+), 9 deletions(-)
diff --git a/application/vlc-android/src/org/videolan/vlc/MediaParsingService.kt b/application/vlc-android/src/org/videolan/vlc/MediaParsingService.kt
index 6e26eb46a..344159f5e 100644
--- a/application/vlc-android/src/org/videolan/vlc/MediaParsingService.kt
+++ b/application/vlc-android/src/org/videolan/vlc/MediaParsingService.kt
@@ -63,7 +63,7 @@ private const val NOTIFICATION_DELAY = 1000L
@ObsoleteCoroutinesApi
@ExperimentalCoroutinesApi
-class MediaParsingService : LifecycleService(), DevicesDiscoveryCb, LifecycleOwner {
+class MediaParsingService : LifecycleService(), DevicesDiscoveryCb {
private val dispatcher = ServiceLifecycleDispatcher(this)
private lateinit var wakeLock: PowerManager.WakeLock
diff --git a/application/vlc-android/src/org/videolan/vlc/PlaybackService.kt b/application/vlc-android/src/org/videolan/vlc/PlaybackService.kt
index 65404ccfe..7bedc7af9 100644
--- a/application/vlc-android/src/org/videolan/vlc/PlaybackService.kt
+++ b/application/vlc-android/src/org/videolan/vlc/PlaybackService.kt
@@ -991,17 +991,13 @@ class PlaybackService : MediaBrowserServiceCompat(), LifecycleOwner {
}
private fun loadLastAudioPlaylist() {
- if (AndroidDevices.isAndroidTv) return
- lifecycleScope.launch {
- awaitMedialibraryStarted()
- if (!playlistManager.loadLastPlaylist()) stopService(Intent(applicationContext, PlaybackService::class.java))
- }
+ if (!AndroidDevices.isAndroidTv) loadLastPlaylist(PLAYLIST_TYPE_AUDIO)
}
fun loadLastPlaylist(type: Int) {
lifecycleScope.launch {
awaitMedialibraryStarted()
- playlistManager.loadLastPlaylist(type)
+ if (!playlistManager.loadLastPlaylist(type)) stopService(Intent(applicationContext, PlaybackService::class.java))
}
}
@@ -1094,7 +1090,7 @@ class PlaybackService : MediaBrowserServiceCompat(), LifecycleOwner {
*/
@JvmOverloads
fun playIndex(index: Int, flags: Int = 0) {
- lifecycleScope.launch { playlistManager.playIndex(index, flags) }
+ lifecycleScope.launch(start = CoroutineStart.UNDISPATCHED) { playlistManager.playIndex(index, flags) }
}
@MainThread
@@ -1159,7 +1155,7 @@ class PlaybackService : MediaBrowserServiceCompat(), LifecycleOwner {
fun append(mediaList: Array<MediaWrapper>) = append(mediaList.toList())
@MainThread
- fun append(mediaList: List<MediaWrapper>) = lifecycleScope.launch {
+ fun append(mediaList: List<MediaWrapper>) = lifecycleScope.launch(start = CoroutineStart.UNDISPATCHED) {
playlistManager.append(mediaList)
onMediaListChanged()
}
More information about the Android
mailing list