summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorMartin Fietz <Martin.Fietz@gmail.com>2016-01-30 12:42:18 +0100
committerMartin Fietz <Martin.Fietz@gmail.com>2016-01-30 18:30:48 +0100
commit8c3a9986f0ddc69c2d964fc6820b6971c09e1f29 (patch)
tree5c9bb06c4669f7871f7e7b7faf50c54c472e92a1 /core
parent4bdf95bd455a0b32e370a063d69ad5613ba78ac0 (diff)
downloadAntennaPod-8c3a9986f0ddc69c2d964fc6820b6971c09e1f29.zip
Feed view: Single feed refresh enforces actually refreshing
Diffstat (limited to 'core')
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/storage/DBTasks.java42
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/storage/DownloadRequester.java5
2 files changed, 41 insertions, 6 deletions
diff --git a/core/src/main/java/de/danoeh/antennapod/core/storage/DBTasks.java b/core/src/main/java/de/danoeh/antennapod/core/storage/DBTasks.java
index 62814524e..ed593bb82 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/storage/DBTasks.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/storage/DBTasks.java
@@ -224,7 +224,28 @@ public final class DBTasks {
*/
public static void refreshCompleteFeed(final Context context, final Feed feed) {
try {
- refreshFeed(context, feed, true);
+ refreshFeed(context, feed, true, false);
+ } catch (DownloadRequestException e) {
+ e.printStackTrace();
+ DBWriter.addDownloadStatus(
+ new DownloadStatus(feed, feed
+ .getHumanReadableIdentifier(),
+ DownloadError.ERROR_REQUEST_ERROR, false, e
+ .getMessage()
+ )
+ );
+ }
+ }
+
+ /**
+ * Downloads all pages of the given feed even if feed has not been modified since last refresh
+ *
+ * @param context Used for requesting the download.
+ * @param feed The Feed object.
+ */
+ public static void forceRefreshCompleteFeed(final Context context, final Feed feed) {
+ try {
+ refreshFeed(context, feed, true, true);
} catch (DownloadRequestException e) {
e.printStackTrace();
DBWriter.addDownloadStatus(
@@ -268,10 +289,23 @@ public final class DBTasks {
public static void refreshFeed(Context context, Feed feed)
throws DownloadRequestException {
Log.d(TAG, "refreshFeed(feed.id: " + feed.getId() +")");
- refreshFeed(context, feed, false);
+ refreshFeed(context, feed, false, false);
+ }
+
+ /**
+ * Refresh a specific feed even if feed has not been modified since last refresh
+ *
+ * @param context Used for requesting the download.
+ * @param feed The Feed object.
+ */
+ public static void forceRefreshFeed(Context context, Feed feed)
+ throws DownloadRequestException {
+ Log.d(TAG, "refreshFeed(feed.id: " + feed.getId() +")");
+ refreshFeed(context, feed, false, true);
}
- private static void refreshFeed(Context context, Feed feed, boolean loadAllPages) throws DownloadRequestException {
+ private static void refreshFeed(Context context, Feed feed, boolean loadAllPages, boolean force)
+ throws DownloadRequestException {
Feed f;
String lastUpdate = feed.hasLastUpdateFailed() ? null : feed.getLastUpdate();
if (feed.getPreferences() == null) {
@@ -281,7 +315,7 @@ public final class DBTasks {
feed.getPreferences().getUsername(), feed.getPreferences().getPassword());
}
f.setId(feed.getId());
- DownloadRequester.getInstance().downloadFeed(context, f, loadAllPages);
+ DownloadRequester.getInstance().downloadFeed(context, f, loadAllPages, force);
}
/**
diff --git a/core/src/main/java/de/danoeh/antennapod/core/storage/DownloadRequester.java b/core/src/main/java/de/danoeh/antennapod/core/storage/DownloadRequester.java
index b934e2c95..22c9538ca 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/storage/DownloadRequester.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/storage/DownloadRequester.java
@@ -162,7 +162,8 @@ public class DownloadRequester {
* @param feed Feed to download
* @param loadAllPages Set to true to download all pages
*/
- public synchronized void downloadFeed(Context context, Feed feed, boolean loadAllPages)
+ public synchronized void downloadFeed(Context context, Feed feed, boolean loadAllPages,
+ boolean force)
throws DownloadRequestException {
if (feedFileValid(feed)) {
String username = (feed.getPreferences() != null) ? feed.getPreferences().getUsername() : null;
@@ -179,7 +180,7 @@ public class DownloadRequester {
}
public synchronized void downloadFeed(Context context, Feed feed) throws DownloadRequestException {
- downloadFeed(context, feed, false);
+ downloadFeed(context, feed, false, false);
}
public synchronized void downloadMedia(Context context, FeedMedia feedmedia)