[Android] Scan: hide notification when parsing finishes
Duncan McNamara
git at videolan.org
Tue Mar 29 05:46:51 UTC 2022
vlc-android | branch: master | Duncan McNamara <dcn.mcnamara at gmail.com> | Wed Mar 23 16:46:34 2022 +0100| [478c4a5b7cff31ae03d01201974b8d98cc871800] | committer: Nicolas Pomepuy
Scan: hide notification when parsing finishes
Fixes #2441
> https://code.videolan.org/videolan/vlc-android/commit/478c4a5b7cff31ae03d01201974b8d98cc871800
---
.../vlc-android/src/org/videolan/vlc/MediaParsingService.kt | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/application/vlc-android/src/org/videolan/vlc/MediaParsingService.kt b/application/vlc-android/src/org/videolan/vlc/MediaParsingService.kt
index 6f7867edb..755a1a7df 100644
--- a/application/vlc-android/src/org/videolan/vlc/MediaParsingService.kt
+++ b/application/vlc-android/src/org/videolan/vlc/MediaParsingService.kt
@@ -70,7 +70,6 @@ class MediaParsingService : LifecycleService(), DevicesDiscoveryCb {
private val binder = LocalBinder()
private lateinit var medialibrary: Medialibrary
- private var parsing = 0F
private var reload = 0
private var currentDiscovery: String? = null
@Volatile private var lastNotificationTime = 0L
@@ -353,8 +352,9 @@ class MediaParsingService : LifecycleService(), DevicesDiscoveryCb {
private suspend fun showNotification(done:Int, scheduled: Int) {
val currentTime = System.currentTimeMillis()
- if (lastNotificationTime == -1L || currentTime - lastNotificationTime < NOTIFICATION_DELAY) return
+ if ((lastNotificationTime == -1L && done != 0) || currentTime - lastNotificationTime < NOTIFICATION_DELAY) return
lastNotificationTime = currentTime
+ val parsing = (done.toFloat() / scheduled.toFloat() * 100F)
val discovery = withContext(Dispatchers.Default) {
val progressText = when {
inDiscovery -> getString(R.string.ml_discovering) + " " + Uri.decode(currentDiscovery?.removeFileProtocole())
@@ -402,8 +402,9 @@ class MediaParsingService : LifecycleService(), DevicesDiscoveryCb {
override fun onParsingStatsUpdated(done: Int, scheduled:Int) {
lastDone = done
lastScheduled = scheduled
- parsing = (done.toFloat() / scheduled.toFloat() * 100F)
- if (parsing != 100F && ::notificationActor.isInitialized) notificationActor.trySend(Show(done, scheduled))
+ val doneParsing = (done == scheduled)
+ if (!doneParsing && ::notificationActor.isInitialized) notificationActor.trySend(Show(done, scheduled))
+ else if (doneParsing && ::notificationActor.isInitialized) notificationActor.trySend(Hide)
}
override fun onReloadStarted(entryPoint: String) {
More information about the Android
mailing list