diff options
author | ByteHamster <ByteHamster@users.noreply.github.com> | 2021-08-27 19:36:07 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-27 19:36:07 +0200 |
commit | 85c8a419acb385cdf249662866715965de219c93 (patch) | |
tree | 90a82d90965c23ae03ebaae98352785df99a9710 | |
parent | c1b23dd19d3b0d6f8489aaf2a2747b81ba5498ee (diff) | |
parent | b33d9850990bb83dc2010e7e163cad462887ad62 (diff) | |
download | AntennaPod-85c8a419acb385cdf249662866715965de219c93.zip |
Merge pull request #5357 from ByteHamster/sync-broken-guid
Make guid repair more reliable with sync
-rw-r--r-- | core/src/main/java/de/danoeh/antennapod/core/storage/DBTasks.java | 17 |
1 files changed, 14 insertions, 3 deletions
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 8b0c4ed75..06f7f9657 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 @@ -24,6 +24,7 @@ import de.danoeh.antennapod.core.sync.SyncService; import de.danoeh.antennapod.core.util.DownloadError; import de.danoeh.antennapod.core.util.LongList; import de.danoeh.antennapod.core.util.comparator.FeedItemPubdateComparator; +import de.danoeh.antennapod.net.sync.model.EpisodeAction; import org.greenrobot.eventbus.EventBus; import java.util.ArrayList; @@ -337,7 +338,7 @@ public final class DBTasks { * Get a FeedItem by its identifying value or download_url. * For de-duplicating items that are not stored yet, see also FeedHandler.dedupItems */ - private static FeedItem searchFeedItemByIdentifyingValue(Feed feed, FeedItem searchItem) { + private static FeedItem searchFeedItemByIdentifyingValue(Context context, Feed feed, FeedItem searchItem) { for (FeedItem item : feed.getItems()) { if (TextUtils.equals(item.getIdentifyingValue(), searchItem.getIdentifyingValue())) { return item; @@ -364,6 +365,16 @@ public final class DBTasks { "The podcast host changed the ID of an existing episode instead of just " + "updating the episode itself. AntennaPod attempted to repair it.", false)); item.setItemIdentifier(searchItem.getItemIdentifier()); + + if (item.isPlayed() && item.getMedia() != null) { + EpisodeAction action = new EpisodeAction.Builder(item, EpisodeAction.PLAY) + .currentTimestamp() + .started(item.getMedia().getDuration() / 1000) + .position(item.getMedia().getDuration() / 1000) + .total(item.getMedia().getDuration() / 1000) + .build(); + SyncService.enqueueEpisodeAction(context, action); + } return item; } } @@ -436,7 +447,7 @@ public final class DBTasks { // Look for new or updated Items for (int idx = 0; idx < newFeed.getItems().size(); idx++) { final FeedItem item = newFeed.getItems().get(idx); - FeedItem oldItem = searchFeedItemByIdentifyingValue(savedFeed, item); + FeedItem oldItem = searchFeedItemByIdentifyingValue(context, savedFeed, item); if (oldItem == null) { // item is new item.setFeed(savedFeed); @@ -469,7 +480,7 @@ public final class DBTasks { Iterator<FeedItem> it = savedFeed.getItems().iterator(); while (it.hasNext()) { FeedItem feedItem = it.next(); - if (searchFeedItemByIdentifyingValue(newFeed, feedItem) == null) { + if (searchFeedItemByIdentifyingValue(context, newFeed, feedItem) == null) { unlistedItems.add(feedItem); it.remove(); } |