aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2015-02-17 08:28:25 -0800
committerScott Jackson <daneren2005@gmail.com>2015-02-17 08:28:25 -0800
commit79a31e6f5cb7656b14b1cae71f7c29dcac1d2a7a (patch)
tree169fecf1d7cb38310f1674b6993dddfa4f851e22 /src
parentf0879be88ce68f3c1ce197ff35141f2d68edd046 (diff)
downloaddsub-79a31e6f5cb7656b14b1cae71f7c29dcac1d2a7a.tar.gz
dsub-79a31e6f5cb7656b14b1cae71f7c29dcac1d2a7a.tar.bz2
dsub-79a31e6f5cb7656b14b1cae71f7c29dcac1d2a7a.zip
#435 Fix ArtistRadio not being restored properly
Diffstat (limited to 'src')
-rw-r--r--src/github/daneren2005/dsub/service/DownloadService.java7
-rw-r--r--src/github/daneren2005/dsub/util/ArtistRadioBuffer.java6
2 files changed, 7 insertions, 6 deletions
diff --git a/src/github/daneren2005/dsub/service/DownloadService.java b/src/github/daneren2005/dsub/service/DownloadService.java
index 5726b696..5ab58bf6 100644
--- a/src/github/daneren2005/dsub/service/DownloadService.java
+++ b/src/github/daneren2005/dsub/service/DownloadService.java
@@ -435,8 +435,9 @@ public class DownloadService extends Service {
if(startShufflePlay != SHUFFLE_MODE_NONE) {
if(startShufflePlay == SHUFFLE_MODE_ALL) {
shufflePlay = true;
- } else {
+ } else if(startShufflePlay == SHUFFLE_MODE_ARTIST) {
artistRadio = true;
+ Log.d(TAG, "Artist id: " + prefs.getString(Constants.PREFERENCES_KEY_SHUFFLE_MODE_EXTRA, null));
artistRadioBuffer.restoreArtist(prefs.getString(Constants.PREFERENCES_KEY_SHUFFLE_MODE_EXTRA, null));
}
SharedPreferences.Editor editor = prefs.edit();
@@ -501,7 +502,9 @@ public class DownloadService extends Service {
SharedPreferences.Editor editor = Util.getPreferences(this).edit();
editor.putInt(Constants.PREFERENCES_KEY_SHUFFLE_MODE, (artistId != null) ? SHUFFLE_MODE_ARTIST : SHUFFLE_MODE_NONE);
- editor.putString(Constants.PREFERENCES_KEY_SHUFFLE_MODE_EXTRA, artistId);
+ if(artistId != null) {
+ editor.putString(Constants.PREFERENCES_KEY_SHUFFLE_MODE_EXTRA, artistId);
+ }
editor.commit();
}
diff --git a/src/github/daneren2005/dsub/util/ArtistRadioBuffer.java b/src/github/daneren2005/dsub/util/ArtistRadioBuffer.java
index 829478f7..f3fc5904 100644
--- a/src/github/daneren2005/dsub/util/ArtistRadioBuffer.java
+++ b/src/github/daneren2005/dsub/util/ArtistRadioBuffer.java
@@ -44,8 +44,6 @@ public class ArtistRadioBuffer {
public ArtistRadioBuffer(DownloadService context) {
this.context = context;
-
- executorService = Executors.newSingleThreadScheduledExecutor();
runnable = new Runnable() {
@Override
public void run() {
@@ -89,7 +87,7 @@ public class ArtistRadioBuffer {
result.add(buffer.remove(buffer.size() - 1));
}
}
- Log.i(TAG, "Taking " + result.size() + " songs from shuffle play buffer. " + buffer.size() + " remaining.");
+ Log.i(TAG, "Taking " + result.size() + " songs from artist radio buffer. " + buffer.size() + " remaining.");
if(result.isEmpty()) {
awaitingResults = true;
}
@@ -102,7 +100,7 @@ public class ArtistRadioBuffer {
private void restart() {
synchronized(buffer) {
- if(buffer.size() <= refillThreshold && lastCount != 0 && executorService.isShutdown()) {
+ if(buffer.size() <= refillThreshold && lastCount != 0 && (executorService == null || executorService.isShutdown())) {
executorService = Executors.newSingleThreadScheduledExecutor();
executorService.scheduleWithFixedDelay(runnable, 0, 10, TimeUnit.SECONDS);
}