[Android] Display local favorites on TV even if there is no network connection

Nicolas Pomepuy git at videolan.org
Mon Nov 23 13:44:56 CET 2020


vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Fri Nov 13 08:55:11 2020 +0100| [fe55b5a6fda3ec738dfae0a2f942184216c4ce7d] | committer: Nicolas Pomepuy

Display local favorites on TV even if there is no network connection

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

 .../java/org/videolan/television/viewmodel/MainTvModel.kt    | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/application/television/src/main/java/org/videolan/television/viewmodel/MainTvModel.kt b/application/television/src/main/java/org/videolan/television/viewmodel/MainTvModel.kt
index 087a5fc9a..3a9508d89 100644
--- a/application/television/src/main/java/org/videolan/television/viewmodel/MainTvModel.kt
+++ b/application/television/src/main/java/org/videolan/television/viewmodel/MainTvModel.kt
@@ -58,6 +58,7 @@ import org.videolan.vlc.mediadb.models.BrowserFav
 import org.videolan.vlc.repository.BrowserFavRepository
 import org.videolan.vlc.repository.DirectoryRepository
 import org.videolan.vlc.util.convertFavorites
+import org.videolan.vlc.util.isSchemeFile
 import org.videolan.vlc.util.scanAllowed
 
 private const val NUM_ITEMS_PREVIEW = 5
@@ -75,7 +76,7 @@ class MainTvModel(app: Application) : AndroidViewModel(app), Medialibrary.OnMedi
     private val showInternalStorage = AndroidDevices.showInternalStorage()
     private val browserFavRepository = BrowserFavRepository.getInstance(context)
     private val mediaMetadataRepository = MediaMetadataRepository.getInstance(context)
-    private var updatedFavoritList: List<MediaWrapper> = listOf()
+    private var updatedFavoriteList: List<MediaWrapper> = listOf()
     var showHistory = false
         private set
     // LiveData
@@ -100,7 +101,7 @@ class MainTvModel(app: Application) : AndroidViewModel(app), Medialibrary.OnMedi
     }
 
     private val favObserver = Observer<List<BrowserFav>> { list ->
-        updatedFavoritList = convertFavorites(list)
+        updatedFavoriteList = convertFavorites(list)
         if (!updateActor.isClosedForSend) updateActor.offer(Unit)
     }
 
@@ -221,7 +222,12 @@ class MainTvModel(app: Application) : AndroidViewModel(app), Medialibrary.OnMedi
             list.add(DummyItem(HEADER_NETWORK, context.getString(R.string.network_browsing), null))
             list.add(DummyItem(HEADER_STREAM, context.getString(R.string.streams), null))
             list.add(DummyItem(HEADER_SERVER, context.getString(R.string.server_add_title), null))
-            updatedFavoritList.forEach {
+            updatedFavoriteList.forEach {
+                it.description = it.uri.scheme
+                list.add(it)
+            }
+        } else {
+            updatedFavoriteList.filter { it.uri.scheme.isSchemeFile() }.forEach {
                 it.description = it.uri.scheme
                 list.add(it)
             }



More information about the Android mailing list