From cd55d71589666db71e964010f422960620a74cab Mon Sep 17 00:00:00 2001 From: dohe Date: Sat, 30 Mar 2024 11:35:12 +0100 Subject: [PATCH 1/2] Update context on bind Signed-off-by: Dominik Henter --- .../owncloudnewsreader/adapter/RssItemViewHolder.java | 1 + .../luhmer/owncloudnewsreader/helper/FavIconHandler.java | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/adapter/RssItemViewHolder.java b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/adapter/RssItemViewHolder.java index 0d4986e4c..ef15e105f 100644 --- a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/adapter/RssItemViewHolder.java +++ b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/adapter/RssItemViewHolder.java @@ -220,6 +220,7 @@ public void bind(@NonNull RssItem rssItem) { ImageView imgViewFavIcon = getImageViewFavIcon(); + favIconHandler.setContext(itemView.getContext()); if (imgViewFavIcon != null) { favIconHandler.loadFavIconForFeed(favIconUrl, imgViewFavIcon, Math.round((marginFavIcon - sizeOfFavIcon) / 2f)); } diff --git a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/helper/FavIconHandler.java b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/helper/FavIconHandler.java index 31291cf25..ce618abbc 100644 --- a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/helper/FavIconHandler.java +++ b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/helper/FavIconHandler.java @@ -48,8 +48,8 @@ public class FavIconHandler { private static final String TAG = FavIconHandler.class.getCanonicalName(); - private final RequestManager mGlide; - private final Context mContext; + private RequestManager mGlide; + private Context mContext; private final int mPlaceHolder; public FavIconHandler(Context context) { @@ -155,4 +155,9 @@ private void UpdateAvgColorOfFeed(long feedId, Bitmap bitmap, Context context) { Log.v(TAG, "Failed to update AVG color of feed: " + feedId); } } + + public void setContext(Context context) { + mContext = context; + mGlide = Glide.with(context); + } } From 47f6b7205849cbe67a06b5ec49793d674312b889 Mon Sep 17 00:00:00 2001 From: Dominik Henter Date: Mon, 1 Apr 2024 12:09:36 +0200 Subject: [PATCH 2/2] Check for context equality Signed-off-by: Dominik Henter --- .../de/luhmer/owncloudnewsreader/helper/FavIconHandler.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/helper/FavIconHandler.java b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/helper/FavIconHandler.java index ce618abbc..513a60364 100644 --- a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/helper/FavIconHandler.java +++ b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/helper/FavIconHandler.java @@ -157,6 +157,9 @@ private void UpdateAvgColorOfFeed(long feedId, Bitmap bitmap, Context context) { } public void setContext(Context context) { + if (context == mContext) { + return; + } mContext = context; mGlide = Glide.with(context); }