From 1a5fb5c35b0992ed988c2103dc47bf6c3175161e Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Thu, 10 Mar 2016 17:55:54 -0800 Subject: Respect the isPastCutoff params for setting a song as completely listened to --- .../github/daneren2005/dsub/service/DownloadService.java | 10 +++++----- .../java/github/daneren2005/dsub/service/Scrobbler.java | 13 ++++++++----- 2 files changed, 13 insertions(+), 10 deletions(-) (limited to 'app/src/main') diff --git a/app/src/main/java/github/daneren2005/dsub/service/DownloadService.java b/app/src/main/java/github/daneren2005/dsub/service/DownloadService.java index 96c97393..84a884ed 100644 --- a/app/src/main/java/github/daneren2005/dsub/service/DownloadService.java +++ b/app/src/main/java/github/daneren2005/dsub/service/DownloadService.java @@ -761,7 +761,7 @@ public class DownloadService extends Service { checkAddBookmark(); } if(currentPlaying != null) { - scrobbler.conditionalScrobble(this, currentPlaying, position, duration); + scrobbler.conditionalScrobble(this, currentPlaying, position, duration, cutoff); } reset(); @@ -1187,7 +1187,7 @@ public class DownloadService extends Service { clearCurrentBookmark(true); } if(currentPlaying != null) { - scrobbler.conditionalScrobble(this, currentPlaying, position, duration); + scrobbler.conditionalScrobble(this, currentPlaying, position, duration, cutoff); } int index = getCurrentPlayingIndex(); @@ -1411,9 +1411,9 @@ public class DownloadService extends Service { } if (playerState == STARTED) { - scrobbler.scrobble(this, currentPlaying, false); + scrobbler.scrobble(this, currentPlaying, false, false); } else if (playerState == COMPLETED) { - scrobbler.scrobble(this, currentPlaying, true); + scrobbler.scrobble(this, currentPlaying, true, true); } if(playerState == STARTED && positionCache == null) { @@ -1459,7 +1459,7 @@ public class DownloadService extends Service { positionCache.stop(); positionCache = null; } - scrobbler.scrobble(this, currentPlaying, true); + scrobbler.scrobble(this, currentPlaying, true, true); onStateUpdate(); } diff --git a/app/src/main/java/github/daneren2005/dsub/service/Scrobbler.java b/app/src/main/java/github/daneren2005/dsub/service/Scrobbler.java index 1d9fecef..168a7777 100644 --- a/app/src/main/java/github/daneren2005/dsub/service/Scrobbler.java +++ b/app/src/main/java/github/daneren2005/dsub/service/Scrobbler.java @@ -3,6 +3,7 @@ package github.daneren2005.dsub.service; import android.content.Context; import android.util.Log; +import github.daneren2005.dsub.domain.MusicDirectory; import github.daneren2005.dsub.domain.PodcastEpisode; import github.daneren2005.dsub.util.SilentBackgroundTask; import github.daneren2005.dsub.util.SongDBHandler; @@ -21,18 +22,18 @@ public class Scrobbler { private String lastSubmission; private String lastNowPlaying; - public void conditionalScrobble(Context context, DownloadFile song, int playerPosition, int duration) { + public void conditionalScrobble(Context context, DownloadFile song, int playerPosition, int duration, boolean isPastCutoff) { // More than 4 minutes if(playerPosition > FOUR_MINUTES) { - scrobble(context, song, true); + scrobble(context, song, true, isPastCutoff); } // More than 50% played else if(duration > 0 && playerPosition > (duration / 2)) { - scrobble(context, song, true); + scrobble(context, song, true, isPastCutoff); } } - public void scrobble(final Context context, final DownloadFile song, final boolean submission) { + public void scrobble(final Context context, final DownloadFile song, final boolean submission, final boolean isPastCutoff) { if(song == null) { return; } @@ -55,7 +56,9 @@ public class Scrobbler { new SilentBackgroundTask(context) { @Override protected Void doInBackground() { - SongDBHandler.getHandler(context).setSongPlayed(song, submission); + if(isPastCutoff) { + SongDBHandler.getHandler(context).setSongPlayed(song, submission); + } // Scrobbling disabled if (!Util.isScrobblingEnabled(context)) { -- cgit v1.2.3