[Android] AudioPlayer: avoid NullPointerException on getActivity()

Jean-Baptiste Kempf git at videolan.org
Fri Jul 4 04:37:33 CEST 2014


vlc-ports/android | branch: master | Jean-Baptiste Kempf <jb at videolan.org> | Fri Jul  4 04:37:09 2014 +0200| [2af3eac61d20bc12aa6edf5baa059cff9cc2a9bc] | committer: Jean-Baptiste Kempf

AudioPlayer: avoid NullPointerException on getActivity()

> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=2af3eac61d20bc12aa6edf5baa059cff9cc2a9bc
---

 vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.java |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.java b/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.java
index a059777..88743ed 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.java
@@ -658,11 +658,13 @@ public class AudioPlayer extends Fragment implements IAudioPlayer {
 
     public void showPlaylistTips() {
         MainActivity activity = (MainActivity)getActivity();
-        activity.showTipViewIfNeeded(R.layout.audio_playlist_tips, PREF_PLAYLIST_TIPS_SHOWN);
+        if(activity != null)
+            activity.showTipViewIfNeeded(R.layout.audio_playlist_tips, PREF_PLAYLIST_TIPS_SHOWN);
     }
 
     public void showAudioPlayerTips() {
         MainActivity activity = (MainActivity)getActivity();
-        activity.showTipViewIfNeeded(R.layout.audio_player_tips, PREF_AUDIOPLAYER_TIPS_SHOWN);
+        if(activity != null)
+            activity.showTipViewIfNeeded(R.layout.audio_player_tips, PREF_AUDIOPLAYER_TIPS_SHOWN);
     }
 }



More information about the Android mailing list