[Android] MedialibProvider: No need for observable delegate

Geoffrey Métais git at videolan.org
Mon Jul 29 16:37:19 CEST 2019


vlc-android | branch: 3.2.x | Geoffrey Métais <geoffrey.metais at gmail.com> | Mon Jul 29 16:34:36 2019 +0200| [c711e098c58e533fb2a72bbcb927cc3b80b883a4] | committer: Geoffrey Métais

MedialibProvider: No need for observable delegate

(cherry picked from commit b84b7115ce2373515fe8e30e997d3ca0fddc1314)

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

 .../videolan/vlc/providers/medialibrary/MedialibraryProvider.kt   | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/providers/medialibrary/MedialibraryProvider.kt b/vlc-android/src/org/videolan/vlc/providers/medialibrary/MedialibraryProvider.kt
index deb36e665..c58739be0 100644
--- a/vlc-android/src/org/videolan/vlc/providers/medialibrary/MedialibraryProvider.kt
+++ b/vlc-android/src/org/videolan/vlc/providers/medialibrary/MedialibraryProvider.kt
@@ -34,7 +34,6 @@ import org.videolan.medialibrary.media.MediaLibraryItem
 import org.videolan.vlc.providers.HeaderProvider
 import org.videolan.vlc.util.*
 import org.videolan.vlc.viewmodels.SortableModel
-import kotlin.properties.Delegates
 
 abstract class MedialibraryProvider<T : MediaLibraryItem>(val context: Context, val scope: SortableModel) : HeaderProvider(),
         ISortModel
@@ -43,8 +42,11 @@ abstract class MedialibraryProvider<T : MediaLibraryItem>(val context: Context,
     protected val medialibrary = AbstractMedialibrary.getInstance()
     private lateinit var dataSource : DataSource<Int, T>
     val loading = MutableLiveData<Boolean>().apply { value = true }
-    var isRefreshing by Delegates.observable(false) { _,_, value -> loading.postValue(value || medialibrary.isWorking) }
-        private set
+    var isRefreshing = medialibrary.isWorking
+        private set(value) {
+            loading.postValue(value || medialibrary.isWorking)
+            field = value
+        }
 
     protected open val sortKey : String = this.javaClass.simpleName
     var sort = settings.getInt(sortKey, AbstractMedialibrary.SORT_DEFAULT)



More information about the Android mailing list