Downloadrequester will now no longer queue downloads which are already

running
This commit is contained in:
daniel oeh 2012-07-19 14:36:40 +02:00
parent 936aea9fc9
commit dbf16830fa

View File

@ -58,6 +58,7 @@ public class DownloadRequester {// TODO handle externalstorage missing
@SuppressLint("NewApi")
private long download(Context context, FeedFile item, File dest) {
if (!isDownloadingFile(item)) {
if (dest.exists()) {
Log.d(TAG, "File already exists. Deleting !");
dest.delete();
@ -85,6 +86,10 @@ public class DownloadRequester {// TODO handle externalstorage missing
context.startService(new Intent(context, DownloadService.class));
context.sendBroadcast(new Intent(ACTION_DOWNLOAD_QUEUED));
return downloadId;
} else {
Log.e(TAG, "URL " + item.getDownload_url() + " is already being downloaded");
return 0;
}
}
public long downloadFeed(Context context, Feed feed) {
@ -203,7 +208,8 @@ public class DownloadRequester {// TODO handle externalstorage missing
public String getMediafilePath(Context context, FeedMedia media) {
File externalStorage = context.getExternalFilesDir(MEDIA_DOWNLOADPATH
+ NumberGenerator.generateLong(media.getItem().getFeed().getTitle()) + "/");
+ NumberGenerator.generateLong(media.getItem().getFeed()
.getTitle()) + "/");
return externalStorage.toString();
}