aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2014-01-18 10:54:24 -0800
committerScott Jackson <daneren2005@gmail.com>2014-01-18 10:54:24 -0800
commit99fec3f3de854d4fa358713595b8ab5b26873aac (patch)
treedca5d73b152d575a1f24b612af8c8cdd9b4c8510
parenta8a19d4fcc46f8e4753d40e21b69e4df75f11535 (diff)
downloaddsub-99fec3f3de854d4fa358713595b8ab5b26873aac.tar.gz
dsub-99fec3f3de854d4fa358713595b8ab5b26873aac.tar.bz2
dsub-99fec3f3de854d4fa358713595b8ab5b26873aac.zip
#250 Keep track of index
-rw-r--r--src/github/daneren2005/dsub/service/DownloadServiceImpl.java11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/github/daneren2005/dsub/service/DownloadServiceImpl.java b/src/github/daneren2005/dsub/service/DownloadServiceImpl.java
index 287959b4..600f2d52 100644
--- a/src/github/daneren2005/dsub/service/DownloadServiceImpl.java
+++ b/src/github/daneren2005/dsub/service/DownloadServiceImpl.java
@@ -104,6 +104,7 @@ public class DownloadServiceImpl extends Service implements DownloadService {
private final Scrobbler scrobbler = new Scrobbler();
private RemoteController remoteController;
private DownloadFile currentPlaying;
+ private int currentPlayingIndex = -1;
private DownloadFile nextPlaying;
private DownloadFile currentDownloading;
private CancellableTask bufferTask;
@@ -329,6 +330,7 @@ public class DownloadServiceImpl extends Service implements DownloadService {
} else {
if (currentPlaying == null) {
currentPlaying = downloadList.get(0);
+ currentPlayingIndex = 0;
currentPlaying.setPlaying(true);
}
checkDownloads();
@@ -604,6 +606,11 @@ public class DownloadServiceImpl extends Service implements DownloadService {
this.currentPlaying.setPlaying(false);
}
this.currentPlaying = currentPlaying;
+ if(currentPlaying == null) {
+ currentPlayingIndex = -1;
+ } else {
+ currentPlayingIndex = downloadList.indexOf(currentPlaying);
+ }
if (currentPlaying != null) {
Util.broadcastNewTrackInfo(this, currentPlaying.getSong());
@@ -641,8 +648,8 @@ public class DownloadServiceImpl extends Service implements DownloadService {
}
@Override
- public synchronized int getCurrentPlayingIndex() {
- return downloadList.indexOf(currentPlaying);
+ public int getCurrentPlayingIndex() {
+ return currentPlayingIndex;
}
private int getNextPlayingIndex() {
int index = getCurrentPlayingIndex();