From 8c3a9986f0ddc69c2d964fc6820b6971c09e1f29 Mon Sep 17 00:00:00 2001 From: Martin Fietz Date: Sat, 30 Jan 2016 12:42:18 +0100 Subject: Feed view: Single feed refresh enforces actually refreshing --- .../de/danoeh/antennapod/core/storage/DBTasks.java | 42 +++++++++++++++++++--- .../antennapod/core/storage/DownloadRequester.java | 5 +-- 2 files changed, 41 insertions(+), 6 deletions(-) (limited to 'core/src/main/java/de') 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) -- cgit v1.2.3