From 8236aba9db41fd3c4929527244a9b2aff33098dc Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Fri, 3 Jan 2014 19:59:21 -0800 Subject: If Most Recent sync is toggled, reset lists --- src/github/daneren2005/dsub/activity/SettingsActivity.java | 4 ++++ src/github/daneren2005/dsub/util/SyncUtil.java | 8 ++++++++ 2 files changed, 12 insertions(+) (limited to 'src') 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"; } -- cgit v1.2.3