[Android] HistoryAdapter: check returns of getExistingInstance

Jean-Baptiste Kempf git at videolan.org
Mon Oct 15 14:16:18 CEST 2012


vlc-ports/android | branch: master | Jean-Baptiste Kempf <jb at videolan.org> | Mon Oct 15 14:15:45 2012 +0200| [104e4ad02e3fd75dd5b44c03c6e3b0c7e4ff63b8] | committer: Jean-Baptiste Kempf

HistoryAdapter: check returns of getExistingInstance

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

 .../src/org/videolan/vlc/gui/HistoryAdapter.java      |   17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/HistoryAdapter.java b/vlc-android/src/org/videolan/vlc/gui/HistoryAdapter.java
index c5cb561..845f582 100644
--- a/vlc-android/src/org/videolan/vlc/gui/HistoryAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/HistoryAdapter.java
@@ -50,7 +50,11 @@ public class HistoryAdapter extends BaseAdapter {
     public HistoryAdapter() {
         mInflater = LayoutInflater.from(VLCApplication.getAppContext());
         mHistory = new ArrayList<String>();
-        LibVLC.getExistingInstance().getMediaListItems((ArrayList<String>)mHistory);
+
+        LibVLC libVLC = LibVLC.getExistingInstance();
+        if (libVLC != null)
+            libVLC.getMediaListItems((ArrayList<String>) mHistory);
+
         EventManager em = EventManager.getInstance();
         em.addHandler(new HistoryEventHandler(this));
     }
@@ -127,10 +131,13 @@ public class HistoryAdapter extends BaseAdapter {
 
     public void refresh() {
         ArrayList<String> s = new ArrayList<String>();
-        LibVLC.getExistingInstance().getMediaListItems(s);
-        mHistory.clear();
-        mHistory = s;
-        this.notifyDataSetChanged();
+        LibVLC libVLC = LibVLC.getExistingInstance();
+        if (libVLC != null) {
+            libVLC.getMediaListItems(s);
+            mHistory.clear();
+            mHistory = s;
+            this.notifyDataSetChanged();
+        }
     }
 
     /**



More information about the Android mailing list