From a05ab3a268382c1be40a61cb289494814ea7ba7c Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Wed, 21 Jan 2015 15:17:46 -0800 Subject: When casting, we still want to clear bookmarks and setup podcasts for deletion --- .../daneren2005/dsub/service/ChromeCastController.java | 1 + .../daneren2005/dsub/service/DLNAController.java | 1 + .../daneren2005/dsub/service/DownloadService.java | 18 ++++++++++++------ 3 files changed, 14 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/github/daneren2005/dsub/service/ChromeCastController.java b/src/github/daneren2005/dsub/service/ChromeCastController.java index 6f35ac1d..40f5d73d 100644 --- a/src/github/daneren2005/dsub/service/ChromeCastController.java +++ b/src/github/daneren2005/dsub/service/ChromeCastController.java @@ -450,6 +450,7 @@ public class ChromeCastController extends RemoteController { case MediaStatus.PLAYER_STATE_IDLE: if (mediaStatus.getIdleReason() == MediaStatus.IDLE_REASON_FINISHED) { downloadService.setPlayerState(PlayerState.COMPLETED); + downloadService.postPlayCleanup(); downloadService.onSongCompleted(); } else if (mediaStatus.getIdleReason() == MediaStatus.IDLE_REASON_INTERRUPTED) { if (downloadService.getPlayerState() != PlayerState.PREPARING) { diff --git a/src/github/daneren2005/dsub/service/DLNAController.java b/src/github/daneren2005/dsub/service/DLNAController.java index 207f6f21..c1ac4d09 100644 --- a/src/github/daneren2005/dsub/service/DLNAController.java +++ b/src/github/daneren2005/dsub/service/DLNAController.java @@ -156,6 +156,7 @@ public class DLNAController extends RemoteController { } else if(downloadService.getPlayerState() == PlayerState.STARTED) { // Played until the end downloadService.setPlayerState(PlayerState.COMPLETED); + downloadService.postPlayCleanup(); downloadService.onSongCompleted(); } else { downloadService.setPlayerState(PlayerState.STOPPED); diff --git a/src/github/daneren2005/dsub/service/DownloadService.java b/src/github/daneren2005/dsub/service/DownloadService.java index ef69c9d3..473815dc 100644 --- a/src/github/daneren2005/dsub/service/DownloadService.java +++ b/src/github/daneren2005/dsub/service/DownloadService.java @@ -1654,12 +1654,7 @@ public class DownloadService extends Service { Log.i(TAG, "Ending position " + pos + " of " + duration); if (!isPartial || (downloadFile.isWorkDone() && (Math.abs(duration - pos) < 10000)) || nextSetup) { playNext(); - - // Finished loading, delete when list is cleared - if (downloadFile.getSong() instanceof PodcastEpisode) { - toDelete.add(downloadFile); - } - clearCurrentBookmark(downloadFile.getSong(), true); + postPlayCleanup(downloadFile); } else { // If file is not completely downloaded, restart the playback from the current position. synchronized (DownloadService.this) { @@ -1941,6 +1936,17 @@ public class DownloadService extends Service { } } } + + public void postPlayCleanup() { + postPlayCleanup(currentPlaying); + } + public void postPlayCleanup(DownloadFile downloadFile) { + // Finished loading, delete when list is cleared + if (downloadFile.getSong() instanceof PodcastEpisode) { + toDelete.add(downloadFile); + } + clearCurrentBookmark(downloadFile.getSong(), true); + } private boolean isPastCutoff() { return isPastCutoff(getPlayerPosition(), getPlayerDuration()); -- cgit v1.2.3