From 419077043effff901729dcb875bc753b77ad680a Mon Sep 17 00:00:00 2001 From: ByteHamster Date: Wed, 12 Feb 2020 17:31:27 +0100 Subject: [PATCH] Fixed Glide not caching chapter images --- .../core/util/EmbeddedChapterImage.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/core/src/main/java/de/danoeh/antennapod/core/util/EmbeddedChapterImage.java b/core/src/main/java/de/danoeh/antennapod/core/util/EmbeddedChapterImage.java index 5cb62e6c2..ac55d0cfd 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/util/EmbeddedChapterImage.java +++ b/core/src/main/java/de/danoeh/antennapod/core/util/EmbeddedChapterImage.java @@ -1,6 +1,8 @@ package de.danoeh.antennapod.core.util; +import android.text.TextUtils; import de.danoeh.antennapod.core.util.playback.Playable; +import java.util.Objects; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -9,10 +11,12 @@ public class EmbeddedChapterImage { final String mime; final int position; final int length; + private final String imageUrl; final Playable media; public EmbeddedChapterImage(Playable media, String imageUrl) { this.media = media; + this.imageUrl = imageUrl; Matcher m = EMBEDDED_IMAGE_MATCHER.matcher(imageUrl); if (m.find()) { this.mime = m.group(1); @@ -43,6 +47,23 @@ public class EmbeddedChapterImage { return media; } + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EmbeddedChapterImage that = (EmbeddedChapterImage) o; + return TextUtils.equals(imageUrl, that.imageUrl); + } + + @Override + public int hashCode() { + return imageUrl.hashCode(); + } + private static boolean isEmbeddedChapterImage(String imageUrl) { return EMBEDDED_IMAGE_MATCHER.matcher(imageUrl).matches(); }