Merge pull request #1071 from TomHennen/cacheallimages

Cache all images (should reduce lag displaying lists of episodes)
This commit is contained in:
Tom Hennen 2015-08-08 17:48:24 -04:00
commit b332942f16
15 changed files with 43 additions and 18 deletions

View File

@ -42,6 +42,7 @@ import de.danoeh.antennapod.core.feed.EventDistributor;
import de.danoeh.antennapod.core.feed.Feed; import de.danoeh.antennapod.core.feed.Feed;
import de.danoeh.antennapod.core.feed.MediaType; import de.danoeh.antennapod.core.feed.MediaType;
import de.danoeh.antennapod.core.feed.SimpleChapter; 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.preferences.UserPreferences;
import de.danoeh.antennapod.core.service.playback.PlaybackService; import de.danoeh.antennapod.core.service.playback.PlaybackService;
import de.danoeh.antennapod.core.storage.DBReader; import de.danoeh.antennapod.core.storage.DBReader;
@ -561,7 +562,7 @@ public class AudioplayerActivity extends MediaplayerActivity implements ItemDesc
.load(media.getImageUri()) .load(media.getImageUri())
.placeholder(R.color.light_gray) .placeholder(R.color.light_gray)
.error(R.color.light_gray) .error(R.color.light_gray)
.diskCacheStrategy(DiskCacheStrategy.SOURCE) .diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY)
.fitCenter() .fitCenter()
.dontAnimate() .dontAnimate()
.into(butShowCover); .into(butShowCover);

View File

@ -37,6 +37,7 @@ import de.danoeh.antennapod.core.dialog.DownloadRequestErrorDialogCreator;
import de.danoeh.antennapod.core.feed.EventDistributor; import de.danoeh.antennapod.core.feed.EventDistributor;
import de.danoeh.antennapod.core.feed.Feed; import de.danoeh.antennapod.core.feed.Feed;
import de.danoeh.antennapod.core.feed.FeedItem; 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.DBReader;
import de.danoeh.antennapod.core.storage.DownloadRequestException; import de.danoeh.antennapod.core.storage.DownloadRequestException;
import de.danoeh.antennapod.core.storage.DownloadRequester; import de.danoeh.antennapod.core.storage.DownloadRequester;
@ -129,7 +130,7 @@ public class DefaultOnlineFeedViewActivity extends OnlineFeedViewActivity {
.load(feed.getImage().getDownload_url()) .load(feed.getImage().getDownload_url())
.placeholder(R.color.light_gray) .placeholder(R.color.light_gray)
.error(R.color.light_gray) .error(R.color.light_gray)
.diskCacheStrategy(DiskCacheStrategy.SOURCE) .diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY)
.fitCenter() .fitCenter()
.dontAnimate() .dontAnimate()
.into(cover); .into(cover);

View File

@ -34,6 +34,7 @@ import de.danoeh.antennapod.core.dialog.ConfirmationDialog;
import de.danoeh.antennapod.core.dialog.DownloadRequestErrorDialogCreator; import de.danoeh.antennapod.core.dialog.DownloadRequestErrorDialogCreator;
import de.danoeh.antennapod.core.feed.Feed; import de.danoeh.antennapod.core.feed.Feed;
import de.danoeh.antennapod.core.feed.FeedPreferences; 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.preferences.UserPreferences;
import de.danoeh.antennapod.core.storage.DBReader; import de.danoeh.antennapod.core.storage.DBReader;
import de.danoeh.antennapod.core.storage.DBWriter; import de.danoeh.antennapod.core.storage.DBWriter;
@ -129,7 +130,7 @@ public class FeedInfoActivity extends ActionBarActivity {
.load(feed.getImageUri()) .load(feed.getImageUri())
.placeholder(R.color.light_gray) .placeholder(R.color.light_gray)
.error(R.color.light_gray) .error(R.color.light_gray)
.diskCacheStrategy(DiskCacheStrategy.SOURCE) .diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY)
.fitCenter() .fitCenter()
.dontAnimate() .dontAnimate()
.into(imgvCover); .into(imgvCover);

View File

@ -24,6 +24,7 @@ import java.lang.ref.WeakReference;
import de.danoeh.antennapod.R; import de.danoeh.antennapod.R;
import de.danoeh.antennapod.core.feed.FeedItem; import de.danoeh.antennapod.core.feed.FeedItem;
import de.danoeh.antennapod.core.feed.FeedMedia; 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.storage.DownloadRequester;
import de.danoeh.antennapod.core.util.Converter; import de.danoeh.antennapod.core.util.Converter;
@ -154,7 +155,7 @@ public class AllEpisodesListAdapter extends BaseAdapter {
Glide.with(context) Glide.with(context)
.load(item.getImageUri()) .load(item.getImageUri())
.diskCacheStrategy(DiskCacheStrategy.SOURCE) .diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY)
.fitCenter() .fitCenter()
.dontAnimate() .dontAnimate()
.into(new CoverTarget(item.getFeed().getImageUri(), holder.placeholder, holder.cover)); .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) { if(fallbackUri != null && txtvPlaceholder != null && imgvCover != null) {
Glide.with(context) Glide.with(context)
.load(fallbackUri) .load(fallbackUri)
.diskCacheStrategy(DiskCacheStrategy.SOURCE) .diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY)
.fitCenter() .fitCenter()
.dontAnimate() .dontAnimate()
.into(new CoverTarget(null, txtvPlaceholder, imgvCover)); .into(new CoverTarget(null, txtvPlaceholder, imgvCover));

View File

@ -15,6 +15,7 @@ import com.bumptech.glide.load.engine.DiskCacheStrategy;
import de.danoeh.antennapod.R; import de.danoeh.antennapod.R;
import de.danoeh.antennapod.core.feed.FeedItem; import de.danoeh.antennapod.core.feed.FeedItem;
import de.danoeh.antennapod.core.glide.ApGlideSettings;
import de.danoeh.antennapod.core.util.Converter; import de.danoeh.antennapod.core.util.Converter;
/** /**
@ -93,7 +94,7 @@ public class DownloadedEpisodesListAdapter extends BaseAdapter {
.load(item.getImageUri()) .load(item.getImageUri())
.placeholder(R.color.light_gray) .placeholder(R.color.light_gray)
.error(R.color.light_gray) .error(R.color.light_gray)
.diskCacheStrategy(DiskCacheStrategy.SOURCE) .diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY)
.fitCenter() .fitCenter()
.dontAnimate() .dontAnimate()
.into(holder.imageView); .into(holder.imageView);

View File

@ -28,6 +28,7 @@ import java.util.List;
import de.danoeh.antennapod.R; import de.danoeh.antennapod.R;
import de.danoeh.antennapod.activity.MainActivity; import de.danoeh.antennapod.activity.MainActivity;
import de.danoeh.antennapod.core.feed.Feed; 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.core.preferences.UserPreferences;
import de.danoeh.antennapod.fragment.AddFeedFragment; import de.danoeh.antennapod.fragment.AddFeedFragment;
import de.danoeh.antennapod.fragment.AllEpisodesFragment; import de.danoeh.antennapod.fragment.AllEpisodesFragment;
@ -264,7 +265,7 @@ public class NavListAdapter extends BaseAdapter
.load(feed.getImageUri()) .load(feed.getImageUri())
.placeholder(R.color.light_gray) .placeholder(R.color.light_gray)
.error(R.color.light_gray) .error(R.color.light_gray)
.diskCacheStrategy(DiskCacheStrategy.SOURCE) .diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY)
.fitCenter() .fitCenter()
.dontAnimate() .dontAnimate()
.into(holder.image); .into(holder.image);

View File

@ -25,6 +25,7 @@ import java.lang.ref.WeakReference;
import de.danoeh.antennapod.R; import de.danoeh.antennapod.R;
import de.danoeh.antennapod.core.feed.FeedItem; import de.danoeh.antennapod.core.feed.FeedItem;
import de.danoeh.antennapod.core.feed.FeedMedia; 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.preferences.UserPreferences;
import de.danoeh.antennapod.core.storage.DownloadRequester; import de.danoeh.antennapod.core.storage.DownloadRequester;
import de.danoeh.antennapod.core.util.Converter; import de.danoeh.antennapod.core.util.Converter;
@ -157,7 +158,7 @@ public class QueueListAdapter extends BaseAdapter {
Glide.with(context) Glide.with(context)
.load(item.getImageUri()) .load(item.getImageUri())
.diskCacheStrategy(DiskCacheStrategy.SOURCE) .diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY)
.fitCenter() .fitCenter()
.dontAnimate() .dontAnimate()
.into(new CoverTarget(item.getFeed().getImageUri(), holder.placeholder, holder.cover)); .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) { if(fallbackUri != null && txtvPlaceholder != null && imgvCover != null) {
Glide.with(context) Glide.with(context)
.load(fallbackUri) .load(fallbackUri)
.diskCacheStrategy(DiskCacheStrategy.SOURCE) .diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY)
.fitCenter() .fitCenter()
.dontAnimate() .dontAnimate()
.into(new CoverTarget(null, txtvPlaceholder, imgvCover)); .into(new CoverTarget(null, txtvPlaceholder, imgvCover));

View File

@ -16,6 +16,7 @@ import de.danoeh.antennapod.core.feed.Feed;
import de.danoeh.antennapod.core.feed.FeedComponent; import de.danoeh.antennapod.core.feed.FeedComponent;
import de.danoeh.antennapod.core.feed.FeedItem; import de.danoeh.antennapod.core.feed.FeedItem;
import de.danoeh.antennapod.core.feed.SearchResult; import de.danoeh.antennapod.core.feed.SearchResult;
import de.danoeh.antennapod.core.glide.ApGlideSettings;
/** /**
* List adapter for search activity. * List adapter for search activity.
@ -78,7 +79,7 @@ public class SearchlistAdapter extends BaseAdapter {
.load(feed.getImageUri()) .load(feed.getImageUri())
.placeholder(R.color.light_gray) .placeholder(R.color.light_gray)
.error(R.color.light_gray) .error(R.color.light_gray)
.diskCacheStrategy(DiskCacheStrategy.SOURCE) .diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY)
.fitCenter() .fitCenter()
.dontAnimate() .dontAnimate()
.into(holder.cover); .into(holder.cover);
@ -95,7 +96,7 @@ public class SearchlistAdapter extends BaseAdapter {
.load(item.getFeed().getImageUri()) .load(item.getFeed().getImageUri())
.placeholder(R.color.light_gray) .placeholder(R.color.light_gray)
.error(R.color.light_gray) .error(R.color.light_gray)
.diskCacheStrategy(DiskCacheStrategy.SOURCE) .diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY)
.fitCenter() .fitCenter()
.dontAnimate() .dontAnimate()
.into(holder.cover); .into(holder.cover);

View File

@ -16,6 +16,7 @@ import org.apache.commons.lang3.StringUtils;
import java.util.List; import java.util.List;
import de.danoeh.antennapod.R; import de.danoeh.antennapod.R;
import de.danoeh.antennapod.core.glide.ApGlideSettings;
import de.danoeh.antennapod.core.gpoddernet.model.GpodnetPodcast; import de.danoeh.antennapod.core.gpoddernet.model.GpodnetPodcast;
/** /**
@ -54,7 +55,7 @@ public class PodcastListAdapter extends ArrayAdapter<GpodnetPodcast> {
.load(podcast.getLogoUrl()) .load(podcast.getLogoUrl())
.placeholder(R.color.light_gray) .placeholder(R.color.light_gray)
.error(R.color.light_gray) .error(R.color.light_gray)
.diskCacheStrategy(DiskCacheStrategy.SOURCE) .diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY)
.fitCenter() .fitCenter()
.dontAnimate() .dontAnimate()
.into(holder.image); .into(holder.image);

View File

@ -17,6 +17,7 @@ import de.danoeh.antennapod.BuildConfig;
import de.danoeh.antennapod.R; import de.danoeh.antennapod.R;
import de.danoeh.antennapod.activity.AudioplayerActivity; import de.danoeh.antennapod.activity.AudioplayerActivity;
import de.danoeh.antennapod.activity.AudioplayerActivity.AudioplayerContentFragment; import de.danoeh.antennapod.activity.AudioplayerActivity.AudioplayerContentFragment;
import de.danoeh.antennapod.core.glide.ApGlideSettings;
import de.danoeh.antennapod.core.util.playback.Playable; import de.danoeh.antennapod.core.util.playback.Playable;
/** /**
@ -85,7 +86,7 @@ public class CoverFragment extends Fragment implements
.load(media.getImageUri()) .load(media.getImageUri())
.placeholder(R.color.light_gray) .placeholder(R.color.light_gray)
.error(R.color.light_gray) .error(R.color.light_gray)
.diskCacheStrategy(DiskCacheStrategy.SOURCE) .diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY)
.dontAnimate() .dontAnimate()
.into(imgvCover); .into(imgvCover);
} }

View File

@ -15,6 +15,7 @@ import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy; import com.bumptech.glide.load.engine.DiskCacheStrategy;
import de.danoeh.antennapod.R; 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.service.playback.PlaybackService;
import de.danoeh.antennapod.core.util.Converter; import de.danoeh.antennapod.core.util.Converter;
import de.danoeh.antennapod.core.util.playback.Playable; import de.danoeh.antennapod.core.util.playback.Playable;
@ -202,7 +203,7 @@ public class ExternalPlayerFragment extends Fragment {
.load(media.getImageUri()) .load(media.getImageUri())
.placeholder(R.color.light_gray) .placeholder(R.color.light_gray)
.error(R.color.light_gray) .error(R.color.light_gray)
.diskCacheStrategy(DiskCacheStrategy.SOURCE) .diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY)
.fitCenter() .fitCenter()
.dontAnimate() .dontAnimate()
.into(imgvCover); .into(imgvCover);

View File

@ -49,6 +49,7 @@ import de.danoeh.antennapod.core.feed.EventDistributor;
import de.danoeh.antennapod.core.feed.FeedItem; import de.danoeh.antennapod.core.feed.FeedItem;
import de.danoeh.antennapod.core.feed.FeedMedia; import de.danoeh.antennapod.core.feed.FeedMedia;
import de.danoeh.antennapod.core.feed.QueueEvent; 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.preferences.UserPreferences;
import de.danoeh.antennapod.core.service.download.Downloader; import de.danoeh.antennapod.core.service.download.Downloader;
import de.danoeh.antennapod.core.storage.DBReader; import de.danoeh.antennapod.core.storage.DBReader;
@ -341,7 +342,7 @@ public class ItemFragment extends Fragment implements LoaderManager.LoaderCallba
.load(item.getImageUri()) .load(item.getImageUri())
.placeholder(R.color.light_gray) .placeholder(R.color.light_gray)
.error(R.color.light_gray) .error(R.color.light_gray)
.diskCacheStrategy(DiskCacheStrategy.SOURCE) .diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY)
.fitCenter() .fitCenter()
.dontAnimate() .dontAnimate()
.into(imgvCover); .into(imgvCover);

View File

@ -57,6 +57,7 @@ import de.danoeh.antennapod.core.feed.FeedItem;
import de.danoeh.antennapod.core.feed.FeedItemFilter; import de.danoeh.antennapod.core.feed.FeedItemFilter;
import de.danoeh.antennapod.core.feed.FeedMedia; import de.danoeh.antennapod.core.feed.FeedMedia;
import de.danoeh.antennapod.core.feed.QueueEvent; 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.glide.FastBlurTransformation;
import de.danoeh.antennapod.core.service.download.DownloadService; import de.danoeh.antennapod.core.service.download.DownloadService;
import de.danoeh.antennapod.core.service.download.Downloader; import de.danoeh.antennapod.core.service.download.Downloader;
@ -519,7 +520,7 @@ public class ItemlistFragment extends ListFragment {
.load(feed.getImageUri()) .load(feed.getImageUri())
.placeholder(R.color.image_readability_tint) .placeholder(R.color.image_readability_tint)
.error(R.color.image_readability_tint) .error(R.color.image_readability_tint)
.diskCacheStrategy(DiskCacheStrategy.SOURCE) .diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY)
.transform(new FastBlurTransformation(getActivity())) .transform(new FastBlurTransformation(getActivity()))
.dontAnimate() .dontAnimate()
.into(imgvBackground); .into(imgvBackground);
@ -528,7 +529,7 @@ public class ItemlistFragment extends ListFragment {
.load(feed.getImageUri()) .load(feed.getImageUri())
.placeholder(R.color.light_gray) .placeholder(R.color.light_gray)
.error(R.color.light_gray) .error(R.color.light_gray)
.diskCacheStrategy(DiskCacheStrategy.SOURCE) .diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY)
.fitCenter() .fitCenter()
.dontAnimate() .dontAnimate()
.into(imgvCover); .into(imgvCover);

View File

@ -0,0 +1,11 @@
package de.danoeh.antennapod.core.glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
/**
* The settings that AntennaPod will use for various Glide options
*/
public class ApGlideSettings {
public static final DiskCacheStrategy AP_DISK_CACHE_STRATEGY = DiskCacheStrategy.ALL;
}

View File

@ -46,6 +46,7 @@ import de.danoeh.antennapod.core.feed.Chapter;
import de.danoeh.antennapod.core.feed.FeedItem; import de.danoeh.antennapod.core.feed.FeedItem;
import de.danoeh.antennapod.core.feed.FeedMedia; import de.danoeh.antennapod.core.feed.FeedMedia;
import de.danoeh.antennapod.core.feed.MediaType; 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;
import de.danoeh.antennapod.core.gpoddernet.model.GpodnetEpisodeAction.Action; import de.danoeh.antennapod.core.gpoddernet.model.GpodnetEpisodeAction.Action;
import de.danoeh.antennapod.core.preferences.GpodnetPreferences; import de.danoeh.antennapod.core.preferences.GpodnetPreferences;
@ -801,7 +802,7 @@ public class PlaybackService extends Service {
icon = Glide.with(PlaybackService.this) icon = Glide.with(PlaybackService.this)
.load(info.playable.getImageUri()) .load(info.playable.getImageUri())
.asBitmap() .asBitmap()
.diskCacheStrategy(DiskCacheStrategy.SOURCE) .diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY)
.into(-1, -1) // this resizing would not be exact, so we have .into(-1, -1) // this resizing would not be exact, so we have
// scale the bitmap ourselves // scale the bitmap ourselves
.get(); .get();