Clover Coverage Report - Subsonic-Android Coverage Report
Coverage timestamp: ven dic 19 2014 17:57:13 EST
../../../../../img/srcFileCovDistChart9.png 32% of files have more coverage
16   52   12   8
12   38   0,75   2
2     6  
1    
This report was generated with an evaluation server license. Purchase Clover or configure your license.
 
  Scrobbler       Line # 13 16 12 83,3% 0.8333333
 
No Tests
 
1    package net.sourceforge.subsonic.androidapp.service;
2   
3    import android.content.Context;
4    import android.util.Log;
5    import net.sourceforge.subsonic.androidapp.util.Util;
6   
7    /**
8    * Scrobbles played songs to Last.fm.
9    *
10    * @author Sindre Mehus
11    * @version $Id$
12    */
 
13    public class Scrobbler {
14   
15    private static final String TAG = Scrobbler.class.getSimpleName();
16   
17    private String lastSubmission;
18    private String lastNowPlaying;
19   
 
20  31 toggle public void scrobble(final Context context, final DownloadFile song, final boolean submission) {
21  31 if (song == null || !Util.isScrobblingEnabled(context)) {
22  26 return;
23    }
24  5 final String id = song.getSong().getId();
25   
26    // Avoid duplicate registrations.
27  5 if (submission && id.equals(lastSubmission)) {
28  0 return;
29    }
30  5 if (!submission && id.equals(lastNowPlaying)) {
31  1 return;
32    }
33  4 if (submission) {
34  1 lastSubmission = id;
35    } else {
36  3 lastNowPlaying = id;
37    }
38   
39  4 new Thread("Scrobble " + song) {
 
40  4 toggle @Override
41    public void run() {
42  4 MusicService service = MusicServiceFactory.getMusicService(context);
43  4 try {
44  4 service.scrobble(id, submission, context, null);
45  0 Log.i(TAG, "Scrobbled '" + (submission ? "submission" : "now playing") + "' for " + song);
46    } catch (Exception x) {
47  4 Log.i(TAG, "Failed to scrobble'" + (submission ? "submission" : "now playing") + "' for " + song, x);
48    }
49    }
50    }.start();
51    }
52    }