Remove episode from queue when gpodder notifies as played (#4562)

This commit is contained in:
Ezequiel 2020-10-22 08:37:03 -03:00 committed by GitHub
parent 3e147c97fe
commit 91f9c19bae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 1 deletions

View File

@ -39,6 +39,7 @@ import de.danoeh.antennapod.core.sync.model.ISyncService;
import de.danoeh.antennapod.core.sync.model.SubscriptionChanges;
import de.danoeh.antennapod.core.sync.model.SyncServiceException;
import de.danoeh.antennapod.core.sync.model.UploadChangesResponse;
import de.danoeh.antennapod.core.util.LongList;
import de.danoeh.antennapod.core.util.URLChecker;
import de.danoeh.antennapod.core.util.gui.NotificationUtils;
import io.reactivex.Completable;
@ -456,7 +457,7 @@ public class SyncService extends Worker {
break;
}
}
LongList queueToBeRemoved = new LongList();
List<FeedItem> updatedItems = new ArrayList<>();
for (EpisodeAction action : mostRecentPlayAction.values()) {
FeedItem playItem = DBReader.getFeedItemByUrl(action.getPodcast(), action.getEpisode());
@ -467,10 +468,12 @@ public class SyncService extends Worker {
if (playItem.getMedia().hasAlmostEnded()) {
Log.d(TAG, "Marking as played");
playItem.setPlayed(true);
queueToBeRemoved.add(playItem.getId());
}
updatedItems.add(playItem);
}
}
DBWriter.removeQueueItem(getApplicationContext(), false, queueToBeRemoved.toArray());
DBWriter.setItemList(updatedItems);
}