diff options
author | H. Lehmann <ByteHamster@users.noreply.github.com> | 2019-01-03 19:05:03 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-01-03 19:05:03 +0100 |
commit | d7e7684cc0a582d0b41d7616a6f69956625f6221 (patch) | |
tree | 150eb13111166e6b7749b2421c3036a85d624108 /app/src | |
parent | 7a92f8a2ba38159253a3dda49cbc0516569a198d (diff) | |
parent | b1ae1f8f2fdaa608880254a714da7db4c00f42e6 (diff) | |
download | AntennaPod-d7e7684cc0a582d0b41d7616a6f69956625f6221.zip |
Merge pull request #2859 from ByteHamster/glide-48
Upgraded Glide to version 4.8.0
Diffstat (limited to 'app/src')
20 files changed, 253 insertions, 168 deletions
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index c3310721f..cff85e905 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -392,10 +392,6 @@ </provider> <meta-data - android:name="de.danoeh.antennapod.core.glide.ApGlideModule" - android:value="GlideModule" /> - - <meta-data android:name="com.google.android.gms.car.application" android:resource="@xml/automotive_app_desc"/> </application> 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 178d0e743..bfa694e5c 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/FeedInfoActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/FeedInfoActivity.java @@ -18,6 +18,7 @@ import android.widget.TextView; import android.widget.Toast; import com.bumptech.glide.Glide; +import com.bumptech.glide.request.RequestOptions; import com.joanzapata.iconify.Iconify; import org.apache.commons.lang3.StringUtils; @@ -122,19 +123,21 @@ public class FeedInfoActivity extends AppCompatActivity { Log.d(TAG, "URL is " + feed.getDownload_url()); Glide.with(FeedInfoActivity.this) .load(feed.getImageLocation()) - .placeholder(R.color.light_gray) - .error(R.color.light_gray) - .diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY) - .fitCenter() - .dontAnimate() + .apply(new RequestOptions() + .placeholder(R.color.light_gray) + .error(R.color.light_gray) + .diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY) + .fitCenter() + .dontAnimate()) .into(imgvCover); Glide.with(FeedInfoActivity.this) .load(feed.getImageLocation()) - .placeholder(R.color.image_readability_tint) - .error(R.color.image_readability_tint) - .diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY) - .transform(new FastBlurTransformation(FeedInfoActivity.this)) - .dontAnimate() + .apply(new RequestOptions() + .placeholder(R.color.image_readability_tint) + .error(R.color.image_readability_tint) + .diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY) + .transform(new FastBlurTransformation()) + .dontAnimate()) .into(imgvBackground); txtvTitle.setText(feed.getTitle()); diff --git a/app/src/main/java/de/danoeh/antennapod/activity/FeedSettingsActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/FeedSettingsActivity.java index f7bde5f21..4698ed90e 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/FeedSettingsActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/FeedSettingsActivity.java @@ -25,6 +25,7 @@ import android.widget.Spinner; import android.widget.TextView; import com.bumptech.glide.Glide; +import com.bumptech.glide.request.RequestOptions; import de.danoeh.antennapod.R; import de.danoeh.antennapod.core.dialog.ConfirmationDialog; @@ -153,19 +154,21 @@ public class FeedSettingsActivity extends AppCompatActivity { FeedPreferences prefs = feed.getPreferences(); Glide.with(FeedSettingsActivity.this) .load(feed.getImageLocation()) - .placeholder(R.color.light_gray) - .error(R.color.light_gray) - .diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY) - .fitCenter() - .dontAnimate() + .apply(new RequestOptions() + .placeholder(R.color.light_gray) + .error(R.color.light_gray) + .diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY) + .fitCenter() + .dontAnimate()) .into(imgvCover); Glide.with(FeedSettingsActivity.this) .load(feed.getImageLocation()) - .placeholder(R.color.image_readability_tint) - .error(R.color.image_readability_tint) - .diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY) - .transform(new FastBlurTransformation(FeedSettingsActivity.this)) - .dontAnimate() + .apply(new RequestOptions() + .placeholder(R.color.image_readability_tint) + .error(R.color.image_readability_tint) + .diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY) + .transform(new FastBlurTransformation()) + .dontAnimate()) .into(imgvBackground); txtvTitle.setText(feed.getTitle()); diff --git a/app/src/main/java/de/danoeh/antennapod/activity/OnlineFeedViewActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/OnlineFeedViewActivity.java index 55128e1fe..73da9a834 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/OnlineFeedViewActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/OnlineFeedViewActivity.java @@ -28,6 +28,7 @@ import android.widget.TextView; import com.bumptech.glide.Glide; +import com.bumptech.glide.request.RequestOptions; import org.apache.commons.lang3.StringUtils; import org.jsoup.Jsoup; import org.jsoup.nodes.Document; @@ -397,11 +398,12 @@ public class OnlineFeedViewActivity extends AppCompatActivity { if (StringUtils.isNotBlank(feed.getImageUrl())) { Glide.with(this) .load(feed.getImageUrl()) - .placeholder(R.color.light_gray) - .error(R.color.light_gray) - .diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY) - .fitCenter() - .dontAnimate() + .apply(new RequestOptions() + .placeholder(R.color.light_gray) + .error(R.color.light_gray) + .diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY) + .fitCenter() + .dontAnimate()) .into(cover); } diff --git a/app/src/main/java/de/danoeh/antennapod/adapter/AllEpisodesRecycleAdapter.java b/app/src/main/java/de/danoeh/antennapod/adapter/AllEpisodesRecycleAdapter.java index da1ce7670..0b2b81edb 100644 --- a/app/src/main/java/de/danoeh/antennapod/adapter/AllEpisodesRecycleAdapter.java +++ b/app/src/main/java/de/danoeh/antennapod/adapter/AllEpisodesRecycleAdapter.java @@ -20,7 +20,6 @@ import android.widget.LinearLayout; import android.widget.ProgressBar; import android.widget.TextView; -import com.bumptech.glide.Glide; import com.joanzapata.iconify.Iconify; import java.lang.ref.WeakReference; @@ -29,7 +28,6 @@ import de.danoeh.antennapod.R; import de.danoeh.antennapod.activity.MainActivity; 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; import de.danoeh.antennapod.core.util.DateUtils; @@ -193,12 +191,12 @@ public class AllEpisodesRecycleAdapter extends RecyclerView.Adapter<AllEpisodesR holder.butSecondary.setTag(item); holder.butSecondary.setOnClickListener(secondaryActionListener); - Glide.with(mainActivityRef.get()) - .load(item.getImageLocation()) - .diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY) - .fitCenter() - .dontAnimate() - .into(new CoverTarget(item.getFeed().getImageLocation(), holder.placeholder, holder.cover, mainActivityRef.get())); + new CoverLoader(mainActivityRef.get()) + .withUri(item.getImageLocation()) + .withFallbackUri(item.getFeed().getImageLocation()) + .withPlaceholderView(holder.placeholder) + .withCoverView(holder.cover) + .load(); } @Nullable diff --git a/app/src/main/java/de/danoeh/antennapod/adapter/CoverLoader.java b/app/src/main/java/de/danoeh/antennapod/adapter/CoverLoader.java new file mode 100644 index 000000000..54ecdae77 --- /dev/null +++ b/app/src/main/java/de/danoeh/antennapod/adapter/CoverLoader.java @@ -0,0 +1,113 @@ +package de.danoeh.antennapod.adapter; + +import android.graphics.drawable.Drawable; +import android.os.Handler; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; +import android.view.View; +import android.widget.ImageView; +import android.widget.TextView; + +import com.bumptech.glide.Glide; +import com.bumptech.glide.RequestBuilder; +import com.bumptech.glide.request.RequestOptions; +import com.bumptech.glide.request.target.CustomViewTarget; + +import java.lang.ref.WeakReference; + +import com.bumptech.glide.request.transition.Transition; +import de.danoeh.antennapod.activity.MainActivity; +import de.danoeh.antennapod.core.glide.ApGlideSettings; + +public class CoverLoader { + private String uri; + private String fallbackUri; + private TextView txtvPlaceholder; + private ImageView imgvCover; + private MainActivity activity; + private int errorResource = -1; + + public CoverLoader(MainActivity activity) { + this.activity = activity; + } + + public CoverLoader withUri(String uri) { + this.uri = uri; + return this; + } + + public CoverLoader withFallbackUri(String uri) { + fallbackUri = uri; + return this; + } + + public CoverLoader withCoverView(ImageView coverView) { + imgvCover = coverView; + return this; + } + + public CoverLoader withError(int errorResource) { + this.errorResource = errorResource; + return this; + } + + public CoverLoader withPlaceholderView(TextView placeholderView) { + txtvPlaceholder = placeholderView; + return this; + } + + public void load() { + RequestOptions options = new RequestOptions() + .diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY) + .fitCenter() + .dontAnimate(); + + if (errorResource != -1) { + options = options.error(errorResource); + } + + RequestBuilder builder = Glide.with(activity) + .load(uri) + .apply(options); + + if (fallbackUri != null && txtvPlaceholder != null && imgvCover != null) { + builder = builder.error(Glide.with(activity) + .load(fallbackUri) + .apply(options)); + } + + builder.into(new CoverTarget(txtvPlaceholder, imgvCover)); + } + + class CoverTarget extends CustomViewTarget<ImageView, Drawable> { + private final WeakReference<TextView> placeholder; + private final WeakReference<ImageView> cover; + + public CoverTarget(TextView txtvPlaceholder, ImageView imgvCover) { + super(imgvCover); + placeholder = new WeakReference<>(txtvPlaceholder); + cover = new WeakReference<>(imgvCover); + } + + @Override + public void onLoadFailed(Drawable errorDrawable) { + + } + + @Override + public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) { + TextView txtvPlaceholder = placeholder.get(); + if (txtvPlaceholder != null) { + txtvPlaceholder.setVisibility(View.INVISIBLE); + } + ImageView ivCover = cover.get(); + ivCover.setImageDrawable(resource); + } + + @Override + protected void onResourceCleared(@Nullable Drawable placeholder) { + ImageView ivCover = cover.get(); + ivCover.setImageDrawable(placeholder); + } + } +}
\ No newline at end of file diff --git a/app/src/main/java/de/danoeh/antennapod/adapter/CoverTarget.java b/app/src/main/java/de/danoeh/antennapod/adapter/CoverTarget.java deleted file mode 100644 index ba6e7b25d..000000000 --- a/app/src/main/java/de/danoeh/antennapod/adapter/CoverTarget.java +++ /dev/null @@ -1,57 +0,0 @@ -package de.danoeh.antennapod.adapter; - -import android.graphics.drawable.Drawable; -import android.view.View; -import android.widget.ImageView; -import android.widget.TextView; - -import com.bumptech.glide.Glide; -import com.bumptech.glide.load.resource.drawable.GlideDrawable; -import com.bumptech.glide.request.animation.GlideAnimation; -import com.bumptech.glide.request.target.GlideDrawableImageViewTarget; - -import java.lang.ref.WeakReference; - -import de.danoeh.antennapod.activity.MainActivity; -import de.danoeh.antennapod.core.glide.ApGlideSettings; - -class CoverTarget extends GlideDrawableImageViewTarget { - - private final WeakReference<String> fallback; - private final WeakReference<TextView> placeholder; - private final WeakReference<ImageView> cover; - private final WeakReference<MainActivity> mainActivity; - - public CoverTarget(String fallbackUri, TextView txtvPlaceholder, ImageView imgvCover, MainActivity activity) { - super(imgvCover); - fallback = new WeakReference<>(fallbackUri); - placeholder = new WeakReference<>(txtvPlaceholder); - cover = new WeakReference<>(imgvCover); - mainActivity = new WeakReference<>(activity); - } - - @Override - public void onLoadFailed(Exception e, Drawable errorDrawable) { - String fallbackUri = fallback.get(); - TextView txtvPlaceholder = placeholder.get(); - ImageView imgvCover = cover.get(); - if (fallbackUri != null && txtvPlaceholder != null && imgvCover != null) { - MainActivity activity = mainActivity.get(); - Glide.with(activity) - .load(fallbackUri) - .diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY) - .fitCenter() - .dontAnimate() - .into(new CoverTarget(null, txtvPlaceholder, imgvCover, activity)); - } - } - - @Override - public void onResourceReady(GlideDrawable drawable, GlideAnimation<? super GlideDrawable> anim) { - super.onResourceReady(drawable, anim); - TextView txtvPlaceholder = placeholder.get(); - if (txtvPlaceholder != null) { - txtvPlaceholder.setVisibility(View.INVISIBLE); - } - } -} 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 014e43ee7..cd636af43 100644 --- a/app/src/main/java/de/danoeh/antennapod/adapter/DownloadedEpisodesListAdapter.java +++ b/app/src/main/java/de/danoeh/antennapod/adapter/DownloadedEpisodesListAdapter.java @@ -13,6 +13,7 @@ import android.widget.TextView; import com.bumptech.glide.Glide; +import com.bumptech.glide.request.RequestOptions; import de.danoeh.antennapod.R; import de.danoeh.antennapod.core.feed.FeedItem; import de.danoeh.antennapod.core.glide.ApGlideSettings; @@ -79,11 +80,12 @@ public class DownloadedEpisodesListAdapter extends BaseAdapter { Glide.with(context) .load(item.getImageLocation()) - .placeholder(R.color.light_gray) - .error(R.color.light_gray) - .diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY) - .fitCenter() - .dontAnimate() + .apply(new RequestOptions() + .placeholder(R.color.light_gray) + .error(R.color.light_gray) + .diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY) + .fitCenter() + .dontAnimate()) .into(holder.imageView); if(item.isPlayed()) { 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 5adf662b3..fbf6b804a 100644 --- a/app/src/main/java/de/danoeh/antennapod/adapter/NavListAdapter.java +++ b/app/src/main/java/de/danoeh/antennapod/adapter/NavListAdapter.java @@ -17,6 +17,7 @@ import android.widget.RelativeLayout; import android.widget.TextView; import com.bumptech.glide.Glide; +import com.bumptech.glide.request.RequestOptions; import com.joanzapata.iconify.Iconify; import com.joanzapata.iconify.widget.IconTextView; @@ -336,11 +337,12 @@ public class NavListAdapter extends BaseAdapter Glide.with(context) .load(feed.getImageLocation()) - .placeholder(R.color.light_gray) - .error(R.color.light_gray) - .diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY) - .fitCenter() - .dontAnimate() + .apply(new RequestOptions() + .placeholder(R.color.light_gray) + .error(R.color.light_gray) + .diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY) + .fitCenter() + .dontAnimate()) .into(holder.image); holder.title.setText(feed.getTitle()); diff --git a/app/src/main/java/de/danoeh/antennapod/adapter/QueueRecyclerAdapter.java b/app/src/main/java/de/danoeh/antennapod/adapter/QueueRecyclerAdapter.java index 3ad9dc79c..df8cafb9d 100644 --- a/app/src/main/java/de/danoeh/antennapod/adapter/QueueRecyclerAdapter.java +++ b/app/src/main/java/de/danoeh/antennapod/adapter/QueueRecyclerAdapter.java @@ -23,6 +23,7 @@ import android.widget.ProgressBar; import android.widget.TextView; import com.bumptech.glide.Glide; +import com.bumptech.glide.request.RequestOptions; import com.joanzapata.iconify.Iconify; import org.apache.commons.lang3.ArrayUtils; @@ -291,12 +292,12 @@ public class QueueRecyclerAdapter extends RecyclerView.Adapter<QueueRecyclerAdap butSecondary.setTag(item); butSecondary.setOnClickListener(secondaryActionListener); - Glide.with(mainActivity.get()) - .load(item.getImageLocation()) - .diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY) - .fitCenter() - .dontAnimate() - .into(new CoverTarget(item.getFeed().getImageLocation(), placeholder, cover, mainActivity.get())); + new CoverLoader(mainActivity.get()) + .withUri(item.getImageLocation()) + .withFallbackUri(item.getFeed().getImageLocation()) + .withPlaceholderView(placeholder) + .withCoverView(cover) + .load(); } } 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 74c0d6473..45cb4af87 100644 --- a/app/src/main/java/de/danoeh/antennapod/adapter/SearchlistAdapter.java +++ b/app/src/main/java/de/danoeh/antennapod/adapter/SearchlistAdapter.java @@ -12,6 +12,7 @@ import android.widget.TextView; import com.bumptech.glide.Glide; +import com.bumptech.glide.request.RequestOptions; import de.danoeh.antennapod.R; import de.danoeh.antennapod.core.feed.Feed; import de.danoeh.antennapod.core.feed.FeedComponent; @@ -81,11 +82,12 @@ public class SearchlistAdapter extends BaseAdapter { Glide.with(context) .load(feed.getImageLocation()) - .placeholder(R.color.light_gray) - .error(R.color.light_gray) - .diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY) - .fitCenter() - .dontAnimate() + .apply(new RequestOptions() + .placeholder(R.color.light_gray) + .error(R.color.light_gray) + .diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY) + .fitCenter() + .dontAnimate()) .into(holder.cover); } else if (component.getClass() == FeedItem.class) { @@ -100,11 +102,12 @@ public class SearchlistAdapter extends BaseAdapter { Glide.with(context) .load(item.getFeed().getImageLocation()) - .placeholder(R.color.light_gray) - .error(R.color.light_gray) - .diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY) - .fitCenter() - .dontAnimate() + .apply(new RequestOptions() + .placeholder(R.color.light_gray) + .error(R.color.light_gray) + .diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY) + .fitCenter() + .dontAnimate()) .into(holder.cover); } diff --git a/app/src/main/java/de/danoeh/antennapod/adapter/StatisticsListAdapter.java b/app/src/main/java/de/danoeh/antennapod/adapter/StatisticsListAdapter.java index d1f1d85bc..31e82dbe0 100644 --- a/app/src/main/java/de/danoeh/antennapod/adapter/StatisticsListAdapter.java +++ b/app/src/main/java/de/danoeh/antennapod/adapter/StatisticsListAdapter.java @@ -13,6 +13,7 @@ import com.bumptech.glide.Glide; import java.util.ArrayList; import java.util.List; +import com.bumptech.glide.request.RequestOptions; import de.danoeh.antennapod.R; import de.danoeh.antennapod.core.feed.Feed; import de.danoeh.antennapod.core.glide.ApGlideSettings; @@ -72,11 +73,12 @@ public class StatisticsListAdapter extends BaseAdapter { Glide.with(context) .load(feed.getImageLocation()) - .placeholder(R.color.light_gray) - .error(R.color.light_gray) - .diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY) - .fitCenter() - .dontAnimate() + .apply(new RequestOptions() + .placeholder(R.color.light_gray) + .error(R.color.light_gray) + .diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY) + .fitCenter() + .dontAnimate()) .into(holder.image); holder.title.setText(feed.getTitle()); diff --git a/app/src/main/java/de/danoeh/antennapod/adapter/SubscriptionsAdapter.java b/app/src/main/java/de/danoeh/antennapod/adapter/SubscriptionsAdapter.java index 9230967ab..763dcb57d 100644 --- a/app/src/main/java/de/danoeh/antennapod/adapter/SubscriptionsAdapter.java +++ b/app/src/main/java/de/danoeh/antennapod/adapter/SubscriptionsAdapter.java @@ -14,6 +14,7 @@ import com.bumptech.glide.Glide; import java.lang.ref.WeakReference; +import com.bumptech.glide.request.RequestOptions; import de.danoeh.antennapod.R; import de.danoeh.antennapod.activity.MainActivity; import de.danoeh.antennapod.core.feed.Feed; @@ -108,7 +109,7 @@ public class SubscriptionsAdapter extends BaseAdapter implements AdapterView.OnI holder.count.setVisibility(View.INVISIBLE); // when this holder is reused, we could else end up with a cover image - Glide.clear(holder.imageView); + Glide.with(mainActivityRef.get()).clear(holder.imageView); return convertView; } @@ -125,13 +126,13 @@ public class SubscriptionsAdapter extends BaseAdapter implements AdapterView.OnI } else { holder.count.setVisibility(View.GONE); } - Glide.with(mainActivityRef.get()) - .load(feed.getImageLocation()) - .error(R.color.light_gray) - .diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY) - .fitCenter() - .dontAnimate() - .into(new CoverTarget(null, holder.feedTitle, holder.imageView, mainActivityRef.get())); + + new CoverLoader(mainActivityRef.get()) + .withUri(feed.getImageLocation()) + .withPlaceholderView(holder.feedTitle) + .withCoverView(holder.imageView) + .withError(R.color.light_gray) + .load(); return convertView; } 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 9cc0e36cf..06c80e173 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 @@ -10,6 +10,7 @@ import android.widget.TextView; import com.bumptech.glide.Glide; +import com.bumptech.glide.request.RequestOptions; import org.apache.commons.lang3.StringUtils; import java.util.List; @@ -52,11 +53,12 @@ public class PodcastListAdapter extends ArrayAdapter<GpodnetPodcast> { if (StringUtils.isNotBlank(podcast.getLogoUrl())) { Glide.with(convertView.getContext()) .load(podcast.getLogoUrl()) - .placeholder(R.color.light_gray) - .error(R.color.light_gray) - .diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY) - .fitCenter() - .dontAnimate() + .apply(new RequestOptions() + .placeholder(R.color.light_gray) + .error(R.color.light_gray) + .diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY) + .fitCenter() + .dontAnimate()) .into(holder.image); } diff --git a/app/src/main/java/de/danoeh/antennapod/adapter/itunes/ItunesAdapter.java b/app/src/main/java/de/danoeh/antennapod/adapter/itunes/ItunesAdapter.java index b103026dc..2cf17c85f 100644 --- a/app/src/main/java/de/danoeh/antennapod/adapter/itunes/ItunesAdapter.java +++ b/app/src/main/java/de/danoeh/antennapod/adapter/itunes/ItunesAdapter.java @@ -12,6 +12,8 @@ import android.widget.TextView; import com.bumptech.glide.Glide; import com.bumptech.glide.load.engine.DiskCacheStrategy; +import com.bumptech.glide.request.RequestOptions; +import de.danoeh.antennapod.core.glide.ApGlideSettings; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; @@ -80,10 +82,11 @@ public class ItunesAdapter extends ArrayAdapter<ItunesAdapter.Podcast> { //Update the empty imageView with the image from the feed Glide.with(context) .load(podcast.imageUrl) - .placeholder(R.color.light_gray) - .diskCacheStrategy(DiskCacheStrategy.NONE) - .fitCenter() - .dontAnimate() + .apply(new RequestOptions() + .placeholder(R.color.light_gray) + .diskCacheStrategy(DiskCacheStrategy.NONE) + .fitCenter() + .dontAnimate()) .into(viewHolder.coverView); //Feed the grid view 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 0230c9036..5a061c7e6 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/CoverFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/CoverFragment.java @@ -11,6 +11,7 @@ import android.widget.TextView; import com.bumptech.glide.Glide; +import com.bumptech.glide.request.RequestOptions; import de.danoeh.antennapod.R; import de.danoeh.antennapod.activity.MediaplayerInfoActivity.MediaplayerInfoContentFragment; import de.danoeh.antennapod.core.glide.ApGlideSettings; @@ -60,9 +61,10 @@ public class CoverFragment extends Fragment implements MediaplayerInfoContentFra txtvEpisodeTitle.setText(media.getEpisodeTitle()); Glide.with(this) .load(media.getImageLocation()) - .diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY) - .dontAnimate() - .fitCenter() + .apply(new RequestOptions() + .diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY) + .dontAnimate() + .fitCenter()) .into(imgvCover); } else { Log.w(TAG, "loadMediaInfo was called while media was null"); 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 d3f3cbd7a..de2f04590 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/ExternalPlayerFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/ExternalPlayerFragment.java @@ -16,6 +16,7 @@ import android.widget.TextView; import com.bumptech.glide.Glide; +import com.bumptech.glide.request.RequestOptions; import de.danoeh.antennapod.R; import de.danoeh.antennapod.core.feed.MediaType; import de.danoeh.antennapod.core.glide.ApGlideSettings; @@ -207,11 +208,12 @@ public class ExternalPlayerFragment extends Fragment { Glide.with(getActivity()) .load(media.getImageLocation()) - .placeholder(R.color.light_gray) - .error(R.color.light_gray) - .diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY) - .fitCenter() - .dontAnimate() + .apply(new RequestOptions() + .placeholder(R.color.light_gray) + .error(R.color.light_gray) + .diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY) + .fitCenter() + .dontAnimate()) .into(imgvCover); fragmentLayout.setVisibility(View.VISIBLE); 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 ea480a7fb..bcca281d4 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/ItemFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/ItemFragment.java @@ -31,6 +31,7 @@ import android.widget.TextView; import android.widget.Toast; import com.bumptech.glide.Glide; +import com.bumptech.glide.request.RequestOptions; import com.joanzapata.iconify.Iconify; import com.joanzapata.iconify.widget.IconButton; @@ -378,11 +379,12 @@ public class ItemFragment extends Fragment implements OnSwipeGesture { Glide.with(getActivity()) .load(item.getImageLocation()) - .placeholder(R.color.light_gray) - .error(R.color.light_gray) - .diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY) - .fitCenter() - .dontAnimate() + .apply(new RequestOptions() + .placeholder(R.color.light_gray) + .error(R.color.light_gray) + .diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY) + .fitCenter() + .dontAnimate()) .into(imgvCover); progbarDownload.setVisibility(View.GONE); 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 e5fda97ce..d9e318069 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/ItemlistFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/ItemlistFragment.java @@ -24,6 +24,8 @@ import android.widget.RelativeLayout; import android.widget.TextView; import com.bumptech.glide.Glide; +import com.bumptech.glide.request.RequestOptions; +import com.joanzapata.iconify.IconDrawable; import com.joanzapata.iconify.Iconify; import com.joanzapata.iconify.widget.IconTextView; @@ -518,20 +520,22 @@ public class ItemlistFragment extends ListFragment { private void loadFeedImage() { Glide.with(getActivity()) .load(feed.getImageLocation()) - .placeholder(R.color.image_readability_tint) - .error(R.color.image_readability_tint) - .diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY) - .transform(new FastBlurTransformation(getActivity())) - .dontAnimate() + .apply(new RequestOptions() + .placeholder(R.color.image_readability_tint) + .error(R.color.image_readability_tint) + .diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY) + .transform(new FastBlurTransformation()) + .dontAnimate()) .into(imgvBackground); Glide.with(getActivity()) .load(feed.getImageLocation()) - .placeholder(R.color.light_gray) - .error(R.color.light_gray) - .diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY) - .fitCenter() - .dontAnimate() + .apply(new RequestOptions() + .placeholder(R.color.light_gray) + .error(R.color.light_gray) + .diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY) + .fitCenter() + .dontAnimate()) .into(imgvCover); } diff --git a/app/src/play/java/de/danoeh/antennapod/dialog/CustomMRControllerDialog.java b/app/src/play/java/de/danoeh/antennapod/dialog/CustomMRControllerDialog.java index 670a1fb6e..eab085479 100644 --- a/app/src/play/java/de/danoeh/antennapod/dialog/CustomMRControllerDialog.java +++ b/app/src/play/java/de/danoeh/antennapod/dialog/CustomMRControllerDialog.java @@ -35,6 +35,7 @@ import android.widget.LinearLayout; import android.widget.TextView; import com.bumptech.glide.Glide; +import com.bumptech.glide.request.RequestOptions; import com.bumptech.glide.request.target.Target; import java.util.concurrent.ExecutionException; @@ -463,10 +464,10 @@ public class CustomMRControllerDialog extends MediaRouteControllerDialog { } else if (iconUri != null) { try { art = Glide.with(getContext().getApplicationContext()) - .load(iconUri.toString()) .asBitmap() - .diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY) - .into(Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL) + .load(iconUri.toString()) + .apply(RequestOptions.diskCacheStrategyOf(ApGlideSettings.AP_DISK_CACHE_STRATEGY)) + .submit(Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL) .get(); } catch (InterruptedException | ExecutionException e) { Log.e(TAG, "Image art load failed", e); |