Skip to content

Commit

Permalink
Don't allow a random list size of less than 1
Browse files Browse the repository at this point in the history
  • Loading branch information
daneren2005 committed Sep 28, 2015
1 parent f9dd3de commit 49a2a6a
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2103,7 +2103,7 @@ private synchronized void checkShufflePlay() {

// 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;
Expand Down Expand Up @@ -2145,7 +2145,7 @@ private synchronized void checkShufflePlay() {
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public void run() {
};

// 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public void run() {
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);
Expand Down

0 comments on commit 49a2a6a

Please sign in to comment.