[Android] TV file browser empty view

Nicolas Pomepuy git at videolan.org
Wed Sep 18 16:11:33 CEST 2019


vlc-android | branch: master | Nicolas Pomepuy <nicolas.pomepuy at gmail.com> | Wed Sep 18 11:21:48 2019 +0200| [4b24528fb1f4caef0b0ea41dd6b8f5968f78e535] | committer: Geoffrey Métais

TV file browser empty view

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

 vlc-android/res/layout/song_browser.xml            | 22 ++++++++++++++++++++++
 .../vlc/gui/tv/browser/BaseBrowserTvFragment.kt    |  1 +
 .../vlc/gui/tv/browser/FileBrowserTvFragment.kt    |  6 +++++-
 .../vlc/gui/tv/browser/MediaBrowserTvFragment.kt   |  2 ++
 4 files changed, 30 insertions(+), 1 deletion(-)

diff --git a/vlc-android/res/layout/song_browser.xml b/vlc-android/res/layout/song_browser.xml
index 8d12b59c7..94529ffbc 100644
--- a/vlc-android/res/layout/song_browser.xml
+++ b/vlc-android/res/layout/song_browser.xml
@@ -10,6 +10,10 @@
         <variable
             name="loading"
             type="boolean" />
+
+        <variable
+                name="empty"
+                type="boolean" />
     </data>
 
     <androidx.constraintlayout.widget.ConstraintLayout
@@ -18,6 +22,24 @@
         android:layout_height="match_parent"
         tools:theme="@style/Theme.VLC.TV">
 
+        <TextView
+                android:id="@+id/textview_nomedia"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_margin="@dimen/default_margin"
+                android:drawableTop="@drawable/ic_no_media"
+                android:drawablePadding="@dimen/default_margin"
+                android:gravity="center"
+                android:maxWidth="600dp"
+                android:text="@string/nomedia"
+                android:textSize="22sp"
+                android:visibility="@{empty ? View.VISIBLE : View.GONE, default=gone}"
+                app:layout_constraintBottom_toBottomOf="@+id/list"
+                app:layout_constraintLeft_toLeftOf="parent"
+                app:layout_constraintRight_toRightOf="parent"
+                app:layout_constraintTop_toTopOf="parent"
+                app:layout_constraintVertical_chainStyle="packed" />
+
         <FrameLayout
             android:id="@+id/headerListContainer"
             android:layout_width="match_parent"
diff --git a/vlc-android/src/org/videolan/vlc/gui/tv/browser/BaseBrowserTvFragment.kt b/vlc-android/src/org/videolan/vlc/gui/tv/browser/BaseBrowserTvFragment.kt
index e43e9b85e..fb4f27408 100644
--- a/vlc-android/src/org/videolan/vlc/gui/tv/browser/BaseBrowserTvFragment.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/tv/browser/BaseBrowserTvFragment.kt
@@ -90,6 +90,7 @@ abstract class BaseBrowserTvFragment : Fragment(), BrowserFragmentInterface, IEv
 
     override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
         binding = SongBrowserBinding.inflate(inflater, container, false)
+        binding.empty = false
         return binding.root
     }
 
diff --git a/vlc-android/src/org/videolan/vlc/gui/tv/browser/FileBrowserTvFragment.kt b/vlc-android/src/org/videolan/vlc/gui/tv/browser/FileBrowserTvFragment.kt
index fead9d144..64147ea85 100644
--- a/vlc-android/src/org/videolan/vlc/gui/tv/browser/FileBrowserTvFragment.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/tv/browser/FileBrowserTvFragment.kt
@@ -34,7 +34,10 @@ import org.videolan.vlc.util.CATEGORY
 import org.videolan.vlc.util.FileUtils
 import org.videolan.vlc.util.ITEM
 import org.videolan.vlc.util.isSchemeSupported
-import org.videolan.vlc.viewmodels.browser.*
+import org.videolan.vlc.viewmodels.browser.BrowserModel
+import org.videolan.vlc.viewmodels.browser.NetworkModel
+import org.videolan.vlc.viewmodels.browser.TYPE_FILE
+import org.videolan.vlc.viewmodels.browser.TYPE_NETWORK
 
 private const val TAG = "FileBrowserTvFragment"
 @UseExperimental(ObsoleteCoroutinesApi::class)
@@ -108,6 +111,7 @@ class FileBrowserTvFragment : BaseBrowserTvFragment(), PathAdapterListener {
                     }
                 }
             }
+            binding.empty = if (isRootLevel && getCategory() == TYPE_NETWORK) false else items.isEmpty()
             if (BuildConfig.DEBUG) Log.d(TAG, "Submit list of ${items.size} items")
             if (BuildConfig.DEBUG) Log.d(TAG, "header size: ${viewModel.provider.headers.size()}")
 
diff --git a/vlc-android/src/org/videolan/vlc/gui/tv/browser/MediaBrowserTvFragment.kt b/vlc-android/src/org/videolan/vlc/gui/tv/browser/MediaBrowserTvFragment.kt
index dec1e683e..55e76c24a 100644
--- a/vlc-android/src/org/videolan/vlc/gui/tv/browser/MediaBrowserTvFragment.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/tv/browser/MediaBrowserTvFragment.kt
@@ -74,6 +74,8 @@ class MediaBrowserTvFragment : BaseBrowserTvFragment() {
         (viewModel.provider as MedialibraryProvider<*>).pagedList.observe(this, Observer { items ->
             submitList(items)
 
+            binding.empty = items.isEmpty()
+
             //headers
             val nbColumns = if ((viewModel as MediaBrowserViewModel).sort == AbstractMedialibrary.SORT_ALPHA || (viewModel as MediaBrowserViewModel).sort == AbstractMedialibrary.SORT_DEFAULT) 9 else 1
 



More information about the Android mailing list