Merge pull request #3677 from ByteHamster/mark-seen-after-download
Mark as seen after download completed
This commit is contained in:
commit
3758caeefe
|
@ -77,6 +77,9 @@ public class MediaDownloadedHandler implements Runnable {
|
||||||
// we've received the media, we don't want to autodownload it again
|
// we've received the media, we don't want to autodownload it again
|
||||||
if (item != null) {
|
if (item != null) {
|
||||||
item.setAutoDownload(false);
|
item.setAutoDownload(false);
|
||||||
|
if (item.isNew()) {
|
||||||
|
item.setPlayed(false);
|
||||||
|
}
|
||||||
// setFeedItem() signals (via EventBus) that the item has been updated,
|
// setFeedItem() signals (via EventBus) that the item has been updated,
|
||||||
// so we do it after the enclosing media has been updated above,
|
// so we do it after the enclosing media has been updated above,
|
||||||
// to ensure subscribers will get the updated FeedMedia as well
|
// to ensure subscribers will get the updated FeedMedia as well
|
||||||
|
@ -90,7 +93,6 @@ public class MediaDownloadedHandler implements Runnable {
|
||||||
DownloadError.ERROR_DB_ACCESS_ERROR, false, e.getMessage());
|
DownloadError.ERROR_DB_ACCESS_ERROR, false, e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (GpodnetPreferences.loggedIn() && item != null) {
|
if (GpodnetPreferences.loggedIn() && item != null) {
|
||||||
GpodnetEpisodeAction action = new GpodnetEpisodeAction.Builder(item, GpodnetEpisodeAction.Action.DOWNLOAD)
|
GpodnetEpisodeAction action = new GpodnetEpisodeAction.Builder(item, GpodnetEpisodeAction.Action.DOWNLOAD)
|
||||||
.currentDeviceId()
|
.currentDeviceId()
|
||||||
|
|
|
@ -308,8 +308,7 @@ public final class DBTasks {
|
||||||
|
|
||||||
@VisibleForTesting(otherwise = VisibleForTesting.PACKAGE_PRIVATE)
|
@VisibleForTesting(otherwise = VisibleForTesting.PACKAGE_PRIVATE)
|
||||||
public static List<? extends FeedItem> enqueueFeedItemsToDownload(final Context context,
|
public static List<? extends FeedItem> enqueueFeedItemsToDownload(final Context context,
|
||||||
List<? extends FeedItem> items)
|
List<? extends FeedItem> items) throws InterruptedException, ExecutionException {
|
||||||
throws InterruptedException, ExecutionException {
|
|
||||||
List<FeedItem> itemsToEnqueue = new ArrayList<>();
|
List<FeedItem> itemsToEnqueue = new ArrayList<>();
|
||||||
if (UserPreferences.enqueueDownloadedEpisodes()) {
|
if (UserPreferences.enqueueDownloadedEpisodes()) {
|
||||||
LongList queueIDList = DBReader.getQueueIDList();
|
LongList queueIDList = DBReader.getQueueIDList();
|
||||||
|
@ -318,9 +317,7 @@ public final class DBTasks {
|
||||||
itemsToEnqueue.add(item);
|
itemsToEnqueue.add(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DBWriter.addQueueItem(context,
|
DBWriter.addQueueItem(context, false, itemsToEnqueue.toArray(new FeedItem[0])).get();
|
||||||
itemsToEnqueue.toArray(new FeedItem[0]))
|
|
||||||
.get();
|
|
||||||
}
|
}
|
||||||
return itemsToEnqueue;
|
return itemsToEnqueue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -294,14 +294,17 @@ public class DBWriter {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Future<?> addQueueItem(final Context context,
|
public static Future<?> addQueueItem(final Context context, final FeedItem... items) {
|
||||||
final FeedItem... items) {
|
return addQueueItem(context, true, items);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Future<?> addQueueItem(final Context context, boolean markAsUnplayed, final FeedItem... items) {
|
||||||
LongList itemIds = new LongList(items.length);
|
LongList itemIds = new LongList(items.length);
|
||||||
for (FeedItem item : items) {
|
for (FeedItem item : items) {
|
||||||
itemIds.add(item.getId());
|
itemIds.add(item.getId());
|
||||||
item.addTag(FeedItem.TAG_QUEUE);
|
item.addTag(FeedItem.TAG_QUEUE);
|
||||||
}
|
}
|
||||||
return addQueueItem(context, false, itemIds.toArray());
|
return addQueueItem(context, false, markAsUnplayed, itemIds.toArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -314,6 +317,20 @@ public class DBWriter {
|
||||||
*/
|
*/
|
||||||
public static Future<?> addQueueItem(final Context context, final boolean performAutoDownload,
|
public static Future<?> addQueueItem(final Context context, final boolean performAutoDownload,
|
||||||
final long... itemIds) {
|
final long... itemIds) {
|
||||||
|
return addQueueItem(context, performAutoDownload, true, itemIds);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Appends FeedItem objects to the end of the queue. The 'read'-attribute of all items will be set to true.
|
||||||
|
* If a FeedItem is already in the queue, the FeedItem will not change its position in the queue.
|
||||||
|
*
|
||||||
|
* @param context A context that is used for opening a database connection.
|
||||||
|
* @param performAutoDownload true if an auto-download process should be started after the operation.
|
||||||
|
* @param markAsUnplayed true if the items should be marked as unplayed when enqueueing
|
||||||
|
* @param itemIds IDs of the FeedItem objects that should be added to the queue.
|
||||||
|
*/
|
||||||
|
public static Future<?> addQueueItem(final Context context, final boolean performAutoDownload,
|
||||||
|
final boolean markAsUnplayed, final long... itemIds) {
|
||||||
return dbExec.submit(() -> {
|
return dbExec.submit(() -> {
|
||||||
if (itemIds.length < 1) {
|
if (itemIds.length < 1) {
|
||||||
return;
|
return;
|
||||||
|
@ -355,7 +372,7 @@ public class DBWriter {
|
||||||
EventBus.getDefault().post(event);
|
EventBus.getDefault().post(event);
|
||||||
}
|
}
|
||||||
EventBus.getDefault().post(FeedItemEvent.updated(updatedItems));
|
EventBus.getDefault().post(FeedItemEvent.updated(updatedItems));
|
||||||
if (markAsUnplayedIds.size() > 0) {
|
if (markAsUnplayed && markAsUnplayedIds.size() > 0) {
|
||||||
DBWriter.markItemPlayed(FeedItem.UNPLAYED, markAsUnplayedIds.toArray());
|
DBWriter.markItemPlayed(FeedItem.UNPLAYED, markAsUnplayedIds.toArray());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue