[Android] TvBaseBrowser: fix selection flicker in list

Duncan McNamara git at videolan.org
Thu Sep 2 12:02:45 UTC 2021


vlc-android | branch: master | Duncan McNamara <dcn.mcnamara at gmail.com> | Tue Aug 31 21:27:23 2021 +0200| [ddb046297c3129efa07e872a4a62a648e72e7405] | committer: Nicolas Pomepuy

TvBaseBrowser: fix selection flicker in list

Add condition call to focus on the list when there is a previous
selection to stop focus from going back to the first item, and then back
to the previously selected item.

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

 .../org/videolan/television/ui/browser/BaseBrowserTvFragment.kt    | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/application/television/src/main/java/org/videolan/television/ui/browser/BaseBrowserTvFragment.kt b/application/television/src/main/java/org/videolan/television/ui/browser/BaseBrowserTvFragment.kt
index 1c7391206..b48387eb1 100644
--- a/application/television/src/main/java/org/videolan/television/ui/browser/BaseBrowserTvFragment.kt
+++ b/application/television/src/main/java/org/videolan/television/ui/browser/BaseBrowserTvFragment.kt
@@ -453,7 +453,12 @@ abstract class BaseBrowserTvFragment<T> : Fragment(), BrowserFragmentInterface,
             setFocus = false
             lifecycleScope.launchWhenStarted {
                 yield()
-                binding.list.requestFocus()
+                // If there is a previous selection, no need to request focus on the list here
+                // as it is requested for the specific item in the onLayoutChildren override above.
+                // This stops a flicker when coming back from playback.
+                if (previouslySelectedItem == -1) {
+                    binding.list.requestFocus()
+                }
             }
         }
         animationDelegate.setVisibility(binding.imageButtonHeader, if (viewModel.provider.headers.isEmpty) View.GONE else View.VISIBLE)



More information about the Android mailing list