From 1c24794ed295bd08504517cc15aa251bf96d712a Mon Sep 17 00:00:00 2001 From: daniel oeh Date: Fri, 10 Aug 2012 15:29:37 +0200 Subject: Prevented crash in DownloadRequester when unbinding fails --- src/de/danoeh/antennapod/storage/DownloadRequester.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'src/de/danoeh/antennapod') diff --git a/src/de/danoeh/antennapod/storage/DownloadRequester.java b/src/de/danoeh/antennapod/storage/DownloadRequester.java index 90891e6a5..004d5165d 100644 --- a/src/de/danoeh/antennapod/storage/DownloadRequester.java +++ b/src/de/danoeh/antennapod/storage/DownloadRequester.java @@ -180,7 +180,7 @@ public class DownloadRequester {// TODO handle externalstorage missing } return false; } - + /** Checks if feedfile with the given download url is in the downloads list */ public boolean isDownloadingFile(String downloadUrl) { for (FeedFile f : downloads) { @@ -255,8 +255,12 @@ public class DownloadRequester {// TODO handle externalstorage missing if (AppConfig.DEBUG) Log.d(TAG, "Connection to service established"); mService.queryDownloads(); - if (mContext != null) { - mContext.unbindService(mConnection); + if (mContext != null && mIsBound) { + try { + mContext.unbindService(mConnection); + } catch (IllegalArgumentException e) { + e.printStackTrace(); + } } } @@ -271,8 +275,7 @@ public class DownloadRequester {// TODO handle externalstorage missing /** Notifies the DownloadService to check if there are any Downloads left */ public void notifyDownloadService(Context context) { mContext = context; - context.bindService(new Intent(context, DownloadService.class), - mConnection, Context.BIND_AUTO_CREATE); - mIsBound = true; + mIsBound = context.bindService(new Intent(context, + DownloadService.class), mConnection, Context.BIND_AUTO_CREATE); } } -- cgit v1.2.3