[Android] MediaParsingService: sanity check
Geoffrey Métais
git at videolan.org
Tue Feb 11 16:00:57 CET 2020
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Tue Feb 11 11:53:16 2020 +0100| [a5bc0ea0f718dc402d5f97b5a149fb4eb0ec79c6] | committer: Geoffrey Métais
MediaParsingService: sanity check
> https://code.videolan.org/videolan/vlc-android/commit/a5bc0ea0f718dc402d5f97b5a149fb4eb0ec79c6
---
.../src/org/videolan/vlc/MediaParsingService.kt | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/application/vlc-android/src/org/videolan/vlc/MediaParsingService.kt b/application/vlc-android/src/org/videolan/vlc/MediaParsingService.kt
index 7c3adf8b1..6e26eb46a 100644
--- a/application/vlc-android/src/org/videolan/vlc/MediaParsingService.kt
+++ b/application/vlc-android/src/org/videolan/vlc/MediaParsingService.kt
@@ -176,11 +176,11 @@ class MediaParsingService : LifecycleService(), DevicesDiscoveryCb, LifecycleOwn
val parse = intent.getBooleanExtra(EXTRA_PARSE, true)
setupMedialibrary(upgrade, parse)
}
- ACTION_RELOAD -> actions.offer(Reload(intent.getStringExtra(EXTRA_PATH)))
- ACTION_FORCE_RELOAD -> actions.offer(ForceReload)
+ ACTION_RELOAD -> actions.safeOffer(Reload(intent.getStringExtra(EXTRA_PATH)))
+ ACTION_FORCE_RELOAD -> actions.safeOffer(ForceReload)
ACTION_DISCOVER -> discover(intent.getStringExtra(EXTRA_PATH))
ACTION_DISCOVER_DEVICE -> discoverStorage(intent.getStringExtra(EXTRA_PATH))
- ACTION_CHECK_STORAGES -> if (settings.getInt(KEY_MEDIALIBRARY_SCAN, -1) != ML_SCAN_OFF) actions.offer(UpdateStorages) else exitCommand()
+ ACTION_CHECK_STORAGES -> if (settings.getInt(KEY_MEDIALIBRARY_SCAN, -1) != ML_SCAN_OFF) actions.safeOffer(UpdateStorages) else exitCommand()
else -> {
exitCommand()
return START_NOT_STICKY
@@ -202,7 +202,7 @@ class MediaParsingService : LifecycleService(), DevicesDiscoveryCb, LifecycleOwn
return
}
discoverTriggered = true
- actions.offer(DiscoverStorage(path))
+ actions.safeOffer(DiscoverStorage(path))
}
private fun discover(path: String) {
@@ -210,7 +210,7 @@ class MediaParsingService : LifecycleService(), DevicesDiscoveryCb, LifecycleOwn
exitCommand()
return
}
- actions.offer(DiscoverFolder(path))
+ actions.safeOffer(DiscoverFolder(path))
}
private fun addDeviceIfNeeded(path: String) {
@@ -243,8 +243,8 @@ class MediaParsingService : LifecycleService(), DevicesDiscoveryCb, LifecycleOwn
private fun setupMedialibrary(upgrade: Boolean, parse: Boolean) {
if (medialibrary.isInitiated) {
medialibrary.resumeBackgroundOperations()
- if (parse && !scanActivated) actions.offer(StartScan(upgrade))
- } else actions.offer(Init(upgrade, parse))
+ if (parse && !scanActivated) actions.safeOffer(StartScan(upgrade))
+ } else actions.safeOffer(Init(upgrade, parse))
}
private suspend fun initMedialib(parse: Boolean, context: Context, shouldInit: Boolean, upgrade: Boolean) {
@@ -366,7 +366,7 @@ class MediaParsingService : LifecycleService(), DevicesDiscoveryCb, LifecycleOwn
override fun onDiscoveryProgress(entryPoint: String) {
if (BuildConfig.DEBUG) Log.v(TAG, "onDiscoveryProgress: $entryPoint")
currentDiscovery = entryPoint
- notificationActor.offer(Show)
+ notificationActor.safeOffer(Show)
}
override fun onDiscoveryCompleted(entryPoint: String) {
@@ -376,7 +376,7 @@ class MediaParsingService : LifecycleService(), DevicesDiscoveryCb, LifecycleOwn
override fun onParsingStatsUpdated(percent: Int) {
if (BuildConfig.DEBUG) Log.v(TAG, "onParsingStatsUpdated: $percent")
parsing = percent
- if (parsing != 100) notificationActor.offer(Show)
+ if (parsing != 100) notificationActor.safeOffer(Show)
}
override fun onReloadStarted(entryPoint: String) {
@@ -400,7 +400,7 @@ class MediaParsingService : LifecycleService(), DevicesDiscoveryCb, LifecycleOwn
} catch (e: Exception) {
if (BuildConfig.DEBUG) Log.d(this::class.java.simpleName, "${e.cause}")
}
- notificationActor.offer(Hide)
+ notificationActor.safeOffer(Hide)
stopForeground(true)
stopService(Intent(applicationContext, MediaParsingService::class.java))
}
More information about the Android
mailing list