[Android] Fix TV grid bug and resume position

Nicolas Pomepuy git at videolan.org
Wed Jul 31 15:21:05 CEST 2019


vlc-android | branch: 3.2.x | Nicolas Pomepuy <nicolas.pomepuy at gmail.com> | Tue Jul 30 14:20:09 2019 +0200| [54a7d5d6b970e2fb0f8ff41163f5e6934d5a232f] | committer: Geoffrey Métais

Fix TV grid bug and resume position

(cherry picked from commit 889bc822f5a2b8590f8a50fd76b550e164a02ec2)

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

 vlc-android/src/org/videolan/vlc/gui/tv/FileTvItemAdapter.kt   | 10 ----------
 .../org/videolan/vlc/gui/tv/browser/FileBrowserTvFragment.kt   |  9 ++++++++-
 2 files changed, 8 insertions(+), 11 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/tv/FileTvItemAdapter.kt b/vlc-android/src/org/videolan/vlc/gui/tv/FileTvItemAdapter.kt
index 091607650..fac2d49a7 100644
--- a/vlc-android/src/org/videolan/vlc/gui/tv/FileTvItemAdapter.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/tv/FileTvItemAdapter.kt
@@ -65,16 +65,6 @@ class FileTvItemAdapter(type: Int, private val eventsHandler: IEventsHandler, va
         }
     }
 
-    override fun onBindViewHolder(holder: MediaTvItemAdapter.AbstractMediaItemViewHolder<MediaBrowserTvItemBinding>, position: Int, payloads: MutableList<Any>) {
-        if (payloads.isNullOrEmpty()) onBindViewHolder(holder, position)
-        else if ((payloads[0] as? Int) == UPDATE_PAYLOAD) {
-            getItem(position).let {
-                holder.binding.title.text = it.title
-                holder.binding.description = it.title
-            }
-        }
-    }
-
     override fun hasSections() = true
 
     override fun setOnFocusChangeListener(focusListener: FocusableRecyclerView.FocusListener?) {
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 21555ae3c..ef4b75995 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
@@ -67,6 +67,7 @@ class FileBrowserTvFragment : BaseBrowserTvFragment() {
         (viewModel.provider as BrowserProvider).dataset.observe(this, Observer { items ->
             submitList(items)
             if (BuildConfig.DEBUG) Log.d("FileBrowserTvFragment", "Submit lis of ${items.size} items")
+            if (BuildConfig.DEBUG) Log.d("FileBrowserTvFragment", "header size: ${viewModel.provider.headers.size()}")
 
             //headers
             val nbColumns = if ((viewModel as BrowserModel).sort == AbstractMedialibrary.SORT_ALPHA || (viewModel as BrowserModel).sort == AbstractMedialibrary.SORT_DEFAULT) 9 else 1
@@ -83,9 +84,15 @@ class FileBrowserTvFragment : BaseBrowserTvFragment() {
             headerAdapter.notifyDataSetChanged()
         })
 
+        (viewModel as BrowserModel).provider.liveHeaders.observe(this, Observer {
+            headerAdapter.notifyDataSetChanged()
+            if (BuildConfig.DEBUG) Log.d("FileBrowserTvFragment", "header size (observe): ${viewModel.provider.headers.size()}")
+        })
+
         (viewModel as BrowserModel).getDescriptionUpdate().observe(this, Observer { pair ->
             if (BuildConfig.DEBUG) Log.d("FileBrowserTvFragment", "Description update: ${pair.first} ${pair.second}")
-            if (pair != null) (adapter as RecyclerView.Adapter<*>).notifyItemChanged(pair.first, pair.second)
+            if (BuildConfig.DEBUG) Log.d("FileBrowserTvFragment", "header size (desc): ${viewModel.provider.headers.size()}")
+            if (pair != null) (adapter as RecyclerView.Adapter<*>).notifyItemChanged(pair.first)
         })
 
         (viewModel as BrowserModel).loading.observe(this, Observer {



More information about the Android mailing list