Opmlreader is now preparing the xml urls
This commit is contained in:
parent
7e2d5a659e
commit
c3d25b5106
|
@ -147,7 +147,7 @@ public class DownloadObserver extends AsyncTask<Void, Void, Void> {
|
||||||
int numDownloads = requester.getNumberOfDownloads();
|
int numDownloads = requester.getNumberOfDownloads();
|
||||||
long ids[] = new long[numDownloads];
|
long ids[] = new long[numDownloads];
|
||||||
for (int i = 0; i < numDownloads; i++) {
|
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();
|
DownloadManager.Query query = new DownloadManager.Query();
|
||||||
query.setFilterById(ids);
|
query.setFilterById(ids);
|
||||||
|
@ -192,7 +192,7 @@ public class DownloadObserver extends AsyncTask<Void, Void, Void> {
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean downloadsLeft() {
|
private boolean downloadsLeft() {
|
||||||
return !requester.downloads.isEmpty();
|
return !requester.hasNoDownloads();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void registerCallback(DownloadObserver.Callback callback) {
|
public void registerCallback(DownloadObserver.Callback callback) {
|
||||||
|
|
|
@ -9,6 +9,7 @@ import org.xmlpull.v1.XmlPullParserException;
|
||||||
import org.xmlpull.v1.XmlPullParserFactory;
|
import org.xmlpull.v1.XmlPullParserFactory;
|
||||||
|
|
||||||
import de.danoeh.antennapod.AppConfig;
|
import de.danoeh.antennapod.AppConfig;
|
||||||
|
import de.danoeh.antennapod.util.URLChecker;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
@ -68,7 +69,7 @@ public class OpmlReader {
|
||||||
Log.d(TAG, "Found new Opml element");
|
Log.d(TAG, "Found new Opml element");
|
||||||
OpmlElement element = new OpmlElement();
|
OpmlElement element = new OpmlElement();
|
||||||
element.setText(xpp.getAttributeValue(null, TEXT));
|
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.setHtmlUrl(xpp.getAttributeValue(null, HTMLURL));
|
||||||
element.setType(xpp.getAttributeValue(null, TYPE));
|
element.setType(xpp.getAttributeValue(null, TYPE));
|
||||||
if (element.getXmlUrl() != null) {
|
if (element.getXmlUrl() != null) {
|
||||||
|
|
|
@ -1,31 +1,26 @@
|
||||||
package de.danoeh.antennapod.storage;
|
package de.danoeh.antennapod.storage;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
import java.io.File;
|
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.annotation.SuppressLint;
|
||||||
import android.app.DownloadManager;
|
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.content.ComponentName;
|
||||||
import android.os.Message;
|
import android.content.Context;
|
||||||
import android.os.RemoteException;
|
|
||||||
import android.content.Intent;
|
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 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
|
public class DownloadRequester {// TODO handle externalstorage missing
|
||||||
private static final String TAG = "DownloadRequester";
|
private static final String TAG = "DownloadRequester";
|
||||||
|
@ -44,10 +39,10 @@ public class DownloadRequester {// TODO handle externalstorage missing
|
||||||
private static DownloadRequester downloader;
|
private static DownloadRequester downloader;
|
||||||
private DownloadManager manager;
|
private DownloadManager manager;
|
||||||
|
|
||||||
public List<FeedFile> downloads;
|
private List<FeedFile> downloads;
|
||||||
|
|
||||||
private DownloadRequester() {
|
private DownloadRequester() {
|
||||||
downloads = Collections.synchronizedList(new ArrayList<FeedFile>());
|
downloads = new CopyOnWriteArrayList<FeedFile>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DownloadRequester getInstance() {
|
public static DownloadRequester getInstance() {
|
||||||
|
@ -177,6 +172,14 @@ public class DownloadRequester {// TODO handle externalstorage missing
|
||||||
return false;
|
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. */
|
/** Remove an object from the downloads-list of the requester. */
|
||||||
public void removeDownload(FeedFile f) {
|
public void removeDownload(FeedFile f) {
|
||||||
downloads.remove(f);
|
downloads.remove(f);
|
||||||
|
|
|
@ -27,6 +27,9 @@ public final class URLChecker {
|
||||||
if (!url.startsWith("http")) {
|
if (!url.startsWith("http")) {
|
||||||
builder.append("http://");
|
builder.append("http://");
|
||||||
if (AppConfig.DEBUG) Log.d(TAG, "Missing http; appending");
|
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);
|
builder.append(url);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue