[Android] TV: Focus helper for player advanced options

Geoffrey Métais git at videolan.org
Thu Jan 24 17:29:05 CET 2019


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Thu Jan 24 17:28:07 2019 +0100| [0b8b4ec9c7a18d071402833a472d3b5e79125f9d] | committer: Geoffrey Métais

TV: Focus helper for player advanced options

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

 .../src/org/videolan/vlc/gui/helpers/PlayerOptionsDelegate.kt       | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/vlc-android/src/org/videolan/vlc/gui/helpers/PlayerOptionsDelegate.kt b/vlc-android/src/org/videolan/vlc/gui/helpers/PlayerOptionsDelegate.kt
index a1e066d64..7bd71894b 100644
--- a/vlc-android/src/org/videolan/vlc/gui/helpers/PlayerOptionsDelegate.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/helpers/PlayerOptionsDelegate.kt
@@ -22,6 +22,7 @@ import androidx.lifecycle.OnLifecycleEvent
 import androidx.recyclerview.widget.LinearLayoutManager
 import androidx.recyclerview.widget.RecyclerView
 import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.delay
 import kotlinx.coroutines.launch
 import org.videolan.vlc.PlaybackService
 import org.videolan.vlc.R
@@ -128,6 +129,11 @@ class PlayerOptionsDelegate(val activity: AppCompatActivity, val service: Playba
             setup()
         }
         rootView.visibility = View.VISIBLE
+        if (AndroidDevices.showTvUi(activity)) AppScope.launch {
+            delay(100L)
+            val position = (recyclerview.layoutManager as LinearLayoutManager).findFirstVisibleItemPosition()
+            (recyclerview.layoutManager as LinearLayoutManager).findViewByPosition(position)?.requestFocus()
+        }
     }
 
     fun hide() {



More information about the Android mailing list