summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorflofriday <flohacksfriday@gmail.com>2024-04-27 11:28:30 +0200
committerGitHub <noreply@github.com>2024-04-27 11:28:30 +0200
commitc063c59af320e15204584ede3611478d880cc407 (patch)
treeedf339a923410c41b0307c21704ed7aef369fad8
parentf69822582d6cb650bf5eca072f76874b6140aa07 (diff)
downloadAntennaPod-c063c59af320e15204584ede3611478d880cc407.zip
Fix sharp corners on placeholders (#7142)
All placeholder now have round corners matching the corner radius of the image that will eventually load.
-rw-r--r--app/src/main/java/de/danoeh/antennapod/ui/screen/drawer/NavListAdapter.java8
-rw-r--r--app/src/main/java/de/danoeh/antennapod/ui/screen/episode/ItemFragment.java6
-rw-r--r--ui/common/src/main/java/de/danoeh/antennapod/ui/common/ImagePlaceholder.java19
-rw-r--r--ui/discovery/src/main/java/de/danoeh/antennapod/ui/discovery/FeedDiscoverAdapter.java7
-rw-r--r--ui/discovery/src/main/java/de/danoeh/antennapod/ui/discovery/OnlineSearchAdapter.java7
-rw-r--r--ui/preferences/src/main/java/de/danoeh/antennapod/ui/preferences/screen/about/SimpleIconListAdapter.java6
6 files changed, 40 insertions, 13 deletions
diff --git a/app/src/main/java/de/danoeh/antennapod/ui/screen/drawer/NavListAdapter.java b/app/src/main/java/de/danoeh/antennapod/ui/screen/drawer/NavListAdapter.java
index aaf872460..601a3954a 100644
--- a/app/src/main/java/de/danoeh/antennapod/ui/screen/drawer/NavListAdapter.java
+++ b/app/src/main/java/de/danoeh/antennapod/ui/screen/drawer/NavListAdapter.java
@@ -24,6 +24,7 @@ import androidx.recyclerview.widget.RecyclerView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import de.danoeh.antennapod.R;
+import de.danoeh.antennapod.ui.common.ImagePlaceholder;
import de.danoeh.antennapod.ui.screen.preferences.PreferenceActivity;
import de.danoeh.antennapod.ui.screen.AllEpisodesFragment;
import de.danoeh.antennapod.ui.screen.download.CompletedDownloadsFragment;
@@ -314,13 +315,14 @@ public class NavListAdapter extends RecyclerView.Adapter<NavListAdapter.Holder>
return;
}
+ float radius = 4 * context.getResources().getDisplayMetrics().density;
Glide.with(context)
.load(feed.getImageUrl())
.apply(new RequestOptions()
- .placeholder(R.color.light_gray)
- .error(R.color.light_gray)
+ .placeholder(ImagePlaceholder.getDrawable(context, radius))
+ .error(ImagePlaceholder.getDrawable(context, radius))
.transform(new FitCenter(),
- new RoundedCorners((int) (4 * context.getResources().getDisplayMetrics().density)))
+ new RoundedCorners((int) radius))
.dontAnimate())
.into(holder.image);
diff --git a/app/src/main/java/de/danoeh/antennapod/ui/screen/episode/ItemFragment.java b/app/src/main/java/de/danoeh/antennapod/ui/screen/episode/ItemFragment.java
index b3a5cbbf0..e31004a57 100644
--- a/app/src/main/java/de/danoeh/antennapod/ui/screen/episode/ItemFragment.java
+++ b/app/src/main/java/de/danoeh/antennapod/ui/screen/episode/ItemFragment.java
@@ -52,6 +52,7 @@ import de.danoeh.antennapod.storage.database.DBReader;
import de.danoeh.antennapod.ui.common.Converter;
import de.danoeh.antennapod.ui.common.DateFormatter;
import de.danoeh.antennapod.ui.common.CircularProgressBar;
+import de.danoeh.antennapod.ui.common.ImagePlaceholder;
import de.danoeh.antennapod.ui.common.ThemeUtils;
import de.danoeh.antennapod.ui.cleaner.ShownotesCleaner;
import de.danoeh.antennapod.ui.episodes.ImageResourceUtils;
@@ -286,10 +287,11 @@ public class ItemFragment extends Fragment {
txtvPublished.setContentDescription(DateFormatter.formatForAccessibility(item.getPubDate()));
}
+ float radius = 8 * getResources().getDisplayMetrics().density;
RequestOptions options = new RequestOptions()
- .error(R.color.light_gray)
+ .error(ImagePlaceholder.getDrawable(getContext(), radius))
.transform(new FitCenter(),
- new RoundedCorners((int) (8 * getResources().getDisplayMetrics().density)))
+ new RoundedCorners((int) radius))
.dontAnimate();
Glide.with(this)
diff --git a/ui/common/src/main/java/de/danoeh/antennapod/ui/common/ImagePlaceholder.java b/ui/common/src/main/java/de/danoeh/antennapod/ui/common/ImagePlaceholder.java
new file mode 100644
index 000000000..b42bc6d17
--- /dev/null
+++ b/ui/common/src/main/java/de/danoeh/antennapod/ui/common/ImagePlaceholder.java
@@ -0,0 +1,19 @@
+package de.danoeh.antennapod.ui.common;
+
+import android.content.Context;
+import android.graphics.drawable.Drawable;
+import android.graphics.drawable.GradientDrawable;
+
+import androidx.core.content.ContextCompat;
+
+
+public class ImagePlaceholder {
+ public static Drawable getDrawable(Context context, float cornerRadius) {
+ GradientDrawable drawable = new GradientDrawable();
+ drawable.setShape(GradientDrawable.RECTANGLE);
+ int color = ContextCompat.getColor(context, R.color.light_gray);
+ drawable.setColor(color);
+ drawable.setCornerRadius(cornerRadius);
+ return drawable;
+ }
+}
diff --git a/ui/discovery/src/main/java/de/danoeh/antennapod/ui/discovery/FeedDiscoverAdapter.java b/ui/discovery/src/main/java/de/danoeh/antennapod/ui/discovery/FeedDiscoverAdapter.java
index ac400da9f..71b498b20 100644
--- a/ui/discovery/src/main/java/de/danoeh/antennapod/ui/discovery/FeedDiscoverAdapter.java
+++ b/ui/discovery/src/main/java/de/danoeh/antennapod/ui/discovery/FeedDiscoverAdapter.java
@@ -10,6 +10,7 @@ import com.bumptech.glide.load.resource.bitmap.FitCenter;
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
import com.bumptech.glide.request.RequestOptions;
import de.danoeh.antennapod.net.discovery.PodcastSearchResult;
+import de.danoeh.antennapod.ui.common.ImagePlaceholder;
import java.util.ArrayList;
import java.util.List;
@@ -61,12 +62,12 @@ public class FeedDiscoverAdapter extends BaseAdapter {
final PodcastSearchResult podcast = getItem(position);
holder.imageView.setContentDescription(podcast.title);
+ float radius = 8 * context.getResources().getDisplayMetrics().density;
Glide.with(context)
.load(podcast.imageUrl)
.apply(new RequestOptions()
- .placeholder(R.color.light_gray)
- .transform(new FitCenter(), new RoundedCorners((int)
- (8 * context.getResources().getDisplayMetrics().density)))
+ .placeholder(ImagePlaceholder.getDrawable(context, radius))
+ .transform(new FitCenter(), new RoundedCorners((int) radius))
.dontAnimate())
.into(holder.imageView);
diff --git a/ui/discovery/src/main/java/de/danoeh/antennapod/ui/discovery/OnlineSearchAdapter.java b/ui/discovery/src/main/java/de/danoeh/antennapod/ui/discovery/OnlineSearchAdapter.java
index a536b8ebd..36335f828 100644
--- a/ui/discovery/src/main/java/de/danoeh/antennapod/ui/discovery/OnlineSearchAdapter.java
+++ b/ui/discovery/src/main/java/de/danoeh/antennapod/ui/discovery/OnlineSearchAdapter.java
@@ -18,6 +18,7 @@ import com.bumptech.glide.request.RequestOptions;
import java.util.List;
import de.danoeh.antennapod.net.discovery.PodcastSearchResult;
+import de.danoeh.antennapod.ui.common.ImagePlaceholder;
public class OnlineSearchAdapter extends ArrayAdapter<PodcastSearchResult> {
/**
@@ -76,14 +77,14 @@ public class OnlineSearchAdapter extends ArrayAdapter<PodcastSearchResult> {
viewHolder.authorView.setVisibility(View.GONE);
}
- //Update the empty imageView with the image from the feed
+ float radius = 4 * context.getResources().getDisplayMetrics().density;
Glide.with(context)
.load(podcast.imageUrl)
.apply(new RequestOptions()
- .placeholder(R.color.light_gray)
+ .placeholder(ImagePlaceholder.getDrawable(context, radius))
.diskCacheStrategy(DiskCacheStrategy.NONE)
.transform(new FitCenter(),
- new RoundedCorners((int) (4 * context.getResources().getDisplayMetrics().density)))
+ new RoundedCorners((int) radius))
.dontAnimate())
.into(viewHolder.coverView);
diff --git a/ui/preferences/src/main/java/de/danoeh/antennapod/ui/preferences/screen/about/SimpleIconListAdapter.java b/ui/preferences/src/main/java/de/danoeh/antennapod/ui/preferences/screen/about/SimpleIconListAdapter.java
index 450f84f78..97c669143 100644
--- a/ui/preferences/src/main/java/de/danoeh/antennapod/ui/preferences/screen/about/SimpleIconListAdapter.java
+++ b/ui/preferences/src/main/java/de/danoeh/antennapod/ui/preferences/screen/about/SimpleIconListAdapter.java
@@ -13,6 +13,7 @@ import com.bumptech.glide.load.resource.bitmap.FitCenter;
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
import com.bumptech.glide.request.RequestOptions;
+import de.danoeh.antennapod.ui.common.ImagePlaceholder;
import de.danoeh.antennapod.ui.preferences.R;
import java.util.List;
@@ -43,12 +44,13 @@ public class SimpleIconListAdapter<T extends SimpleIconListAdapter.ListItem> ext
if (item.imageUrl == null) {
view.findViewById(R.id.icon).setVisibility(View.GONE);
} else {
+ float radius = 4 * context.getResources().getDisplayMetrics().density;
Glide.with(context)
.load(item.imageUrl)
.apply(new RequestOptions()
+ .placeholder(ImagePlaceholder.getDrawable(context, radius))
.diskCacheStrategy(DiskCacheStrategy.NONE)
- .transform(new FitCenter(), new RoundedCorners((int)
- (4 * context.getResources().getDisplayMetrics().density)))
+ .transform(new FitCenter(), new RoundedCorners((int) radius))
.dontAnimate())
.into(((ImageView) view.findViewById(R.id.icon)));
}