diff options
author | daniel oeh <daniel.oeh@gmail.com> | 2012-08-10 15:29:37 +0200 |
---|---|---|
committer | daniel oeh <daniel.oeh@gmail.com> | 2012-08-10 15:29:37 +0200 |
commit | 1c24794ed295bd08504517cc15aa251bf96d712a (patch) | |
tree | a541e75443a9778c758b09583ab54dea47c9ab4d /src | |
parent | 13f04e9fd94147da58bdc084fa699f66b788f6a3 (diff) | |
download | AntennaPod-1c24794ed295bd08504517cc15aa251bf96d712a.zip |
Prevented crash in DownloadRequester when unbinding fails
Diffstat (limited to 'src')
-rw-r--r-- | src/de/danoeh/antennapod/storage/DownloadRequester.java | 15 |
1 files changed, 9 insertions, 6 deletions
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); } } |