[Android] Fix NullPointerException when showing the audio tips

Nicolas Pomepuy git at videolan.org
Tue Oct 26 06:45:23 UTC 2021


vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Tue Oct 19 12:18:48 2021 +0200| [6e84b10b0a42b2398d84e406657981eca257a793] | committer: Nicolas Pomepuy

Fix NullPointerException when showing the audio tips

Fixes #2201

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

 .../org/videolan/vlc/gui/audio/AudioPlaylistTipsDelegate.kt    |  4 ++++
 .../src/org/videolan/vlc/gui/helpers/PlayerOptionsDelegate.kt  | 10 ++++++----
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/application/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlaylistTipsDelegate.kt b/application/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlaylistTipsDelegate.kt
index 65400fac6..84ff31c47 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlaylistTipsDelegate.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlaylistTipsDelegate.kt
@@ -45,6 +45,8 @@ import androidx.lifecycle.ViewModelProvider
 import androidx.transition.Fade
 import androidx.transition.TransitionManager
 import kotlinx.android.synthetic.main.audio_playlist_tips.*
+import kotlinx.coroutines.ExperimentalCoroutinesApi
+import kotlinx.coroutines.ObsoleteCoroutinesApi
 import org.videolan.tools.*
 import org.videolan.vlc.R
 import org.videolan.vlc.databinding.PlaylistItemBinding
@@ -53,6 +55,8 @@ import org.videolan.vlc.gui.helpers.TipsUtils
 import org.videolan.vlc.media.MediaUtils
 import org.videolan.vlc.viewmodels.PlaylistModel
 
+ at ObsoleteCoroutinesApi
+ at ExperimentalCoroutinesApi
 class AudioPlaylistTipsDelegate(private val activity: AudioPlayerContainerActivity) {
     private lateinit var thirdItemBinding: PlaylistItemBinding
     private lateinit var secondItemBinding: PlaylistItemBinding
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/helpers/PlayerOptionsDelegate.kt b/application/vlc-android/src/org/videolan/vlc/gui/helpers/PlayerOptionsDelegate.kt
index 8b1cb099b..9ebea893d 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/helpers/PlayerOptionsDelegate.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/helpers/PlayerOptionsDelegate.kt
@@ -196,14 +196,16 @@ class PlayerOptionsDelegate(val activity: FragmentActivity, val service: Playbac
             ID_SHOW_AUDIO_TIPS -> {
                 hide()
                 val audioPlayerContainerActivity = activity as AudioPlayerContainerActivity
-                val vsc = audioPlayerContainerActivity.findViewById<ViewStubCompat>(R.id.audio_player_tips)
-                audioPlayerContainerActivity.tipsDelegate.init(vsc)
+                audioPlayerContainerActivity.findViewById<ViewStubCompat>(R.id.audio_player_tips)?.let {
+                    audioPlayerContainerActivity.tipsDelegate.init(it)
+                }
             }
             ID_SHOW_PLAYLIST_TIPS -> {
                 hide()
                 val audioPlayerContainerActivity = activity as AudioPlayerContainerActivity
-                val vsc = audioPlayerContainerActivity.findViewById<ViewStubCompat>(R.id.audio_playlist_tips)
-                audioPlayerContainerActivity.playlistTipsDelegate.init(vsc)
+                audioPlayerContainerActivity.findViewById<ViewStubCompat>(R.id.audio_playlist_tips)?.let {
+                    audioPlayerContainerActivity.playlistTipsDelegate.init(it)
+                }
             }
             ID_BOOKMARK -> {
                 hide()



More information about the Android mailing list