[Android] Check observer nullity

Geoffrey Métais git at videolan.org
Fri Feb 27 11:36:02 CET 2015


vlc-ports/android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Fri Feb 27 11:35:19 2015 +0100| [57b7f87a046da0d1c191d55be0b92e5c70709487] | committer: Geoffrey Métais

Check observer nullity

May fix Android bug on some 4.x devices

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

 .../org/videolan/vlc/gui/audio/AudioBrowserListAdapter.java |    7 +++++++
 .../src/org/videolan/vlc/gui/audio/AudioPagerAdapter.java   |   11 +++++++----
 .../org/videolan/vlc/gui/audio/AudioPlaylistAdapter.java    |    7 +++++++
 3 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserListAdapter.java b/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserListAdapter.java
index ec4cca1..f4f1f25 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserListAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserListAdapter.java
@@ -36,6 +36,7 @@ import org.videolan.vlc.util.Util;
 import android.app.Activity;
 import android.content.Context;
 import android.content.SharedPreferences;
+import android.database.DataSetObserver;
 import android.graphics.Bitmap;
 import android.preference.PreferenceManager;
 import android.util.SparseArray;
@@ -523,4 +524,10 @@ public class AudioBrowserListAdapter extends BaseAdapter implements SectionIndex
     void setContextPopupMenuListener(ContextPopupMenuListener l) {
         mContextPopupMenuListener = l;
     }
+
+    @Override
+    public void unregisterDataSetObserver(DataSetObserver observer) {
+        if (observer != null)
+            super.unregisterDataSetObserver(observer);
+    }
 }
diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/AudioPagerAdapter.java b/vlc-android/src/org/videolan/vlc/gui/audio/AudioPagerAdapter.java
index 5828a2d..131c57f 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioPagerAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioPagerAdapter.java
@@ -22,13 +22,10 @@
 
 package org.videolan.vlc.gui.audio;
 
-import android.content.Context;
+import android.database.DataSetObserver;
 import android.support.v4.view.PagerAdapter;
 import android.view.View;
 import android.view.ViewGroup;
-import android.widget.ListView;
-
-import org.videolan.vlc.R;
 
 import java.util.ArrayList;
 
@@ -72,4 +69,10 @@ public class AudioPagerAdapter extends PagerAdapter {
         else
             return mTitles[position];
     }
+
+    @Override
+    public void unregisterDataSetObserver(DataSetObserver observer) {
+        if (observer != null)
+            super.unregisterDataSetObserver(observer);
+    }
 }
diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlaylistAdapter.java b/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlaylistAdapter.java
index 83bb146..e0f5fd6 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlaylistAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlaylistAdapter.java
@@ -31,6 +31,7 @@ import org.videolan.vlc.widget.AudioPlaylistItemViewGroup;
 import android.content.Context;
 import android.content.SharedPreferences;
 import android.content.res.ColorStateList;
+import android.database.DataSetObserver;
 import android.preference.PreferenceManager;
 import android.view.LayoutInflater;
 import android.view.MotionEvent;
@@ -183,4 +184,10 @@ public class AudioPlaylistAdapter extends ArrayAdapter<MediaWrapper> {
         View layoutFooter;
         AudioPlaylistItemViewGroup itemGroup;
     }
+
+    @Override
+    public void unregisterDataSetObserver(DataSetObserver observer) {
+        if (observer != null)
+            super.unregisterDataSetObserver(observer);
+    }
 }



More information about the Android mailing list