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 6c73e8c12..f0e119bb4 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 @@ 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; @@ -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; 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 6e9b8309f..2af468f69 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 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); 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 7da35f77e..6996acaf5 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 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);