[Android] TV: Fix NPE for network browsing

Geoffrey Métais git at videolan.org
Mon Sep 16 16:06:21 CEST 2019


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

TV: Fix NPE for network browsing

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

 .../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