mirror of
https://github.com/AntennaPod/AntennaPod.git
synced 2025-01-31 02:44:53 +01:00
Prevented crash in DownloadRequester when unbinding fails
This commit is contained in:
parent
13f04e9fd9
commit
1c24794ed2
@ -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);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user