diff options
author | Scott Jackson <daneren2005@gmail.com> | 2013-01-01 21:33:11 -0800 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2013-01-01 21:33:11 -0800 |
commit | 8068fc7478741a41695fe063df54990e595ff35d (patch) | |
tree | ed4a423708578801e734edefc3a139377daf3789 /subsonic-android/src/github | |
parent | 9dcc8661148c0189b428b212b3569dee00a895b9 (diff) | |
download | dsub-8068fc7478741a41695fe063df54990e595ff35d.tar.gz dsub-8068fc7478741a41695fe063df54990e595ff35d.tar.bz2 dsub-8068fc7478741a41695fe063df54990e595ff35d.zip |
Fix shuffle buffer being cleared on every shuffle
Diffstat (limited to 'subsonic-android/src/github')
5 files changed, 24 insertions, 32 deletions
diff --git a/subsonic-android/src/github/daneren2005/dsub/activity/SubsonicTabActivity.java b/subsonic-android/src/github/daneren2005/dsub/activity/SubsonicTabActivity.java index 250417e7..5f889e67 100644 --- a/subsonic-android/src/github/daneren2005/dsub/activity/SubsonicTabActivity.java +++ b/subsonic-android/src/github/daneren2005/dsub/activity/SubsonicTabActivity.java @@ -455,9 +455,13 @@ public class SubsonicTabActivity extends SherlockActivity { final EditText genreBox = (EditText)dialogView.findViewById(R.id.genre);
final SharedPreferences prefs = Util.getPreferences(SubsonicTabActivity.this);
- startYearBox.setText(prefs.getString(Constants.PREFERENCES_KEY_SHUFFLE_START_YEAR, ""));
- endYearBox.setText(prefs.getString(Constants.PREFERENCES_KEY_SHUFFLE_END_YEAR, ""));
- genreBox.setText(prefs.getString(Constants.PREFERENCES_KEY_SHUFFLE_GENRE, ""));
+ final String oldStartYear = prefs.getString(Constants.PREFERENCES_KEY_SHUFFLE_START_YEAR, "");
+ final String oldEndYear = prefs.getString(Constants.PREFERENCES_KEY_SHUFFLE_END_YEAR, "");
+ final String oldGenre = prefs.getString(Constants.PREFERENCES_KEY_SHUFFLE_GENRE, "");
+
+ startYearBox.setText(oldStartYear);
+ endYearBox.setText(oldEndYear);
+ genreBox.setText(oldGenre);
AlertDialog.Builder builder = new AlertDialog.Builder(SubsonicTabActivity.this);
builder.setTitle("Shuffle By")
@@ -470,8 +474,6 @@ public class SubsonicTabActivity extends SherlockActivity { String genre = genreBox.getText().toString();
String startYear = startYearBox.getText().toString();
String endYear = endYearBox.getText().toString();
- getDownloadService().setShuffleParams((genre.length() == 0) ? null : genre,
- (startYear.length() == 0) ? null : startYear, (endYear.length() == 0) ? null : endYear);
SharedPreferences.Editor editor = prefs.edit();
editor.putString(Constants.PREFERENCES_KEY_SHUFFLE_START_YEAR, startYear);
diff --git a/subsonic-android/src/github/daneren2005/dsub/service/DownloadService.java b/subsonic-android/src/github/daneren2005/dsub/service/DownloadService.java index 4f5d2f17..663a6e6c 100644 --- a/subsonic-android/src/github/daneren2005/dsub/service/DownloadService.java +++ b/subsonic-android/src/github/daneren2005/dsub/service/DownloadService.java @@ -38,8 +38,6 @@ public interface DownloadService { void setShufflePlayEnabled(boolean enabled); boolean isShufflePlayEnabled(); - - void setShuffleParams(String genre, String startYear, String endYear); void shuffle(); diff --git a/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java b/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java index 7e6a0070..b1b4c01b 100644 --- a/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java +++ b/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java @@ -312,11 +312,6 @@ public class DownloadServiceImpl extends Service implements DownloadService { public synchronized boolean isShufflePlayEnabled() { return shufflePlay; } - - @Override - public void setShuffleParams(String genre, String startYear, String endYear) { - shufflePlayBuffer.setOptions(genre, startYear, endYear); - } @Override public synchronized void shuffle() { diff --git a/subsonic-android/src/github/daneren2005/dsub/service/RESTMusicService.java b/subsonic-android/src/github/daneren2005/dsub/service/RESTMusicService.java index bc54ac36..47f92bde 100644 --- a/subsonic-android/src/github/daneren2005/dsub/service/RESTMusicService.java +++ b/subsonic-android/src/github/daneren2005/dsub/service/RESTMusicService.java @@ -502,19 +502,19 @@ public class RESTMusicService implements MusicService { names.add("size"); values.add(size); - if (musicFolderId != null) { + if (musicFolderId != null && musicFolderId != "") { names.add("musicFolderId"); values.add(musicFolderId); } - if(genre != null) { + if(genre != null && genre != "") { names.add("genre"); values.add(genre); } - if(startYear != null) { + if(startYear != null && startYear != "") { names.add("fromYear"); values.add(startYear); } - if(endYear != null) { + if(endYear != null && endYear != "") { names.add("toYear"); values.add(endYear); } diff --git a/subsonic-android/src/github/daneren2005/dsub/util/ShufflePlayBuffer.java b/subsonic-android/src/github/daneren2005/dsub/util/ShufflePlayBuffer.java index c82f0708..3c9ccc58 100644 --- a/subsonic-android/src/github/daneren2005/dsub/util/ShufflePlayBuffer.java +++ b/subsonic-android/src/github/daneren2005/dsub/util/ShufflePlayBuffer.java @@ -25,7 +25,9 @@ import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; import android.content.Context; +import android.content.SharedPreferences; import android.util.Log; +import github.daneren2005.dsub.activity.SubsonicTabActivity; import github.daneren2005.dsub.domain.MusicDirectory; import github.daneren2005.dsub.service.MusicService; import github.daneren2005.dsub.service.MusicServiceFactory; @@ -46,12 +48,12 @@ public class ShufflePlayBuffer { private int currentServer; private String currentFolder; - private String genre; - private String startYear; - private String endYear; + private String genre = ""; + private String startYear = ""; + private String endYear = ""; public ShufflePlayBuffer(Context context) { - this.context = context; + this.context = context; executorService = Executors.newSingleThreadScheduledExecutor(); Runnable runnable = new Runnable() { @Override @@ -105,22 +107,17 @@ public class ShufflePlayBuffer { private void clearBufferIfnecessary() { synchronized (buffer) { - if (currentServer != Util.getActiveServer(context) || currentFolder != Util.getSelectedMusicFolderId(context)) { + final SharedPreferences prefs = Util.getPreferences(context); + if (currentServer != Util.getActiveServer(context) || currentFolder != Util.getSelectedMusicFolderId(context) + || genre != prefs.getString(Constants.PREFERENCES_KEY_SHUFFLE_GENRE, "") || startYear != prefs.getString(Constants.PREFERENCES_KEY_SHUFFLE_START_YEAR, "") + || endYear != prefs.getString(Constants.PREFERENCES_KEY_SHUFFLE_END_YEAR, "")) { currentServer = Util.getActiveServer(context); currentFolder = Util.getSelectedMusicFolderId(context); + genre = prefs.getString(Constants.PREFERENCES_KEY_SHUFFLE_GENRE, ""); + startYear = prefs.getString(Constants.PREFERENCES_KEY_SHUFFLE_START_YEAR, ""); + endYear = prefs.getString(Constants.PREFERENCES_KEY_SHUFFLE_END_YEAR, ""); buffer.clear(); } } } - - public void setOptions(String genre, String startYear, String endYear) { - this.genre = genre; - this.startYear = startYear; - this.endYear = endYear; - - synchronized (buffer) { - buffer.clear(); - } - } - } |