aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/thedevstack/conversationsplus/entities/DownloadableFile.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/de/thedevstack/conversationsplus/entities/DownloadableFile.java')
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/entities/DownloadableFile.java15
1 files changed, 6 insertions, 9 deletions
diff --git a/src/main/java/de/thedevstack/conversationsplus/entities/DownloadableFile.java b/src/main/java/de/thedevstack/conversationsplus/entities/DownloadableFile.java
index 7566c199..9a677cd0 100644
--- a/src/main/java/de/thedevstack/conversationsplus/entities/DownloadableFile.java
+++ b/src/main/java/de/thedevstack/conversationsplus/entities/DownloadableFile.java
@@ -20,6 +20,8 @@ import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import de.thedevstack.conversationsplus.Config;
+import de.thedevstack.conversationsplus.utils.MimeUtils;
+
import android.util.Log;
public class DownloadableFile extends File {
@@ -56,18 +58,13 @@ public class DownloadableFile extends File {
public String getMimeType() {
String path = this.getAbsolutePath();
- try {
- String mime = URLConnection.guessContentTypeFromName(path.replace("#",""));
- if (mime != null) {
- return mime;
- } else if (mime == null && path.endsWith(".webp")) {
- return "image/webp";
+ int start = path.lastIndexOf('.') + 1;
+ if (start < path.length()) {
+ String mime = MimeUtils.guessMimeTypeFromExtension(path.substring(start));
+ return mime == null ? "" : mime;
} else {
return "";
}
- } catch (final StringIndexOutOfBoundsException e) {
- return "";
- }
}
public void setExpectedSize(long size) {