Fixed Glide not caching chapter images

This commit is contained in:
ByteHamster 2020-02-12 17:31:27 +01:00
parent 9182b6da14
commit 419077043e

View File

@ -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();
}