[Android] TV: Set empty view in browsers

Geoffrey Métais git at videolan.org
Wed Dec 12 16:15:02 CET 2018


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Wed Dec 12 16:13:28 2018 +0100| [f00cc2a94e8e137b61a4fae46e4e764d04bbcf52] | committer: Geoffrey Métais

TV: Set empty view in browsers

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

 .../org/videolan/vlc/gui/tv/browser/CategoriesFragment.kt    | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/tv/browser/CategoriesFragment.kt b/vlc-android/src/org/videolan/vlc/gui/tv/browser/CategoriesFragment.kt
index 36aa9aa8b..1bc2c0374 100644
--- a/vlc-android/src/org/videolan/vlc/gui/tv/browser/CategoriesFragment.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/tv/browser/CategoriesFragment.kt
@@ -25,12 +25,12 @@ package org.videolan.vlc.gui.tv.browser
 
 import android.content.SharedPreferences
 import android.os.Bundle
+import android.view.View
+import android.widget.ImageView
+import androidx.core.content.ContextCompat
 import androidx.leanback.app.BackgroundManager
 import androidx.leanback.app.BrowseSupportFragment
 import androidx.leanback.widget.*
-import androidx.core.content.ContextCompat
-import android.view.View
-import android.widget.ImageView
 import org.videolan.medialibrary.media.MediaLibraryItem
 import org.videolan.medialibrary.media.MediaWrapper
 import org.videolan.vlc.R
@@ -98,13 +98,17 @@ open class CategoriesFragment<T : BaseModel<out MediaLibraryItem>> : BrowseSuppo
     }
 
     protected fun update(map: Map<String, List<MediaLibraryItem>>?) {
-        if (map === null) return
+        if (map.isNullOrEmpty()) {
+            (activity as? VerticalGridActivity)?.run { updateEmptyView(true) }
+            return
+        }
         val rows = mutableMapOf<String, ListRow>()
         for ((key, list) in map) {
             val row = getCategoryRow(key)
             (row.adapter as ArrayObjectAdapter).setItems(list, TvUtil.diffCallback)
             rows[key] = row
         }
+        (activity as? VerticalGridActivity)?.run { updateEmptyView(false) }
         //TODO  Activate animations once IndexOutOfRange Exception is fixed
         rowsAdapter.setItems(rows.values.toList(), null /*TvUtil.listDiffCallback*/)
         categoryRows = rows



More information about the Android mailing list