From 99fec3f3de854d4fa358713595b8ab5b26873aac Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Sat, 18 Jan 2014 10:54:24 -0800 Subject: #250 Keep track of index --- src/github/daneren2005/dsub/service/DownloadServiceImpl.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src') 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(); -- cgit v1.2.3