diff options
author | Scott Jackson <daneren2005@gmail.com> | 2016-05-29 22:35:57 -0500 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2016-05-29 22:35:57 -0500 |
commit | fb6048141ee594dc2d30a96be3150b6a94983852 (patch) | |
tree | 0c251d496bcccaf13415168b53d73f70947be0df /app | |
parent | 6384c5ed2a654cf18948a901f8a35685d17ee248 (diff) | |
download | dsub-fb6048141ee594dc2d30a96be3150b6a94983852.tar.gz dsub-fb6048141ee594dc2d30a96be3150b6a94983852.tar.bz2 dsub-fb6048141ee594dc2d30a96be3150b6a94983852.zip |
Fix crappy network causing newest podcasts to never load
Diffstat (limited to 'app')
5 files changed, 17 insertions, 10 deletions
diff --git a/app/src/main/java/github/daneren2005/dsub/fragments/SelectPodcastsFragment.java b/app/src/main/java/github/daneren2005/dsub/fragments/SelectPodcastsFragment.java index 25be47b1..2e2a16b3 100644 --- a/app/src/main/java/github/daneren2005/dsub/fragments/SelectPodcastsFragment.java +++ b/app/src/main/java/github/daneren2005/dsub/fragments/SelectPodcastsFragment.java @@ -175,7 +175,7 @@ public class SelectPodcastsFragment extends SelectRecyclerFragment<Serializable> if(!Util.isOffline(context) && ServerInfo.hasNewestPodcastEpisodes(context)) { try { - newestEpisodes = musicService.getNewestPodcastEpisodes(10, context, listener); + newestEpisodes = musicService.getNewestPodcastEpisodes(refresh, context, listener, 10); for(MusicDirectory.Entry entry: newestEpisodes.getChildren()) { for(PodcastChannel channel: channels) { diff --git a/app/src/main/java/github/daneren2005/dsub/service/CachedMusicService.java b/app/src/main/java/github/daneren2005/dsub/service/CachedMusicService.java index 3be04cff..1a17dfb3 100644 --- a/app/src/main/java/github/daneren2005/dsub/service/CachedMusicService.java +++ b/app/src/main/java/github/daneren2005/dsub/service/CachedMusicService.java @@ -22,8 +22,6 @@ import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; -import java.util.Collections; -import java.util.Comparator; import java.util.Iterator; import java.util.List; import java.util.ListIterator; @@ -59,7 +57,6 @@ import github.daneren2005.dsub.util.SongDBHandler; import github.daneren2005.dsub.util.SyncUtil; import github.daneren2005.dsub.util.TimeLimitedCache; import github.daneren2005.dsub.util.FileUtil; -import github.daneren2005.dsub.util.UpdateHelper; import github.daneren2005.dsub.util.Util; import static github.daneren2005.dsub.domain.MusicDirectory.Entry; @@ -926,8 +923,18 @@ public class CachedMusicService implements MusicService { } @Override - public MusicDirectory getNewestPodcastEpisodes(int count, Context context, ProgressListener progressListener) throws Exception { - return musicService.getNewestPodcastEpisodes(count, context, progressListener); + public MusicDirectory getNewestPodcastEpisodes(boolean refresh, Context context, ProgressListener progressListener, int count) throws Exception { + MusicDirectory result = null; + + String cacheName = getCacheName(context, "newestPodcastEpisodes"); + try { + result = musicService.getNewestPodcastEpisodes(refresh, context, progressListener, count); + FileUtil.serialize(context, result, cacheName); + } catch(IOException e) { + result = FileUtil.deserialize(context, cacheName, MusicDirectory.class, 24); + } finally { + return result; + } } @Override diff --git a/app/src/main/java/github/daneren2005/dsub/service/MusicService.java b/app/src/main/java/github/daneren2005/dsub/service/MusicService.java index 876b45fd..22f154c4 100644 --- a/app/src/main/java/github/daneren2005/dsub/service/MusicService.java +++ b/app/src/main/java/github/daneren2005/dsub/service/MusicService.java @@ -149,7 +149,7 @@ public interface MusicService { MusicDirectory getPodcastEpisodes(boolean refresh, String id, Context context, ProgressListener progressListener) throws Exception; - MusicDirectory getNewestPodcastEpisodes(int count, Context context, ProgressListener progressListener) throws Exception; + MusicDirectory getNewestPodcastEpisodes(boolean refresh, Context context, ProgressListener progressListener, int count) throws Exception; void refreshPodcasts(Context context, ProgressListener progressListener) throws Exception; diff --git a/app/src/main/java/github/daneren2005/dsub/service/OfflineMusicService.java b/app/src/main/java/github/daneren2005/dsub/service/OfflineMusicService.java index e1929bf8..e004101d 100644 --- a/app/src/main/java/github/daneren2005/dsub/service/OfflineMusicService.java +++ b/app/src/main/java/github/daneren2005/dsub/service/OfflineMusicService.java @@ -775,7 +775,7 @@ public class OfflineMusicService implements MusicService { } @Override - public MusicDirectory getNewestPodcastEpisodes(int count, Context context, ProgressListener progressListener) throws Exception { + public MusicDirectory getNewestPodcastEpisodes(boolean refresh, Context context, ProgressListener progressListener, int count) throws Exception { throw new OfflineException(ERRORMSG); } diff --git a/app/src/main/java/github/daneren2005/dsub/service/RESTMusicService.java b/app/src/main/java/github/daneren2005/dsub/service/RESTMusicService.java index 1d9fd4af..4c3a121d 100644 --- a/app/src/main/java/github/daneren2005/dsub/service/RESTMusicService.java +++ b/app/src/main/java/github/daneren2005/dsub/service/RESTMusicService.java @@ -1336,8 +1336,8 @@ public class RESTMusicService implements MusicService { } @Override - public MusicDirectory getNewestPodcastEpisodes(int count, Context context, ProgressListener progressListener) throws Exception { - Reader reader = getReader(context, progressListener, "getNewestPodcasts", null, Arrays.asList("count"), Arrays.<Object>asList(count)); + public MusicDirectory getNewestPodcastEpisodes(boolean refresh, Context context, ProgressListener progressListener, int count) throws Exception { + Reader reader = getReader(context, progressListener, "getNewestPodcasts", null, Arrays.asList("count"), Arrays.<Object>asList(count), true); try { return new PodcastEntryParser(context, getInstance(context)).parse(null, reader, progressListener); |