[Android] Fix TV key events forwarded to the wrong fragment

Nicolas Pomepuy git at videolan.org
Mon Nov 23 13:24:29 CET 2020


vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Wed Nov 18 10:16:53 2020 +0100| [f5a8984e898f6a8d061464330e696d7cd0e112d8] | committer: Nicolas Pomepuy

Fix TV key events forwarded to the wrong fragment

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

 .../java/org/videolan/television/ui/browser/VerticalGridActivity.kt  | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/application/television/src/main/java/org/videolan/television/ui/browser/VerticalGridActivity.kt b/application/television/src/main/java/org/videolan/television/ui/browser/VerticalGridActivity.kt
index b08a12a6b..48f02088b 100644
--- a/application/television/src/main/java/org/videolan/television/ui/browser/VerticalGridActivity.kt
+++ b/application/television/src/main/java/org/videolan/television/ui/browser/VerticalGridActivity.kt
@@ -101,8 +101,11 @@ class VerticalGridActivity : BaseTvActivity(), BrowserActivityInterface {
                 (fragment as DetailsFragment).showDetails()
                 return true
             }
-            if ((fragment as? OnKeyPressedListener)?.onKeyPressed(keyCode) == true) {
+            try {
+                if ((supportFragmentManager.fragments[0] as? OnKeyPressedListener)?.onKeyPressed(keyCode) == true) {
                     return true
+                }
+            } catch (e: IndexOutOfBoundsException) {
             }
         }
         return super.onKeyDown(keyCode, event)



More information about the Android mailing list