[Android] TV: Fix NPE for network browsing

Geoffrey Métais git at videolan.org
Mon Sep 23 18:10:39 CEST 2019


vlc-android | branch: 3.2.x | Geoffrey Métais <geoffrey.metais at gmail.com> | Mon Sep 16 10:25:37 2019 +0200| [4d276e7eac5e7ec4bed2de2654a74362aabc96bf] | committer: Geoffrey Métais

TV: Fix NPE for network browsing

(cherry picked from commit 5e6557c578c90d57ea841cdfd341efde16ac34b9)

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

 .../org/videolan/vlc/gui/tv/browser/FileBrowserTvFragment.kt | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/tv/browser/FileBrowserTvFragment.kt b/vlc-android/src/org/videolan/vlc/gui/tv/browser/FileBrowserTvFragment.kt
index cdb0fcbbe..96f431e2f 100644
--- a/vlc-android/src/org/videolan/vlc/gui/tv/browser/FileBrowserTvFragment.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/tv/browser/FileBrowserTvFragment.kt
@@ -145,17 +145,17 @@ class FileBrowserTvFragment : BaseBrowserTvFragment(), PathAdapterListener {
 
     override fun onStart() {
         super.onStart()
-        setBreadcrumb(viewModel.currentItem as MediaWrapper)
+        (viewModel.currentItem as? MediaWrapper).setBreadcrumb()
     }
 
-    private fun setBreadcrumb(media: MediaWrapper) {
-        val ariane = requireActivity().findViewById<RecyclerView>(org.videolan.vlc.R.id.ariane)
+    private fun MediaWrapper?.setBreadcrumb() {
+        if (this == null) return
+        val ariane = requireActivity().findViewById<RecyclerView>(R.id.ariane)
                 ?: return
-
-        if (isSchemeSupported(media.uri?.scheme)) {
+        if (isSchemeSupported(uri?.scheme)) {
             ariane.visibility = View.VISIBLE
             ariane.layoutManager = LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false)
-            ariane.adapter = PathAdapter(this, media)
+            ariane.adapter = PathAdapter(this at FileBrowserTvFragment, this)
             if (ariane.itemDecorationCount == 0) {
                 val did = object : DividerItemDecoration(requireContext(), HORIZONTAL) {
                     override fun getItemOffsets(outRect: Rect, view: View, parent: RecyclerView, state: RecyclerView.State) {



More information about the Android mailing list