diff --git a/src/de/danoeh/antennapod/asynctask/DownloadObserver.java b/src/de/danoeh/antennapod/asynctask/DownloadObserver.java index 0a75a4471..a626be34e 100644 --- a/src/de/danoeh/antennapod/asynctask/DownloadObserver.java +++ b/src/de/danoeh/antennapod/asynctask/DownloadObserver.java @@ -147,7 +147,7 @@ public class DownloadObserver extends AsyncTask { int numDownloads = requester.getNumberOfDownloads(); long ids[] = new long[numDownloads]; for (int i = 0; i < numDownloads; i++) { - ids[i] = requester.downloads.get(i).getDownloadId(); + ids[i] = requester.getDownloadAt(i).getDownloadId(); } DownloadManager.Query query = new DownloadManager.Query(); query.setFilterById(ids); @@ -192,7 +192,7 @@ public class DownloadObserver extends AsyncTask { } private boolean downloadsLeft() { - return !requester.downloads.isEmpty(); + return !requester.hasNoDownloads(); } public void registerCallback(DownloadObserver.Callback callback) { diff --git a/src/de/danoeh/antennapod/opml/OpmlReader.java b/src/de/danoeh/antennapod/opml/OpmlReader.java index 0deed97ea..476fc151a 100644 --- a/src/de/danoeh/antennapod/opml/OpmlReader.java +++ b/src/de/danoeh/antennapod/opml/OpmlReader.java @@ -9,6 +9,7 @@ import org.xmlpull.v1.XmlPullParserException; import org.xmlpull.v1.XmlPullParserFactory; import de.danoeh.antennapod.AppConfig; +import de.danoeh.antennapod.util.URLChecker; import android.content.Context; import android.util.Log; @@ -68,7 +69,7 @@ public class OpmlReader { Log.d(TAG, "Found new Opml element"); OpmlElement element = new OpmlElement(); element.setText(xpp.getAttributeValue(null, TEXT)); - element.setXmlUrl(xpp.getAttributeValue(null, XMLURL)); + element.setXmlUrl(URLChecker.prepareURL(xpp.getAttributeValue(null, XMLURL))); element.setHtmlUrl(xpp.getAttributeValue(null, HTMLURL)); element.setType(xpp.getAttributeValue(null, TYPE)); if (element.getXmlUrl() != null) { diff --git a/src/de/danoeh/antennapod/storage/DownloadRequester.java b/src/de/danoeh/antennapod/storage/DownloadRequester.java index 9ec9b0a86..0f341e568 100644 --- a/src/de/danoeh/antennapod/storage/DownloadRequester.java +++ b/src/de/danoeh/antennapod/storage/DownloadRequester.java @@ -1,31 +1,26 @@ package de.danoeh.antennapod.storage; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; import java.io.File; -import java.util.concurrent.Callable; +import java.util.List; +import java.util.concurrent.CopyOnWriteArrayList; -import de.danoeh.antennapod.feed.*; -import de.danoeh.antennapod.service.DownloadService; -import de.danoeh.antennapod.util.NumberGenerator; -import de.danoeh.antennapod.AppConfig; -import de.danoeh.antennapod.R; - -import android.util.Log; -import android.database.Cursor; import android.annotation.SuppressLint; import android.app.DownloadManager; -import android.content.Context; -import android.net.Uri; -import android.os.Messenger; -import android.content.ServiceConnection; -import android.os.IBinder; import android.content.ComponentName; -import android.os.Message; -import android.os.RemoteException; +import android.content.Context; import android.content.Intent; +import android.content.ServiceConnection; +import android.net.Uri; +import android.os.IBinder; +import android.util.Log; import android.webkit.URLUtil; +import de.danoeh.antennapod.AppConfig; +import de.danoeh.antennapod.feed.Feed; +import de.danoeh.antennapod.feed.FeedFile; +import de.danoeh.antennapod.feed.FeedImage; +import de.danoeh.antennapod.feed.FeedMedia; +import de.danoeh.antennapod.service.DownloadService; +import de.danoeh.antennapod.util.NumberGenerator; public class DownloadRequester {// TODO handle externalstorage missing private static final String TAG = "DownloadRequester"; @@ -44,10 +39,10 @@ public class DownloadRequester {// TODO handle externalstorage missing private static DownloadRequester downloader; private DownloadManager manager; - public List downloads; + private List downloads; private DownloadRequester() { - downloads = Collections.synchronizedList(new ArrayList()); + downloads = new CopyOnWriteArrayList(); } public static DownloadRequester getInstance() { @@ -176,6 +171,14 @@ public class DownloadRequester {// TODO handle externalstorage missing } return false; } + + public boolean hasNoDownloads() { + return downloads.isEmpty(); + } + + public FeedFile getDownloadAt(int index) { + return downloads.get(index); + } /** Remove an object from the downloads-list of the requester. */ public void removeDownload(FeedFile f) { diff --git a/src/de/danoeh/antennapod/util/URLChecker.java b/src/de/danoeh/antennapod/util/URLChecker.java index 7eca63f4a..94a9c276e 100644 --- a/src/de/danoeh/antennapod/util/URLChecker.java +++ b/src/de/danoeh/antennapod/util/URLChecker.java @@ -27,6 +27,9 @@ public final class URLChecker { if (!url.startsWith("http")) { builder.append("http://"); if (AppConfig.DEBUG) Log.d(TAG, "Missing http; appending"); + } else if (url.startsWith("https")) { + if (AppConfig.DEBUG) Log.d(TAG, "Replacing https with http"); + url.replaceFirst("https", "http"); } builder.append(url);