summaryrefslogtreecommitdiff
path: root/core/src/main
diff options
context:
space:
mode:
authorByteHamster <info@bytehamster.com>2022-01-25 22:08:05 +0100
committerByteHamster <info@bytehamster.com>2022-01-25 22:08:05 +0100
commitd4d506345b222406a41ddd2a49af5c208f76e236 (patch)
treea221bd74d64a9c8837504a74405fa12c0d7f8f87 /core/src/main
parentc376be44dd14132dafe49e311714b637e3af61fd (diff)
downloadantennapod-d4d506345b222406a41ddd2a49af5c208f76e236.zip
Move mime type guessing out of MediaType enum
Diffstat (limited to 'core/src/main')
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/feed/LocalFeedUpdater.java18
1 files changed, 3 insertions, 15 deletions
diff --git a/core/src/main/java/de/danoeh/antennapod/core/feed/LocalFeedUpdater.java b/core/src/main/java/de/danoeh/antennapod/core/feed/LocalFeedUpdater.java
index 5d685c24f..7ddaa080a 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/feed/LocalFeedUpdater.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/feed/LocalFeedUpdater.java
@@ -34,6 +34,7 @@ import de.danoeh.antennapod.model.feed.FeedItem;
import de.danoeh.antennapod.model.feed.FeedMedia;
import de.danoeh.antennapod.model.feed.FeedPreferences;
import de.danoeh.antennapod.model.playback.MediaType;
+import de.danoeh.antennapod.parser.feed.util.MimeTypeUtils;
public class LocalFeedUpdater {
@@ -74,21 +75,8 @@ public class LocalFeedUpdater {
List<DocumentFile> mediaFiles = new ArrayList<>();
Set<String> mediaFileNames = new HashSet<>();
for (DocumentFile file : documentFolder.listFiles()) {
- String mime = file.getType();
- if (mime == null) {
- continue;
- }
-
- MediaType mediaType = MediaType.fromMimeType(mime);
- if (mediaType == MediaType.UNKNOWN) {
- String path = file.getUri().toString();
- int fileExtensionPosition = path.lastIndexOf('.');
- if (fileExtensionPosition >= 0) {
- String extensionWithoutDot = path.substring(fileExtensionPosition + 1);
- mediaType = MediaType.fromFileExtension(extensionWithoutDot);
- }
- }
-
+ String mimeType = MimeTypeUtils.getMimeType(file.getType(), file.getUri().toString());
+ MediaType mediaType = MediaType.fromMimeType(mimeType);
if (mediaType == MediaType.AUDIO || mediaType == MediaType.VIDEO) {
mediaFiles.add(file);
mediaFileNames.add(file.getName());