Feed view: Single feed refresh enforces actually refreshing
This commit is contained in:
parent
4bdf95bd45
commit
8c3a9986f0
@ -121,9 +121,8 @@ public class DownloadLogAdapter extends BaseAdapter {
|
|||||||
if(holder.typeId == Feed.FEEDFILETYPE_FEED) {
|
if(holder.typeId == Feed.FEEDFILETYPE_FEED) {
|
||||||
Feed feed = DBReader.getFeed(holder.id);
|
Feed feed = DBReader.getFeed(holder.id);
|
||||||
if (feed != null) {
|
if (feed != null) {
|
||||||
feed.setLastUpdate(null); // force refresh
|
|
||||||
try {
|
try {
|
||||||
DBTasks.refreshFeed(context, feed);
|
DBTasks.forceRefreshFeed(context, feed);
|
||||||
} catch (DownloadRequestException e) {
|
} catch (DownloadRequestException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -63,10 +63,10 @@ public class FeedMenuHandler {
|
|||||||
final Feed selectedFeed) throws DownloadRequestException {
|
final Feed selectedFeed) throws DownloadRequestException {
|
||||||
switch (item.getItemId()) {
|
switch (item.getItemId()) {
|
||||||
case R.id.refresh_item:
|
case R.id.refresh_item:
|
||||||
DBTasks.refreshFeed(context, selectedFeed);
|
DBTasks.forceRefreshFeed(context, selectedFeed);
|
||||||
break;
|
break;
|
||||||
case R.id.refresh_complete_item:
|
case R.id.refresh_complete_item:
|
||||||
DBTasks.refreshCompleteFeed(context, selectedFeed);
|
DBTasks.forceRefreshCompleteFeed(context, selectedFeed);
|
||||||
break;
|
break;
|
||||||
case R.id.filter_items:
|
case R.id.filter_items:
|
||||||
showFilterDialog(context, selectedFeed);
|
showFilterDialog(context, selectedFeed);
|
||||||
|
@ -224,7 +224,28 @@ public final class DBTasks {
|
|||||||
*/
|
*/
|
||||||
public static void refreshCompleteFeed(final Context context, final Feed feed) {
|
public static void refreshCompleteFeed(final Context context, final Feed feed) {
|
||||||
try {
|
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) {
|
} catch (DownloadRequestException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
DBWriter.addDownloadStatus(
|
DBWriter.addDownloadStatus(
|
||||||
@ -268,10 +289,23 @@ public final class DBTasks {
|
|||||||
public static void refreshFeed(Context context, Feed feed)
|
public static void refreshFeed(Context context, Feed feed)
|
||||||
throws DownloadRequestException {
|
throws DownloadRequestException {
|
||||||
Log.d(TAG, "refreshFeed(feed.id: " + feed.getId() +")");
|
Log.d(TAG, "refreshFeed(feed.id: " + feed.getId() +")");
|
||||||
refreshFeed(context, feed, false);
|
refreshFeed(context, feed, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void refreshFeed(Context context, Feed feed, boolean loadAllPages) throws DownloadRequestException {
|
/**
|
||||||
|
* 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, boolean force)
|
||||||
|
throws DownloadRequestException {
|
||||||
Feed f;
|
Feed f;
|
||||||
String lastUpdate = feed.hasLastUpdateFailed() ? null : feed.getLastUpdate();
|
String lastUpdate = feed.hasLastUpdateFailed() ? null : feed.getLastUpdate();
|
||||||
if (feed.getPreferences() == null) {
|
if (feed.getPreferences() == null) {
|
||||||
@ -281,7 +315,7 @@ public final class DBTasks {
|
|||||||
feed.getPreferences().getUsername(), feed.getPreferences().getPassword());
|
feed.getPreferences().getUsername(), feed.getPreferences().getPassword());
|
||||||
}
|
}
|
||||||
f.setId(feed.getId());
|
f.setId(feed.getId());
|
||||||
DownloadRequester.getInstance().downloadFeed(context, f, loadAllPages);
|
DownloadRequester.getInstance().downloadFeed(context, f, loadAllPages, force);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -162,7 +162,8 @@ public class DownloadRequester {
|
|||||||
* @param feed Feed to download
|
* @param feed Feed to download
|
||||||
* @param loadAllPages Set to true to download all pages
|
* @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 {
|
throws DownloadRequestException {
|
||||||
if (feedFileValid(feed)) {
|
if (feedFileValid(feed)) {
|
||||||
String username = (feed.getPreferences() != null) ? feed.getPreferences().getUsername() : null;
|
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 {
|
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)
|
public synchronized void downloadMedia(Context context, FeedMedia feedmedia)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user