[Android] Monitor updated media thumbnails
Geoffrey Métais
git at videolan.org
Wed Apr 4 18:35:32 CEST 2018
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Tue Mar 20 16:40:42 2018 +0100| [95d99a4abe258006645df00f4f473afa61d0f34f] | committer: Geoffrey Métais
Monitor updated media thumbnails
> https://code.videolan.org/videolan/vlc-android/commit/95d99a4abe258006645df00f4f473afa61d0f34f
---
vlc-android/src/org/videolan/vlc/viewmodels/VideosProvider.kt | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/vlc-android/src/org/videolan/vlc/viewmodels/VideosProvider.kt b/vlc-android/src/org/videolan/vlc/viewmodels/VideosProvider.kt
index 82767570b..204c0af7d 100644
--- a/vlc-android/src/org/videolan/vlc/viewmodels/VideosProvider.kt
+++ b/vlc-android/src/org/videolan/vlc/viewmodels/VideosProvider.kt
@@ -20,6 +20,7 @@
package org.videolan.vlc.viewmodels
+import android.arch.lifecycle.Observer
import android.arch.lifecycle.ViewModel
import android.arch.lifecycle.ViewModelProvider
import kotlinx.coroutines.experimental.CommonPool
@@ -35,6 +36,12 @@ class VideosProvider(private val group: String?) : MedialibraryModel<MediaWrappe
override fun canSortByDuration() = true
override fun canSortByLastModified() = true
+ private val thumbObs = Observer<MediaWrapper> { media -> updateActor.offer(MediaUpdate(listOf(media!!))) }
+
+ init {
+ Medialibrary.lastThumb.observeForever(thumbObs)
+ }
+
override fun onMediaAdded(mediaList: Array<out MediaWrapper>?) {
if (!Util.isArrayEmpty<MediaWrapper>(mediaList)) updateActor.offer(MediaListAddition(mediaList!!.filter { it.type == MediaWrapper.TYPE_VIDEO }))
}
@@ -70,6 +77,7 @@ class VideosProvider(private val group: String?) : MedialibraryModel<MediaWrappe
super.onCleared()
medialibrary.removeMediaAddedCb()
medialibrary.removeMediaUpdatedCb()
+ Medialibrary.lastThumb.removeObserver(thumbObs)
}
class Factory(val group: String?): ViewModelProvider.NewInstanceFactory() {
More information about the Android
mailing list