[Android] Fix lost focus on TV jump

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


vlc-android | branch: master | Nicolas Pomepuy <nicolas.pomepuy at gmail.com> | Tue Jun 11 16:03:30 2019 +0200| [94fe89956f4851fca4e24d14fb4e162aab22c909] | committer: Geoffrey Métais

Fix lost focus on TV jump

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

 .../src/org/videolan/vlc/gui/tv/browser/BaseBrowserTvFragment.kt   | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/tv/browser/BaseBrowserTvFragment.kt b/vlc-android/src/org/videolan/vlc/gui/tv/browser/BaseBrowserTvFragment.kt
index 9b9822a59..f592c78eb 100644
--- a/vlc-android/src/org/videolan/vlc/gui/tv/browser/BaseBrowserTvFragment.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/tv/browser/BaseBrowserTvFragment.kt
@@ -43,6 +43,7 @@ import androidx.databinding.BindingAdapter
 import androidx.fragment.app.Fragment
 import androidx.leanback.app.BackgroundManager
 import androidx.recyclerview.widget.GridLayoutManager
+import androidx.recyclerview.widget.LinearLayoutManager
 import androidx.recyclerview.widget.RecyclerView
 import kotlinx.android.synthetic.main.song_browser.*
 import kotlinx.coroutines.*
@@ -303,7 +304,11 @@ abstract class BaseBrowserTvFragment : Fragment(), BrowserFragmentInterface, IEv
         hideHeaderSelectionScreen()
 
         val positionForSectionByName = viewModel.provider.getPositionForSectionByName(header)
-        if (list.getChildAt(positionForSectionByName) == null) {
+        val linearLayoutManager: LinearLayoutManager = list.layoutManager as LinearLayoutManager
+
+        val view = linearLayoutManager.findViewByPosition(positionForSectionByName)
+
+        if (view == null) {
             adapter.focusNext = positionForSectionByName
         } else {
             list.getChildAt(positionForSectionByName).requestFocus()



More information about the Android mailing list