Opmlreader is now preparing the xml urls

This commit is contained in:
daniel oeh 2012-07-23 19:06:22 +02:00
parent 7e2d5a659e
commit c3d25b5106
4 changed files with 31 additions and 24 deletions

View File

@ -147,7 +147,7 @@ public class DownloadObserver extends AsyncTask<Void, Void, Void> {
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<Void, Void, Void> {
}
private boolean downloadsLeft() {
return !requester.downloads.isEmpty();
return !requester.hasNoDownloads();
}
public void registerCallback(DownloadObserver.Callback callback) {

View File

@ -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) {

View File

@ -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<FeedFile> downloads;
private List<FeedFile> downloads;
private DownloadRequester() {
downloads = Collections.synchronizedList(new ArrayList<FeedFile>());
downloads = new CopyOnWriteArrayList<FeedFile>();
}
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) {

View File

@ -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);