aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2014-01-03 19:59:21 -0800
committerScott Jackson <daneren2005@gmail.com>2014-01-03 19:59:21 -0800
commit8236aba9db41fd3c4929527244a9b2aff33098dc (patch)
tree64cbd0cdf8f333df9e11181a62c9798e32a817fa /src
parent828563a4919e82da1356d9f40c2cf6c73d610d3b (diff)
downloaddsub-8236aba9db41fd3c4929527244a9b2aff33098dc.tar.gz
dsub-8236aba9db41fd3c4929527244a9b2aff33098dc.tar.bz2
dsub-8236aba9db41fd3c4929527244a9b2aff33098dc.zip
If Most Recent sync is toggled, reset lists
Diffstat (limited to 'src')
-rw-r--r--src/github/daneren2005/dsub/activity/SettingsActivity.java4
-rw-r--r--src/github/daneren2005/dsub/util/SyncUtil.java8
2 files changed, 12 insertions, 0 deletions
diff --git a/src/github/daneren2005/dsub/activity/SettingsActivity.java b/src/github/daneren2005/dsub/activity/SettingsActivity.java
index c415d164..a1a58758 100644
--- a/src/github/daneren2005/dsub/activity/SettingsActivity.java
+++ b/src/github/daneren2005/dsub/activity/SettingsActivity.java
@@ -47,6 +47,7 @@ import github.daneren2005.dsub.service.MusicService;
import github.daneren2005.dsub.service.MusicServiceFactory;
import github.daneren2005.dsub.util.Constants;
import github.daneren2005.dsub.util.LoadingTask;
+import github.daneren2005.dsub.util.SyncUtil;
import github.daneren2005.dsub.view.ErrorDialog;
import github.daneren2005.dsub.util.FileUtil;
import github.daneren2005.dsub.util.Util;
@@ -243,6 +244,9 @@ public class SettingsActivity extends PreferenceActivity implements SharedPrefer
DownloadService downloadService = DownloadServiceImpl.getInstance();
downloadService.setSleepTimerDuration(Integer.parseInt(sharedPreferences.getString(key, "60")));
}
+ else if(Constants.PREFERENCES_KEY_SYNC_MOST_RECENT.equals(key)) {
+ SyncUtil.removeMostRecentSyncFiles(this);
+ }
scheduleBackup();
}
diff --git a/src/github/daneren2005/dsub/util/SyncUtil.java b/src/github/daneren2005/dsub/util/SyncUtil.java
index fe7b4e29..99e6824c 100644
--- a/src/github/daneren2005/dsub/util/SyncUtil.java
+++ b/src/github/daneren2005/dsub/util/SyncUtil.java
@@ -7,6 +7,7 @@ import android.content.Intent;
import android.support.v4.app.NotificationCompat;
import android.util.Log;
+import java.io.File;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
@@ -157,6 +158,13 @@ public final class SyncUtil {
}
return list;
}
+ public static void removeMostRecentSyncFiles(Context context) {
+ int total = Util.getServerCount(context);
+ for(int i = 0; i < total; i++) {
+ File file = new File(context.getCacheDir(), getMostRecentSyncFile(context, i));
+ file.delete();
+ }
+ }
public static String getMostRecentSyncFile(Context context, int instance) {
return "sync-most_recent-" + (Util.getRestUrl(context, null, instance, false)).hashCode() + ".ser";
}