diff options
Diffstat (limited to 'src/github/daneren2005/dsub/service/CachedMusicService.java')
-rw-r--r-- | src/github/daneren2005/dsub/service/CachedMusicService.java | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/src/github/daneren2005/dsub/service/CachedMusicService.java b/src/github/daneren2005/dsub/service/CachedMusicService.java index 3c6168d2..3930fc3e 100644 --- a/src/github/daneren2005/dsub/service/CachedMusicService.java +++ b/src/github/daneren2005/dsub/service/CachedMusicService.java @@ -382,7 +382,27 @@ public class CachedMusicService implements MusicService { @Override public MusicDirectory getPodcastEpisodes(boolean refresh, String id, Context context, ProgressListener progressListener) throws Exception { - return musicService.getPodcastEpisodes(refresh, id, context, progressListener); + checkSettingsChanged(context); + String altId = "p-" + id; + TimeLimitedCache<MusicDirectory> cache = refresh ? null : cachedMusicDirectories.get(altId); + MusicDirectory result = (cache == null) ? null : cache.get(); + + if(result == null) { + if(!refresh) { + result = FileUtil.deserialize(context, getCacheName(context, "directory", altId), MusicDirectory.class, 10); + } + + if(result == null) { + result = musicService.getPodcastEpisodes(refresh, id, context, progressListener); + FileUtil.serialize(context, result, getCacheName(context, "directory", altId)); + } + cache = new TimeLimitedCache<MusicDirectory>(TTL_MUSIC_DIR, TimeUnit.SECONDS); + cache.set(result); + cachedMusicDirectories.put(altId, cache); + } + return result; + + } @Override |