[Android] Fix crash when loading subtitles

Nicolas Pomepuy git at videolan.org
Fri Apr 26 12:45:38 CEST 2019


vlc-android | branch: master | Nicolas Pomepuy <nicolas.pomepuy at gmail.com> | Wed Apr 17 12:59:06 2019 +0200| [17e2a8414a98c82410c0213d1a149afb0823ec45] | committer: Geoffrey Métais

Fix crash when loading subtitles

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

 vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.kt  | 2 +-
 vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.kt | 2 +-
 .../src/org/videolan/vlc/gui/browser/MediaBrowserFragment.kt        | 6 +++---
 .../src/org/videolan/vlc/gui/browser/NetworkBrowserFragment.kt      | 6 +++---
 vlc-android/src/org/videolan/vlc/gui/folders/FoldersFragment.kt     | 4 ++--
 5 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.kt b/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.kt
index 25129f46e..7832444f7 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.kt
@@ -206,7 +206,7 @@ class AudioBrowserFragment : BaseAudioBrowser(), SwipeRefreshLayout.OnRefreshLis
     override fun onStart() {
         super.onStart()
         setFabPlayShuffleAllVisibility()
-        fabPlay.setImageResource(R.drawable.ic_fab_shuffle)
+        fabPlay?.setImageResource(R.drawable.ic_fab_shuffle)
     }
 
     override fun onPrepareOptionsMenu(menu: Menu?) {
diff --git a/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.kt b/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.kt
index 72a6c6a81..a6297b4b7 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.kt
@@ -158,7 +158,7 @@ abstract class BaseBrowserFragment : MediaBrowserFragment<BrowserModel>(), IRefr
 
     override fun onStart() {
         super.onStart()
-        fabPlay.run {
+        fabPlay?.run {
             setImageResource(R.drawable.ic_fab_play)
             updateFab()
         }
diff --git a/vlc-android/src/org/videolan/vlc/gui/browser/MediaBrowserFragment.kt b/vlc-android/src/org/videolan/vlc/gui/browser/MediaBrowserFragment.kt
index ffd82e701..cb9058a92 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/MediaBrowserFragment.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/MediaBrowserFragment.kt
@@ -64,7 +64,7 @@ abstract class MediaBrowserFragment<T : SortableModel> : Fragment(), ActionMode.
     var swipeRefreshLayout: SwipeRefreshLayout? = null
     lateinit var mediaLibrary: Medialibrary
     var actionMode: ActionMode? = null
-    lateinit var fabPlay: FloatingActionButton
+    var fabPlay: FloatingActionButton? = null
     open lateinit var viewModel: T
         protected set
     private var restart = false
@@ -102,7 +102,7 @@ abstract class MediaBrowserFragment<T : SortableModel> : Fragment(), ActionMode.
     }
 
     protected open fun hasFAB(): Boolean {
-        return true
+        return swipeRefreshLayout != null
     }
 
     protected open fun setBreadcrumb() {
@@ -120,7 +120,7 @@ abstract class MediaBrowserFragment<T : SortableModel> : Fragment(), ActionMode.
         setBreadcrumb()
         updateActionBar()
         setFabPlayVisibility(true)
-        fabPlay.setOnClickListener { v -> onFabPlayClick(v) }
+        fabPlay?.setOnClickListener { v -> onFabPlayClick(v) }
         if (restart) onRestart()
     }
 
diff --git a/vlc-android/src/org/videolan/vlc/gui/browser/NetworkBrowserFragment.kt b/vlc-android/src/org/videolan/vlc/gui/browser/NetworkBrowserFragment.kt
index aef42e08c..905307f69 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/NetworkBrowserFragment.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/NetworkBrowserFragment.kt
@@ -98,8 +98,8 @@ class NetworkBrowserFragment : BaseBrowserFragment() {
     override fun onStart() {
         super.onStart()
         if (!isRootDirectory) LocalBroadcastManager.getInstance(VLCApplication.getAppContext()).registerReceiver(mLocalReceiver, IntentFilter(VlcLoginDialog.ACTION_DIALOG_CANCELED))
-        fabPlay.setImageResource(if (isRootDirectory) R.drawable.ic_fab_add else R.drawable.ic_fab_play)
-        fabPlay.setOnClickListener(this)
+        fabPlay?.setImageResource(if (isRootDirectory) R.drawable.ic_fab_add else R.drawable.ic_fab_play)
+        fabPlay?.setOnClickListener(this)
         setFabPlayVisibility(true)
     }
 
@@ -187,6 +187,6 @@ class NetworkBrowserFragment : BaseBrowserFragment() {
 
     override fun onUpdateFinished(adapter: RecyclerView.Adapter<*>) {
         super.onUpdateFinished(adapter)
-        if (isRootDirectory) fabPlay.show()
+        if (isRootDirectory) fabPlay?.show()
     }
 }
diff --git a/vlc-android/src/org/videolan/vlc/gui/folders/FoldersFragment.kt b/vlc-android/src/org/videolan/vlc/gui/folders/FoldersFragment.kt
index dc45cf0a5..fe24943f7 100644
--- a/vlc-android/src/org/videolan/vlc/gui/folders/FoldersFragment.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/folders/FoldersFragment.kt
@@ -85,8 +85,8 @@ class FoldersFragment : MediaBrowserFragment<PagedFoldersModel>(), CoroutineScop
 
     override fun onStart() {
         super.onStart()
-        setFabPlayVisibility(true);
-        fabPlay.setImageResource(R.drawable.ic_fab_play);
+        setFabPlayVisibility(true)
+        fabPlay?.setImageResource(R.drawable.ic_fab_play)
     }
 
 



More information about the Android mailing list