[Android] Fix TV first item not correctly focused

Nicolas Pomepuy git at videolan.org
Mon Aug 2 05:50:04 UTC 2021


vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Tue Jul 27 08:29:18 2021 +0200| [d94fbb0f0e1648b40be3aee65f5c346788a96738] | committer: Nicolas Pomepuy

Fix TV first item not correctly focused

Fixes #2109

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

 .../main/java/org/videolan/television/ui/FileTvItemAdapter.kt  | 10 ++++++----
 1 file changed, 6 insertions(+), 4 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 ff05b7195..e3162e57f 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
@@ -141,10 +141,12 @@ class FileTvItemAdapter(private val eventsHandler: IEventsHandler<MediaLibraryIt
                 }
             binding.container.layoutParams.width = itemSize
             binding.container.onFocusChangeListener = View.OnFocusChangeListener { _, hasFocus ->
-                TvAdapterUtils.itemFocusChange(hasFocus, itemSize, binding.container, false) {
-                    if (layoutPosition in dataset.indices) {
-                        eventsHandler.onItemFocused(binding.root, getItem(layoutPosition))
-                        focusListener?.onFocusChanged(layoutPosition)
+                binding.container.post {
+                    TvAdapterUtils.itemFocusChange(hasFocus, itemSize, binding.container, false) {
+                        if (layoutPosition in dataset.indices) {
+                            eventsHandler.onItemFocused(binding.root, getItem(layoutPosition))
+                            focusListener?.onFocusChanged(layoutPosition)
+                        }
                     }
                 }
             }



More information about the Android mailing list