[Android] Fix header list on TV not displayed in grid

Nicolas Pomepuy git at videolan.org
Thu Jun 13 14:44:56 CEST 2019


vlc-android | branch: master | Nicolas Pomepuy <nicolas.pomepuy at gmail.com> | Tue Jun 11 15:09:21 2019 +0200| [3dea7c05688ca4f2670a2a863fe70d0cd5e1f1a9] | committer: Geoffrey Métais

Fix header list on TV not displayed in grid

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

 .../src/org/videolan/vlc/gui/tv/MediaHeaderAdapter.kt        | 12 ++++++------
 .../org/videolan/vlc/gui/tv/browser/FileBrowserTvFragment.kt |  2 +-
 .../videolan/vlc/gui/tv/browser/MediaBrowserTvFragment.kt    |  2 +-
 3 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/tv/MediaHeaderAdapter.kt b/vlc-android/src/org/videolan/vlc/gui/tv/MediaHeaderAdapter.kt
index 0bf63c136..1adced6b2 100644
--- a/vlc-android/src/org/videolan/vlc/gui/tv/MediaHeaderAdapter.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/tv/MediaHeaderAdapter.kt
@@ -11,26 +11,26 @@ import org.videolan.vlc.databinding.SongHeaderItemBinding
 
 class MediaHeaderAdapter(private val onHeaderSelected: OnHeaderSelected) : RecyclerView.Adapter<MediaHeaderAdapter.ViewHolder>() {
 
-    val alphaItems = listOf("A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "#")
+    private val alphaItems = listOf("A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "#")
 
     var sortType = Medialibrary.SORT_ALPHA
 
     var items = ArrayList<String>()
 
-    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MediaHeaderAdapter.ViewHolder {
+    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
         return ViewHolder(DataBindingUtil.inflate(LayoutInflater.from(parent.context), R.layout.song_header_item, parent, false) as SongHeaderItemBinding)
     }
 
     override fun getItemCount(): Int {
         return when (sortType) {
-            Medialibrary.SORT_ALPHA -> alphaItems.size
+            Medialibrary.SORT_ALPHA, Medialibrary.SORT_DEFAULT -> alphaItems.size
             else -> items.size
         }
     }
 
-    override fun onBindViewHolder(holder: MediaHeaderAdapter.ViewHolder, position: Int) {
+    override fun onBindViewHolder(holder: ViewHolder, position: Int) {
 
-        if (sortType == Medialibrary.SORT_ALPHA) {
+        if (sortType == Medialibrary.SORT_ALPHA || sortType == Medialibrary.SORT_DEFAULT) {
             holder.binding.headerText = alphaItems[position]
             holder.binding.hasContent = items.contains(alphaItems[position])
         } else {
@@ -40,7 +40,7 @@ class MediaHeaderAdapter(private val onHeaderSelected: OnHeaderSelected) : Recyc
     }
 
     fun getItem(position: Int): String {
-        return if (sortType == Medialibrary.SORT_ALPHA) {
+        return if (sortType == Medialibrary.SORT_ALPHA || sortType == Medialibrary.SORT_DEFAULT) {
             alphaItems[position]
         } else {
             items[position]
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 e083e240c..809ca1e57 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
@@ -69,7 +69,7 @@ class FileBrowserTvFragment : BaseBrowserTvFragment() {
             if (BuildConfig.DEBUG) Log.d("FileBrowserTvFragment", "Submit lis of ${items.size} items")
 
             //headers
-            val nbColumns = if ((viewModel as BrowserModel).sort == Medialibrary.SORT_ALPHA) 9 else 1
+            val nbColumns = if ((viewModel as BrowserModel).sort == Medialibrary.SORT_ALPHA || (viewModel as BrowserModel).sort == Medialibrary.SORT_DEFAULT) 9 else 1
 
             headerList.layoutManager = GridLayoutManager(requireActivity(), nbColumns)
             headerAdapter.sortType = (viewModel as BrowserModel).sort
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 d1d08e2cd..4deb25c78 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
@@ -67,7 +67,7 @@ class MediaBrowserTvFragment : BaseBrowserTvFragment() {
             submitList(items)
 
             //headers
-            val nbColumns = if ((viewModel as MediaBrowserViewModel).sort == Medialibrary.SORT_ALPHA) 9 else 1
+            val nbColumns = if ((viewModel as MediaBrowserViewModel).sort == Medialibrary.SORT_ALPHA || (viewModel as MediaBrowserViewModel).sort == Medialibrary.SORT_DEFAULT) 9 else 1
 
             headerList.layoutManager = GridLayoutManager(requireActivity(), nbColumns)
             headerAdapter.sortType = (viewModel as MediaBrowserViewModel).sort



More information about the Android mailing list