diff options
author | Scott Jackson <daneren2005@gmail.com> | 2014-09-23 15:03:37 -0700 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2014-09-23 15:03:37 -0700 |
commit | afb593f2be23339ec52fb96d8498739c40480f04 (patch) | |
tree | f72e88578c464eaa9a407e71021d75ef49d2f31e /src/github/daneren2005 | |
parent | 0ae5f68c6f719b83a1aa21600ed0dfa4d80824d0 (diff) | |
download | dsub-afb593f2be23339ec52fb96d8498739c40480f04.tar.gz dsub-afb593f2be23339ec52fb96d8498739c40480f04.tar.bz2 dsub-afb593f2be23339ec52fb96d8498739c40480f04.zip |
#43 Keep track of whether or not we are playing a single album for replay gain purposes
Diffstat (limited to 'src/github/daneren2005')
-rw-r--r-- | src/github/daneren2005/dsub/service/DownloadService.java | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/src/github/daneren2005/dsub/service/DownloadService.java b/src/github/daneren2005/dsub/service/DownloadService.java index d008035c..7f822c58 100644 --- a/src/github/daneren2005/dsub/service/DownloadService.java +++ b/src/github/daneren2005/dsub/service/DownloadService.java @@ -138,6 +138,7 @@ public class DownloadService extends Service { private boolean downloadOngoing = false; private float volume = 1.0f; private boolean singleAlbum = false; + private String singleAlbumName; private AudioEffectsController effectsController; private RemoteControlState remoteState = RemoteControlState.LOCAL; @@ -316,7 +317,7 @@ public class DownloadService extends Service { for (MusicDirectory.Entry song : songs) { if(song != null) { DownloadFile downloadFile = new DownloadFile(this, song, save); - downloadList.add(getCurrentPlayingIndex() + offset, downloadFile); + addToDownloadList(downloadFile, getCurrentPlayingIndex() + offset); offset++; } } @@ -327,7 +328,7 @@ public class DownloadService extends Service { int index = getCurrentPlayingIndex(); for (MusicDirectory.Entry song : songs) { DownloadFile downloadFile = new DownloadFile(this, song, save); - downloadList.add(downloadFile); + addToDownloadList(downloadFile, -1); } if(!autoplay && (size - 1) == index) { setNextPlaying(); @@ -354,6 +355,27 @@ public class DownloadService extends Service { } lifecycleSupport.serializeDownloadQueue(); } + private void addToDownloadList(DownloadFile file, int offset) { + if(offset == -1) { + downloadList.add(downloadList); + } else { + downloadList.add(offset, file); + } + + // Check if we are still dealing with a single album + // Don't bother with check if it is already false + if(singleAlbum) { + // If first download, set album to it + if(singleAlbumName == null) { + singleAlbumName = file.getSong().getAlbum(); + } else { + // Otherwise, check again previous album name + if(!singleAlbumName.equals(file.getSong().getAlbum())) { + singleAlbum = false; + } + } + } + } public synchronized void downloadBackground(List<MusicDirectory.Entry> songs, boolean save) { for (MusicDirectory.Entry song : songs) { DownloadFile downloadFile = new DownloadFile(this, song, save); @@ -616,6 +638,8 @@ public class DownloadService extends Service { suggestedPlaylistName = null; suggestedPlaylistId = null; + singleAlbum = true; + singleAlbumName = null; } public synchronized void remove(int which) { @@ -1792,6 +1816,7 @@ public class DownloadService extends Service { } } currentPlayingIndex = downloadList.indexOf(currentPlaying); + singleAlbum = false; if (revisionBefore != revision) { updateJukeboxPlaylist(); |