From f012b3222b9341e8380edc79c05eba1b04c2d00a Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Fri, 27 Dec 2013 17:31:09 -0800 Subject: #231 Fix sync adapters not serializing refreshes --- src/github/daneren2005/dsub/service/CachedMusicService.java | 6 +++--- src/github/daneren2005/dsub/service/RESTMusicService.java | 2 +- src/github/daneren2005/dsub/service/sync/PlaylistSyncAdapter.java | 2 +- src/github/daneren2005/dsub/service/sync/SubsonicSyncAdapter.java | 3 ++- 4 files changed, 7 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/github/daneren2005/dsub/service/CachedMusicService.java b/src/github/daneren2005/dsub/service/CachedMusicService.java index 3930fc3e..dfd2239e 100644 --- a/src/github/daneren2005/dsub/service/CachedMusicService.java +++ b/src/github/daneren2005/dsub/service/CachedMusicService.java @@ -57,7 +57,7 @@ public class CachedMusicService implements MusicService { private static final int MUSIC_DIR_CACHE_SIZE = 20; private static final int TTL_MUSIC_DIR = 5 * 60; // Five minutes - private final MusicService musicService; + private final RESTMusicService musicService; private final LruCache> cachedMusicDirectories; private final TimeLimitedCache cachedLicenseValid = new TimeLimitedCache(120, TimeUnit.SECONDS); private final TimeLimitedCache cachedIndexes = new TimeLimitedCache(60 * 60, TimeUnit.SECONDS); @@ -67,7 +67,7 @@ public class CachedMusicService implements MusicService { private final TimeLimitedCache> cachedPodcastChannels = new TimeLimitedCache>(10 * 3600, TimeUnit.SECONDS); private String restUrl; - public CachedMusicService(MusicService musicService) { + public CachedMusicService(RESTMusicService musicService) { this.musicService = musicService; cachedMusicDirectories = new LruCache>(MUSIC_DIR_CACHE_SIZE); } @@ -474,7 +474,7 @@ public class CachedMusicService implements MusicService { } private void checkSettingsChanged(Context context) { - String newUrl = Util.getRestUrl(context, null); + String newUrl = musicService.getRestUrl(context, null); if (!Util.equals(newUrl, restUrl)) { cachedMusicFolders.clear(); cachedMusicDirectories.evictAll(); diff --git a/src/github/daneren2005/dsub/service/RESTMusicService.java b/src/github/daneren2005/dsub/service/RESTMusicService.java index c37f02e5..348f3c1c 100644 --- a/src/github/daneren2005/dsub/service/RESTMusicService.java +++ b/src/github/daneren2005/dsub/service/RESTMusicService.java @@ -1362,7 +1362,7 @@ public class RESTMusicService implements MusicService { return networkInfo == null ? -1 : networkInfo.getType(); } - private String getRestUrl(Context context, String method) { + public String getRestUrl(Context context, String method) { if(instance == null) { return Util.getRestUrl(context, method); } else { diff --git a/src/github/daneren2005/dsub/service/sync/PlaylistSyncAdapter.java b/src/github/daneren2005/dsub/service/sync/PlaylistSyncAdapter.java index a1b20f73..ba4f34c9 100644 --- a/src/github/daneren2005/dsub/service/sync/PlaylistSyncAdapter.java +++ b/src/github/daneren2005/dsub/service/sync/PlaylistSyncAdapter.java @@ -69,7 +69,7 @@ public class PlaylistSyncAdapter extends SubsonicSyncAdapter { SyncSet cachedPlaylist = playlistList.get(i); String id = cachedPlaylist.id; try { - MusicDirectory playlist = musicService.getPlaylist(false, id, serverName, context, null); + MusicDirectory playlist = musicService.getPlaylist(true, id, serverName, context, null); // Get list of original paths List origPathList = new ArrayList(); diff --git a/src/github/daneren2005/dsub/service/sync/SubsonicSyncAdapter.java b/src/github/daneren2005/dsub/service/sync/SubsonicSyncAdapter.java index 97a68835..a78b696e 100644 --- a/src/github/daneren2005/dsub/service/sync/SubsonicSyncAdapter.java +++ b/src/github/daneren2005/dsub/service/sync/SubsonicSyncAdapter.java @@ -37,6 +37,7 @@ import android.util.Log; import java.util.List; import github.daneren2005.dsub.domain.MusicDirectory; +import github.daneren2005.dsub.service.CachedMusicService; import github.daneren2005.dsub.service.DownloadFile; import github.daneren2005.dsub.service.RESTMusicService; import github.daneren2005.dsub.util.Constants; @@ -48,7 +49,7 @@ import github.daneren2005.dsub.util.Util; public class SubsonicSyncAdapter extends AbstractThreadedSyncAdapter { private static final String TAG = SubsonicSyncAdapter.class.getSimpleName(); - protected RESTMusicService musicService = new RESTMusicService(); + protected CachedMusicService musicService = new CachedMusicService(new RESTMusicService()); private Context context; public SubsonicSyncAdapter(Context context, boolean autoInitialize) { -- cgit v1.2.3