aboutsummaryrefslogtreecommitdiff
path: root/src/github
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2014-09-19 15:03:02 -0700
committerScott Jackson <daneren2005@gmail.com>2014-09-19 15:03:02 -0700
commit49764baa821198b014efdfe6b856f32c49a1595a (patch)
tree013555e9564d76a72ec5979f0af70868062ee3a9 /src/github
parent40f4baecca74fbc25f42fab83f763c1612b4089c (diff)
downloaddsub-49764baa821198b014efdfe6b856f32c49a1595a.tar.gz
dsub-49764baa821198b014efdfe6b856f32c49a1595a.tar.bz2
dsub-49764baa821198b014efdfe6b856f32c49a1595a.zip
#388 Call conditionalScrobble in next/clear, cleanup isPastCutoff use
Diffstat (limited to 'src/github')
-rw-r--r--src/github/daneren2005/dsub/service/DownloadService.java37
1 files changed, 26 insertions, 11 deletions
diff --git a/src/github/daneren2005/dsub/service/DownloadService.java b/src/github/daneren2005/dsub/service/DownloadService.java
index 33ec85c6..9d30889d 100644
--- a/src/github/daneren2005/dsub/service/DownloadService.java
+++ b/src/github/daneren2005/dsub/service/DownloadService.java
@@ -566,7 +566,9 @@ public class DownloadService extends Service {
public synchronized void clear(boolean serialize) {
// Delete podcast if fully listened to
- boolean cutoff = isPastCutoff();
+ int position = getPlayerPosition();
+ int duration = getPlayerDuration();
+ boolean cutoff = isPastCutoff(position, duration);
if(currentPlaying != null && currentPlaying.getSong() instanceof PodcastEpisode) {
if(cutoff) {
currentPlaying.delete();
@@ -584,6 +586,9 @@ public class DownloadService extends Service {
// Check if we should be adding a new bookmark here
checkAddBookmark();
}
+ if(currentPlaying != null) {
+ scrobbler.conditionalScrobble(this, currentPlaying, position, duration);
+ }
reset();
downloadList.clear();
@@ -898,12 +903,20 @@ public class DownloadService extends Service {
}
// Delete podcast if fully listened to
+ int position = getPlayerPosition();
+ int duration = getPlayerDuration();
+ boolean cutoff = isPastCutoff(position, duration);
if(currentPlaying != null && currentPlaying.getSong() instanceof PodcastEpisode) {
- if(isPastCutoff()) {
+ if(cutoff) {
toDelete.add(currentPlaying);
}
}
- clearCurrentBookmark();
+ if(cutoff) {
+ clearCurrentBookmark(true);
+ }
+ if(currentPlaying != null) {
+ scrobbler.conditionalScrobble(context, currentPlaying, position, duration);
+ }
int index = getCurrentPlayingIndex();
int nextPlayingIndex = getNextPlayingIndex();
@@ -1787,35 +1800,37 @@ public class DownloadService extends Service {
}
private boolean isPastCutoff() {
- int duration = getPlayerDuration();
+ return isPastCutoff(getPlayerPosition(), getPlayerDuration());
+ }
+ private boolean isPastCutoff(int position, int duration) {
int cutoffPoint = (int) (duration * DELETE_CUTOFF);
- return duration > 0 && getPlayerPosition() > cutoffPoint;
+ return duration > 0 && position > cutoffPoint;
}
private void clearCurrentBookmark() {
clearCurrentBookmark(false);
}
- private void clearCurrentBookmark(boolean delete) {
+ private void clearCurrentBookmark(boolean checkDelete) {
// If current is null, nothing to do
if(currentPlaying == null) {
return;
}
- clearCurrentBookmark(currentPlaying.getSong(), delete);
+ clearCurrentBookmark(currentPlaying.getSong(), checkDelete);
}
- private void clearCurrentBookmark(final MusicDirectory.Entry entry, boolean delete) {
+ private void clearCurrentBookmark(final MusicDirectory.Entry entry, boolean checkDelete) {
// If no bookmark, move on
if(entry.getBookmark() == null) {
return;
}
// If delete is not specified, check position
- if(!delete) {
- delete = isPastCutoff();
+ if(!checkDelete) {
+ checkDelete = isPastCutoff();
}
// If supposed to delete
- if(delete) {
+ if(checkDelete) {
new SilentBackgroundTask<Void>(this) {
@Override
public Void doInBackground() throws Throwable {