diff options
author | Scott Jackson <daneren2005@gmail.com> | 2015-09-28 16:52:28 -0700 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2015-09-28 16:52:28 -0700 |
commit | 49a2a6a29be4e5effdb7516e39b8d13d0d351bb7 (patch) | |
tree | b5661326ff61464977f8bc73b7790d55a4c65037 | |
parent | f9dd3ded43829e883e747a96c8523e74b4ea8d17 (diff) | |
download | dsub-49a2a6a29be4e5effdb7516e39b8d13d0d351bb7.tar.gz dsub-49a2a6a29be4e5effdb7516e39b8d13d0d351bb7.tar.bz2 dsub-49a2a6a29be4e5effdb7516e39b8d13d0d351bb7.zip |
Don't allow a random list size of less than 1
3 files changed, 4 insertions, 4 deletions
diff --git a/app/src/main/java/github/daneren2005/dsub/service/DownloadService.java b/app/src/main/java/github/daneren2005/dsub/service/DownloadService.java index 6c73e8c1..f0e119bb 100644 --- a/app/src/main/java/github/daneren2005/dsub/service/DownloadService.java +++ b/app/src/main/java/github/daneren2005/dsub/service/DownloadService.java @@ -2103,7 +2103,7 @@ public class DownloadService extends Service { // Get users desired random playlist size SharedPreferences prefs = Util.getPreferences(this); - int listSize = Integer.parseInt(prefs.getString(Constants.PREFERENCES_KEY_RANDOM_SIZE, "20")); + int listSize = Math.max(1, Integer.parseInt(prefs.getString(Constants.PREFERENCES_KEY_RANDOM_SIZE, "20"))); boolean wasEmpty = downloadList.isEmpty(); long revisionBefore = revision; @@ -2145,7 +2145,7 @@ public class DownloadService extends Service { private synchronized void checkArtistRadio() { // Get users desired random playlist size SharedPreferences prefs = Util.getPreferences(this); - int listSize = Integer.parseInt(prefs.getString(Constants.PREFERENCES_KEY_RANDOM_SIZE, "20")); + int listSize = Math.max(1, Integer.parseInt(prefs.getString(Constants.PREFERENCES_KEY_RANDOM_SIZE, "20"))); boolean wasEmpty = downloadList.isEmpty(); long revisionBefore = revision; diff --git a/app/src/main/java/github/daneren2005/dsub/util/ArtistRadioBuffer.java b/app/src/main/java/github/daneren2005/dsub/util/ArtistRadioBuffer.java index 6e9b8309..2af468f6 100644 --- a/app/src/main/java/github/daneren2005/dsub/util/ArtistRadioBuffer.java +++ b/app/src/main/java/github/daneren2005/dsub/util/ArtistRadioBuffer.java @@ -52,7 +52,7 @@ public class ArtistRadioBuffer { }; // Calculate out the capacity and refill threshold based on the user's random size preference - int shuffleListSize = Integer.parseInt(Util.getPreferences(context).getString(Constants.PREFERENCES_KEY_RANDOM_SIZE, "20")); + int shuffleListSize = Math.max(1, Integer.parseInt(Util.getPreferences(context).getString(Constants.PREFERENCES_KEY_RANDOM_SIZE, "20"))); // ex: default 20 -> 50 capacity = shuffleListSize * 5 / 2; capacity = Math.min(500, capacity); diff --git a/app/src/main/java/github/daneren2005/dsub/util/ShufflePlayBuffer.java b/app/src/main/java/github/daneren2005/dsub/util/ShufflePlayBuffer.java index 7da35f77..6996acaf 100644 --- a/app/src/main/java/github/daneren2005/dsub/util/ShufflePlayBuffer.java +++ b/app/src/main/java/github/daneren2005/dsub/util/ShufflePlayBuffer.java @@ -73,7 +73,7 @@ public class ShufflePlayBuffer { executorService.scheduleWithFixedDelay(runnable, 1, 10, TimeUnit.SECONDS); // Calculate out the capacity and refill threshold based on the user's random size preference - int shuffleListSize = Integer.parseInt(Util.getPreferences(context).getString(Constants.PREFERENCES_KEY_RANDOM_SIZE, "20")); + int shuffleListSize = Math.max(1, Integer.parseInt(Util.getPreferences(context).getString(Constants.PREFERENCES_KEY_RANDOM_SIZE, "20"))); // ex: default 20 -> 50 capacity = shuffleListSize * 5 / 2; capacity = Math.min(500, capacity); |