From 28654256a22bcaaf72074ef0247f9fbc9d8d65f8 Mon Sep 17 00:00:00 2001 From: daneren2005 Date: Wed, 4 Dec 2013 14:40:05 -0800 Subject: #160 Automatically delete fully listened to podcasts --- src/github/daneren2005/dsub/service/DownloadServiceImpl.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/github/daneren2005/dsub/service/DownloadServiceImpl.java b/src/github/daneren2005/dsub/service/DownloadServiceImpl.java index 56f79a0e..abee1153 100644 --- a/src/github/daneren2005/dsub/service/DownloadServiceImpl.java +++ b/src/github/daneren2005/dsub/service/DownloadServiceImpl.java @@ -31,6 +31,7 @@ import github.daneren2005.dsub.audiofx.VisualizerController; import github.daneren2005.dsub.domain.Bookmark; import github.daneren2005.dsub.domain.MusicDirectory; import github.daneren2005.dsub.domain.PlayerState; +import github.daneren2005.dsub.domain.PodcastEpisode; import github.daneren2005.dsub.domain.RemoteControlState; import github.daneren2005.dsub.domain.RepeatMode; import github.daneren2005.dsub.receiver.MediaButtonIntentReceiver; @@ -509,6 +510,15 @@ public class DownloadServiceImpl extends Service implements DownloadService { } public synchronized void clear(boolean serialize) { + // Delete podcast if fully listened to + if(currentPlaying != null && currentPlaying.getSong() instanceof PodcastEpisode) { + // Make sure > 95% of the way through + int cutoffPoint = getPlayerDuration() * 0.95; + if(duration > 0 && cachedPosition > cutoffPoint) { + currentPlaying.delete(); + } + } + reset(); downloadList.clear(); revision++; -- cgit v1.2.3