diff options
author | H. Lehmann <ByteHamster@users.noreply.github.com> | 2019-12-17 15:42:58 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-12-17 15:42:58 +0100 |
commit | 06605d516d49cbd16e2098610af2bc9ca4b2702b (patch) | |
tree | 7141d714ba569540848c1c04db05140b1ef59aad /core | |
parent | 72520d7ac431532a412328977a86a03e38f674f3 (diff) | |
parent | c148f76ef79ec0503a5e25534544b26819a2d94d (diff) | |
download | AntennaPod-06605d516d49cbd16e2098610af2bc9ca4b2702b.zip |
Merge pull request #3689 from ByteHamster/signal-unread-change
Signal unread items update after downloading
Diffstat (limited to 'core')
-rw-r--r-- | core/src/main/java/de/danoeh/antennapod/core/service/download/handler/MediaDownloadedHandler.java | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/download/handler/MediaDownloadedHandler.java b/core/src/main/java/de/danoeh/antennapod/core/service/download/handler/MediaDownloadedHandler.java index 901c2a4ac..40be2895c 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/service/download/handler/MediaDownloadedHandler.java +++ b/core/src/main/java/de/danoeh/antennapod/core/service/download/handler/MediaDownloadedHandler.java @@ -8,6 +8,7 @@ import androidx.annotation.NonNull; import java.util.concurrent.ExecutionException; +import de.danoeh.antennapod.core.event.UnreadItemsUpdateEvent; import de.danoeh.antennapod.core.feed.FeedItem; import de.danoeh.antennapod.core.feed.FeedMedia; import de.danoeh.antennapod.core.gpoddernet.model.GpodnetEpisodeAction; @@ -18,6 +19,7 @@ import de.danoeh.antennapod.core.storage.DBReader; import de.danoeh.antennapod.core.storage.DBWriter; import de.danoeh.antennapod.core.util.ChapterUtils; import de.danoeh.antennapod.core.util.DownloadError; +import org.greenrobot.eventbus.EventBus; /** * Handles a completed media download. @@ -44,6 +46,8 @@ public class MediaDownloadedHandler implements Runnable { Log.e(TAG, "Could not find downloaded media object in database"); return; } + // media.setDownloaded modifies played state + boolean broadcastUnreadStateUpdate = media.getItem() != null && media.getItem().isNew(); media.setDownloaded(true); media.setFile_url(request.getDestination()); media.checkEmbeddedPicture(); // enforce check @@ -77,13 +81,13 @@ public class MediaDownloadedHandler implements Runnable { // we've received the media, we don't want to autodownload it again if (item != null) { item.setAutoDownload(false); - if (item.isNew()) { - item.setPlayed(false); - } // setFeedItem() signals (via EventBus) that the item has been updated, // so we do it after the enclosing media has been updated above, // to ensure subscribers will get the updated FeedMedia as well DBWriter.setFeedItem(item).get(); + if (broadcastUnreadStateUpdate) { + EventBus.getDefault().post(new UnreadItemsUpdateEvent()); + } } } catch (InterruptedException e) { Log.e(TAG, "MediaHandlerThread was interrupted"); |