resolved bug in how we were choosing the default cleanup parameter

This commit is contained in:
Tom Hennen 2015-10-02 07:56:34 -04:00
parent 60e341cf78
commit 0beeeb4351
5 changed files with 10 additions and 6 deletions

View File

@ -65,6 +65,7 @@ public class DBTasksTest extends InstrumentationTestCase {
SharedPreferences.Editor prefEdit = PreferenceManager.getDefaultSharedPreferences(context.getApplicationContext()).edit();
prefEdit.putString(UserPreferences.PREF_EPISODE_CACHE_SIZE, Integer.toString(EPISODE_CACHE_SIZE));
prefEdit.putInt(UserPreferences.PREF_EPISODE_CLEANUP, UserPreferences.EPISODE_CLEANUP_DEFAULT);
prefEdit.commit();
UserPreferences.init(context);

View File

@ -442,9 +442,9 @@ public class PreferenceController implements SharedPreferences.OnSharedPreferenc
String[] entries = new String[values.length];
for (int x = 0; x < values.length; x++) {
int v = Integer.parseInt(values[x]);
if (v == -1) {
if (v == UserPreferences.EPISODE_CLEANUP_QUEUE) {
entries[x] = res.getString(R.string.episode_cleanup_queue_removal);
} else if (v == -2){
} else if (v == UserPreferences.EPISODE_CLEANUP_NULL){
entries[x] = res.getString(R.string.episode_cleanup_never);
} else if (v == 0) {
entries[x] = res.getString(R.string.episode_cleanup_after_listening);

View File

@ -98,6 +98,9 @@ public class UserPreferences {
// Experimental
public static final String PREF_SONIC = "prefSonic";
public static final String PREF_NORMALIZER = "prefNormalizer";
public static final int EPISODE_CLEANUP_QUEUE = -1;
public static final int EPISODE_CLEANUP_NULL = -2;
public static final int EPISODE_CLEANUP_DEFAULT = 0;
// Constants
private static int EPISODE_CACHE_SIZE_UNLIMITED = -1;
@ -494,9 +497,9 @@ public class UserPreferences {
public static EpisodeCleanupAlgorithm getEpisodeCleanupAlgorithm() {
int cleanupValue = prefs.getInt(PREF_EPISODE_CLEANUP, -1);
if (cleanupValue == -1) {
if (cleanupValue == EPISODE_CLEANUP_QUEUE) {
return new APQueueCleanupAlgorithm();
} else if (cleanupValue == -2) {
} else if (cleanupValue == EPISODE_CLEANUP_NULL) {
return new APNullCleanupAlgorithm();
} else {
return new APCleanupAlgorithm(cleanupValue);

View File

@ -90,6 +90,6 @@ public class APCleanupAlgorithm extends EpisodeCleanupAlgorithm {
@Override
public int getDefaultCleanupParameter() {
return 0;
return getNumEpisodesToCleanup(0);
}
}

View File

@ -74,6 +74,6 @@ public class APQueueCleanupAlgorithm extends EpisodeCleanupAlgorithm {
@Override
public int getDefaultCleanupParameter() {
return 0;
return getNumEpisodesToCleanup(0);
}
}