From 008347313f0481e2096b70e2d494055d9e9ebb66 Mon Sep 17 00:00:00 2001 From: Tom Hennen Date: Tue, 4 Aug 2015 21:09:55 -0400 Subject: 'feeditem' is the id of the FeedItem SQL statement previously used 'id' which was actually the id of the FeedMedia item and not the FeedItem --- core/src/main/java/de/danoeh/antennapod/core/storage/PodDBAdapter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'core/src/main/java/de/danoeh') diff --git a/core/src/main/java/de/danoeh/antennapod/core/storage/PodDBAdapter.java b/core/src/main/java/de/danoeh/antennapod/core/storage/PodDBAdapter.java index f9ac39349..904a416df 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/storage/PodDBAdapter.java +++ b/core/src/main/java/de/danoeh/antennapod/core/storage/PodDBAdapter.java @@ -1711,7 +1711,7 @@ public class PodDBAdapter { } if(oldVersion < 1030002) { db.execSQL("UPDATE FeedItems SET auto_download=0 WHERE " + - "(read=1 OR id IN (SELECT id FROM FeedMedia WHERE position>0 OR downloaded=1)) " + + "(read=1 OR id IN (SELECT feeditem FROM FeedMedia WHERE position>0 OR downloaded=1)) " + "AND id NOT IN (SELECT feeditem FROM Queue)"); } EventBus.getDefault().post(ProgressEvent.end()); -- cgit v1.2.3 From fe6796f102bb8c126cfad80d957bffe0cb04fa34 Mon Sep 17 00:00:00 2001 From: Tom Hennen Date: Tue, 4 Aug 2015 21:25:25 -0400 Subject: Updated version code for RC5 Also updated the oldVersion used by the UPDATE FeedItems sql statement. We don't want to run the 1030002 version ever, and the 1030005 version should fix any users that used the 1030002 version (with the possibility that some items that shouldn't have had auto_download set to 0 did have it set to 0, but accepting that that's not a terrible problem). --- core/src/main/java/de/danoeh/antennapod/core/storage/PodDBAdapter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'core/src/main/java/de/danoeh') diff --git a/core/src/main/java/de/danoeh/antennapod/core/storage/PodDBAdapter.java b/core/src/main/java/de/danoeh/antennapod/core/storage/PodDBAdapter.java index 904a416df..edb7598ab 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/storage/PodDBAdapter.java +++ b/core/src/main/java/de/danoeh/antennapod/core/storage/PodDBAdapter.java @@ -1709,7 +1709,7 @@ public class PodDBAdapter { db.execSQL("ALTER TABLE " + PodDBAdapter.TABLE_NAME_FEEDS + " ADD COLUMN " + PodDBAdapter.KEY_AUTO_DELETE_ACTION + " INTEGER DEFAULT 0"); } - if(oldVersion < 1030002) { + if(oldVersion < 1030005) { db.execSQL("UPDATE FeedItems SET auto_download=0 WHERE " + "(read=1 OR id IN (SELECT feeditem FROM FeedMedia WHERE position>0 OR downloaded=1)) " + "AND id NOT IN (SELECT feeditem FROM Queue)"); -- cgit v1.2.3 From 224832300f4a8d0b42e257a23f0ae69957518a01 Mon Sep 17 00:00:00 2001 From: Tom Hennen Date: Tue, 4 Aug 2015 22:09:53 -0400 Subject: only autodownload new items --- .../antennapod/core/service/download/DownloadService.java | 7 ++++++- .../danoeh/antennapod/core/storage/APDownloadAlgorithm.java | 12 ++++++------ 2 files changed, 12 insertions(+), 7 deletions(-) (limited to 'core/src/main/java/de/danoeh') diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadService.java b/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadService.java index 19a710d24..4fdaf6843 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadService.java +++ b/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadService.java @@ -325,6 +325,11 @@ public class DownloadService extends Service { cancelNotificationUpdater(); unregisterReceiver(cancelDownloadReceiver); + // TODO: I'm not sure this is actually needed. + // We could just invoke the autodownloadUndownloadeditems method + // and it would get everything it's supposed to. By sending it the + // items in newMediaFiles we're overriding the download algorithm, + // which is not something we should probably do. if (!newMediaFiles.isEmpty()) { Log.d(TAG, "newMediaFiles exist, autodownload them"); DBTasks.autodownloadUndownloadedItems(getApplicationContext(), @@ -783,7 +788,7 @@ public class DownloadService extends Service { if(item.getPubDate() == null) { Log.d(TAG, item.toString()); } - if (!item.isPlayed() && item.hasMedia() && !item.getMedia().isDownloaded()) { + if (item.isNew() && item.hasMedia() && !item.getMedia().isDownloaded()) { newMediaFiles.add(item.getMedia().getId()); } } diff --git a/core/src/main/java/de/danoeh/antennapod/core/storage/APDownloadAlgorithm.java b/core/src/main/java/de/danoeh/antennapod/core/storage/APDownloadAlgorithm.java index 0e6b23696..c2e971dce 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/storage/APDownloadAlgorithm.java +++ b/core/src/main/java/de/danoeh/antennapod/core/storage/APDownloadAlgorithm.java @@ -22,7 +22,7 @@ public class APDownloadAlgorithm implements AutomaticDownloadAlgorithm { private final APCleanupAlgorithm cleanupAlgorithm = new APCleanupAlgorithm(); /** - * Looks for undownloaded episodes in the queue or list of unread items and request a download if + * Looks for undownloaded episodes in the queue or list of new items and request a download if * 1. Network is available * 2. The device is charging or the user allows auto download on battery * 3. There is free space in the episode cache @@ -57,12 +57,12 @@ public class APDownloadAlgorithm implements AutomaticDownloadAlgorithm { candidates = DBReader.getFeedItems(context, mediaIds); } else { final List queue = DBReader.getQueue(context); - final List unreadItems = DBReader.getUnreadItemsList(context); - candidates = new ArrayList(queue.size() + unreadItems.size()); + final List newItems = DBReader.getNewItemsList(context); + candidates = new ArrayList(queue.size() + newItems.size()); candidates.addAll(queue); - for(FeedItem unreadItem : unreadItems) { - if(candidates.contains(unreadItem) == false) { - candidates.add(unreadItem); + for(FeedItem newItem : newItems) { + if(candidates.contains(newItem) == false) { + candidates.add(newItem); } } } -- cgit v1.2.3