[Android] Fix TV list progress refresh when coming back from the player

Nicolas Pomepuy git at videolan.org
Wed Feb 9 14:56:38 UTC 2022


vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Mon Jan 17 14:11:16 2022 +0100| [3cce2fa6e0d2a6c37b483aa08e27f9ab7dd638ff] | committer: Nicolas Pomepuy

Fix TV list progress refresh when coming back from the player

Fixes #2317

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

 .../java/org/videolan/television/ui/FileTvItemAdapter.kt     |  4 ++--
 .../java/org/videolan/television/ui/MediaTvItemAdapter.kt    | 12 ++++--------
 2 files changed, 6 insertions(+), 10 deletions(-)

diff --git a/application/television/src/main/java/org/videolan/television/ui/FileTvItemAdapter.kt b/application/television/src/main/java/org/videolan/television/ui/FileTvItemAdapter.kt
index 450dec69f..27feaa37b 100644
--- a/application/television/src/main/java/org/videolan/television/ui/FileTvItemAdapter.kt
+++ b/application/television/src/main/java/org/videolan/television/ui/FileTvItemAdapter.kt
@@ -85,8 +85,8 @@ class FileTvItemAdapter(private val eventsHandler: IEventsHandler<MediaLibraryIt
         if (payloads.isNullOrEmpty()) onBindViewHolder(holder, position)
         else for (payload in payloads) {
             when (holder.binding) {
-                is MediaBrowserTvItemBinding -> (holder.binding as MediaBrowserTvItemBinding).description = if (payload is String) payload else getItem(position).description
-                is MediaBrowserTvItemListBinding -> (holder.binding as MediaBrowserTvItemListBinding).description = if (payload is String) payload else getItem(position).description
+                is MediaBrowserTvItemBinding -> if (payload is String) (holder.binding as MediaBrowserTvItemBinding).description =  payload else onBindViewHolder(holder, position)
+                is MediaBrowserTvItemListBinding -> if (payload is String) (holder.binding as MediaBrowserTvItemListBinding).description = payload else onBindViewHolder(holder, position)
             }
 
         }
diff --git a/application/television/src/main/java/org/videolan/television/ui/MediaTvItemAdapter.kt b/application/television/src/main/java/org/videolan/television/ui/MediaTvItemAdapter.kt
index b0052450a..fd5fed0de 100644
--- a/application/television/src/main/java/org/videolan/television/ui/MediaTvItemAdapter.kt
+++ b/application/television/src/main/java/org/videolan/television/ui/MediaTvItemAdapter.kt
@@ -24,6 +24,7 @@ import org.videolan.medialibrary.interfaces.media.MediaWrapper
 import org.videolan.medialibrary.media.MediaLibraryItem
 import org.videolan.resources.R
 import org.videolan.resources.UPDATE_PAYLOAD
+import org.videolan.resources.UPDATE_SELECTION
 import org.videolan.resources.interfaces.FocusListener
 import org.videolan.television.databinding.MediaBrowserTvItemBinding
 import org.videolan.television.databinding.MediaBrowserTvItemListBinding
@@ -82,16 +83,11 @@ class MediaTvItemAdapter(type: Int, private val eventsHandler: IEventsHandler<Me
     }
 
     override fun onBindViewHolder(holder: AbstractMediaItemViewHolder<ViewDataBinding>, position: Int, payloads: List<Any>) {
-        if (payloads.isNullOrEmpty())
-            onBindViewHolder(holder, position)
-        else {
-            val payload = payloads[0]
-            if (payload is MediaLibraryItem) {
-                val isSelected = payload.hasStateFlags(MediaLibraryItem.FLAG_SELECTED)
+        if (!payloads.isNullOrEmpty() && payloads[0] is MediaLibraryItem)  {
+            val isSelected = (payloads[0] as MediaLibraryItem).hasStateFlags(MediaLibraryItem.FLAG_SELECTED)
                 holder.setCoverlay(isSelected)
                 holder.selectView(isSelected)
-            }
-        }
+        } else onBindViewHolder(holder, position)
     }
 
     override fun onViewRecycled(holder: AbstractMediaItemViewHolder<ViewDataBinding>) {



More information about the Android mailing list