diff options
author | Tom Hennen <tom.hennen@gmail.com> | 2015-08-08 14:22:09 -0400 |
---|---|---|
committer | Tom Hennen <tom.hennen@gmail.com> | 2015-08-08 14:22:09 -0400 |
commit | d252544d2fee0e8a2c6a18b38777cf4dc7b641c6 (patch) | |
tree | 888deb499aa74ddee803ebe5f864f8fbd880dd38 | |
parent | 57fde20d71f5d766e5e1fa50ccbcb2bda5357cb3 (diff) | |
download | AntennaPod-d252544d2fee0e8a2c6a18b38777cf4dc7b641c6.zip |
Cache all images (should reduce lag displaying lists of episodes)
Cache strategy is now set in ApGlideSettings and referenced everywhere else from there.
15 files changed, 43 insertions, 18 deletions
diff --git a/app/src/main/java/de/danoeh/antennapod/activity/AudioplayerActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/AudioplayerActivity.java index 28301313b..294acd427 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/AudioplayerActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/AudioplayerActivity.java @@ -42,6 +42,7 @@ import de.danoeh.antennapod.core.feed.EventDistributor; import de.danoeh.antennapod.core.feed.Feed; import de.danoeh.antennapod.core.feed.MediaType; import de.danoeh.antennapod.core.feed.SimpleChapter; +import de.danoeh.antennapod.core.glide.ApGlideSettings; import de.danoeh.antennapod.core.preferences.UserPreferences; import de.danoeh.antennapod.core.service.playback.PlaybackService; import de.danoeh.antennapod.core.storage.DBReader; @@ -561,7 +562,7 @@ public class AudioplayerActivity extends MediaplayerActivity implements ItemDesc .load(media.getImageUri()) .placeholder(R.color.light_gray) .error(R.color.light_gray) - .diskCacheStrategy(DiskCacheStrategy.SOURCE) + .diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY) .fitCenter() .dontAnimate() .into(butShowCover); diff --git a/app/src/main/java/de/danoeh/antennapod/activity/DefaultOnlineFeedViewActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/DefaultOnlineFeedViewActivity.java index 9114fdd1a..0993ed6d6 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/DefaultOnlineFeedViewActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/DefaultOnlineFeedViewActivity.java @@ -37,6 +37,7 @@ import de.danoeh.antennapod.core.dialog.DownloadRequestErrorDialogCreator; import de.danoeh.antennapod.core.feed.EventDistributor; import de.danoeh.antennapod.core.feed.Feed; import de.danoeh.antennapod.core.feed.FeedItem; +import de.danoeh.antennapod.core.glide.ApGlideSettings; import de.danoeh.antennapod.core.storage.DBReader; import de.danoeh.antennapod.core.storage.DownloadRequestException; import de.danoeh.antennapod.core.storage.DownloadRequester; @@ -129,7 +130,7 @@ public class DefaultOnlineFeedViewActivity extends OnlineFeedViewActivity { .load(feed.getImage().getDownload_url()) .placeholder(R.color.light_gray) .error(R.color.light_gray) - .diskCacheStrategy(DiskCacheStrategy.SOURCE) + .diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY) .fitCenter() .dontAnimate() .into(cover); diff --git a/app/src/main/java/de/danoeh/antennapod/activity/FeedInfoActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/FeedInfoActivity.java index 4d3a43c56..9cdaf2fc6 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/FeedInfoActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/FeedInfoActivity.java @@ -34,6 +34,7 @@ import de.danoeh.antennapod.core.dialog.ConfirmationDialog; import de.danoeh.antennapod.core.dialog.DownloadRequestErrorDialogCreator; import de.danoeh.antennapod.core.feed.Feed; import de.danoeh.antennapod.core.feed.FeedPreferences; +import de.danoeh.antennapod.core.glide.ApGlideSettings; import de.danoeh.antennapod.core.preferences.UserPreferences; import de.danoeh.antennapod.core.storage.DBReader; import de.danoeh.antennapod.core.storage.DBWriter; @@ -129,7 +130,7 @@ public class FeedInfoActivity extends ActionBarActivity { .load(feed.getImageUri()) .placeholder(R.color.light_gray) .error(R.color.light_gray) - .diskCacheStrategy(DiskCacheStrategy.SOURCE) + .diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY) .fitCenter() .dontAnimate() .into(imgvCover); diff --git a/app/src/main/java/de/danoeh/antennapod/adapter/AllEpisodesListAdapter.java b/app/src/main/java/de/danoeh/antennapod/adapter/AllEpisodesListAdapter.java index aebcc5e41..4b6ee8f91 100644 --- a/app/src/main/java/de/danoeh/antennapod/adapter/AllEpisodesListAdapter.java +++ b/app/src/main/java/de/danoeh/antennapod/adapter/AllEpisodesListAdapter.java @@ -24,6 +24,7 @@ import java.lang.ref.WeakReference; import de.danoeh.antennapod.R; import de.danoeh.antennapod.core.feed.FeedItem; import de.danoeh.antennapod.core.feed.FeedMedia; +import de.danoeh.antennapod.core.glide.ApGlideSettings; import de.danoeh.antennapod.core.storage.DownloadRequester; import de.danoeh.antennapod.core.util.Converter; @@ -154,7 +155,7 @@ public class AllEpisodesListAdapter extends BaseAdapter { Glide.with(context) .load(item.getImageUri()) - .diskCacheStrategy(DiskCacheStrategy.SOURCE) + .diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY) .fitCenter() .dontAnimate() .into(new CoverTarget(item.getFeed().getImageUri(), holder.placeholder, holder.cover)); @@ -183,7 +184,7 @@ public class AllEpisodesListAdapter extends BaseAdapter { if(fallbackUri != null && txtvPlaceholder != null && imgvCover != null) { Glide.with(context) .load(fallbackUri) - .diskCacheStrategy(DiskCacheStrategy.SOURCE) + .diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY) .fitCenter() .dontAnimate() .into(new CoverTarget(null, txtvPlaceholder, imgvCover)); diff --git a/app/src/main/java/de/danoeh/antennapod/adapter/DownloadedEpisodesListAdapter.java b/app/src/main/java/de/danoeh/antennapod/adapter/DownloadedEpisodesListAdapter.java index 0cf761503..2b1eccea5 100644 --- a/app/src/main/java/de/danoeh/antennapod/adapter/DownloadedEpisodesListAdapter.java +++ b/app/src/main/java/de/danoeh/antennapod/adapter/DownloadedEpisodesListAdapter.java @@ -15,6 +15,7 @@ import com.bumptech.glide.load.engine.DiskCacheStrategy; import de.danoeh.antennapod.R; import de.danoeh.antennapod.core.feed.FeedItem; +import de.danoeh.antennapod.core.glide.ApGlideSettings; import de.danoeh.antennapod.core.util.Converter; /** @@ -93,7 +94,7 @@ public class DownloadedEpisodesListAdapter extends BaseAdapter { .load(item.getImageUri()) .placeholder(R.color.light_gray) .error(R.color.light_gray) - .diskCacheStrategy(DiskCacheStrategy.SOURCE) + .diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY) .fitCenter() .dontAnimate() .into(holder.imageView); diff --git a/app/src/main/java/de/danoeh/antennapod/adapter/NavListAdapter.java b/app/src/main/java/de/danoeh/antennapod/adapter/NavListAdapter.java index a063ad9b1..3c91cbbbb 100644 --- a/app/src/main/java/de/danoeh/antennapod/adapter/NavListAdapter.java +++ b/app/src/main/java/de/danoeh/antennapod/adapter/NavListAdapter.java @@ -28,6 +28,7 @@ import java.util.List; import de.danoeh.antennapod.R; import de.danoeh.antennapod.activity.MainActivity; import de.danoeh.antennapod.core.feed.Feed; +import de.danoeh.antennapod.core.glide.ApGlideSettings; import de.danoeh.antennapod.core.preferences.UserPreferences; import de.danoeh.antennapod.fragment.AddFeedFragment; import de.danoeh.antennapod.fragment.AllEpisodesFragment; @@ -264,7 +265,7 @@ public class NavListAdapter extends BaseAdapter .load(feed.getImageUri()) .placeholder(R.color.light_gray) .error(R.color.light_gray) - .diskCacheStrategy(DiskCacheStrategy.SOURCE) + .diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY) .fitCenter() .dontAnimate() .into(holder.image); diff --git a/app/src/main/java/de/danoeh/antennapod/adapter/QueueListAdapter.java b/app/src/main/java/de/danoeh/antennapod/adapter/QueueListAdapter.java index 81208749a..60c125fda 100644 --- a/app/src/main/java/de/danoeh/antennapod/adapter/QueueListAdapter.java +++ b/app/src/main/java/de/danoeh/antennapod/adapter/QueueListAdapter.java @@ -25,6 +25,7 @@ import java.lang.ref.WeakReference; import de.danoeh.antennapod.R; import de.danoeh.antennapod.core.feed.FeedItem; import de.danoeh.antennapod.core.feed.FeedMedia; +import de.danoeh.antennapod.core.glide.ApGlideSettings; import de.danoeh.antennapod.core.preferences.UserPreferences; import de.danoeh.antennapod.core.storage.DownloadRequester; import de.danoeh.antennapod.core.util.Converter; @@ -157,7 +158,7 @@ public class QueueListAdapter extends BaseAdapter { Glide.with(context) .load(item.getImageUri()) - .diskCacheStrategy(DiskCacheStrategy.SOURCE) + .diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY) .fitCenter() .dontAnimate() .into(new CoverTarget(item.getFeed().getImageUri(), holder.placeholder, holder.cover)); @@ -186,7 +187,7 @@ public class QueueListAdapter extends BaseAdapter { if(fallbackUri != null && txtvPlaceholder != null && imgvCover != null) { Glide.with(context) .load(fallbackUri) - .diskCacheStrategy(DiskCacheStrategy.SOURCE) + .diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY) .fitCenter() .dontAnimate() .into(new CoverTarget(null, txtvPlaceholder, imgvCover)); diff --git a/app/src/main/java/de/danoeh/antennapod/adapter/SearchlistAdapter.java b/app/src/main/java/de/danoeh/antennapod/adapter/SearchlistAdapter.java index 8c1464e97..83f5dcb4d 100644 --- a/app/src/main/java/de/danoeh/antennapod/adapter/SearchlistAdapter.java +++ b/app/src/main/java/de/danoeh/antennapod/adapter/SearchlistAdapter.java @@ -16,6 +16,7 @@ import de.danoeh.antennapod.core.feed.Feed; import de.danoeh.antennapod.core.feed.FeedComponent; import de.danoeh.antennapod.core.feed.FeedItem; import de.danoeh.antennapod.core.feed.SearchResult; +import de.danoeh.antennapod.core.glide.ApGlideSettings; /** * List adapter for search activity. @@ -78,7 +79,7 @@ public class SearchlistAdapter extends BaseAdapter { .load(feed.getImageUri()) .placeholder(R.color.light_gray) .error(R.color.light_gray) - .diskCacheStrategy(DiskCacheStrategy.SOURCE) + .diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY) .fitCenter() .dontAnimate() .into(holder.cover); @@ -95,7 +96,7 @@ public class SearchlistAdapter extends BaseAdapter { .load(item.getFeed().getImageUri()) .placeholder(R.color.light_gray) .error(R.color.light_gray) - .diskCacheStrategy(DiskCacheStrategy.SOURCE) + .diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY) .fitCenter() .dontAnimate() .into(holder.cover); diff --git a/app/src/main/java/de/danoeh/antennapod/adapter/gpodnet/PodcastListAdapter.java b/app/src/main/java/de/danoeh/antennapod/adapter/gpodnet/PodcastListAdapter.java index b9993b455..743f9fc86 100644 --- a/app/src/main/java/de/danoeh/antennapod/adapter/gpodnet/PodcastListAdapter.java +++ b/app/src/main/java/de/danoeh/antennapod/adapter/gpodnet/PodcastListAdapter.java @@ -16,6 +16,7 @@ import org.apache.commons.lang3.StringUtils; import java.util.List; import de.danoeh.antennapod.R; +import de.danoeh.antennapod.core.glide.ApGlideSettings; import de.danoeh.antennapod.core.gpoddernet.model.GpodnetPodcast; /** @@ -54,7 +55,7 @@ public class PodcastListAdapter extends ArrayAdapter<GpodnetPodcast> { .load(podcast.getLogoUrl()) .placeholder(R.color.light_gray) .error(R.color.light_gray) - .diskCacheStrategy(DiskCacheStrategy.SOURCE) + .diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY) .fitCenter() .dontAnimate() .into(holder.image); diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/CoverFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/CoverFragment.java index fbd27779d..a1667cce0 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/CoverFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/CoverFragment.java @@ -17,6 +17,7 @@ import de.danoeh.antennapod.BuildConfig; import de.danoeh.antennapod.R; import de.danoeh.antennapod.activity.AudioplayerActivity; import de.danoeh.antennapod.activity.AudioplayerActivity.AudioplayerContentFragment; +import de.danoeh.antennapod.core.glide.ApGlideSettings; import de.danoeh.antennapod.core.util.playback.Playable; /** @@ -85,7 +86,7 @@ public class CoverFragment extends Fragment implements .load(media.getImageUri()) .placeholder(R.color.light_gray) .error(R.color.light_gray) - .diskCacheStrategy(DiskCacheStrategy.SOURCE) + .diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY) .dontAnimate() .into(imgvCover); } diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/ExternalPlayerFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/ExternalPlayerFragment.java index 454fe35dd..634c3c546 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/ExternalPlayerFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/ExternalPlayerFragment.java @@ -15,6 +15,7 @@ import com.bumptech.glide.Glide; import com.bumptech.glide.load.engine.DiskCacheStrategy; import de.danoeh.antennapod.R; +import de.danoeh.antennapod.core.glide.ApGlideSettings; import de.danoeh.antennapod.core.service.playback.PlaybackService; import de.danoeh.antennapod.core.util.Converter; import de.danoeh.antennapod.core.util.playback.Playable; @@ -202,7 +203,7 @@ public class ExternalPlayerFragment extends Fragment { .load(media.getImageUri()) .placeholder(R.color.light_gray) .error(R.color.light_gray) - .diskCacheStrategy(DiskCacheStrategy.SOURCE) + .diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY) .fitCenter() .dontAnimate() .into(imgvCover); diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/ItemFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/ItemFragment.java index 90bf623da..4edb7f36f 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/ItemFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/ItemFragment.java @@ -49,6 +49,7 @@ import de.danoeh.antennapod.core.feed.EventDistributor; import de.danoeh.antennapod.core.feed.FeedItem; import de.danoeh.antennapod.core.feed.FeedMedia; import de.danoeh.antennapod.core.feed.QueueEvent; +import de.danoeh.antennapod.core.glide.ApGlideSettings; import de.danoeh.antennapod.core.preferences.UserPreferences; import de.danoeh.antennapod.core.service.download.Downloader; import de.danoeh.antennapod.core.storage.DBReader; @@ -341,7 +342,7 @@ public class ItemFragment extends Fragment implements LoaderManager.LoaderCallba .load(item.getImageUri()) .placeholder(R.color.light_gray) .error(R.color.light_gray) - .diskCacheStrategy(DiskCacheStrategy.SOURCE) + .diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY) .fitCenter() .dontAnimate() .into(imgvCover); diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/ItemlistFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/ItemlistFragment.java index 9b2fd0a7c..63ebf234e 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/ItemlistFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/ItemlistFragment.java @@ -57,6 +57,7 @@ import de.danoeh.antennapod.core.feed.FeedItem; import de.danoeh.antennapod.core.feed.FeedItemFilter; import de.danoeh.antennapod.core.feed.FeedMedia; import de.danoeh.antennapod.core.feed.QueueEvent; +import de.danoeh.antennapod.core.glide.ApGlideSettings; import de.danoeh.antennapod.core.glide.FastBlurTransformation; import de.danoeh.antennapod.core.service.download.DownloadService; import de.danoeh.antennapod.core.service.download.Downloader; @@ -519,7 +520,7 @@ public class ItemlistFragment extends ListFragment { .load(feed.getImageUri()) .placeholder(R.color.image_readability_tint) .error(R.color.image_readability_tint) - .diskCacheStrategy(DiskCacheStrategy.SOURCE) + .diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY) .transform(new FastBlurTransformation(getActivity())) .dontAnimate() .into(imgvBackground); @@ -528,7 +529,7 @@ public class ItemlistFragment extends ListFragment { .load(feed.getImageUri()) .placeholder(R.color.light_gray) .error(R.color.light_gray) - .diskCacheStrategy(DiskCacheStrategy.SOURCE) + .diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY) .fitCenter() .dontAnimate() .into(imgvCover); diff --git a/core/src/main/java/de/danoeh/antennapod/core/glide/ApGlideSettings.java b/core/src/main/java/de/danoeh/antennapod/core/glide/ApGlideSettings.java new file mode 100644 index 000000000..cc8a1fe4b --- /dev/null +++ b/core/src/main/java/de/danoeh/antennapod/core/glide/ApGlideSettings.java @@ -0,0 +1,11 @@ +package de.danoeh.antennapod.core.glide; + +import com.bumptech.glide.load.engine.DiskCacheStrategy; + +/** + * Created by Tom on 8/8/15. + */ +public class ApGlideSettings { + + public static final DiskCacheStrategy AP_DISK_CACHE_STRATEGY = DiskCacheStrategy.ALL; +} diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java b/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java index aa1816e1c..7e3f27856 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java +++ b/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java @@ -46,6 +46,7 @@ import de.danoeh.antennapod.core.feed.Chapter; import de.danoeh.antennapod.core.feed.FeedItem; import de.danoeh.antennapod.core.feed.FeedMedia; import de.danoeh.antennapod.core.feed.MediaType; +import de.danoeh.antennapod.core.glide.ApGlideSettings; import de.danoeh.antennapod.core.gpoddernet.model.GpodnetEpisodeAction; import de.danoeh.antennapod.core.gpoddernet.model.GpodnetEpisodeAction.Action; import de.danoeh.antennapod.core.preferences.GpodnetPreferences; @@ -801,7 +802,7 @@ public class PlaybackService extends Service { icon = Glide.with(PlaybackService.this) .load(info.playable.getImageUri()) .asBitmap() - .diskCacheStrategy(DiskCacheStrategy.SOURCE) + .diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY) .into(-1, -1) // this resizing would not be exact, so we have // scale the bitmap ourselves .get(); |