aboutsummaryrefslogtreecommitdiff
path: root/app/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main')
-rw-r--r--app/src/main/java/github/daneren2005/dsub/service/DownloadService.java10
-rw-r--r--app/src/main/java/github/daneren2005/dsub/service/Scrobbler.java13
2 files changed, 13 insertions, 10 deletions
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<Void>(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)) {