[Android] src: Check for null in ALL WeakHandlers, fix a bunch of crashes

Edward Wang git at videolan.org
Fri Aug 3 18:06:35 CEST 2012


android | branch: master | Edward Wang <edward.c.wang at compdigitec.com> | Fri Aug  3 12:06:37 2012 -0400| [a74e85bac5164db633b877d8c37bcfc301e6d9f7] | committer: Edward Wang

src: Check for null in ALL WeakHandlers, fix a bunch of crashes

> http://git.videolan.org/gitweb.cgi/android.git/?a=commit;h=a74e85bac5164db633b877d8c37bcfc301e6d9f7
---

 vlc-android/src/org/videolan/vlc/AudioService.java                 |    4 ++++
 .../src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java       |    2 ++
 vlc-android/src/org/videolan/vlc/gui/audio/AudioListFragment.java  |    2 ++
 .../src/org/videolan/vlc/gui/video/VideoPlayerActivity.java        |    2 ++
 4 files changed, 10 insertions(+)

diff --git a/vlc-android/src/org/videolan/vlc/AudioService.java b/vlc-android/src/org/videolan/vlc/AudioService.java
index ce48b8e..fddaa14 100644
--- a/vlc-android/src/org/videolan/vlc/AudioService.java
+++ b/vlc-android/src/org/videolan/vlc/AudioService.java
@@ -269,6 +269,8 @@ public class AudioService extends Service {
         @Override
         public void handleMessage(Message msg) {
             AudioService service = getOwner();
+            if(service == null) return;
+
             switch (msg.getData().getInt("event")) {
                 case EventManager.MediaPlayerPlaying:
                     Log.i(TAG, "MediaPlayerPlaying");
@@ -340,6 +342,8 @@ public class AudioService extends Service {
         @Override
         public void handleMessage(Message msg) {
             AudioService service = getOwner();
+            if(service == null) return;
+
             switch (msg.what) {
                 case SHOW_PROGRESS:
                     if (service.mCallback.size() > 0) {
diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java b/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java
index 03a970c..8ee6e01 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java
@@ -372,6 +372,8 @@ public class AudioBrowserFragment extends SherlockFragment implements ISortable
         @Override
         public void handleMessage(Message msg) {
             AudioBrowserFragment fragment = getOwner();
+            if(fragment == null) return;
+
             switch (msg.what) {
                 case MediaLibrary.MEDIA_ITEMS_UPDATED:
                     fragment.updateLists();
diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/AudioListFragment.java b/vlc-android/src/org/videolan/vlc/gui/audio/AudioListFragment.java
index 4ec87e1..0a77d85 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioListFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioListFragment.java
@@ -209,6 +209,8 @@ public class AudioListFragment extends SherlockListFragment {
         @Override
         public void handleMessage(Message msg) {
             AudioListFragment fragment = getOwner();
+            if(fragment == null) return;
+
             switch (msg.what) {
                 case MediaLibrary.MEDIA_ITEMS_UPDATED:
                     fragment.updateList();
diff --git a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
index 5c83445..0d4da85 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -478,6 +478,8 @@ public class VideoPlayerActivity extends Activity {
         @Override
         public void handleMessage(Message msg) {
             VideoPlayerActivity activity = getOwner();
+            if(activity == null) return;
+
             switch (msg.getData().getInt("event")) {
                 case EventManager.MediaPlayerPlaying:
                     Log.i(TAG, "MediaPlayerPlaying");



More information about the Android mailing list