[Android] VideoListAdapter: Avoid NPE

Geoffrey Métais git at videolan.org
Wed Feb 14 17:36:35 CET 2018


vlc-android | branch: 3.0.x | Geoffrey Métais <geoffrey.metais at gmail.com> | Wed Feb 14 14:38:17 2018 +0100| [08b3551d839a77143b068fa95cc4ac601edbf30e] | committer: Geoffrey Métais

VideoListAdapter: Avoid NPE

(cherry picked from commit 879998f0e6734276a14b3f7fa5abfb8a0b04f66e)

> https://code.videolan.org/videolan/vlc-android/commit/08b3551d839a77143b068fa95cc4ac601edbf30e
---

 vlc-android/src/org/videolan/vlc/gui/video/VideoListAdapter.java | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/video/VideoListAdapter.java b/vlc-android/src/org/videolan/vlc/gui/video/VideoListAdapter.java
index d7fb579d7..60a89c84b 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoListAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoListAdapter.java
@@ -21,10 +21,10 @@
 package org.videolan.vlc.gui.video;
 
 import android.content.Context;
+import android.content.SharedPreferences;
 import android.databinding.BindingAdapter;
 import android.databinding.DataBindingUtil;
 import android.databinding.ViewDataBinding;
-import android.preference.PreferenceManager;
 import android.support.annotation.MainThread;
 import android.support.annotation.Nullable;
 import android.support.v7.widget.GridLayoutManager;
@@ -77,7 +77,8 @@ public class VideoListAdapter extends SortableAdapter<MediaWrapper, VideoListAda
     VideoListAdapter(IEventsHandler eventsHandler) {
         super();
         mEventsHandler = eventsHandler;
-        mIsSeenMediaMarkerVisible = PreferenceManager.getDefaultSharedPreferences(VLCApplication.getAppContext()).getBoolean("media_seen", true);
+        final SharedPreferences settings = VLCApplication.getSettings();
+        mIsSeenMediaMarkerVisible = settings == null || settings.getBoolean("media_seen", true);
     }
 
     @Override



More information about the Android mailing list