aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2014-09-20 07:32:11 -0700
committerScott Jackson <daneren2005@gmail.com>2014-09-20 07:32:11 -0700
commitb245a1491a83c71a3b95c0e1091d9153b6a7ebb7 (patch)
tree006a1b9df9c846abd7896ea5c17fe4b0e87bde09 /src
parente5fb6784104c852c234c074486ab03e47c470b67 (diff)
downloaddsub-b245a1491a83c71a3b95c0e1091d9153b6a7ebb7.tar.gz
dsub-b245a1491a83c71a3b95c0e1091d9153b6a7ebb7.tar.bz2
dsub-b245a1491a83c71a3b95c0e1091d9153b6a7ebb7.zip
Fix spacing
Diffstat (limited to 'src')
-rw-r--r--src/github/daneren2005/dsub/service/Scrobbler.java94
1 files changed, 47 insertions, 47 deletions
diff --git a/src/github/daneren2005/dsub/service/Scrobbler.java b/src/github/daneren2005/dsub/service/Scrobbler.java
index 239094fd..1f8538c9 100644
--- a/src/github/daneren2005/dsub/service/Scrobbler.java
+++ b/src/github/daneren2005/dsub/service/Scrobbler.java
@@ -14,28 +14,28 @@ import github.daneren2005.dsub.util.Util;
* @version $Id$
*/
public class Scrobbler {
- private static final String TAG = Scrobbler.class.getSimpleName();
- private static final int FOUR_MINUTES = 4 * 60 * 1000;
+ private static final String TAG = Scrobbler.class.getSimpleName();
+ private static final int FOUR_MINUTES = 4 * 60 * 1000;
- private String lastSubmission;
- private String lastNowPlaying;
-
- public void conditionalScrobble(Context context, DownloadFile song, int playerPosition, int duration) {
- // More than 4 minutes
- if(playerPosition > FOUR_MINUTES) {
- scrobble(context, song, true);
- }
- // More than 50% played
- else if(duration > 0 && playerPosition > (duration / 2)) {
- scrobble(context, song, true);
- }
- }
+ private String lastSubmission;
+ private String lastNowPlaying;
+
+ public void conditionalScrobble(Context context, DownloadFile song, int playerPosition, int duration) {
+ // More than 4 minutes
+ if(playerPosition > FOUR_MINUTES) {
+ scrobble(context, song, true);
+ }
+ // More than 50% played
+ else if(duration > 0 && playerPosition > (duration / 2)) {
+ scrobble(context, song, true);
+ }
+ }
+
+ public void scrobble(final Context context, final DownloadFile song, final boolean submission) {
+ if (song == null || !Util.isScrobblingEnabled(context)) {
+ return;
+ }
- public void scrobble(final Context context, final DownloadFile song, final boolean submission) {
- if (song == null || !Util.isScrobblingEnabled(context)) {
- return;
- }
-
// Ignore if online with no network access
if(!Util.isOffline(context) && !Util.isNetworkConnected(context)) {
return;
@@ -45,41 +45,41 @@ public class Scrobbler {
if(song.getSong() instanceof PodcastEpisode) {
return;
}
-
+
// Ignore songs which are under 30 seconds per Last.FM guidelines
Integer duration = song.getSong().getDuration();
if(duration != null && duration > 0 && duration < 30) {
return;
}
- final String id = song.getSong().getId();
+ final String id = song.getSong().getId();
- // Avoid duplicate registrations.
- if (submission && id.equals(lastSubmission)) {
- return;
- }
- if (!submission && id.equals(lastNowPlaying)) {
- return;
- }
+ // Avoid duplicate registrations.
+ if (submission && id.equals(lastSubmission)) {
+ return;
+ }
+ if (!submission && id.equals(lastNowPlaying)) {
+ return;
+ }
- if (submission) {
- lastSubmission = id;
- } else {
- lastNowPlaying = id;
- }
+ if (submission) {
+ lastSubmission = id;
+ } else {
+ lastNowPlaying = id;
+ }
- new SilentBackgroundTask<Void>(context) {
- @Override
- protected Void doInBackground() {
- MusicService service = MusicServiceFactory.getMusicService(context);
- try {
- service.scrobble(id, submission, context, null);
- Log.i(TAG, "Scrobbled '" + (submission ? "submission" : "now playing") + "' for " + song);
- } catch (Exception x) {
- Log.i(TAG, "Failed to scrobble'" + (submission ? "submission" : "now playing") + "' for " + song, x);
- }
+ new SilentBackgroundTask<Void>(context) {
+ @Override
+ protected Void doInBackground() {
+ MusicService service = MusicServiceFactory.getMusicService(context);
+ try {
+ service.scrobble(id, submission, context, null);
+ Log.i(TAG, "Scrobbled '" + (submission ? "submission" : "now playing") + "' for " + song);
+ } catch (Exception x) {
+ Log.i(TAG, "Failed to scrobble'" + (submission ? "submission" : "now playing") + "' for " + song, x);
+ }
return null;
- }
- }.execute();
- }
+ }
+ }.execute();
+ }
}